Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » JDBC(JDBC connection to mysql)
JDBC [message #1792111] Wed, 11 July 2018 16:28 Go to next message
Srikant Nair is currently offline Srikant NairFriend
Messages: 1
Registered: July 2018
Junior Member
Hi This is my JDBC program


import java.sql.*;
public class jdbcconnection {

/**
* @param args
*/
public static void main(String[] args) {
Connection con=null;
Statement st=null;
try{
//Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test?useSSL=false","root","Srikant1");
String sql="insert into employee values(105,'rahul',104)";
st=con.createStatement();
int x=st.executeUpdate(sql);
if(x==1)
System.out.println("record inserted");
else
System.out.println("record not inserted");
}catch(Exception e){
e.printStackTrace();
}
finally{
try{
if(st!=null)
st.close();
if(con!=null)
con.close();
}catch(Exception e){
e.printStackTrace();
}
}
}}

But when i run this


error message
java.sql.SQLNonTransientConnectionException: CLIENT_PLUGIN_AUTH is required
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:108)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:87)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:61)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:71)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:79)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:862)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:444)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at jdbcconnection.main(jdbcconnection.java:12)
Caused by: com.mysql.cj.exceptions.UnableToConnectException: CLIENT_PLUGIN_AUTH is required
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:59)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:83)
at com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:220)
at com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1411)
at com.mysql.cj.NativeSession.connect(NativeSession.java:165)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:982)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:852)
... 6 more

Re: JDBC [message #1792115 is a reply to message #1792111] Wed, 11 July 2018 19:32 Go to previous message
Patrick Moran is currently offline Patrick MoranFriend
Messages: 141
Registered: March 2018
Senior Member
I suggest that you start with something much simpler, get it to work, and then gradually introduce the picky kinds of things that your connection seems to require for whatever your programming purposes are.
Here is what I used when I was trying to make sure what was holding back a connection to a sqlite database. Maybe you can do something similar to start with:

import java.sql.*;
import javax.swing.*;
import java.sql.Connection;

	
public class sqliteConnection {
	
	public static Connection dbConnector(){
		Connection conn = null;
		JOptionPane.showMessageDialog (null, "Ready for the try block after declaring conn.");
		try {
			JOptionPane.showMessageDialog (null, "Just inside the try-catch block.");
			Class.forName("org.sqlite.JDBC");
			JOptionPane.showMessageDialog (null, "Did the Class.forName stuff. Ready for conn- ...");
			conn = DriverManager.getConnection("jdbc:sqlite:/Users/JohnPaulJones/EmployeeData.sqlite"); //Can't be Connection conn
			JOptionPane.showMessageDialog(null,  "Connection Successful.");
			return conn;
		}catch (Exception e)
		{
			JOptionPane.showMessageDialog(null,"sqliteconnection fails with exception:  " + e);
			return null;
		}
	}
}


I'm on a Mac, so the path is easier to write. For Windows I think you have to use backslashes and you have to escape them so they will function as real backslashes, i.e., instead of Mac's / you have to write \\ to get the path to work right.

Also, I would google for "CLIENT_PLUGIN_AUTH" to find out what this is and where your program should be able to find it.

[Updated on: Wed, 11 July 2018 19:37]

Report message to a moderator

Previous Topic:Workspace continuous refresh
Next Topic:Installation errors
Goto Forum:
  


Current Time: Tue Mar 19 03:06:03 GMT 2024

Powered by FUDForum. Page generated in 0.05988 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top