1 message in com.mysql.lists.javaProblems with connection between java...| From | Sent On | Attachments |
|---|---|---|
| Stéphane D'Hoedt | 27 Sep 2000 04:01 |
| Subject: | Problems with connection between java and Mysql![]() |
|---|---|
| From: | Stéphane D'Hoedt (step...@arbalet.com) |
| Date: | 09/27/2000 04:01:58 AM |
| List: | com.mysql.lists.java |
Hello,
I have a small question to ask.
I have installed MYSQL 3.23.19-beta on my computer who is running on Windows NT.
I would like to make a connection between java and the database, so I
downloadede the driver "mm.mysql.jdbc-1.2a".
The path of the driver is put in the classpath like asked in the manual.
The JAVA version that I use is JAVA 1.2.2
My host is "localhost"
I made a table in my database named test with two columns in it (child and
parent).
Then I wrote some code in java I compiled it and then I ran it and I had an
error.
This is the code that i wrote:
import java.io.*; import java.sql.*;
public class JDBCSample
{
public static void main( String argv[] )
{
try {
System.out.println("OK try");
Class.forName( "org.gjt.mm.mysql.Driver" );
String url =
"jdbc:mysql://localhost/arbalet?user=stephane&password=rlh182";
System.out.println("url " + url);
Connection con = DriverManager.getConnection( url );
System.out.println("con " + con);
Statement select = con.createStatement();
String sql = "select * from test";
sql = new String(sql.getBytes("SJIS"), "8859_1" );
ResultSet res = select.executeQuery( sql );
int count = 0;
while( res.next() ) {
count++;
String result = res.getString( "child" ) + "\t" + res.getString(
"parent" );
result = new String( result.getBytes("8859_1"), "SJIS" );
System.out.println( result );
}
System.out.println( "Record count=" + count );
select.close();
con.close();
}
catch ( Exception e ) {
e.printStackTrace();
}
}
}
And this is the error that I received:
OK try url jdbc:mysql://localhost/arbalet?user=stephane&password=rlh182 java.sql.SQLException: Communication link failure: Bad handshake at org.gjt.mm.mysql.MysqlIO.init(MysqlIO.java, Compiled Code) at org.gjt.mm.mysql.Connection.<init>(Connection.java:229) at org.gjt.mm.mysql.Driver.connect(Driver.java:126) at java.sql.DriverManager.getConnection(DriverManager.java:457) at java.sql.DriverManager.getConnection(DriverManager.java:159) at JDBCSample.main(JDBCSample.java, Compiled Code)
I hope you can help me with it.
I already tried a couple of times but nothing helps.
Thanks in advance, Stephane




