1 message in com.mysql.lists.javaRe: Java/JDBC/MySQL with mm driver - ...
FromSent OnAttachments
Christian Mack23 May 2000 22:55 
Subject:Re: Java/JDBC/MySQL with mm driver - Connection Refused
From:Christian Mack (mack@gmx.de)
Date:05/23/2000 10:55:30 PM
List:com.mysql.lists.java

"Soulier, Frederic P" wrote:

Hello,

Sorry my 1st posting seems to have gone wrong, the attachment is missing...

I am trying to use the mm JDBC driver to connect to mysql without success
(connection refused). I cannot see what is wrong as the user is defined in the 'user' table in the
'mysql' database and manual connection works fine.

I am using: jdk1.2.2 RC4 (from www.blackdown.org) mySQL 3.20.32a mm.mysql.jdbc-2.0pre5 Mandrake 7.0 SMP kernel

Any help much appreciated!

Cheers, Fred

Here is more data:

************************************************

My ConnectDB class:

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

public class ConnectDB { Connection mySQLcon;

//------------------------------------ // This main() is for testing purposes //------------------------------------ public static void main (String args[]) { ConnectDB db = null;

System.out.println("ConnectDB class testing...");

try { db = new ConnectDB(args[0]); System.out.println("Connection to database established...");

db.close(); System.out.println("Connection to database closed..."); } catch (Exception E) { System.err.println("** Unable to connect to database **"); E.printStackTrace(); }

}

//-------------------------------------------------- // Establishes a connection with the database server //-------------------------------------------------- public ConnectDB (String dbName) throws SQLException { // URL String String url = "jdbc:mysql://localhost/" + dbName +
"?user=frederic&password=xxxxxxx";

try { Class.forName("org.gjt.mm.mysql.Driver").newInstance(); } catch (Exception E) { System.err.println("** Unable to load driver **"); E.printStackTrace(); }

System.out.println("JDBC driver loaded...");

System.out.println(url);

// Make connection mySQLcon = DriverManager.getConnection(url); }

//----------------------------------------------- // Closes the connection with the database server //----------------------------------------------- public void close () throws SQLException { mySQLcon.close(); }

}

************************************************

$java ConnectDB StockMarket

ConnectDB class testing... JDBC driver loaded... jdbc:mysql://localhost/StockMarket?user=frederic&password=xxxxxxx java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java, Compiled
Code) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java,
Compiled Code) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java, Compiled Code) at java.net.Socket.<init>(Socket.java, Compiled Code) at java.net.Socket.<init>(Socket.java, Compiled Code) at org.gjt.mm.mysql.MysqlIO.<init>(MysqlIO.java, Compiled Code) at org.gjt.mm.mysql.jdbc2.IO.<init>(IO.java, Compiled Code) at org.gjt.mm.mysql.jdbc2.Connection.createNewIO(Connection.java,
Compiled Code) at org.gjt.mm.mysql.Connection.connectionInit(Connection.java, Compiled
Code) at org.gjt.mm.mysql.jdbc2.Connection.connectionInit(Connection.java,
Compiled Code) at org.gjt.mm.mysql.Driver.connect(Driver.java, Compiled Code) at java.sql.DriverManager.getConnection(DriverManager.java, Compiled
Code) at java.sql.DriverManager.getConnection(DriverManager.java, Compiled
Code) at ConnectDB.<init>(ConnectDB.java, Compiled Code) at ConnectDB.main(ConnectDB.java, Compiled Code) ** Unable to connect to database **java.sql.SQLException: Cannot load connection
class 'java.sql.SQLException: Cannot connect to MySQL server on localhost:3306.Is
there a MySQL server running on the machine/port you are trying to connect to?
(java.net.ConnectException)'. at org.gjt.mm.mysql.Driver.connect(Driver.java, Compiled Code) at java.sql.DriverManager.getConnection(DriverManager.java, Compiled
Code) at java.sql.DriverManager.getConnection(DriverManager.java, Compiled
Code) at ConnectDB.<init>(ConnectDB.java, Compiled Code) at ConnectDB.main(ConnectDB.java, Compiled Code)

****************************************

#mysqlaccess localhost frederic StockMarket

mysqlaccess Version 2.0p3, 06 Oct 1997 By RUG-AIV, by Yves Carlier (Yves@rug.ac.be) This software comes with ABSOLUTELY NO WARRANTY.

Access-rights for USER 'frederic', from HOST 'localhost', to DB 'StockMarket' +-----------------+---+ +-----------------+---+ | Select_priv | Y | | Drop_priv | Y | | Insert_priv | Y | | Reload_priv | Y | | Update_priv | Y | | Shutdown_priv | N | | Delete_priv | Y | | Process_priv | N | | Create_priv | Y | | File_priv | N | +-----------------+---+ +-----------------+---+ NOTE: A password is required for user `frederic' :-(

The following rules are used: db : 'No matching rule' host : 'Not processed: host-field is not empty in db-table.' user :
'localhost','frederic','2dde72c83eeeeacc','Y','Y','Y','Y','Y','Y','Y','N','N','N'

BUGs can be reported by email to Yves@rug.ac.be

****************************************

#mysqladmin version

mysqladmin Ver 5.3 Distrib 3.20.32a, for pc-linux-gnu on i686 TCX Datakonsult AB, by Monty

Server version 3.20.32a Protocol version 9 Connection Localhost via UNIX socket TCP port 3306 UNIX socket /var/lib/mysql/mysql.sock Uptime: 30 min 40 sec Running threads: 2 Questions: 248 Reloads: 1 Open tables: 4

****************************************

as user 'frederic', the entry:

$mysql --host=localhost --password=xxxxxxx StockMarket

connects to the database "StockMarket" perfectly well.

Hi Fred

You have an really old mysql. But this shouldn't be an problem.

The only possible problem I can see is your network. The mysql commandline tool uses perhaps a UNIX socket to connect to the mysqld
server (I'm not sure if your version did this with 'localhost'). Did you try to use 127.0.0.1 instead of localhost?

Hope this helps.

Tschau Christian