4 messages in com.mysql.lists.javaRe: SQLException
FromSent OnAttachments
Adnan Al-bar19 Mar 2002 09:44 
Igor Fedulov19 Mar 2002 10:04 
F Shasanya19 Mar 2002 10:16 
Adnan Al-bar21 Mar 2002 09:15 
Subject:Re: SQLException
From:Igor Fedulov (ifed@outlook.net)
Date:03/19/2002 10:04:22 AM
List:com.mysql.lists.java

I am having an SQLException which says

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.security.AccessControlException) SQLException vendor code: 0 SQLState: 08S01

The java code try to connect to a database in url formatted string which looks like this

public static final String url = "jdbc:mysql://localhost/"; and then dcon = DriverManager.getConnection(url, "aalbar", "password");

How to refere to a database in the url? What else am I doing wrong?

Hey:

Assuming that you have mysql running on the same machine with networking enabled (check if 'netstat -atun | grep LISTEN' produces a service listening on port 3306 (which is the default port for mysql server)).

to specify database in your url use following format:

"jdbc:mysql://localhost:<port>/<db_name>", i.e.:

"jdbc:mysql://localhost:3306/test" will specify 'test' database

Best regards,