Bug #24981 MySQL Connector/J, OpenOffice.org, java.net.SocketException: Connection Refused
Submitted: 11 Dec 2006 22:37 Modified: 23 Jan 2007 15:17
Reporter: Thomas Ronayne Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.0.4 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[11 Dec 2006 22:37] Thomas Ronayne
Description:
Unable to connect OpenOffice.org 2.0.4 to MySQL data base with JDBC (MySQL Connection/J, version 5.0.4).

Error messages are (typical) java.net.ConnectException: Connection refused. Stacktrace at com.mysql.jdbc.StandardSocketFactory.connect (StandardSocketFactory.java:156)
at com.mysql.jdbc.MysqlO.<init>(MyslqO.java:276).

Slackware Linux 2,6,18, java version "1.5.0_09", Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b01), Java HotSpot(TM) Client VM (build 1.5.0_09-b01, mixed mode, sharing).

Tried building mysql-connector-java-5.0.4 using Ant with the same result.

How to repeat:
Always happens.
[6 Jan 2007 21:24] Tonci Grgin
Hi Thomas and thanks for your problem report. So far I'm unable to reproduce it. I am using JDK 1.4.2, OpenOffice 2.0.0.1 on my Suse 10.0 box. Did you get this problem after upgrading JVM or OpenOffice?
[6 Jan 2007 21:30] Tonci Grgin
And, I'm using MySQL server 5.0.34BK on localhost, non-standard port with root account.
[6 Jan 2007 22:05] Thomas Ronayne
No, as described was the first try at using Connector.

However, I've just upgraded OpenOffice.org to 2.1 (today) and haven't gotten back to trying Connector... I'll have to dig back through the directions and see if I can get a connection established. I'll let you know what happens.
[6 Jan 2007 22:09] Tonci Grgin
Ok Thomas, I'm waiting on your results. Meanwhile I'm upgrading my Suse too.
[6 Jan 2007 22:51] Thomas Ronayne
You know, I'm wondering if I'm doing this right (same results)? I'm doing this in the wizard (and I could very well be doing something stupid):

Connect to an exiting data base (MySQL in the drop down);
Connect using JDBC
Name of data base: address
Host: localhost
Port: 3306
Drive Class: com.mysql.jdbc.Driver (and it loads when I test it)
User name: me
Password: mine
Test connection: fails

I connect to that data base directly with MySQL no problem; it has content, I can see it. Trying to connect with the wizard or in Writer I'm getting:

SQL Status: 08S01

Communications link failure due to underlying exception: 

** BEGIN NESTED EXCEPTION ** 

java.net.SocketException
MESSAGE: java.net.ConnectException: Connection refused

STACKTRACE:

java.net.SocketException: java.net.ConnectException: Connection refused
	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
	at com.mysql.jdbc.Connection.createNewIO(Connection.java:2666)
	at com.mysql.jdbc.Connection.<init>(Connection.java:1531)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)

** END NESTED EXCEPTION **

Last packet sent to the server was 0 ms ago.
[7 Jan 2007 21:01] Tonci Grgin
Thomas, what happens when you choose "Connect to existing database: JDBC" (not MySQL) and type full connect string on the second page (jdbc:// ...)? What would be/is your actual connect string? Are you sure you're using c/J 5.0.4 since my Suse comes with 3.1.x? What jar does your CLASSPATH point to? Are you trying to connect to MySQL server 5.x or 4.x?

You can find the description and the common solutions in:
http://dev.mysql.com/doc/refman/5.0/en/connector-j-usagenotes-troubleshooting.html
and
http://dev.mysql.com/doc/refman/5.0/en/error-messages-server.html
[7 Jan 2007 23:41] Thomas Ronayne
Here's the Java version:
fubar-trona-/home/trona: java -version
java version "1.5.0_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b01)
Java HotSpot(TM) Client VM (build 1.5.0_09-b01, mixed mode, sharing)

The classpath (reported in OpenOffice, Options, Java, Classpath is:
/usr/share/java/mysql-connector-java-5.0.4-bin.jar

As you suggest, I enter the URL:
jdbc:mysql://localhost/address
and the class
com.mysql.jdbc.Driver
(the class loads successfully with "Test class")

Test Connection fails with java.SocketException

I'm taking the above from the JDBC Connection help Data Source URL.

I've tried every combination of URL; "localhost," "fubar" (the machine name -- appropriate, eh?) and 192.168.1.10 (that actual machine address).

I just know I'm missing something here, but I can't come up with what that might be.

Thanks.
[10 Jan 2007 15:34] Daniel Bunzendahl
Hello All,

I have the same problem...

On several machines:

Standard-Installation of Xubuntu with OOO 2.04
Suse 10.1 OOO 2.04 on 2 several Machines (Laptop & Workstation) in step by step upgraded Installations (from Suse 9.0 upto 10.1)

I think there is a generaly problem in the configuration ?!
[10 Jan 2007 22:32] Mark Matthews
Are you sure that MySQL hasn't been started with --skip-networking?

Connector/J can only make connections over TCP/IP on Unix (because Java doesn't have support for unix domain sockets), and many recent Linux distributions install MySQL to only startup listening on unix domain sockets.
[10 Jan 2007 22:45] Thomas Ronayne
Well, well, well...

No, I wasn't sure that MySQL was started with --skip-networking, so I went and looked and whadda ya know -- commented that out of the start-up, restart MySQL, open Base, connect to the thing (at long last).

Kind of make me wonder, though... I'm pretty sure I read all the directions and never saw a mention of that anywhere (and, yes, I could have missed it, but...). Maybe a "Note: Make Sure Skip-Networking is note Enabled" in the instructions?

Thank you for all the time and trouble.
[15 Jan 2007 6:49] Tonci Grgin
Hi Thomas. I dissagree, please check server manual for "skip-networking", among many links you'll find this "To disallow TCP/IP connections entirely, start mysqld with the --skip-networking option."

As this is not a connector bug nor it lacks documenting I'm setting this report to "Not a bug".
[15 Jan 2007 15:55] Mark Matthews
Documentation team. As the reporter states, this is probably a good thing to include in the FAQ for Connector/J (i.e. it needs TCP/IP access to the server, so watch out for --skip-networking, with one option to limit connections to localhost is to bind to localhost only with the server).
[23 Jan 2007 15:17] MC Brown
I've updated the FAQ for C/J to note the networking requirements, and to check for firewalls and other filters with a link to the Can not connect to server notes.