Thanks to Buck and Hans for your reponses. Unfortunately, I'm still having the same problem. I tried:
1) moving the mysql driver JAR file to $TOMCAT/common/lib as Buck suggested
2) unpacking the JAR file into $WEBAPP/WEB-INF/classes
3) getting the latest mysql driver from mysql.com

Still same results, a scriptlet-based connection works, the JSTL doesn't. I've tried both the 1.0.2 version of the JSTL tags as well as the nightly build from last Friday.

Here again is the corresponding connection code. There's no difference that I can see between the driver class name or database URL. Any further suggestions?

Thanks for your help!

-- john


Hans Bergsten wrote:

Bell, Buck (c) wrote:

Hi John,

My $.02. Although I'm not using MySQL, my experience with Tomcat 4.1.12 has
been that I must place the JDBC Driver classes in the Tomcat common/lib
directory. Although this is somewhat in contrast to the JSTL and other
JARs, I found that including the JDBC driver classes in WEB-INF/lib not only
caused the error you described, it did so even when I had the JARs in both
locations. So, you might want to try including the classes ONLY in
common/lib. Of course, once you get the JAR issue resolved, setting up a
JNDI DataSource (with a pooled connection) is even better.

You need to place them in common/lib only if you use JNDI (because the
JNDI machinery is relying on other class loaders than the ones used
for regular web app resources). Without JNDI, they should be found in
WEB-INF/lib. I agree that using JNDI is a good idea, but what John is
trying should work without it.

Hans

-----Original Message-----
From: John C Cartwright [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 18, 2002 11:32 AM
To: Tag Libraries Users List
Subject: Re: problem with SQL tags


Thank you for your reply, Hans. The JDBC driver classes are in the webapps WEB-INF/lib directory and I was assuming that they are being found because a non-JSTL JSP page with a scriptlet block containing:

Connection con;
try {
Class.forName("org.gjt.mm.mysql.Driver");
con = DriverManager.getConnection("jdbc:mysql://myhost.noaa.gov:3306/testdb","test
user","testpass");
} catch (Exception e) {
throw (new ServletException("Error loading Driver: " +e.getMessage()));
}


seems to work fine. Does JSTL look for the Driver classes in a location other than the scriplet-based connection code?

Thanks again!

-- john





Hans Bergsten wrote:


John C Cartwright wrote:


Hello All,

I am hoping that someone can help me to get going with the SQL tags. I'm trying to connect to a mysql database using tomcat4.1.12 and version 1.0.2 of the library.

Here's my JSP:

<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql"; %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"; %>

<HTML>
<HEAD>
</HEAD>
<BODY>
<sql:setDataSource var="monitorDS"
url="jdbc:mysql://myhost.noaa.gov:3306/testdb"
driver="org.gjt.mm.mysql.Driver"
user="testuser"
password="testpass"
/>
</BODY>
</HTML>

I'm getting a:
org.apache.jasper.JasperException: Unable to get connection, DataSource invalid: "No suitable driver"


This is because the JDBC driver classes are not found by the web
container. Make sure you have installed them in the WEB-INF/lib
directory of the application.


[...]

Hans






--
=====================================================
John Cartwright
Associate Scientist
Geospatial Data Services Group
CIRES, National Geophysical Data Center/NOAA
(303) 497-6284
[EMAIL PROTECTED]
=====================================================




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to