java.sql.* works, JSTL:SQL does not ?

From: Steffen Neumann <sneumann(at)TechFak(dot)Uni-Bielefeld(dot)DE>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: java.sql.* works, JSTL:SQL does not ?
Date: 2004-11-18 14:39:21
Message-ID: s5uy8gzte5i.fsf@ravel.TechFak.Uni-Bielefeld.DE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,

I am having a problem getting JSP pages with JSTL SQL
connecting to PostgreSQL to work in JDeveloper/OC4J.

I do have a working setup connecting to postgres
from a plain JSP page, as well as connecting
to an Oracle server from both JSTL SQL and plain JSP.
The JSP pages are at the end of this mail.

I tried several URLs, like
url="jdbc:postgresql://localhost:5432/tea"
url="jdbc:postgresql:tea"
to no avail.

What could be the difference between the hand-created Connection
and the JSTL variant ? What could be the difference between
the postgresql.jar and the oracle JDBC driver that makes the
latter work in my setup ? The postgresql.jar is taken from libpgjava
in Debian and has been compiled with JDK 1.4 package from Blackdown

Postgresql is 7.4.5-3 (Debian), using postgresql-jdbc[23]-7.4.2.jar,
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)

Hope there is someone out who could help,
yours,
Steffen

============================================================================
This code works fine in my setup and delivers the results:

<%@ page contentType="text/html;charset=US-ASCII"
import="java.sql.*"%>

<%
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection("jdbc:postgresql:tea", "myusername", "mypassword");
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>untitled</title>
</head>
<body>
<%
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from fgroup");
while (rs.next()) {
%>
<%=rs.getString("gname")%>
<%
}
%>
</body>
</html>
---------------------------------------------------------------------

This code gives an JspException

<%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql"%>
<%@ page contentType="text/html;charset=US-ASCII"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>untitled</title>
</head>
<body>

<sql:setDataSource
url="jdbc:postgresql://localhost:5432/tea"
driver="org.postgresql.Driver"
user="myusername" password="mypassword" />

(untitled1.jsp:16) <sql:query var="news">
SELECT gname FROM fgroup
</sql:query>
</body>
</html>

javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "No suitable driver"
at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:308)
at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:192)
at org.apache.taglibs.standard.tag.el.sql.QueryTag.doStartTag(QueryTag.java:125)
at _untitled1._jspService(untitled1.jsp:16)
[/untitled1.jsp]
at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:139)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:349)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:604)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:534)

---------------------------------------------------------------------

This code works fine in my setup and delivers the results:

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql"%>
<%@ page contentType="text/html;charset=US-ASCII"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>untitled</title>
</head>
<body>

<sql:setDataSource
dataSource="jdbc:oracle:thin:@my.host.de:1521:SID,oracle.jdbc.driver.OracleDriver,myusername,mypassword" />

<sql:query var="genes">
SELECT gid, gname FROM fgroup
</sql:query>

<table width="100%">
<%-- Get the column names for the header of the table --%>
<c:forEach var="columnName" items="${genes.columnNames}">
<th><c:out value="${columnName}"/></th>
</c:forEach>

<%-- Get the value of each column while iterating over rows --%>
<c:forEach var="row" items="${genes.rows}">
<tr>
<c:forEach var="column" items="${row}">
<td><c:out value="${column.value}"/></td>
</c:forEach>
</tr>
</c:forEach>
</table>
</body>
</html>

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Vadim Nasardinov 2004-11-18 18:20:32 1+1+16 = 18 failures (was: Re: JDBC CTS 1.2.1)
Previous Message Oliver Jowett 2004-11-17 20:25:34 Re: JDBC CTS 1.2.1