I am trying to query a local SQL Server using the following application.properties file:
spring.datasource.url=jdbc:sqlserver://somesqlservername;databaseName=somedbanme
spring.datasource.username=someusername
spring.datasource.password=somepass
And the following code to access the db with jdbc:
@RestController
public class UserController {
@Autowired
private JdbcTemplate jdbcTemplate;
@GetMapping(value="/User")
public User getUser(@RequestParam BigInteger id) {
String sql = "SOME SQL QUERY";
User user = (User) jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(User.class));
return user;
}
}
The following error occurs when i invoke the service:
com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target". ClientConnectionId:8f7627f2-78cf-4479-89fe-9eba6f7be4a5