Note that there are some explanatory texts on larger screens.

plurals
  1. POClass not found exception with com.mysql.jdbc.Driver
    primarykey
    data
    text
    <p>This is my first post and I hoping I can reach out to the group. I'm pulling my hair out with this problem.</p> <p>I'm running a EC2 Ubuntu micro instance with LAMP. I'm using Java with JDBC to access the mysql database.</p> <p>The issue is that the Java code keeps throwing a "ClassNotFound" Exception when I execute: Class.forName("com.mysql.jdbc.Driver");</p> <p>I have installed the following:</p> <pre><code>sudo apt-get install mysql-server sudo apt-get install mysql-client sudo apt-get install libmysql-java </code></pre> <p>My imports in the Java file are:</p> <pre><code>import java.text.CharacterIterator; import java.text.StringCharacterIterator; import java.util.regex.*; import java.sql.*; import java.util.Properties; import java.net.*; import java.sql.Connection; import java.sql.DriverManager; </code></pre> <p>My $CLASSPATH shows:</p> <pre><code>.:/usr/share/java/mysql.jar:/usr/share/java/mysql-connector-java.jar:/usr/share/java/mysql.jar:/usr/share/java/mysql-connector-java.jar:/usr/share/java/mysql-5.1.10.jar:/usr/share/java/mysql-connector-java-5.1.10.jar </code></pre> <p>In /usr/share/java I have:</p> <pre><code>drwxr-xr-x 3 root root 4096 2012-05-25 02:01 . drwxr-xr-x 316 root root 12288 2012-05-24 21:21 .. -rwxrwxrwx 1 root root 448964 2009-11-23 22:38 gnome-java-bridge.jar -rwxrwxrwx 1 root root 2621 2010-03-05 04:16 libintl.jar lrwxrwxrwx 1 root root 31 2012-05-25 02:01 mysql-5.1.10.jar -&gt; mysql-connector-java-5.1.10.jar -rwxrwxrwx 1 root root 754057 2010-01-26 08:02 mysql-connector-java-5.1.10.jar lrwxrwxrwx 1 root root 31 2012-05-25 02:01 mysql-connector-java.jar -&gt; mysql-connector-java-5.1.10.jar lrwxrwxrwx 1 root root 16 2012-05-25 02:01 mysql.jar -&gt; mysql-5.1.10.jar </code></pre> <p>This is the code that always throws up the exception message to an output file:</p> <pre><code>try { try { Class.forName("com.mysql.jdbc.Driver"); outyyy.write("Class loaded \n"); } catch (ClassNotFoundException e) { outyyy.write("Class not found! \n"); outyyy.write(e.getMessage() + " \n"); } this._connection = DriverManager.getConnection(url, this._user, this._pass); this._isConnected = true; } catch (Exception e) { this._isConnected = false; } </code></pre> <p>I'm not sure if it's relevant but I can access and query the database just fine using PHP.</p> <p>Any assistance is much appreciated.</p> <p>Thanks, Andy</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload