Reputation: 179
I have a problem connecting to a database with JDBC. I get the following error upon connecting: CLIENT_PLUGIN_AUTH is required
Here is my code:
private void connect() {
try {
connection = DriverManager.getConnection("jdbc:mysql://"+url+":"+port+"/"+database, username, password);
System.out.println(Messages.MYSQL_CONNECT_SUCCESS.toString());
}
catch(Exception e) {
System.out.println(Messages.MYSQL_CONNECT_FAIL.toString()+e.getMessage());
}
}
Is my connection string wrong? This is what I added to my Maven dependencies:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.5</version>
</dependency>
I use this code (with different messages) in another project that does not use Maven, and it works fine. The credentials work. I've attempted to add Class.forName("com.mysql.jdbc.Driver");
but it doesn't change the result.
Upvotes: 2
Views: 5979
Reputation: 1011
Replace your URL with the below and try it
jdbc:mysql://"+url+":"+port+"/"+database?autoReconnect=true&useSSL=false, username, password
This is related to SSL.
Upvotes: 3