4 messages in com.mysql.lists.javaRe: SQLException| From | Sent On | Attachments |
|---|---|---|
| Adnan Al-bar | 19 Mar 2002 09:44 | |
| Igor Fedulov | 19 Mar 2002 10:04 | |
| F Shasanya | 19 Mar 2002 10:16 | |
| Adnan Al-bar | 21 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,
-- HTTP is a stateless protocol, and the Internet is a stateless development environment
-- Igor Fedulov E-mail : ifed...@outlook.net Work Ph: 773.775.1595 Home Ph: 773.281.8938 Cell Ph: 773.580.5935




