*malagant*
August 22nd, 2008, 06:43 PM
hi,
maybe someone can help me with my programming problem :/
import java.sql.*;
public class test2 {
public static void main(String[] args) throws Exception {
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
Connection conn = DriverManager.getConnection ("jdbc:mysql://<my_hostname>/<my_database>", "<my_username>", "<my_password>");
conn.close();
}
}
And the result:
Exception in thread "main" com.mysql.jdbc.CommunicationsException: Communications link failure
Last packet sent to the server was 0 ms ago.
at com.mysql.jdbc.SQLError.createCommunicationsExcept ion(SQLError.java:1070)
at com.mysql.jdbc.ConnectionImpl.createNewIO(Connecti onImpl.java:2104)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:729)
at com.mysql.jdbc.ConnectionImpl.getInstance(Connecti onImpl.java:298)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:283)
at java.sql.DriverManager.getConnection(libgcj.so.81)
at java.sql.DriverManager.getConnection(libgcj.so.81)
at test2.main(test2.java:6)
Caused by: java.io.CharConversionException
at gnu.gcj.convert.Input_iconv.read(libgcj.so.81)
at java.lang.String.init(libgcj.so.81)
at java.lang.String.<init>(libgcj.so.81)
at com.mysql.jdbc.SingleByteCharsetConverter.<init>(SingleByteCharsetConverter.java:153)
at com.mysql.jdbc.SingleByteCharsetConverter.initChar set(SingleByteCharsetConverter.java:108)
at com.mysql.jdbc.SingleByteCharsetConverter.getInsta nce(SingleByteCharsetConverter.java:86)
at com.mysql.jdbc.ConnectionImpl.getCharsetConverter( ConnectionImpl.java:2767)
at com.mysql.jdbc.StringUtils.getBytes(StringUtils.ja va:681)
at com.mysql.jdbc.Buffer.writeStringNoNull(Buffer.jav a:665)
at com.mysql.jdbc.Buffer.writeString(Buffer.java:639)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:12 87)
at com.mysql.jdbc.ConnectionImpl.createNewIO(Connecti onImpl.java:2032)
...6 more
I'm using Ubuntu, Eclipse SDK 3.2.2 and the JDBC driver for MySQL that comes via the paketmanager (v5.1.5).
I added /usr/share/java/mysql-connector-java-5.1.5.jar to the Build Path as an external JAR.
The error message appears while using java-1.5.0-gcj-4.2-1.5.0.0.
I tried java-6-sun-1.6.0.06 and openjdk as well, but with both JREs, the program just hangs up, without throwing an exception.
It is not a problem with the database, i can connect from Windows without a problem, and using the MySQL Administrator tool, i can connect from Linux as well. So it must be a problem with JDBC (?).
Does anyone have an idea? :)
maybe someone can help me with my programming problem :/
import java.sql.*;
public class test2 {
public static void main(String[] args) throws Exception {
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
Connection conn = DriverManager.getConnection ("jdbc:mysql://<my_hostname>/<my_database>", "<my_username>", "<my_password>");
conn.close();
}
}
And the result:
Exception in thread "main" com.mysql.jdbc.CommunicationsException: Communications link failure
Last packet sent to the server was 0 ms ago.
at com.mysql.jdbc.SQLError.createCommunicationsExcept ion(SQLError.java:1070)
at com.mysql.jdbc.ConnectionImpl.createNewIO(Connecti onImpl.java:2104)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:729)
at com.mysql.jdbc.ConnectionImpl.getInstance(Connecti onImpl.java:298)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:283)
at java.sql.DriverManager.getConnection(libgcj.so.81)
at java.sql.DriverManager.getConnection(libgcj.so.81)
at test2.main(test2.java:6)
Caused by: java.io.CharConversionException
at gnu.gcj.convert.Input_iconv.read(libgcj.so.81)
at java.lang.String.init(libgcj.so.81)
at java.lang.String.<init>(libgcj.so.81)
at com.mysql.jdbc.SingleByteCharsetConverter.<init>(SingleByteCharsetConverter.java:153)
at com.mysql.jdbc.SingleByteCharsetConverter.initChar set(SingleByteCharsetConverter.java:108)
at com.mysql.jdbc.SingleByteCharsetConverter.getInsta nce(SingleByteCharsetConverter.java:86)
at com.mysql.jdbc.ConnectionImpl.getCharsetConverter( ConnectionImpl.java:2767)
at com.mysql.jdbc.StringUtils.getBytes(StringUtils.ja va:681)
at com.mysql.jdbc.Buffer.writeStringNoNull(Buffer.jav a:665)
at com.mysql.jdbc.Buffer.writeString(Buffer.java:639)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:12 87)
at com.mysql.jdbc.ConnectionImpl.createNewIO(Connecti onImpl.java:2032)
...6 more
I'm using Ubuntu, Eclipse SDK 3.2.2 and the JDBC driver for MySQL that comes via the paketmanager (v5.1.5).
I added /usr/share/java/mysql-connector-java-5.1.5.jar to the Build Path as an external JAR.
The error message appears while using java-1.5.0-gcj-4.2-1.5.0.0.
I tried java-6-sun-1.6.0.06 and openjdk as well, but with both JREs, the program just hangs up, without throwing an exception.
It is not a problem with the database, i can connect from Windows without a problem, and using the MySQL Administrator tool, i can connect from Linux as well. So it must be a problem with JDBC (?).
Does anyone have an idea? :)