Gareth,

What are the errors?

We're running mysql under Tomcat and our corresponding code is:
            Class.forName("org.gjt.mm.mysql.Driver").newInstance();
            this.connection = DriverManager.getConnection("jdbc:mysql://" +
this.databaseHost +":" + this.databasePort + "/" + this.databaseName +
"?user=" + this.databaseUsername + "&password=" + this.databasePassword);

This works fine, but I guess it's more likely a class loading problem you're
having.  I'd check that mysql.jar is under Tomcat/common/lib.  We've also
got jdbc2_0-stdext.jar there, although I'm not sure this is required any
more.

Andy

> -----Original Message-----
> From: Lawrence, Gareth [mailto:[EMAIL PROTECTED]]
> Sent: 15 April 2002 05:53
> To: 'Tomcat Users List'
> Subject: Mysql and Tomcat
>
>
> Greetings All,
>
> Just when I though everything was sweet I'm having a nasty
> problem.  I'm running:
> Debian Linux, Tomcat 4.0.3, Mysql, Ant, MM JDBC driver.
>
> Basically I've set everything up sweet and when I run a test file
> from the command line (java test.class) I get a connection to the
> database no problems.  Unfortunately when I try and do the same
> thing through a servlet loaded onto Tomcat I get grief!!!  See below
> I get two errors outputted in the browser window, the second one
> could be caused by the first :-)
>
> If anyway has any ideas about this, please let me know this is a
> desperate one :-(((
>
> Thanks heaps and heaps,
>
> Gareth
>
> Code:
>
>     try {
>         //Registering the MySQL JDBC Driver
>         Class.forName("org.gjt.mm.mysql.Driver").newInstance();
>     }
>         catch (Exception E) {
>         out.println("<p>Exception: Created Driver</p>");
>         System.err.println("Unable to load driver.");
>         E.printStackTrace();
>     }
>
>     try {
>         //create variable url containing connecting value
>         String url="jdbc:mysql://localhost/weblearn";
>         //Create Connection Object from java.sql.*
>         Connection Conn = DriverManager.getConnection(url, "root", "");
>     }
>         //Exceptions if something went wrong
>         catch (SQLException E) {
>         out.println("<p>SQL Exception</p>");
>     }
>
>
>



--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to