LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   missing jdbc isnt actually missing. (http://www.linuxquestions.org/questions/programming-9/missing-jdbc-isnt-actually-missing-451499/)

trscookie 06-04-2006 10:26 AM

missing jdbc isnt actually missing.
 
hello all ive just emerge'd jdbc-mysql and i cant get a single jdbc application to work, im trying to do an assignment for university, and part of it is to write a jdbc database using mysql i tried this code from sun.

Code:
Code:

package JDBC.Connect;

  import java.sql.*;

  public class Connect
  {
      public static void main (String[] args)
      {
          Connection conn = null;

          try
          {
              String userName = "testuser";
              String password = "testpass";
              String url = "jdbc:mysql://localhost/test";
              Class.forName ("com.mysql.jdbc.Driver").newInstance ();
              conn = DriverManager.getConnection (url, userName, password);
              System.out.println ("Database connection established");
          }
          catch (Exception e)
          {
              System.err.println ("Cannot connect to database server");
          }
          finally
          {
              if (conn != null)
              {
                  try
                  {
                      conn.close ();
                      System.out.println ("Database connection terminated");
                  }
                  catch (Exception e) { /* ignore close errors */ }
              }
          }
      }
  }



but this is the error i get:

Code:
Code:

Cannot connect to database server
if i add e.getMessage to the end of the last output it says:
Code:

com.mysql.jdbc.Driver
so basicly i think that its looking for the jdbc class file, however 1. i dont know where gentoo puts it, and 2. i wouldnt know what to do with it when i have found it!!!.

please please help this is worth 65% of my whole course and i cant even get it to connect to the database!!! cheers trscookie


All times are GMT -5. The time now is 11:16 AM.