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
_______________________________________________________________
Paal Are Solberg,
IT-gruppeleder, Porsgrunn
Høgskolen i Telemark, Kjølnes Ring 56, 3914 Porsgrunn
Tel: 35 57 50 53/33 18 03 52 mobil: 918 600 41 fax: 35 57 50 01
Epost: Paal.A.Solberg@stripped