tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "DingHui" ...@bisp.com>
Subject Re: mySQL/JDBC/Tomcat4 documentation
Date Wed, 27 Feb 2002 02:34:28 GMT
The following code demonstrate how to initilize MYSQL JDBC driver.

try {
   Class.forName("org.gjt.mm.mysql.Driver");
  } catch (ClassNotFoundException e) {
   System.out.println(e);
  }

  try {
   Connection con = DriverManager.getConnection("jdbc:mysql://localhost/mydata", "username",
"password");
   Statement stmt = con.createStatement();
   ResultSet rs = stmt.executeQuery("SELECT NAME FROM TEST");
      // Display the SQL Results
         while(rs.next()) {
          System.out.println(rs.getString("NAME"));
      }

      // Make sure our database resources are released
      rs.close();
      stmt.close();
      con.close();
   }catch (SQLException se) {
          // Inform user of any SQL errors
       System.out.println("SQL Exception: " + se.getMessage());
       se.printStackTrace(System.out);
   }
----- Original Message ----- 
From: "Steve Madonna" <steve@netune.com>
To: <tomcat-user@jakarta.apache.org>
Sent: Wednesday, February 27, 2002 8:38 AM
Subject: mySQL/JDBC/Tomcat4 documentation


> Anyone know were I can get some documentation on installing
> mm.mysql-2.0.4-bin.jar file? I keep getting that "not sutible driver" error
> everyone keeps talking about.
> 
> Thx in advance.
> 
> -Steve
> 
Mime
View raw message