LINUX.ORG.RU

java не соединяется с mysql


0

0

Уже голову сломал себе. Подключаюсь под учетной записью root на локальной машине -

mysql -u root -p -h localhost -> все ок.

Запускаю ява программу (не мою) с теми же настройками: java -jar app.jar ->

com.mysql.jdbc.CommunicationsException: Communications link failure

Last packet sent to the server was 0 ms ago.
	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)
	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2104)
	at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:729)
	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:298)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:283)
	at java.sql.DriverManager.getConnection(DriverManager.java:525)
	at java.sql.DriverManager.getConnection(DriverManager.java:171)
	at ru.jimbot.db.DBAdaptor.open(DBAdaptor.java:95)
	at ru.jimbot.db.DBAdaptor.openConnection(DBAdaptor.java:71)
	at ru.jimbot.modules.chat.UserWork.<init>(UserWork.java:68)
	at ru.jimbot.modules.chat.ChatServer.start(ChatServer.java:69)
	at ru.jimbot.Manager.startAll(Manager.java:258)
	at ru.jimbot.StartBot3.main(StartBot3.java:63)
Caused by: java.net.ConnectException: Connection refused
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
	at java.net.Socket.connect(Socket.java:520)
	at java.net.Socket.connect(Socket.java:470)
	at java.net.Socket.<init>(Socket.java:367)
	at java.net.Socket.<init>(Socket.java:209)
	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
ERROR - com.mysql.jdbc.CommunicationsException: Communications link failure Last packet sent to the server was 0 ms ago.
ERROR - 	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2027)
	... 11 more
ERROR - 	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2104)
ERROR - 	at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:729)
ERROR - 	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:298)
ERROR - 	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:283)
INFO - Ошибка подключения к базе данных!!!
ERROR - 	at java.sql.DriverManager.getConnection(DriverManager.java:525)
ERROR - 	at java.sql.DriverManager.getConnection(DriverManager.java:171)
ERROR - 	at ru.jimbot.db.DBAdaptor.open(DBAdaptor.java:95)
ERROR - 	at ru.jimbot.db.DBAdaptor.openConnection(DBAdaptor.java:71)
ERROR - 	at ru.jimbot.modules.chat.UserWork.<init>(UserWork.java:68)
ERROR - 	at ru.jimbot.modules.chat.ChatServer.start(ChatServer.java:69)
ERROR - 	at ru.jimbot.Manager.startAll(Manager.java:258)
ERROR - 	at ru.jimbot.StartBot3.main(StartBot3.java:63)
ERROR - Caused by: java.net.ConnectException: Connection refused
ERROR - 	at java.net.PlainSocketImpl.socketConnect(Native Method)
ERROR - 	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
ERROR - 	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
ERROR - 	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
ERROR - 	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
ERROR - 	at java.net.Socket.connect(Socket.java:520)
ERROR - 	at java.net.Socket.connect(Socket.java:470)
ERROR - 	at java.net.Socket.<init>(Socket.java:367)
ERROR - 	at java.net.Socket.<init>(Socket.java:209)
ERROR - 	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
ERROR - 	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
ERROR - 	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2027)
ERROR - 	... 11 more

На другом сервере с теми же настройками работало.

Приложение использует: mysql-connector-java-5.1.5-bin.jar

Mysql Server version: 5.0.51a-24+lenny2+spu1 (Debian) sun-java5-jre Debian stable+testing

Куда бы копнуть?

★★★★★
Ответ на: комментарий от nnz

Через TCP/IP. Написал 2 строчки на пхп для соединения с базой - работает.

pi11 ★★★★★
() автор топика
Ответ на: комментарий от thevery

Отключил теперь ошибка такая-

Last packet sent to the server was 1 ms ago.
	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)
	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2104)
	at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:729)
	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:298)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:283)
	at java.sql.DriverManager.getConnection(DriverManager.java:525)
	at java.sql.DriverManager.getConnection(DriverManager.java:171)
	at ru.jimbot.db.DBAdaptor.open(DBAdaptor.java:95)
	at ru.jimbot.db.DBAdaptor.openConnection(DBAdaptor.java:71)
	at ru.jimbot.modules.chat.UserWork.<init>(UserWork.java:68)
	at ru.jimbot.modules.chat.ChatServer.start(ChatServer.java:69)
	at ru.jimbot.Manager.startAll(Manager.java:258)
	at ru.jimbot.StartBot3.main(StartBot3.java:63)
Caused by: java.net.SocketException: Network is unreachable
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
	at java.net.Socket.connect(Socket.java:520)ERROR - com.mysql.jdbc.CommunicationsException: Communications link failure Last packet sent to the server was 1 ms ago.
ERROR - 	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)
ERROR - 	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2104)
ERROR - 	at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:729)
ERROR - 	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:298)
ERROR - 	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:283)
ERROR - 	at java.sql.DriverManager.getConnection(DriverManager.java:525)
ERROR - 	at java.sql.DriverManager.getConnection(DriverManager.java:171)
ERROR - 	at ru.jimbot.db.DBAdaptor.open(DBAdaptor.java:95)
ERROR - 	at ru.jimbot.db.DBAdaptor.openConnection(DBAdaptor.java:71)
ERROR - 	at ru.jimbot.modules.chat.UserWork.<init>(UserWork.java:68)
ERROR - 	at ru.jimbot.modules.chat.ChatServer.start(ChatServer.java:69)
ERROR - 	at ru.jimbot.Manager.startAll(Manager.java:258)

	at java.net.Socket.connect(Socket.java:470)
	at java.net.Socket.<init>(Socket.java:367)
	at java.net.Socket.<init>(Socket.java:209)
	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2027)
	... 11 more
ERROR - 	at ru.jimbot.StartBot3.main(StartBot3.java:63)
INFO - Ошибка подключения к базе данных!!!
ERROR - Caused by: java.net.SocketException: Network is unreachable
ERROR - 	at java.net.PlainSocketImpl.socketConnect(Native Method)
ERROR - 	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
ERROR - 	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
ERROR - 	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
ERROR - 	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
ERROR - 	at java.net.Socket.connect(Socket.java:520)
ERROR - 	at java.net.Socket.connect(Socket.java:470)
ERROR - 	at java.net.Socket.<init>(Socket.java:367)
ERROR - 	at java.net.Socket.<init>(Socket.java:209)
ERROR - 	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
ERROR - 	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
ERROR - 	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2027)
ERROR - 	... 11 more
pi11 ★★★★★
() автор топика
Ответ на: комментарий от pi11

Ан нет. не отключился ipv6.

pi11 ★★★★★
() автор топика
Ответ на: комментарий от thevery

Может мало гуглил, но быстро найти ответа не смог.

pi11 ★★★★★
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.