Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem connecting to MySQL using JDBC

4 views
Skip to first unread message

Mohap

unread,
Feb 24, 2001, 10:23:58 PM2/24/01
to
Hi

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.

Mohap

unread,
Feb 24, 2001, 11:41:40 PM2/24/01
to
you can ignore this... I figured out I'm using an older version of MM.

0 new messages