2 messages in com.mysql.lists.javacannot connect to mysql
FromSent OnAttachments
Paal Are Solberg15 Jul 1999 03:09 
Christian Mack20 Jul 1999 13:15 
Subject:cannot connect to mysql
From:Paal Are Solberg (Paal@hit.no)
Date:07/15/1999 03:09:39 AM
List:com.mysql.lists.java

Trying to get started on java applications and jdbc...but I'm having trouble with the basics. Can anyone help me over these initial hurdles?

Client running NT 4.0. Mysql 3.22.21 up and running on Linux on the machine 'dbserver'

On the client I try this:

C:\>C:\jdk1.1.7B\bin\javac -classpath C:\jdk1.1.7B\lib\classes.zip;C:\mm\mm.mysql.jdbc.1.1f\mysql.jar testfile.java

-this compiles; I try to run the class file :

C:\>C:\jdk1.1.7B\bin\java -classpath C:\jdk1.1.7B\lib\classes.zip;C:\mm\mm.mysql.jdbc.1.1f\mysql.jar;. testfile

-this is what follows:

Driver registered java.sql.SQLException: Cannot connect to MySQL server on anton:3306. Is there are MySQL server running on the machine/port you are trying to connect to? at org.gjt.mm.mysql.Connection.<init><Connection.java:237> at org.gjt.mm.mysql.Driver.connect<Driver.java:126> at java.sql.DriverManager.getConnection<Compiled code> at java.sql.DriverManager.getConnection<DriverManager.java:126> at testfile.main(testfile.java:21)

- code for testfile.java:

import java.sql.*;

public class testfile { public static void main(String args[]){ String url = "jdbc:mysql://dbserver:3306/javatest"; String user = "myname"; String password = "mypassword";

String myDriver = "org.gjt.mm.mysql.Driver";

try { Class.forName(myDriver); System.out.println("Driver registered"); } catch (Exception e){ System.out.println("could not register driver"); return; } try{

Connection con = DriverManager.getConnection(url,user,password); System.out.println("we have connection"); //this never reached... con.close(); } catch (SQLException ex ){ ex.printStackTrace(); } } }

kind regards Paal Are