I'm trying to connect to the MySQL database with SpringBoot but it gives me an error
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.sql.*;
@RestController
@RequestMapping
public class miController {
private static String driver = "com.mysql.jdbc.Driver";
private static String server = "jdbc:mysql://localhost/pruebas";
private static Connection conexion = null;
miController(){
conectar();
}
private void conectar() {
try {
Class.forName(driver);
conexion = DriverManager.getConnection(server, "yo", "pass");
} catch (Exception e) {
System.out.println("Error: Imposible realizar la conexion a BD.");
e.printStackTrace();
}
}
@RequestMapping(value = "/hola", method = RequestMethod.GET)
public @ResponseBody String hola() {
return "Hola mundo2!! " ;
}
}
The code of the error it gives when the application starts is:
Thu Jun 28 17:24:42 CEST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Error: Imposible realizar la conexion a BD.
java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:869)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:865)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1746)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1226)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2188)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2219)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2014)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)