1 Reply Latest reply on May 21, 2006 8:17 AM by dominique echalier

    mysql-connector-java-3.1.12 problem with apache while OK wit

    dominique echalier Newbie

      With terminal I have :

      CLASSPATH=/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/:/Library/Java/Extensions/:./
      SUDO_GID=20
      SECURITYSESSIONID=210800
      _=/usr/bin/printenv

      127:/Library/WebServer/Documents/Java root# java TestMySQL
      2006-05-21 13:39:00.0 ************************** = OK
      127:/Library/WebServer/Documents/Java root#

      with

      import java.sql.*;
      /**
       * mysql-connector-java-3.1.12-bin.jar
       *
       */
      /**
       * % javac /Library/WebServer/Documents/Java/TestMySQL.java
       * % java -classpath /usr/local/lib/mysql/mysql-connector-java-3.1.12-bin.jar:. TestMySQL
       */
      public class TestMySQL {
      
      
       public static void main(String argv[]) throws Exception {
      
       // Load the driver class
       //
       Class.forName("org.gjt.mm.mysql.Driver");
      
       //Class theClass = null;
       //try {
       // theClass = Thread.currentThread().getContextClassLoader().loadClass("org.gjt.mm.mysql.Driver");
       //}
       //catch (ClassNotFoundException e) {
       // theClass = getClass().getClassLoader().loadClass("org.gjt.mm.mysql.Driver");
       //}
       Connection conn = DriverManager.getConnection(
       "jdbc:mysql:///test",
       "",
       ""
       );
       Statement stmt = conn.createStatement();
       ResultSet rset = stmt.executeQuery("SELECT now();");
       while (rset.next()) {
       System.out.println(rset.getString(1));
       }
      
       // Close result set, statement and DB connection
       //
       rset.close();
       stmt.close();
       conn.close();
       }
      }
      


      I have a simple TestMySQL.html file with applet TestMySQL.class in it.

      Nothing but "Applet TestMySQL not inited"

      When I uncomment the try/catch lines, java compiler generate an error...
      With "Class.forName("org.gjt.mm.mysql.Driver");" no problem.

      Running MacOS X 10.3.9, Apache/1.3.33 (Darwin) PHP/4.4.1 mod_ssl/2.8.24 OpenSSL/0.9.7i and JVM 1.4.2_09

      Thanks for help.