java.lang.ExceptionInInitializerError on DriverManager.getConnection
Posted by: Andy Ford
Date: February 13, 2006 08:46AM

I've just installed mysql-connector-java-3.1.12-bin.jar in my classpath and tried to connect to my local mySQL DB.

Compiling the following works fine, but running it and connecting to mySQL fails with ...
--------------------------
package ps;
import java.sql.*;

public class DataCollector {

private String database = "oui";
private String user = "user";
private String passwd = "password";
private int portNum = 3306;

public DataCollector () {
}

public void getData() {
Statement stmt = null;
Connection conn = null;
ResultSet rs = null;

try {

Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1/" + database + "?port=" + portNum + "&user=" + user + "&password=" + passwd + "&autoReconnect=false");
etc
etc

... fails with the following error...

Exception in thread "main" java.lang.ExceptionInInitializerError
at com.mysql.jdbc.Connection.<init>(Connection.java:1175)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:193)
at ps.DataCollector.getData(DataCollector.java:46)
at ps.PacketSchedular.main(PacketSchedular.java:30)
Caused by: java.lang.RuntimeException: Unable to initialize character set mapping tables
at com.mysql.jdbc.CharsetMapping.<clinit>(CharsetMapping.java:73)
... 6 more

I'm not sure where to look to fix this.

I'm running
Solaris 2.8
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)

Any suggestions

Thanks

Options: ReplyQuote


Subject
Written By
Posted
java.lang.ExceptionInInitializerError on DriverManager.getConnection
February 13, 2006 08:46AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.