3 messages in com.mysql.lists.javaRe: Trouble connection to MySql db vi...
FromSent OnAttachments
James Linder01 Feb 2004 18:50 
Mark Matthews01 Feb 2004 20:31 
James Linder02 Feb 2004 20:36 
Subject:Re: Trouble connection to MySql db via JDBC
From:Mark Matthews (ma@mysql.com)
Date:02/01/2004 08:31:23 PM
List:com.mysql.lists.java

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

James Linder wrote:

Hello,

I'm trying to connect to a MySql database via JDBC and am getting a "Connection Refused" exception and I can't figure out why. Would anyone have any ideas as to what might be going on or any suggestions of what else I could try?

[snip]

I've tried putting the username and password in the url like: "jdbc:mysql:// localhost/testdb?user=testuser&password=testpass".

I'm running this against MySQL version 4.0.16 through tomcat 4.1.27 using sun's jdk 1.4.2_03 on a hard disk install of Knoppix v3.3-2003-11-19.

[snip]

Hi,

Since Knoppix is Debian-based, most likely your mysqld has been started with '--skip-networking'. The following instructions (from the 'Troubleshooting' section of the README, will probably help:

"I'm trying to use MySQL Connector/J in an applet or application and I get an exception similar to:

SQLException: Cannot connect to MySQL server on host:3306. Is there a MySQL server running on the machine/port you are trying to connect to? (java.security.AccessControlException) SQLState: 08S01 VendorError: 0

What's wrong?"

Resolution:

Either you're running an Applet, your MySQL server has been installed with the "--skip-networking" option set, or your MySQL server has a firewall sitting in front of it.

Applets can only make network connections back to the machine that the webserver that served the .class files for the applet. This means that mysql must run on the same machine (or you must have some sort of port re-direction) for this to work. This also means that you will not be able to test applets from your local filesystem, you must always deploy them to a webserver.

MySQL Connector/J can only communicate with MySQL using TCP/IP, as Java does not support Unix domain sockets. TCP/IP communication with MySQL might be affected if MySQL was started with the "--skip-networking" flag, or if it is firewalled.

If MySQL has been started with the "--skip-networking" option set (The Debian Linux install does this for example), you need to comment it out in the file /etc/mysql/my.cnf or /etc/my.cnf. Of course your my.cnf file might also exist in the "data" directory of your MySQL server, or anywhere else (depending on how MySQL was compiled for your system). Binaries created by MySQL AB always look in /etc/my.cnf and [datadir]/my.cnf.

If your MySQL server has been firewalled, you will need to have the firewall configured to allow TCP/IP connections from the host where your Java code is running to the MySQL server on the port that MySQL is listening (by default, 3306). "

Regards,

-Mark

- -- Mr. Mark Matthews MySQL AB, Software Development Manager, J2EE and Windows Platforms Office: +1 708 332 0507 www.mysql.com

Want to swim with the dolphins? (April 14-16, 2004) http://www.mysql.com/uc2004/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAHdKwtvXNTca6JD8RAhHIAJ4iuEzpeEqHq/ZhHPuRN5xCn5INNQCfWBbS DrIdm9OL2kDdZoRaN7TP3mw= =moeZ -----END PGP SIGNATURE-----