From: "Михаил Паршин ака SKeeper" <alt-skeeper@yandex.ru> To: ALT Linux Community general discussions <community@lists.altlinux.org> Subject: [Comm] java mysql Date: Wed, 25 Mar 2009 16:26:02 +0300 Message-ID: <49CA30EA.9090005@yandex.ru> (raw) Всем доброго времени суток. Система: 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)
next reply other threads:[~2009-03-25 13:26 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-03-25 13:26 Михаил Паршин ака SKeeper [this message] 2009-03-25 13:30 ` Slava Semushin 2009-03-25 14:14 ` Михаил Паршин ака SKeeper
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=49CA30EA.9090005@yandex.ru \ --to=alt-skeeper@yandex.ru \ --cc=community@lists.altlinux.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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