You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by "Stella Fredö (EMW)" <St...@emw.ericsson.se> on 2000/09/01 16:25:37 UTC

problem with data pooled connection

Hi, 

I am trying to, in my servlet, has a PoolConnection from oracle's j8.1.6 on tomcat3.2beta on the NT 4 platform.
When I compile it, no complains come out. 

When I run it, the tomcat complains that
java.lang.NoClassDefFoundError: oracle/jdbc/pool/OracleDataSource

I do have the classes21_01.zip included in my classpath, otherwise, I would not pass the compile.

Why tomcat could not find the OracleDataSource that is included in the classes21_01.zip ?

Any prompt tips?


regards
Stella Fredö
------test code---------

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.sql.*;
import oracle.jdbc.pool.*;
import oracle.jdbc.driver.*;
import oracle.jdbc.pool.OracleDataSource;

public class Pool2TestServlet extends HttpServlet{

     private OracleConnectionPoolDataSource ocpds;
     private OracleConnectionCacheImpl ods;

     public void init(ServletConfig config) throws ServletException 
     {
        super.init(config);
        try {
          ocpds =new OracleConnectionPoolDataSource();
ocpds.setDriverType("thin");
ocpds.setServerName("dummy1");
ocpds.setNetworkProtocol("tcp");
ocpds.setDatabaseName("dummy3");
ocpds.setPortNumber(1521);
ocpds.setUser("dummy4"); 
ocpds.setPassword("dummy5");

          ocpds.setUser("dummy6");
          ocpds.setPassword("dummy7");

          // Associate it with the Cache
          ods = new OracleConnectionCacheImpl(ocpds);

          // Set the Max Limit
          ods.setMaxLimit (3);

          // Set the Scheme
          ods.setCacheScheme (OracleConnectionCacheImpl.FIXED_RETURN_NULL_SCHEME);
        }
        catch (Exception e) {
          throw new UnavailableException(this, "Couldn't create connection pool");
        }    
     }

     public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException 
     {
        Connection con = null;
        res.setContentType("text/plain");
        PrintWriter out = res.getWriter(); 
        out.println("Updating salary");

        ResultSet rs = null;
        ResultSetMetaData md = null;
        try {
         con = ods.getConnection();
         Statement stmt = con.createStatement();
         rs = stmt.executeQuery("SELECT * FROM behorighet");
         md = rs.getMetaData();
         out.println("<H1>Employee data</H1>");
         while (rs.next())
         {
            out.println("<BR>");
            for (int i = 1; i < md.getColumnCount(); i++)
            {
               out.print(rs.getString(i) + ", ");
            }
         }
         stmt.close();
         rs.close();
         con.close();
        }
        catch (Exception e) {
           // Any error is grounds for rollback
           try { 
              con.rollback();
           }
           catch (Exception ignored) { } 
           out.println("No more connections available, try later");
        }   
     }

     public void destroy() {

        try { 
           ods.close();
            }
        catch (Exception ignored) { } 
     }
}
------------------------------------------------