LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-17-2007, 02:10 PM   #1
trscookie
Member
 
Registered: Apr 2004
Location: oxford
Distribution: gentoo
Posts: 463

Rep: Reputation: 30
java jdbc and ubuntu problem


Hello all,

Ive just installed Ubuntu and Im trying to build a Java application on it that requires JDBC, I can get it to run on my Gentoo box just not Ubuntu and I think that there could be two reasons to this, one is that I've installed the wrong driver or I've set the CLASSPATH up incorrectly.


This is how I installed the JDBC driver:
Code:
adrian@adrian:~$ sudo apt-cache search jdbc
Password:
...
libmysql-java - Java database (JDBC) driver for MySQL
...


adrian@adrian:~$ sudo apt-get install libmysql-java



Then this is the error I get if I DON'T set the CLASSPATH:

Code:
Error: could not find the jdbc driver: com.mysql.jdbc.Driver not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
Export driver location.
Error with SQL: java.sql.SQLException: No driver found for jdbc:mysql://localhost/diaryDB.


However if I search for the JDBC driver and set the CLASSPATH:
Code:
adrian@adrian:~$ locate jdbc | grep .jar
/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/jre/lib/jdbc-stdext.jar

echo "export CLASSPATH=$CLASSPATH:"/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/jre/lib/jdbc-stdext.jar"" >> ~/.bashrc


I get this error:
Code:
Creating a new host
Error: could not find the jdbc driver: com.mysql.jdbc.Driver not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./,file:/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/jre/lib/jdbc-stdext.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
Export driver location.



A speedy response would be much appreciated, Thanks trscookie.
 
Old 01-19-2007, 01:21 PM   #2
iuaui
Member
 
Registered: Sep 2005
Location: Nummela, Southern Finland
Distribution: Fedora Core 4, Fedora Core 5, Redhat 9.0, Solaris 10, WInXP pro, W2k pro
Posts: 30

Rep: Reputation: 15
Hi,

have you tried "locate mysql | grep .jar" ?
I had same kind of problems finding my mysql-connector library for application server...

Because that jdbc-stdext.jar is definately NOT the driver your MySql uses.
 
Old 01-21-2007, 11:35 AM   #3
robbbert
Member
 
Registered: Oct 2005
Location: Hannover, Germany
Distribution: Let there be Ubuntu... :o)
Posts: 573

Rep: Reputation: 32
Here's what I would do (again):

1. Install Sun Java (right, the JDK/SDK, not just the JRE. I suppose you're needing it anyways at some point.) (And get rid of that 1.4 GNU Java version.):
Code:
sudo apt-get install sun-java5-jdk
2. Make sure the command "java" points to Sun's JRE one:
Code:
sudo update-alternatives --config java
3. Download the mySQL JDBC driver, and copy the JAR to /usr/lib/jvm/java-1.5.0-sun/jre/lib/ext

4. Set the classpath to include /usr/lib/jvm/java-1.5.0-sun/jre/lib/ext
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
jdbc mysql java - please help me j0hnd0e Linux - Software 2 07-22-2006 05:23 AM
Java JDBC driver mickeyboa Fedora 2 07-23-2005 07:53 AM
JDBC connection in java balanagireddy Programming 1 06-30-2004 07:34 AM
JDBC PROBLEM (JAVA using JCreator) keikun_naruchan Programming 3 06-04-2004 02:02 AM
I was working with jdbc in java in which we need navalarora Linux - Software 0 12-05-2003 06:41 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration