tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Boon K. Chee" <>
Subject Re: problem with mysql and tomcat
Date Wed, 24 Apr 2002 16:49:27 GMT
Dear Manny,

      I'm not an expert in mysql, but I did manage to run my apache2, tomcat
4 and mysql without any problem. I think the problem you have might not be
the mm.mysql driver problem. It seems to me that either your sql
statement(when you open the connection to mysql) is not quite right because
the mysql server has denied your access to the database. Make sure you put
your sql statement correctly when you open a connection. Below is the sample
code I use to connect to mysql:

  String connectionURL = "jdbc:mysql://servername/database_name";
  Connection connection = null;
  Statement statement = null;
  ResultSet resultSet = null;
   connection = DriverManager.getConnection(connectionURL, "username", 
   statement = connection.createStatement();
   resultSet = statement.executeQuery("SELECT Name, Username FROM tblUsers "
            "ORDER BY Name");
   while ({
    out.println("<tr><td>" + resultSet.getString("Name") + "</td><td>"
       + resultSet.getString("Username") + "</td></tr>");
   if (resultSet != null){
  } catch (ClassNotFoundException e){
   System.err.println("Couldn't find the mm " + "database driver: " + e
  } catch (InstantiationException e) {
  } catch (IllegalAccessException e) {
  } catch (SQLException e) {
   System.err.println("SQL Problem : " + e.getMessage());
   System.err.println("SQL State   : " + e.getSQLState());
   System.err.println("Vendor Error: " + e.getErrorCode());

    Just substitute those servername, database_name, username and password
with your own. Hope this help. bye.

-------Original Message-------

From: Tomcat Users List
Date: Tuesday, April 23, 2002 01:38:04 AM
Subject: problem with mysql and tomcat

hi i've downloaded the mysql and loaded the driver(mm.nysql) driver for it
If i try to use it in a regular program without involving the server(tomcat3
2.1) it works fine . i can get the resultset etc which is fine. But when i
created another applicatoin which involved the use of Tomcat it gives me
error saying 

Started: 21:13:29.210 PM
Error: java.sql.SQLException: Invalid authorization specification: Access
denied for user: 'username@localhost' (Using password: YES) 

i've looked at hundreds of webpages but nothing so far has revealed a
suitable reaason and solution for it. one webpage said to put the jar file
in WEB-INF/lib dir but in my version of tomcat3.2.1 theres no subdirectory
as that . if anyone knows the solution to it please let me email
address is
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message