S
shahbazc
Hi,
I am running tomcat 5.5.4 and trying to use JSTL sql tag. I setup a
data source though Tomcat's admin web-app for Postgresql (8 beta). I
made sure the jdbc jar is in common/lib (I even specifically added it
to the class path through setclasspath.sh). I still get a
"java.sql.SQLException: No suitable driver" exception.
I tested the jdbc driver using jdbctester...because of that I'm pretty
sure the driver works. I copied the URL format from jdbctester to
tomcat (some online references suggested that the url might be
malformed), but it still doesn't work!
Following is some relevant information:
test.jsp (I DON'T get any exception in the code between <% and %>
tags!):---------------------------------------------
<html>
<head>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
</head>
<body>
<%
org.postgresql.jdbc3.Jdbc3PoolingDataSource source=new
org.postgresql.jdbc3.Jdbc3PoolingDataSource();
source.setDataSourceName("ssx");
source.setServerName("localhost");
source.setDatabaseName("ss");
source.setUser("postgres");
out.println(new org.postgresql.Driver());
%>
<sql:setDataSource driver="org.postgresql.Driver"
url="jdbcostgresql://localhost/ss"
user="postgres" dataSource="new
org.postgresql.jdbc3.Jdbc3PoolingDataSource()"
var="ds" scope="session" />
<sql:query var="result" dataSource="jdbc/postgres"
sql="select symbol,sum(orders) from loaddata where month=200411 group
by symbol"/>
<table>
<c:forEach items="$result.rows}" var="row">
<tr><td>hello!</td></tr>
</c:forEach>
</table>
</body>
</html>
web.xml:-------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>Hello, World Application</display-name>
<description>
This is a simple web application with a source code
organization
based on the recommendations of the Application Developer's
Guide.
</description>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>mypackage.Hello</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/sql</taglib-uri>
<taglib-location>/WEB-INF/tld/sql.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/core</taglib-uri>
<taglib-location>/WEB-INF/tld/c.tld</taglib-location>
</taglib>
<!--I explicitly added this resource-ref, hopeing that this would fix
my problem-->
<resource-ref>
<description>postgreSQL Datasource example</description>
<res-ref-name>jdbc/postgres</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
server.xml:---------------------
<?xml version='1.0' encoding='utf-8'?>
<Server>
<Listener
className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
<Listener
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer"
value="30"/>
<Resource auth="Container" description="User database that can be
updated and saved" name="UserDatabase"
type="org.apache.catalina.UserDatabase"
pathname="conf/tomcat-users.xml"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
<Resource name="jdbc/postgres" type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver" password="" maxIdle="2"
maxWait="5000" validationQuery="select count(*) from loaddata where
month=200411" username="postgres" url="jdbcostgresql://localhost/ss"
maxActive="4"/>
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8080" redirectPort="8443" maxSpareThreads="75"
maxThreads="150" minSpareThreads="25">
</Connector>
<Connector port="8009" protocol="AJP/1.3"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"
redirectPort="8443">
</Connector>
<Engine defaultHost="localhost" name="Catalina">
<Host appBase="webapps" name="localhost">
</Host>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
</Engine>
</Service>
</Server>
By the way, this seemed like the most relevant newsgroup, if there is a
better source for help, please let me know. Thanks!
I am running tomcat 5.5.4 and trying to use JSTL sql tag. I setup a
data source though Tomcat's admin web-app for Postgresql (8 beta). I
made sure the jdbc jar is in common/lib (I even specifically added it
to the class path through setclasspath.sh). I still get a
"java.sql.SQLException: No suitable driver" exception.
I tested the jdbc driver using jdbctester...because of that I'm pretty
sure the driver works. I copied the URL format from jdbctester to
tomcat (some online references suggested that the url might be
malformed), but it still doesn't work!
Following is some relevant information:
test.jsp (I DON'T get any exception in the code between <% and %>
tags!):---------------------------------------------
<html>
<head>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
</head>
<body>
<%
org.postgresql.jdbc3.Jdbc3PoolingDataSource source=new
org.postgresql.jdbc3.Jdbc3PoolingDataSource();
source.setDataSourceName("ssx");
source.setServerName("localhost");
source.setDatabaseName("ss");
source.setUser("postgres");
out.println(new org.postgresql.Driver());
%>
<sql:setDataSource driver="org.postgresql.Driver"
url="jdbcostgresql://localhost/ss"
user="postgres" dataSource="new
org.postgresql.jdbc3.Jdbc3PoolingDataSource()"
var="ds" scope="session" />
<sql:query var="result" dataSource="jdbc/postgres"
sql="select symbol,sum(orders) from loaddata where month=200411 group
by symbol"/>
<table>
<c:forEach items="$result.rows}" var="row">
<tr><td>hello!</td></tr>
</c:forEach>
</table>
</body>
</html>
web.xml:-------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>Hello, World Application</display-name>
<description>
This is a simple web application with a source code
organization
based on the recommendations of the Application Developer's
Guide.
</description>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>mypackage.Hello</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/sql</taglib-uri>
<taglib-location>/WEB-INF/tld/sql.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/core</taglib-uri>
<taglib-location>/WEB-INF/tld/c.tld</taglib-location>
</taglib>
<!--I explicitly added this resource-ref, hopeing that this would fix
my problem-->
<resource-ref>
<description>postgreSQL Datasource example</description>
<res-ref-name>jdbc/postgres</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
server.xml:---------------------
<?xml version='1.0' encoding='utf-8'?>
<Server>
<Listener
className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
<Listener
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer"
value="30"/>
<Resource auth="Container" description="User database that can be
updated and saved" name="UserDatabase"
type="org.apache.catalina.UserDatabase"
pathname="conf/tomcat-users.xml"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
<Resource name="jdbc/postgres" type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver" password="" maxIdle="2"
maxWait="5000" validationQuery="select count(*) from loaddata where
month=200411" username="postgres" url="jdbcostgresql://localhost/ss"
maxActive="4"/>
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8080" redirectPort="8443" maxSpareThreads="75"
maxThreads="150" minSpareThreads="25">
</Connector>
<Connector port="8009" protocol="AJP/1.3"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"
redirectPort="8443">
</Connector>
<Engine defaultHost="localhost" name="Catalina">
<Host appBase="webapps" name="localhost">
</Host>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
</Engine>
</Service>
</Server>
By the way, this seemed like the most relevant newsgroup, if there is a
better source for help, please let me know. Thanks!