ALT Linux Community general discussions
 help / color / mirror / Atom feed
* [Comm] java mysql
@ 2009-03-25 13:26 Михаил Паршин ака SKeeper
  2009-03-25 13:30 ` Slava Semushin
  0 siblings, 1 reply; 3+ messages in thread
From: Михаил Паршин ака SKeeper @ 2009-03-25 13:26 UTC (permalink / raw)
  To: ALT Linux Community general discussions

Всем доброго времени суток.

Система: 4.1 branch
IDE: Eclipse
JRE: 1.6

Вроде как делаю все правильно, но видимо где-то туплю. Сам не догоняю, 
так что прошу помощи.
Скачал и подключил при помощи "Add External JARs" 
mysql-сonnector-java-5.1.7.
Имя БД, юзер и пароль верные. Есть стандартный код (вроде как во всех 
примерах подключения к мускулю из явы он одинаков):

try
{
сonnection сonnect = DriverManager.getсonnection("jdbc:mysql://localhost/
tovarouchet?user=root&password=<pass>");
Statement stmt = сonnect.createStatement();
}
catch(SQLException e)
{
System.out.println("Ошибка! Не удалось подключиться к базе данных!");
e.printStackTrace();
}

При запуске на выполнение вываливает эксепшн:
Ошибка! Не удалось подключиться к базе данных!
CommunicationsException: Communications link failure


Last packet sent to the server was 0 ms ago.

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.сonnectionImpl.createNewIO(сonnectionImpl.java:2120)
at com.mysql.jdbc.сonnectionImpl.<init>(сonnectionImpl.java:723)
at com.mysql.jdbc.JDBC4сonnection.<init>(JDBC4сonnection.java:46)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.сonnectionImpl.getInstance(сonnectionImpl.java:302)
at 
com.mysql.jdbc.NonRegisteringDriver.сonnect(NonRegisteringDriver.java:282)
at java.sql.DriverManager.getсonnection(DriverManager.java:582)
at java.sql.DriverManager.getсonnection(DriverManager.java:207)
at ru.tovarouchet.utils.DBсonnect.сonnect(DBсonnect.java:32)
at ru.tovarouchet.TovaroUchet.test(TovaroUchet.java:212)
at ru.tovarouchet.TovaroUchet.main(TovaroUchet.java:242)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 
Communications link failure

Last packet sent to the server was 1 ms ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:335)
at com.mysql.jdbc.сonnectionImpl.createNewIO(сonnectionImpl.java:2043)
... 14 more
Caused by: java.net.сonnectException: сonnection refused
at java.net.PlainSocketImpl.socketсonnect(Native Method)
at java.net.PlainSocketImpl.doсonnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.сonnectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.сonnect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.сonnect(SocksSocketImpl.java:366)
at java.net.Socket.сonnect(Socket.java:519)
at java.net.Socket.сonnect(Socket.java:469)
at java.net.Socket.<init>(Socket.java:366)
at java.net.Socket.<init>(Socket.java:208)
at 
com.mysql.jdbc.StandardSocketFactory.сonnect(StandardSocketFactory.java:253)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
... 15 more
Exception in thread "main" java.lang.NullPointerException
at ru.tovarouchet.utils.DBсonnect.executeUpdate(DBсonnect.java:61)
at ru.tovarouchet.TovaroUchet.test(TovaroUchet.java:213)
at ru.tovarouchet.TovaroUchet.main(TovaroUchet.java:242)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-03-25 14:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-25 13:26 [Comm] java mysql Михаил Паршин ака SKeeper
2009-03-25 13:30 ` Slava Semushin
2009-03-25 14:14   ` Михаил Паршин ака SKeeper

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git