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.