Hello,
I am having a problem trying to figure out JSTL with connection pooling.
I am using Tomcat. I understand that <sql:setDataSource> can't handle
connection pooling.
So I create a datasource the way I always do without JSTL (using
JNDI).
I'm having a problem passing that connection to <sql:query>
I don't know how to use variables in the tags.
My datasource is called 'ds', but I don't know how to use it with
sql:query.
pageScope.ds doesn't work.
I'm a complete JSTL newbie and totally confused.
Does anyone have any ideas?
Below is the code
thank you for the help!
Troy Campano
------------------------- CODE HERE
-----------------------------------------
<%@ page contentType="text/html; charset=iso-8859-1" language="java"
import="java.sql.*,javax.sql.*,oracle.jdbc.pool.*,javax.naming.*,java.io.*"
%>
<%@ taglib prefix="mt"
uri="http://jakarta.apache.org/taglibs/mailer-1.0
<http://jakarta.apache.org/taglibs/mailer-1.0> " %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core
<http://java.sun.com/jstl/core> " %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql
<http://java.sun.com/jstl/sql> " %>
Step 1: Starting Page<br>
<br>
Step 2: Creating a list of groups to get the report
<%
Connection conn = null;
try
{
//**************************************************************************
***********************
// Request Connection from Connection Pool
//**************************************************************************
***********************
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
DataSource ds = (DataSource) envContext.lookup("jdbc/ReportManagerPool");
conn = ds.getConnection();
//**************************************************************************
***********************
%>
<sql:query dataSource="${pageScope.ds}" var="myresultset"
sql="SELECT table_name FROM all_tables" />
<%
}
catch(SQLException e)
{
throw new SQLException(e.getMessage());
}
finally
{
if (conn != null)
{
try
{
conn.close();
}
catch (SQLException e)
{
// Nothing coherent to do here.
// Pray nothing else goes wrong.
e.printStackTrace();
}
}
}
%>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com