TL DR:
Every time I try to use JDBC to connect to a local MySQL server (which runs on tons of other SQL clients), it does not connect at all, and I get an exception:
- Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communication communication error
- .... stack trace ...
- Called: java.net.SocketException: invalid argument: connect
More detailed information:
I have a local MySQL server that I can connect to using the following information:
- address: localhost or 127.0.0.1 (both work)
- port: 3306
- and my username / password / db name
: HeidiSQL, phpmyadmin, MySQL Workbench mysqladmin
mysqladmin , , tcp/ip.
mysqladmin , "skip_networking" (. ).
MySQL ( ).
JDBC- v5.1.15, mysql-connector-java-5.1.15-bin.jar. Eclipse.
7 (Ultimate, 64 , ) .
, , . , , ...
. , - , , ... :/heh.
, , ( qaru.site/questions/47575/..., qaru.site/questions/896013/..., https://serverfault.com/questions/89955/unable-to-connect-to-mysql-through-jdbc-connector-through-tomcat-or-externally )
:
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);
}
}
: http://pastebin.com/qv332y86
MySQL: 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:
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