2 messages in com.mysql.lists.javaRe: mm.mysql.jdbc-1.0
FromSent OnAttachments
Marco Guidi20 Dec 2000 02:23 
Mark Matthews20 Dec 2000 03:40 
Subject:Re: mm.mysql.jdbc-1.0
From:Mark Matthews (mmat@thematthews.org)
Date:12/20/2000 03:40:21 AM
List:com.mysql.lists.java

Marco Guidi wrote:

I'm a newbie of the Java language so may be that my problem is not a graet one, but I was not able to solve it yesterday.

I use jdk1.2.2 with linux.

Did someone deal with the jdbc driver in Subject ?

I'm not able to understand which classes must be imported from java.sql and which from org.gjt.mm.mysql.

if I try to compile the following java code I get the error

javac A.java ./org/gjt/mm/mysql/Driver.java:121: class org.gjt.mm.mysql.Connection is an abstract class. It can't be instantiated. return new Connection (host(), port(), Props, database(), Url, this); ^ 1 error

This is because the ./org/gjt/mm/mysql/Driver.java file contains

public java.sql.Connection connect(String Url, Properties Info) throws java.sql.SQLException { if((Props = parseURL(Url, Info)) == null) return null;

return new Connection (host(), port(), Props, database(), Url, this); }

In the ./org/gjt/mm/mysql/Connection.java file there is a Connection class that impelemnts java.sql.Connection but it seems that the ./org/gjt/mm/mysql/Connection class doesn't implement all the methods of the java.sql.Connection interface.

If in A.java I replace all the imports whit the following

import java.util.*; import java.sql.*;

I can compile but I get the error [mg@pegasus mm.mysql.jdbc-1.0]$ !javac javac A.java [mg@pegasus mm.mysql.jdbc-1.0]$ java A prima della connessione Connection failed : Communication link failure: Bad handshake [mg@pegasus mm.mysql.jdbc-1.0]$

??Bad handshake??

It seems as if it doesn't use the org.gjt.mm.mysql.Driver...

//file A.java

import java.util.*; import org.gjt.mm.mysql.Driver; import org.gjt.mm.mysql.Connection; import java.sql.DriverManager;

public class A { public static void main(String args[]){ try { Driver D; D=(Driver)Class.forName("org.gjt.mm.mysql.Driver").newInstance();

Connection Conn = null; System.out.println("prima della connessione");

Conn = (org.gjt.mm.mysql.Connection)DriverManager.getConnection("jdbc:mysql://localhost/prova","pippo","pippo");

System.out.println("dopo la connessione"); // DriverManager.registerDriver(D);

return; } catch (Exception E) { System.out.println("Connection failed : "+E.getMessage()); } }

To unsubscribe, send a message to the address shown in the List-Unsubscribe header of this message. If you cannot see it, e-mail java@lists.mysql.com instead.

Two things, you are trying to compile a JDBC-1.1 driver with JDK-2.0 which uses JDBC-2.0 (so it won't work), and you're using a _very_ old version of the driver. Please upgrade to the latest version (2.0.3) available at http://mmmysql.sourceforge.net/

-Mark