5 messages in com.mysql.lists.javaCannot get connected to MySQL-3.23.52...
FromSent OnAttachments
sagara w21 Sep 2002 13:40 
Mark Matthews21 Sep 2002 14:44 
sagara w22 Sep 2002 01:34 
Mark Matthews22 Sep 2002 05:58 
sagara w23 Sep 2002 02:17 
Subject:Cannot get connected to MySQL-3.23.52 using Connector/J 2.0.14
From:sagara w (saga@yahoo.com)
Date:09/21/2002 01:40:01 PM
List:com.mysql.lists.java

Cannot get connected to MySQL-3.23.52 using Connector/J 2.0.14

I use MySQL-3.23.52 with JDK 1.4.1 on Red Hat Linux 7.2 on a Pentium III based PC server with 256MB RAM.

I did following steps: 1. tar –xvzf mysql-connector-java-2.0.14.tar.gz 2. jar xvf mysql-connector-java-2.0.14-bin.jar 3. set CLASSPATH to “.:/usr/local/mysql-connector-java-2.0.14/mysql-connector-java-2.0.14-bin.jar”

Here is the code fragment of my JDBCtest.java program:

import java.io.*; import java.sql.*; import javax.sql.*; import java.util.*;

class JDBCtest { public static void main(String[] args) { Connection Conn=null; Statement St = null; ResultSet RS = null;

try {

Class.forName("com.mysql.jdbc.Driver").newInstance();

System.out.println("Driver registration successful...");

Conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&password=rootpass");

System.out.println("getConnection successful..."); . . .

When I run the program, it prints “Driver registration successful...” and hangs at the DriverManager.getConnection for a long time and prints the following message:

Error Occured Cannot connect to MySQL server on localhost:3306. Is there a MySQ L server running on the machine/port you are trying to connect to? (java.net.Con nectException) Sql State 08S01

I have modified the JNDIDataSource.java, complied and ran. There also it hangs at the Connection con = ds.getConnection("root", "rootpass") and prints the following message:

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 com.mysql.jdbc.Connection.connectionInit(Unknown Source) at com.mysql.jdbc.jdbc2.Connection.connectionInit(Unknown Source) at com.mysql.jdbc.Driver.connect(Unknown Source) at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(Unknown Source) at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(Unknown Source) at JNDIDataSource.main(JNDIDataSource.java:63)

I can get connected to the same MySQL server in my Perl programs.

Can Connector/J 2.0.14 be used with MySQL-3.23.52 with JDK 1.4.1 on Red Hat Linux 7.2 on a Pentium III based PC server? If possible, could somebody please post a code sample indicating how to get connected to the MySQL server?

Many thanks in advance

Regards Sagara