Results 1 to 3 of 3

Thread: Mysql problem

  1. #1
    Nick15 is offline Member
    Join Date
    May 2007
    Posts
    38
    Rep Power
    0

    Default Mysql problem

    Hi everybody I am trying to do a basic library system.
    the problem is:
    I downloaded MySQL driver (connector/j) I copied .jar in CLASSPATH/jre/lib/ext
    but it didn't work, I tried to copy the .jar in the directory of my application where I have my .java (or .class in execution time)
    but when I execute the application the following error appear:

    java.lang.ClassNotFoundException: Resource not found:
    com/mysql/jdbc/Driver.class

    this is the code:
    Java Code:
    try{
         
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    aqui parece estar el error.
          String url =
    "jdbc:mysql://mysql.webcindario.com";
          String login = "user";
          String password = "password";
          Connection conn =
    DriverManager.getConnection(url,login,password);  
          if (conn != null)
          {
            JOptionPane.showMessageDialog(null,
    "conexion", "alert", JOptionPane.ERROR_MESSAGE);
            conn.close();
          } 
        }
        catch(SQLException sql)
        {
          sql.printStackTrace();
        }
        catch(ClassNotFoundException cnfe)
        {
          cnfe.printStackTrace();
        }
        catch (Exception ex) {
          ex.printStackTrace();
        }
    Please help me
    Nick
    Last edited by Nick15; 06-01-2007 at 12:41 AM.

  2. #2
    pegitha is offline Member
    Join Date
    Apr 2007
    Location
    Indiana
    Posts
    83
    Rep Power
    0

    Default

    Is this a web app ?

  3. #3
    Freddie is offline Member
    Join Date
    May 2007
    Posts
    41
    Rep Power
    0

    Default

    I give you 2 solutions:

    1 the official one: Add the driver to classpath, never mind where the applet and the connector are
    it would be something like this:
    JAVA_HOME=/usr/local/jdk1.x
    export JAVA_HOME
    CLASSPATH=${JAVA_HOME}/lib/tools.jar
    CLASSPATH=${CLASSPATH}:${JAVA_HOME}/jre/lib/ext/theconnector.jar
    export CLASSPATH
    (is an example)

    2. not official one (but it works!): unzip connector.jar, do it with winrar (WinRAR archiver, a powerful tool to process RAR and ZIP files) when you unzip there are folders in a hierarchy order,
    start with 'com' folder,explorer it: com->mysql->jdbc, copy 'com' folder (with its content) into directory where there are the applet whose connect to mysql
    and that is!

    good luck!

Similar Threads

  1. problem in connecting to mysql database
    By nancyv in forum Java Servlet
    Replies: 6
    Last Post: 04-02-2008, 11:33 AM
  2. Replies: 0
    Last Post: 03-29-2008, 03:36 PM
  3. mysql driver problem
    By mokingsu in forum JDBC
    Replies: 4
    Last Post: 01-17-2008, 05:27 PM
  4. Replies: 0
    Last Post: 12-24-2007, 09:47 AM
  5. JSP and MySQL
    By Ed in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 07-04-2007, 05:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •