Hi all
I am new to mysql with java. Need help on connecting to mysql through
JDBC
version: mysql 4.0.12, source installation with the following configure:
./configure --prefix=/usr/local/mysql
--with-unix-socket-path=/usr/local/mysql/run/mysql_socket
--with-mysqld-user=mysql --with-comment --with-debug
JDBC: mysql-connector-java-3.0.6-stable
OS: Mac OS 10.2.4 with java 1.4.1
when I try to connect using the following
try
{
String userName = "root";
String password = "password";
String url = "jdbc:mysql://localhost/test";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName,
password);
System.out.println ("Database connection established");
}
catch (Exception e)
{
System.err.println ("Cannot connect to database server");
}
I got the following error
Exception in thread "main" java.lang.NoClassDefFoundError:
com/mysql/jdbc/SingleByteCharsetConverter
at
com.mysql.jdbc.Connection.checkServerEncoding(Connection.java:1918)
at
com.mysql.jdbc.Connection.initializePropsFromServer(Connection.java:2327
)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1526)
at com.mysql.jdbc.Connection.<init>(Connection.java:485)
at com.mysql.jdbc.Driver.connect(Driver.java:341)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at sample.Connect.main(Connect.java:27)
looks like it is to do with my mysql encoding settings??
thanks
Best regards
Justin