tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Madonna <st...@netune.com>
Subject RE: mySQL/JDBC/Tomcat4 documentation
Date Wed, 27 Feb 2002 22:18:50 GMT
The app seems to throw the same exception. I'm begining to think there's
something I missed in the configuration file?

-----Original Message-----
From: Filip Hanik [mailto:mail@filip.net]
Sent: Wednesday, February 27, 2002 2:09 PM
To: Tomcat Users List
Subject: RE: mySQL/JDBC/Tomcat4 documentation


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

is not a good way of doing it, if you driver is in the WEB-INF/lib directory
you want to do

Driver d =
Thread.currentThread().getContextClassLoader().loadClass("org.gjt.mm.mysql.D
river").newInstance();
d.getConnection(bla bla bla)

or you can do

Driver d =
this.getClass().getClassLoader().loadClass("org.gjt.mm.mysql.Driver").newIns
tance();
d.getConnection(bla bla bla)


or

Thread.currentThread().getContextClassLoader().loadClass("org.gjt.mm.mysql.D
river");
DriverManager.getConnection(bla bla bla)

Filip

~
Namaste - I bow to the divine in you
~
Filip Hanik
Software Architect
filip@filip.net
www.filip.net

>-----Original Message-----
>From: Steve Madonna [mailto:steve@netune.com]
>Sent: Wednesday, February 27, 2002 2:04 PM
>To: 'Tomcat Users List'
>Subject: RE: mySQL/JDBC/Tomcat4 documentation
>
>
>Right at line 2 in your code is were we are having trouble. Apparenlty our
>code is written the same way, but it still doesn't seem like the
>JDBC driver
>has loaded:
>
>java.sql.SQLException: org.gjt.mm.mysql.Driver
>
>The driver is in the WEB-INF/lib/ directory.
>
>Is there a config file that needs to allow permissions for this?
>
>-----Original Message-----
>From: DingHui [mailto:dh@bisp.com]
>Sent: Tuesday, February 26, 2002 6:34 PM
>To: Tomcat Users List
>Subject: Re: mySQL/JDBC/Tomcat4 documentation
>
>
>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
>>
>


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message