GCJ and MySQL Connector for Java

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi everyone,

  I've created a little program to connect to my local MySQL database
and then exit, just for test. Here it is:

  package org.testing;
  import java.sql.*;
  public class TestConnectMySQL {

      public static void main(String[] args) {

          System.out.print("Creating the Database URL...");
          String dbURL = "jdbc:mysql://localhost/MyDat";
          System.out.println("Done!");

          try{
              Class.forName("com.mysql.jdbc.Driver"); // or
Class.forName("org.gjt.mm.mysql.Driver") yields the same result

              DriverManager.setLogStream(System.err);

              System.out.print("Connecting, please wait...");

              Connection conn = DriverManager.getConnection(dbURL);

              System.out.println("Done!");

              System.out.println("OK successfully connected,\n" +
                      "will close now!");
              conn.close();
              System.out.println("Terminated successfully");
          }
          catch(ClassNotFoundException e){System.out.println("Cannot
load driver:\n " + e);}
          catch(SQLException e){System.out.println("Failed Access :-(" + e);}
          catch(Exception e){}
      }
  }

  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}}

 which is produced from my program.

 Compiling into bytecode with Sun's compiler and then executing java
-classpath /usr/share/java/mysql-connector-java.jar TestConnectMySQL
establishes the connection and program executes properly.

 Any ideas? Is it a GCJ issue?

 Thank you all in andance,
 Spyros "Foucault" Stathopoulos


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux