tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher Williams" <ccwillia...@ntlworld.com>
Subject Re: tomcat+j2sdk+mysql-connecto+mysql
Date Tue, 02 Sep 2003 10:14:45 GMT
Try to isolate the problem.  Check that you can get a Connection object by
doing something like the following:

String driver = ...;
String url = ...;
String userName = ...;
String pw = ...;
Connection conn = null;

try {
    Class.forName(driver);
    conn = DriverManager.getConnection(url, userName, pw);
} catch (Exception e) {
    e.printStackTrace();
}

// Do something with conn...
if (null != conn) {
    ...
    try {
        conn.close();
    } catch (Exception e) {}
    conn = null;
}

This will enable you to isolate where your problem lies.  If you can get a
Connection object then your database and JDBC driver are set up correctly,
you have the correct URL for the data source, you have a valid user name and
password and the problem lies with the Wrox ConnectionPool class.  Otherwise
some element of your database setup is incorrect.

Check that you are referencing the driver class correctly.  When I need to
talk to MySQL I use the Connector /J driver available from the MySQL web
site:
http://www.mysql.com/downloads/api-jdbc-stable.html

The name of the driver is:
    com.mysql.jdbc.Driver
Check that you have spelt it correctly.

Assume that you are accessing a MySQL database called "my_db" on localhost.
The URL to the datasource takes the form:
    jdbc:mysql://localhost:3306/im_audit
If MySQL is not listening on port 3306, you will need to change the port
value.  I leave user name and password to you - you can always use "root"
during development.

Chris Williams.



Mime
View raw message