I am having a probem connecting to the MySQL (Win32) database I have on
localhost. The program is simply supposed to create a table in the database
but I get runtime errors. Here it is:
import java.sql.*;
public class Test {
public static void main(String args[])throws Exception {
Class.forName("org.gjt.mm.mysql.Driver");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost/db?user=root;password=he
llo");
Statement stmt = con.createStatement();
String createTableCoffees = "CREATE TABLE COFFEES " +
"(COF_NAME VARCHAR(32), SUP_ID INTEGER, PRICE FLOAT, " +
"SALES INTEGER, TOTAL INTEGER)";
stmt.executeUpdate(createTableCoffees);
}
}
Here is the error I get:
Exception in thread "main" java.sql.SQLException: Communication link
failure: Bad handshake
at org.gjt.mm.mysql.MysqlIO.init(MysqlIO.java)
at org.gjt.mm.mysql.Connection.<init>(Connection.java)
at org.gjt.mm.mysql.Driver.connect(Driver.java)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Test.main(Test.java:8)
I'm pretty sure the driver works because when I changed the password to an
invalid one, it gave a runtime error saying it was a bad password.So why am
I getting this 'Bad Handshake' error. Thanks, I'd appreciate any help at
all.