Hi everybody,
I'm trying to connect to a mySQL database on the
localhost through a jdbc (mm.mysql.jdbc-1.2b I
downloaded it from mySQL home page) driver, but I
cannot establish the connection for users that need a
password. The java code I use is approximately the
following:
private String url = "jdbc:mysql://localhost/test";
public static void main(String[] args) {
ProvaJDBC thisclass = new ProvaJDBC();
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Driver dr =
DriverManager.getDriver(thisclass.url);
System.out.println("Connessione:
"+dr.acceptsURL(thisclass.url)+"
"+dr.getMinorVersion());
Connection con =
DriverManager.getConnection(thisclass.url, "user",
"password
......................
}
}
catch(SQLException e) {
System.out.println("SQLException: " +
e.getMessage());
System.out.println("SQLState: " +
e.getSQLState());
System.out.println("VendorError: " +
e.getErrorCode());
e.printStackTrace();
}
This code works perfectly for users that don't need to
specify a password (that is, I specify a null or void string password),
while it gets an error when a
password is needed. The error is:
SQLState: 08S01
VendorError: 1043
java.sql.SQLException: Communication link failure: Bad
handshake
at
java.lang.Throwable.<init>(Throwable.java:96)
at
java.lang.Exception.<init>(Exception.java:44)
at
java.sql.SQLException.<init>(SQLException.java:45)
at
org.gjt.mm.mysql.MysqlIO.init(MysqlIO.java:278)
at
org.gjt.mm.mysql.Connection.<init>(Connection.java:230)
at
org.gjt.mm.mysql.Driver.connect(Driver.java:126)
at
java.sql.DriverManager.getConnection(DriverManager.java:523)
at
java.sql.DriverManager.getConnection(DriverManager.java:183)
at ProvaJDBC.main(ProvaJDBC.java:12)
Is there anyone who can help me?
thanx, Attilio Mattiocco
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php