View previous topic :: View next topic |
Author |
Message |
dustfinger Guru
Joined: 15 Aug 2004 Posts: 449
|
Posted: Sun Jul 31, 2005 10:50 pm Post subject: ClassNotFoundException: com.mysql.jdbc.Driver [SOLVED] |
|
|
Both my system wide and user class paths are as follows:
Code: |
CLASSPATH=${CLASSPATH}:/usr/share/jta/lib/jta.jar:/usr/share/ant-core/lib/ant.jar:/usr/share/javacc/lib/javacc.jar:/usr/share/jdbc-mysql/lib/jdbc-mysql.jar:/usr/share/cyrus-sasl-2/lib/cyrus-sasl.jar:/usr/share/ant-core/lib/ant-launcher.jar:/usr/share/log4j/lib/log4j.jar:/usr/share/jdbc2-stdext/lib/jdbc2_0-stdext.jar:/usr/lib/db-4.2.jar:/usr/share/junit/lib/junit.jar
|
I have mysql, apache2, tomcat5 and the mod_jk all emerged. I had to unmask the following:
/etc/portage/package.keywords wrote: |
www-apache/mod_jk ~x86
net-www/apache ~x86
dev-libs/apr ~x86
net-www/gentoo-webroot-default ~x86
dev-libs/apr-util ~x86
|
I have sun-jdk-1.4.2.08 set as my default VM, however I have also tried this with blackdown-jdk-1.4.2.02 set as my default VM.
With mysql, apache2 and tomcat5 all running I tried running a simple java program that uses com.mysql.jdbc.Driver. I have tried the same with org.gjt.mm.mysql.Driver
Code: |
Class.forName("com.mysql.jdbc.Driver");
|
In either case I recieve the java.lang.ClassNotFoundException. Please advise.
dustfinger. _________________ Unanswered Post Initiative:
https://forums.gentoo.org/viewtopic.php?t=119906
Last edited by dustfinger on Tue Aug 02, 2005 11:50 pm; edited 1 time in total |
|
Back to top |
|
|
MrStaticVoid Tux's lil' helper
Joined: 25 Jul 2003 Posts: 114 Location: Maryland
|
Posted: Mon Aug 01, 2005 12:14 am Post subject: |
|
|
For some strange reason, Tomcat from Portage doesn't use the CLASSPATH variable. To use jdbc-mysql:
Code: | # ln -s /usr/share/jdbc-mysql/lib/jdbc-mysql.jar /usr/share/tomcat-5/common/lib/
# /etc/init.d/tomcat restart |
And load org.gjt.mm.mysql.Driver in your code. It should work then. |
|
Back to top |
|
|
dustfinger Guru
Joined: 15 Aug 2004 Posts: 449
|
Posted: Tue Aug 02, 2005 11:08 pm Post subject: |
|
|
Thank you MrStaticVoid,
I am now able to load org.gjt.mm.mysql.Driver from a jsp page. I am, however, unable to load org.gjt.mm.mysql.Driver from a terminal java application. I still get java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver. I even tried
Code: |
ln -s /usr/share/jdbc-mysql/lib/jdbc-mysql.jar /opt/sun-jdk-1.4.2.08/lib/
|
I doulbe checked java-config -l and found
[jdbc-mysql] MySQL JDBC driver (/usr/share/jdbc-mysql/package.env)
[jdbc2-stdext] A standard set of libs for Server-Side JDBC support (/usr/share/jdbc2-stdext/package.env)
So I don't understand why java can't find the class?
dustfinger.
-- EDIT --
I added export CLASSPATH=/usr/share/jdbc-mysql/lib/jdbc-mysql.jar to my .bashrc file and problem solved. I would like to know why adding jdbc-mysql to the classpath using java-config was not sufficient.
---------- _________________ Unanswered Post Initiative:
https://forums.gentoo.org/viewtopic.php?t=119906 |
|
Back to top |
|
|
audiodef Watchman
Joined: 06 Jul 2005 Posts: 6639 Location: The soundosphere
|
Posted: Thu Sep 29, 2005 3:57 pm Post subject: |
|
|
MrStaticVoid wrote: | For some strange reason, Tomcat from Portage doesn't use the CLASSPATH variable. To use jdbc-mysql:
Code: | # ln -s /usr/share/jdbc-mysql/lib/jdbc-mysql.jar /usr/share/tomcat-5/common/lib/
# /etc/init.d/tomcat restart |
And load org.gjt.mm.mysql.Driver in your code. It should work then. |
This solution worked for me. Just before doing this, I had to emerge jdbc-mysql, which asks you to go to Sun's website and download a couple of files. |
|
Back to top |
|
|
nomadsoul Apprentice
Joined: 14 Mar 2004 Posts: 172
|
Posted: Fri Sep 15, 2006 3:19 pm Post subject: |
|
|
I have the same problem with com.mysql.jdbc.Driver and oobase2. How can i solve this?
I already merged jdbc-mysql. |
|
Back to top |
|
|
|