Pergunta

I am getting the below error when i am trying to connect to my database.

Exception in thread "main" java.lang.NoClassDefFoundError:     java.util.concurrent.ConcurrentHashMap
at com.mysql.jdbc.NonRegisteringDriver.<clinit>(NonRegisteringDriver.java:83)
at java.lang.Class.initializeClass(libgcj.so.7rh)
at java.lang.Class.initializeClass(libgcj.so.7rh)
at java.lang.Class.forName(libgcj.so.7rh)
at java.lang.Class.forName(libgcj.so.7rh)
at test.main(test.java:14)

Information :

Platform : RHEL 5 Java : jdk1.6.0_45 jdbc connector : mysql-connector-java-5.1.26-bin.jar Sever: Tomcat 6

I have placed the jdbc connector inside usr/share/java/ Directory. and my program to test the connection is placed in the root folder.

I have set the CLASSPATH to point to the connector using EXPORT command. and I am using javac filename.java command to compile & java filename to run it.

Foi útil?

Solução 2

I have installed the old version of mysql connector which was compatible with RHEL5 and now its working fine. Thanks !!

Outras dicas

A JDBC driver doesn't need to be installed or configured. You download the jar, add it to the runtime classpath of your application, and you're done:

java -cp someJar.jar:someDirectory:theMySQLJdbcDriver.jar com.foo.bar.Main
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top