TL;DR:
Every time I try to use JDBC to connect to a local MySQL server (that works on tons of other sql clients), it doesn't connect at all and I get an exception:
- Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- .... stack trace ....
- Caused by: java.net.SocketException: Invalid argument: connect
More detailed info:
I've got a local MySQL server running that I can connect to with using the following info:
- address: localhost or 127.0.0.1 (both work)
- port: 3306
- and my username/password/db name
Using the applications: HeidiSQL, phpmyadmin, MySQL Workbench and mysqladmin
Running mysqladmin version confirms that the server is up, working, and has tcp/ip enabled.
Doing mysqladmin variables shows that "skip_networking" is off (see below for full config).
The MySQL log shows nothing out of the ordinary (also below).
I'm using JDBC connector v5.1.15, mysql-connector-java-5.1.15-bin.jar. It's in my project class path with Eclipse.
All windows 7 (Ultimate, 64bit if it matters) firewalls are off.
Yet I still get the stack trace error as shown below. I can't for the life of me figure out what's wrong when everything else is able to connect just fine...
I've tried to include all relevant information below. I'm hoping it's just something simple and stupid that I've overlooked and can't find because I'm looking too hard...but eh who knows :/ heh.
I've tried everything I've been able to find in other similar questions online but nothing seems to work (incl. https://stackoverflow.com/a/2985169/211750 , https://stackoverflow.com/a/2103092/211750 , https://serverfault.com/questions/89955/unable-to-connect-to-mysql-through-jdbc-connector-through-tomcat-or-externally and others)
My test code:
package sqltest;
import com.mysql.jdbc.Driver;
import java.sql.DriverManager;
import java.util.Properties;
public class main {
public static void main(String[] args) throws Exception {
String url = "jdbc:mysql://localhost:3306/dbname?user=user&password=****&";
Driver driver = (Driver) Class.forName("com.mysql.jdbc.Driver").newInstance();
DriverManager.getConnection(url);
}
}
Stack trace: http://pastebin.com/qv332y86
MySQL variables dump: http://pastebin.com/merSEDdD
My.ini: http://pastebin.com/EWZX2enz
MySQL mysqladmin version:
Server version 5.5.20-log
Protocol version 10
Connection localhost via TCP/IP
TCP port 3306
Uptime: 1 min 37 sec
Threads: 1 Questions: 17 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.175
MySQL log:
120314 21:37:20 [Note] Plugin 'FEDERATED' is disabled.
120314 21:37:20 InnoDB: The InnoDB memory heap is disabled
120314 21:37:20 InnoDB: Mutexes and rw_locks use Windows interlocked functions
120314 21:37:20 InnoDB: Compressed tables use zlib 1.2.3
120314 21:37:20 InnoDB: Initializing buffer pool, size = 128.0M
120314 21:37:20 InnoDB: Completed initialization of buffer pool
120314 21:37:20 InnoDB: highest supported file format is Barracuda.
120314 21:37:20 InnoDB: Waiting for the background threads to start
120314 21:37:21 InnoDB: 1.1.8 started; log sequence number 1619921
120314 21:37:21 [Note] Event Scheduler: Loaded 0 events
120314 21:37:21 [Note] wampmysqld: ready for connections.
Version: '5.5.20-log' socket: '' port: 3306 MySQL Community Server (GPL)
120314 21:38:02 [Note] wampmysqld: Normal shutdown
120314 21:38:02 [Note] Event Scheduler: Purging the queue. 0 events
120314 21:38:02 InnoDB: Starting shutdown...
120314 21:38:02 InnoDB: Shutdown completed; log sequence number 1619921
120314 21:38:02 [Note] wampmysqld: Shutdown complete