[Comm] java mysql
íÉÈÁÉÌ ðÁÒÛÉÎ ÁËÁ SKeeper
alt-skeeper ÎÁ yandex.ru
óÒ íÁÒ 25 16:26:02 MSK 2009
÷ÓÅÍ ÄÏÂÒÏÇÏ ×ÒÅÍÅÎÉ ÓÕÔÏË.
óÉÓÔÅÍÁ: 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)
ðÏÄÒÏÂÎÁÑ ÉÎÆÏÒÍÁÃÉÑ Ï ÓÐÉÓËÅ ÒÁÓÓÙÌËÉ community