1 Reply Latest reply: May 17, 2007 5:45 AM by 807606 RSS

    Connection Pooling using JNDI

    807606
      [hi cn any one solve my prblm in jdbc connection pooling.
      the message I am getting is
      The requested resource (/prabhat/Deptjndi.jsp) is not available.
      I have done the mapping of my appln in web.xml file that is as follow
      [code]
      <resource-ref>
           <description>
                Data Source for Title Table
                </description>
                <res-ref-name>jdbc/moviecatalog</res-ref-name>
                <res-auth>Container</res-auth>
           </resource-ref>
      In server.xml I have dn:
      <Resource name="jdbc/moviecatalog" auth="Container"
      type="javax.sql.DataSource"/>
      <ResourceParams name="jdbc/moviecatalog">

      <parameter>
      <name>factory</name>
      <value>org.apache.commons.dpsc.BasicDataSourceFactory</value>
      </parameter>

      <parameter>
      <name>maxActive</name>
      <value>100</value>
      </parameter>

           <parameter>
           <name>maxIdle</name>
           <value>30000</value>
           </parameter>

           <parameter>
           <name>maxWait</name>
           <value>30000</value>
           </parameter>

           <parameter>
           <name>username</name>
           <value></value>
           </parameter>
           
           <parameter>
           <name>password</name>
           <value></value>
           </parameter>

           <parameter>
           <name>driverClassName</name>
           <value>sun.jdbc.odbc.JdbcOdbcDriver</value>
           </parameter>

           <parameter>
           <name>url</name>
           <value>jdbc:odbc:moviecatalog</value>
           </parameter>

      </ResourceParams>

      Plz help me out....
      <%@ page session="false"%>
      <%@ page import="java.util.*"%>
      <%@ page import="java.sql.*"%>
      <html>
      <head><title>Department Manager</title></head>
      <body style="font-size:9pt;">
      
      <h1 style="font-size: 130%">
      Department Manager
      </h1>
      <%
       InitialContext initCtx=new InitialContext();
       Context ctx=(Context) initCtx.lookup("java:comp/env");
       DataSource ds=(DataSource) ctx.lookup("jdbc/moviecatalog");
       Connection con=null;
       try{
              con=ds.getConnection();
              String sql="select * from titles";
              Statement stmt=con.createStatement();
              ResultSet rs=stmt.executeQuery(sql);
      %>
      <dl>
      <%
           while(rs.next()){
                String title_id=rs.getString(1);
                 String title_name=rs.getString(2);
                 String rating=rs.getString(3);
                 String price=rs.getString(4);
                 String type_id=rs.getString(5);
                 String category_id=rs.getString(6);
                 %>
                 <dt><b><%=title_id %></b></dt>
                 <dd>
                   <%=title_name %>,<%=rating %>,<%=price %><br>
                   (999)555-0822 x<%=type_id%>,<%=category_id%>
                   </dd>
                <%
      }
              rs.close();
                rs=null;
                stmt.close();
                stmt=null;
       }
       finally{
              if(con!=null){
                     con.close();
              }
       }
                           %>
      
      </dl>
      </body>
      </html>
      [/code