From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on sa.int.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,SPF_PASS autolearn=ham version=3.2.5 X-Yandex-Spam: 1 X-Yandex-Front: smtp5 X-Yandex-TimeMark: 1237987491 X-BornDate: 1217970000 X-Yandex-Karma: 0 X-Yandex-KarmaStatus: 0 X-MsgDayCount: 1 X-Comment: RFC 2476 MSA function at smtp5.yandex.ru logged sender identity as: alt-skeeper Message-ID: <49CA30EA.9090005@yandex.ru> Date: Wed, 25 Mar 2009 16:26:02 +0300 From: =?UTF-8?B?0JzQuNGF0LDQuNC7INCf0LDRgNGI0LjQvSDQsNC60LAgU0tlZXBlcg==?= User-Agent: Thunderbird 2.0.0.17 (X11/20080929) MIME-Version: 1.0 To: ALT Linux Community general discussions Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: [Comm] java mysql X-BeenThere: community@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Community general discussions List-Id: ALT Linux Community general discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Mar 2009 13:25:22 -0000 Archived-At: List-Archive: List-Post: Всем доброго времени суток. Система: 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="); 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.(сonnectionImpl.java:723) at com.mysql.jdbc.JDBC4сonnection.(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.(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.(Socket.java:366) at java.net.Socket.(Socket.java:208) at com.mysql.jdbc.StandardSocketFactory.сonnect(StandardSocketFactory.java:253) at com.mysql.jdbc.MysqlIO.(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)