List:MySQL and Java« Previous MessageNext Message »
From:Paal Are Solberg Date:July 15 1999 10:10am
Subject:cannot connect to mysql
View as plain text  
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

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

C:\>C:\jdk1.1.7B\bin\java -classpath
C:\jdk1.1.7B\lib\;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 java.sql.DriverManager.getConnection<Compiled code>
        at java.sql.DriverManager.getConnection<>
        at testfile.main(

- code for

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 =  "";

      try {
         System.out.println("Driver registered");
      catch (Exception e){
         System.out.println("could not register driver");

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

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

cannot connect to mysqlPaal Are Solberg15 Jul
  • Re: cannot connect to mysqlChristian Mack21 Jul