tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thyago Lisboa Mota" <thy...@tre-ce.gov.br>
Subject Datasource in JSP
Date Wed, 12 Nov 2003 19:15:45 GMT
I have a datasource configured with the name 'jdbc/TestDB' as in http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html.
 I wanna use this datasource in a JSP test using 'jakarta/dbtags' taglib.  What is the name
I should use for the 'dataSource' attribute of the 'connection' element ? Ive already tested
with "jdbc/TestDB", "java:comp/env/jdbc/testDb" and "comp/env/jdbc/testDB" and didnt work...
Dbtags is configured alright because I already tested using a direct connection... 

My test.JSP
 <%@ taglib uri="http://jakarta.apache.org/taglibs/dbtags" prefix="sql" %>
 <sql:connection id="bd" dataSource="??what name should I use??">
  <sql:userId>user</sql:userId>
  <sql:password>password</sql:password>
 </sql:connection>

Contents of my web applicationĀ“s context: 
<Context
    path=""
    docBase="ROOT"
    debug="0"
    reloadable="true"
    crossContext="true">
    
    <Resource 
        name="jdbc/TestDB"
        auth="Container"
        type="javax.sql.DataSource"/>
    
    <ResourceParams 
        name="jdbc/TestDB">
        <parameter>
            <name>factory</name>
            <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
        </parameter>
        <parameter>
            <name>maxActive</name>
            <value>100</value>
         </parameter>
         <parameter>
           <name>maxIdle</name>
           <value>30</value>
         </parameter>
        <parameter>
           <name>maxWait</name>
           <value>10000</value>
         </parameter>         
         <parameter>
           <name>username</name>
           <value>user</value>
         </parameter>
         <parameter>
           <name>password</name>
           <value>password</value>
         </parameter>
        <parameter>
            <name>driverClassName</name>
           <value>oracle.jdbc.OracleDriver</value>
         </parameter>
         <parameter>
           <name>url</name>
           <value>jdbc:oracle:thin:myschema@127.0.0.1:1521:mysid</value>
         </parameter>
    </ResourceParams>                                 
</Context>

Contents of my web.xml: 
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
  <display-name>Web test</display-name>
  <description>
     Test
  </description>
   <taglib>
    <taglib-uri>http://jakarta.apache.org/taglibs/dbtags</taglib-uri>
    <taglib-location>/WEB-INF/dbtags.tld</taglib-location>
   </taglib>  
  <resource-ref>
      <description>Test Data Source</description>
      <res-ref-name>jdbc/TestDB</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>
   
</web-app>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message