Unable to establish JDBC connection

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Ian

Unable to establish JDBC connection

Post by Ian » Mon Feb 17, 2003 12:16 pm

Hi,

Unable to run JDBC examples as I am unable to establish a JDBC connection.

I am using XP as my OS and MySQL with the mysql-connector-java-2.0.14-bin.jar as my driver and is installed in the $JAVA_HOME/jre/lib/ext directory of my Java SDK.


Using MySql I set up a user ian@localhost with a passowrd of merlin89.
as shown below and I can connect to the database through the MySql client.



Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

c:\>cd mysql

c:\mysql>cd bin

c:\mysql\bin>mysql -u ian -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 3.23.55-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> status;
--------------
mysql Ver 11.18 Distrib 3.23.55, for Win95/Win98 (i32)

Connection id: 2
Current database:
Current user: ian@localhost
Server version: 3.23.55-nt
Protocol version: 10
Connection: localhost via TCP/IP
Client characterset: latin1
Server characterset: latin1
TCP port: 3306
Uptime: 32 min 50 sec

Threads: 1 Questions: 29 Slow queries: 0 Opens: 6 Flush tables: 1 Open tabl
es: 0 Queries per second avg: 0.015
--------------

mysql>


I am using the following code to test the connection.

import java.sql.*;
public class Connect
{
public static void main (String[] args)
{

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

java.sql.Connection conn;

conn = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/jfreechartdb?user=ian&password=merlin89");
System.out.println ("Database connection established");
}
catch (Exception e)
{
System.err.println ("Cannot connect to database server");
}

}
}

I am unable to establish the connection has anybody got any ideas.

Its bugging me big time.

Thanks
Ian

David Gilbert

Re: Unable to establish JDBC connection

Post by David Gilbert » Mon Feb 17, 2003 4:43 pm

Not sure...do you get any helpful exception messages?

Regards,

Dave Gilbert

Locked