This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: GCJ and MySQL Connector for Java
- From: Anthony Green <green at redhat dot com>
- To: Spyros Stathopoulos <foucault dot online at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sun, 20 Nov 2005 07:43:36 -0800
- Subject: Re: GCJ and MySQL Connector for Java
- References: <235746bf0511200710g5760e1cap5663ee8b2d8efcea@mail.gmail.com>
On Sun, 2005-11-20 at 17:10 +0200, Spyros Stathopoulos wrote:
> I compile it succesfully with gcj as following
> gcj -o MySQL-Test --main=org.testing.TestConnectMySQL -classpath
> /usr/share/java/mysql-connector-java.jar:.
> src/org/testing/TestConnectMySQ
> L.java
>
> However when I am trying to execute the output program I get the
> following error:
>
> Cannot load driver:
> java.lang.ClassNotFoundException: com.mysql.jdbc.Driver not found in
> gnu.gcj.runtime.SystemClassLoader{urls=[file:./,file:./],
> parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
Your program isn't finding the mysql-connector-java code. There are
lots of ways to fix this:
1. Compile mysql-connector-java.jar to native code and force it into the
MySQL-Test link; or..
2. On Linux, compile mysql-connector-java.jar into lib-com-mysql-jdbc.so
and make sure the runtime linker can find it (perhaps by setting
LD_LIBRARY_PATH); or...
3. Set your CLASSPATH environment variable to point at
mysql-connector-java.jar before running MySQL-Test; or...
4. Do [3] and also set up a mapping between the .jar file and a
native .so using gcj-dbtool; or...
5. If you're using Fedora Core 4 or better, just download, build and
install the mysql connector source RPM from here:
http://people.redhat.com/green/FC/ , then do [3]. It will use a
natively compiled version at runtime.
AG