GCJ and MySQL Connector for Java

Spyros Stathopoulos foucault.online@gmail.com
Tue Nov 22 09:16:00 GMT 2005


OK, I have something new, however I do not know if this is a "legal" way.

I've bundled all the source files for mysql connector found in the
source rpm in a single jar file and compiled it into a shared library,
which I've copied in /usr/lib.

gcj  -classpath /usr/share/java/log4j.jar -shared -o
libmysql-connector-java-3.1.8.so mysql-connector-java-3.1.8.jar

After running ldconfig, I compile sucessfully my program with GCJ as following:

gcj  -O0 -g  "--classpath=/usr/share/java/mysql-connector-java.jar:./src/:"
 -c src/org/testing/TestConnectMySQL.java -o
src/org/testing/TestConnectMySQL.o

gcj  -O0 -g  --main=org.testing.TestConnectMySQL
src/org/testing/Connect.o  -odebug/MySQL-Test -Ldebug
-lmysql-connector-java-3.1.8

However I still get the exact same error.

It seems I'm missing something :-/


On 11/20/05, Spyros Stathopoulos <foucault.online@gmail.com> wrote:
> Hi Anthony and thanks for your answer,
>
> I am trying out the first way you have suggested, which is the easier
> for me to understand :-) , however I have several errors
>
> com/mysql/jdbc/ServerPreparedStatement.java: In class
> 'com.mysql.jdbc.Connection':
> com/mysql/jdbc/ServerPreparedStatement.java: In method
> 'com.mysql.jdbc.Connection.execSQL(com.mysql.jdbc.Statement,java.lang.String,int,com.mysql.jdbc.Buffer,int,int,boolean,boolean,java.lang.String,boolean,byte)':
> com/mysql/jdbc/ServerPreparedStatement.java:2323: error: verification
> error at PC=636
> com/mysql/jdbc/ServerPreparedStatement.java:2323: error: might
> transfer control into subroutine
> com/mysql/jdbc/ServerPreparedStatement.java: In class
> 'com.mysql.jdbc.ServerPreparedStatement':
> com/mysql/jdbc/ServerPreparedStatement.java: In method
> 'com.mysql.jdbc.ServerPreparedStatement.executeBatch()':
> com/mysql/jdbc/ServerPreparedStatement.java:713: error: verification
> error at PC=521
> com/mysql/jdbc/ServerPreparedStatement.java:713: error: might transfer
> control into subroutine
> com/mysql/jdbc/log/Log4JLogger.java: In class 'com.mysql.jdbc.log.Log4JLogger':
> com/mysql/jdbc/log/Log4JLogger.java: In constructor '(java.lang.String)':
> com/mysql/jdbc/log/Log4JLogger.java:41: error: cannot find file for
> class org.apache.log4j.Logger
> com/mysql/jdbc/log/Log4JLogger.java:42: error: cannot find file for
> class org.apache.log4j.Logger
> com/mysql/jdbc/log/Log4JLogger.java:42: confused by earlier errors, bailing out
>
> By the way I've tried out 3; it doesn't seem to work, however I'm
> giving it a try again.
>
> Spyros "Foucault" Stathopoulos
>
> On 11/20/05, Anthony Green <green@redhat.com> wrote:
> > 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
> >
> >
> >
>



More information about the Gcc-help mailing list