Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ClassNotFoundException: com.mysql.jdbc.Driver [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
dustfinger
Guru
Guru


Joined: 15 Aug 2004
Posts: 449

PostPosted: Sun Jul 31, 2005 10:50 pm    Post subject: ClassNotFoundException: com.mysql.jdbc.Driver [SOLVED] Reply with quote

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
View user's profile Send private message
MrStaticVoid
Tux's lil' helper
Tux's lil' helper


Joined: 25 Jul 2003
Posts: 114
Location: Maryland

PostPosted: Mon Aug 01, 2005 12:14 am    Post subject: Reply with quote

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
View user's profile Send private message
dustfinger
Guru
Guru


Joined: 15 Aug 2004
Posts: 449

PostPosted: Tue Aug 02, 2005 11:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
audiodef
Watchman
Watchman


Joined: 06 Jul 2005
Posts: 6639
Location: The soundosphere

PostPosted: Thu Sep 29, 2005 3:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
nomadsoul
Apprentice
Apprentice


Joined: 14 Mar 2004
Posts: 172

PostPosted: Fri Sep 15, 2006 3:19 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum