tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <h...@gefionsoftware.com>
Subject Re: problem with SQL tags
Date Mon, 18 Nov 2002 17:00:06 GMT
John C Cartwright wrote:
> 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","testuser","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?

JSTL uses the standard Java API to look up the driver classes, which
means it finds any class that is in the web apps classpath. It's the
same no matter what type of code you use in the JSP page. If the class
files really are in WEB-INF/lib, the only thing I can suggest is making
sure that the JDBC URL is syntactically correct. If you still can't
get it to work, it may be a bug in the JSTL implementation. Are you sure
you use the JSTL implementation from Apache Taglibs? Note that Resin
bundles it's own implementation.

Hans

> 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
> 
> 
> 
> 

-- 
Hans Bergsten                                <hans@gefionsoftware.com>
Gefion Software                       <http://www.gefionsoftware.com/>
Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
Details at                                    <http://TheJSPBook.com/>


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message