Tomcat5.0.28 connection pooling urgent plz.......................

hi all,
I am new to jndi concet.I am trying to do connection pooling in tomcat 5.0.28.
I have searched google a lot but not been able to succeed in this.
I have created the datasource (ccmtest) from tomcat Administration.So it will automatically writes<resource></resourceparams> info in server.xml.
I manually written <resource-ref> in web.xml
I am trying to access the pool from java class.and i have written the following code
Properties p=new roperties(); p.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.commons.dbcp.BasicDataSourceFactory");
p.put(Context.PROVIDER_URL,"http://localhost:8080");
Context context = new InitialContext(p);
               DataSource ds=(DataSource)context.lookup("java:/comp/env/jdbc/ccmtest");
               Connection conn = ds.getConnection();
but i am getting the following error:
javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.com mons.dbcp.BasicDataSourceFactory [Root exception is java.lang.ClassCastException]
First i didn't placed the code like p.put(Context.INITIAL_CONTEXT_FACTORY,.........but when i didn't place the code i got the error:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
I have placed the commonsdbcp.jar,commonspool.jar,commonscollections.jar in classpath.
Plz help me
Advance thanks.

hi aniseed
First of all thanks for the solution.
i have read that documentation several times.and done the same thing what ever documented in that page u have given but still get the error:
javax.naming.NoInitialContextException: Cannot instantiate class: com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory [Root exception is java.lang.ClassCastException]

Similar Messages

  • Form Server Connection pooling - Urgent

    how does form server maintains connection pooling. I have defined a single db user through which form server establishes connections with the db, and created application users at application level. The information I like to know if form server maintains certain connection pooling and allow users to get connected if user limit exceeds but responed to them with delay. if it does maintains connection pooling then please elaborate how.???

    Forms doesn't do connection pooling -- each user requires a separate database connection.
    > Allowing remote Internet user connect directly to the
    database appears to pose a serious security/denial-of-
    service risk.
    So this is one of the good reasons to move the web Forms architecture.
    > It doesn't seem appropriate to ask unaffiliated remote
    users to know about, let alone remember database
    credentials for an external database, just to enable
    them to use a simple web-enabled form. Embedding the
    database credentials into the form appears to pose a
    more obvious security risk.
    With Forms on the web, you can hide the username/password/database details from the user. That information can be stored centrally -- either with Forms itself, or with an LDAP server. The end user doesn't have to know any of the details.
    We have customers running their Forms applications on the internet, and the users have no idea of the connection details to the database.
    For extra security, you can use SSL. Forms on the web, though, by default uses 40 bit encryption.
    Why then does Oracle Forms use this client-server
    architecture? Are there any plans to migrate away from,
    or provide an alternative to, this architecture in
    the near future?
    We do have an architecture to resolve these issues. It's called the Forms Listener Servlet Architecture and it's been available for over 2 years.
    If you go to the Forms area on OTN, you can read all about it:
    http://otn.oracle.com/products/forms/content.html
    Regards,
    Robin Zimmermann
    Forms Product Management

  • MySQL connectivity Problem URGENT plz

    Hi
    plz can any one help me... its urgent
    i need java to connect to MySQL database.with mm.mysql.Driver
    the following sample code is just copied from the site and made changes in hostname, dbname and username.
    classpath has been given correctly for the mm.mysql.Driver package (mysql.jar).
    Thanx in advance....
    Result
    compilation --> success
    while executing i get the following Error.
    java.sql.SQLException: General Error: null
         at org.git.mm.mysql.connection.<init>(Connection.java)
         at org.git.mm.mysql.Driver.connect(Driver.java)
         at java.sql.DriverManager.getConnection(DriverManager.java: 515)
         at java.sql.DriverManager.getConnection(DriverManager.java: 197)
         at JDBCDemoCreate.getConnection(JDBCDemoCreate.java: 36)
         at JDBCDemoCreate.<init>(JDBCDemoCreate.java: 14)
    java.lang.NullPointerException
         at JDBCDemoCreate.<init>(JDBCDemoCreate.java: 17)
         at JDBCDemoCreate.main(JDBCDemoCreate.java: 47)
    Here is the code. can any one try this !
    // JDBCDemoCreate.java
    1.     import java.util.*;
    2.     import java.sql.*;
    3.
    4.     public class JDBCDemoCreate {
    5.
    6.     private static final String hostname = "hostname";
    7.     private static final String port = "3306";
    8.     private static final String database = "dbname";
    9.     private static final String username = "username";
    10.     private static final String password = "";
    11.
    12.     public JDBCDemoCreate() {
    13.
    14.          Connection c = getConnection();
    15.
    16.          try {
    17.               Statement s = (Statement)c.createStatement();
    18.               s.executeUpdate("CREATE TABLE rich ( id int primary key, name char(25) )");
    19.          } catch ( Exception e ) {
    20.               e.printStackTrace();
    21.          }
    22.
    23.     }
    24.
    25.     private Connection getConnection() {
    26          // Register the driver using Class.forName()
    27.          try {
    28.               Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    29.          } catch ( Exception e ) {
    30.               e.printStackTrace();
    31.          }
    32.
    33.          // ask the DriverManager for a connection to the database
    34.          Connection conn = null;
    35.          try {
    36.               conn = DriverManager.getConnection("jdbc:mysql://" + hostname +
    37.                                                                      ":"+ port +"/" + database +
    38.                                                                      "?user=" + username +
    39.                                                                      "&password=" + password );
    40.          } catch (Exception e) {
    41.               e.printStackTrace();
    42.          }
    43.          return conn;
    44.     }
    45.     
    46.     public static void main( String[] args ) {
    47.          new JDBCDemoCreate();
    48.     }
    49.}

    Hi!
    You can try with this code coz, i worked with this code only and then i can talk to the database.
    Connection con;
    Class.forName("org.gjt.mm.mysql.Driver";
    con = DriverManager.getConnection("jdbc:mysql:///db?user=root&password=");
    Try it out!
    Queries regarding this is welcome. Either in this forum itself or u can contact in the mail, the id is
    [email protected]
    Regards,
    dinesh

  • Urgent...Help Needed.1. Helper Class 2. Connection Pool

    Hello,
    1. There are few helper classes which has to be
    shared b/w session and entity beans. But it
    seems,state of the object is not transfered to entity
    bean though the class has implemented Serializable
    interface. I have archived all the helper class and
    copied to j2ee\home\lib directory. The same jar file
    is made accessible to server via updating <library-
    path> in j2ee/home/config/application.xml file.
    2. How can i utilise connection pooling in oc4j. In data-sources.xml, i am using
    "OracleConnectionPoolDataSource" class. But i feel that connection pool is not utilised coz server hangs in the middle of the retrieval.
    The value of max-connections is 50.
    We are actually migrating from Weblogic 5.1.0 to Oracle 9i AS. In weblogic, we had given 10 max connections in weblogic.properties,it is working fine. But i dont understand why it is not working in 9i AS though the max-connections is 50.
    Kindly let me know the solution at the earliest as it is very urgent to get the program running...
    Thanx and Regards,
    Achyuth

    Hi,
    hopefully I can help you.
    1. There are few helper classes which has to be ...We have just the same constellation. We have put the HelperClasses in the
    J2EE/home/lib dir, NOT specifying it in the application.xml. So everything works fine.
    The only thing: never, again: never put these files within WEB-INF and the lib-dir.
    With the HelperClasses in both we have only faced massive problems, mostly ClasCastExceptions.
    We had once all the helperClasses within J2EE/home/applications/lib, but this requires to
    specify this dir within the orion-application.xml within the appl dir in applications-deployment.
    It also worked fine.
    2. How can i utilise connection pooling in oc4j. In data-sources.xml, i am using ...I'm not sure of this, but I think, the container handles Connection Pooling, no matter what Factory you
    specify. But I think, the Class hasn't to be OracleConnectionPool ... but I have to check this (right now
    I have no access to our datasource.xml ..)
    cu
    ed

  • Urgent regarding connection pooling

    Please can someone thorw some light on how to implement connection pooling in simple way. I have seen lots of code snippet and did lots of reading.
    I need to know about how many classes i would need. and how do i use the classes.
    If someone can provide code snippet then that would be great
    thanks..please consider it to be urgent.

    Why reinvent the wheel?
    Most JDBC drivers will have connection pooling already implemented, and you just need to use it.
    You should be using the interface javax.sql.DataSource
    http://java.sun.com/j2se/1.5.0/docs/api/javax/sql/DataSource.html
    The recommended approach in Java/JSP is to have a DataSource object accessed via JNDI.
    Most servlet containers will let you define JNDI datasources to access the database connections from your app.
    For instance Tomcat: http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
    Good luck,
    evnafets

  • Problem in Filling Pool, In ConnectionPooling Code:Urgent Plz

    Hi All,
    I m using this program for Connection Pooling.
    import java.sql.*;
    import javax.sql.*;
    import java.util.*;
    import java.io.*;
    import javax.naming.*;
    public class ConnectionPool implements Runnable{
      private DataSource datasource;
      private int maxConnections;
      private int initialConnections;
      private boolean waitIfBusy;
      private boolean connectionPending = false;
      private Vector<java.sql.Connection> availableConnections;
      private Vector<java.sql.Connection> busyConnections;
      public ConnectionPool()throws SQLException {
        try{
             Context ic = new InitialContext();
              this.datasource = (DataSource)ic.lookup("java:msgds");                    
              System.out.println("DataSource Found msgds");
         }catch(Exception e){
              System.out.println("Error in ConnectionPool COnstructor While Locatin ashishds");
        this.waitIfBusy = true;   
        this.waitIfBusy = waitIfBusy;
        this.maxConnections = 5;
        this.initialConnections = 2;
        availableConnections = new Vector<java.sql.Connection>(2);
        busyConnections = new Vector<java.sql.Connection>();
        for(int i=0; i<initialConnections; i++) {
          availableConnections.addElement(makeNewConnection());
      public synchronized Connection getConnection()
          throws SQLException {
        if (!availableConnections.isEmpty()) {
          Connection existingConnection =
            (Connection)availableConnections.lastElement();
          int lastIndex = availableConnections.size() - 1;
          availableConnections.removeElementAt(lastIndex);
          // If connection on available list is closed (e.g.,
          // it timed out), then remove it from available list
          // and repeat the process of obtaining a connection.
          // Also wake up threads that were waiting for a
          // connection because maxConnection limit was reached.
          if (existingConnection.isClosed()) {
            notifyAll(); // Freed up a spot for anybody waiting
            return(getConnection());
          } else {
            busyConnections.addElement(existingConnection);
            return(existingConnection);
        } else {
          // Three possible cases:
          // 1) You haven't reached maxConnections limit. So
          //    establish one in the background if there isn't
          //    already one pending, then wait for
          //    the next available connection (whether or not
          //    it was the newly established one).
          // 2) You reached maxConnections limit and waitIfBusy
          //    flag is false. Throw SQLException in such a case.
          // 3) You reached maxConnections limit and waitIfBusy
          //    flag is true. Then do the same thing as in second
          //    part of step 1: wait for next available connection.
          if ((totalConnections() < maxConnections) &&
              !connectionPending) {
            makeBackgroundConnection();
          } else if (!waitIfBusy) {
            throw new SQLException("Connection limit reached");
          // Wait for either a new connection to be established
          // (if you called makeBackgroundConnection) or for
          // an existing connection to be freed up.
          try {
            wait();
          } catch(InterruptedException ie) {}
          // Someone freed up a connection, so try again.
          return(getConnection());
      // You can't just make a new connection in the foreground
      // when none are available, since this can take several
      // seconds with a slow network connection. Instead,
      // start a thread that establishes a new connection,
      // then wait. You get woken up either when the new connection
      // is established or if someone finishes with an existing
      // connection.
      private void makeBackgroundConnection() {
        connectionPending = true;
        try {
          Thread connectThread = new Thread(this);
          connectThread.start();
        } catch(OutOfMemoryError oome) {
          // Give up on new connection
      public void run() {
        try {
          Connection connection = makeNewConnection();
          synchronized(this) {
            availableConnections.addElement(connection);
            connectionPending = false;
            notifyAll();
        } catch(Exception e) { // SQLException or OutOfMemory
          // Give up on new connection and wait for existing one
          // to free up.
      // This explicitly makes a new connection. Called in
      // the foreground when initializing the ConnectionPool,
      // and called in the background when running.
      private Connection makeNewConnection()
          throws SQLException {
        try {    
          // Establish network connection to database
          Connection connection = datasource.getConnection();
          return(connection);
        } catch(Exception cnfe) {
          // Simplify try/catch blocks of people using this by
          // throwing only one exception type.
          throw new SQLException("Error in makeNewConnection() : " +cnfe);
      public synchronized void free(Connection connection) {
        busyConnections.removeElement(connection);
        availableConnections.addElement(connection);
        // Wake up threads that are waiting for a connection
        notifyAll();
      public synchronized int totalConnections() {
        return(availableConnections.size() +
               busyConnections.size());
      /** Close all the connections. Use with caution:
       *  be sure no connections are in use before
       *  calling. Note that you are not <I>required</I> to
       *  call this when done with a ConnectionPool, since
       *  connections are guaranteed to be closed when
       *  garbage collected. But this method gives more control
       *  regarding when the connections are closed.
      public synchronized void closeAllConnections() {
        closeConnections(availableConnections);
        availableConnections = new Vector<java.sql.Connection>();
        closeConnections(busyConnections);
        busyConnections = new Vector<java.sql.Connection>();
      private void closeConnections(Vector connections) {
        try {
          for(int i=0; i<connections.size(); i++) {
            Connection connection =
              (Connection)connections.elementAt(i);
            if (!connection.isClosed()) {
              connection.close();
        } catch(SQLException sqle) {
          // Ignore errors; garbage collect anyhow
      public synchronized String toString() {
        String info =
          "ConnectionPool(Data Source is :"+datasource+ ")" +
          ", available=" + availableConnections.size() +
          ", busy=" + busyConnections.size() +
          ", max=" + maxConnections;
        return(info);
    }To Test This code, I had created one Servlet. In This Servlet I m calling like this:
    in
    init(){
         connectionPool = new ConnectionPool();
    }in
    in
    service(){
         private ConnectionPool connectionPool=null;
         connection = connectionPool.getConnection();
    }in destroy of
    destroy{
         if(connectionPool != null){
                  connectionPool.closeAllConnections();     
    }The Problem is that, Many a times it work, many a times it shows following Error:
    09:56:35,109 WARN  [JBossManagedConnectionPool] Unable to fill pool
    org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException:
    Listener refused the connection with the following error:
    ORA-12516, TNS:listener could not find available handler with matching protocol stack
    The Connection descriptor used by the client was:
    192.168.1.8:1521
            at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFa
    ctory.java:177)
            at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConn
    ectionPool.java:539)
            at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.fillToMin(InternalManagedConnectionPool.java:486)
            at org.jboss.resource.connectionmanager.PoolFiller.run(PoolFiller.java:74)
            at java.lang.Thread.run(Thread.java:595)
    Caused by: java.sql.SQLException: Listener refused the connection with the following error:
    ORA-12516, TNS:listener could not find available handler with matching protocol stack
    The Connection descriptor used by the client was:
    192.168.1.8:1521
            at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
            at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261)
            at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
            at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
            at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
            at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
            at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
            at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFa
    ctory.java:169)
            ... 4 moreI M using JBoss 4.0, With OracleXE. I had defined my DataSource-> msgds in mydb-ds.xml of deploy folder of JBoss.
    which is like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <datasources>
      <local-tx-datasource>
        <jndi-name>msgds</jndi-name>
        <connection-url>jdbc:oracle:thin:@192.168.1.8:1521</connection-url>   
        <driver-class>oracle.jdbc.OracleDriver</driver-class>
        <!-- The login and password -->
        <user-name>ashish</user-name>
        <password>ashish</password>
        <min-pool-size>5</min-pool-size>
        <max-pool-size>100</max-pool-size>
        <idle-timeout-minutes>0</idle-timeout-minutes>
      </local-tx-datasource>
    </datasources>I want to know whether This is a right approach to do Connection Pooling. How can I implement this Using Commons.
    What changes i need to made in my mydb-ds.xml if I use Commons Package and also in the code.

    never ask for help to be sent to your email, always post in this thread so that if someone else has the same question they can get the help too.
    this should help get you started... just make sure you get the apache dbcp package (you may need some commons things too, like commons pool)
    private BasicDataSource dataSource;
    * This function actually initializes the datasource, which is
    * in charge of setting up the BasicDataSource, which handles
    * all the database pooling.
    protected synchronized void initDataSource() {
         loadProperties(); // this loads my database properties from a config file
         try {
              dataSource = new BasicDataSource();
              dataSource.setDefaultAutoCommit(true);
              dataSource.setDefaultCatalog(catalogName);
              dataSource.setDriverClassName(jdbcDriver);
              dataSource.setUsername(jdbcUserID);
              dataSource.setPassword(jdbcPassword);
              dataSource.setUrl(jdbcURL);
              dataSource.setMinIdle(minCons);
              dataSource.setMaxIdle(maxCons);
              dataSource.setMaxActive(maxCons);
              dataSource.setMaxWait(5000); // milliseconds to wait for connection if none are available
              dataSource.setAccessToUnderlyingConnectionAllowed(true);
              // will validate each connection before handing it out
              dataSource.setTestOnBorrow(true);
              dataSource.setValidationQuery("select getDate()");
              // setup to test idle objects in the pool
              dataSource.setTestWhileIdle(true);
              dataSource.setTimeBetweenEvictionRunsMillis(600000); // run every 10 minutes
              dataSource.setMinEvictableIdleTimeMillis(60000);  // only examine connections idle for more than 10 minutes
              dataSource.setNumTestsPerEvictionRun(-3); // when this is negative one Nth of connections will be examined
         } catch (Exception e) {
              //whatever you want
    public Connection getConnection() {
         try {
              Connection con = dataSource.getConnection();
              if(con == null) {
                   throw new Exception("Error: DataSource gave a null connection object");
              return con;
         } catch (Exception e) {
              // whatever
    public void freeConnection(Connection con) {
         freeConnection(con, false);
    public void freeConnection(Connection con, boolean isError) {
         try {
              if(con == null) return;
              if(!con.isClosed()) {
                   if(isError && !con.getAutoCommit()) {
                        con.rollback();
                   con.clearWarnings();
                   con.close(); // this adds the con back to the pool
         } catch(Exception e) {
              // whatever
    }     

  • Urgent please - Error Testing connection pool

    I have a connection pool and datasource working fine, but when I click at the testing hyperlink on the weblogic console/jdbc/testing, the following message apear at the Unix console.
    Caused by: javax.management.MalformedObjectNameException: bad object name,property Location has multiple values in Name=hom59DataSource,Type=ApplicationRuntime,Location=cbdHom,ServerRuntime=cbdHom,Loc
    ation=cbdHom,Type=JDBCDataSourceRuntime
    at java.lang.Throwable.<init>(Throwable.java:57)
    at java.lang.Throwable.<init>(Throwable.java:68)
    at weblogic.management.WebLogicObjectName.extractProperties(WebLogicObjectName.java:571)
    at weblogic.management.WebLogicObjectName.<init>(WebLogicObjectName.java:326)
    at weblogic.management.WebLogicObjectName.setParentFromObjectName(WebLogicObjectName.java:934)
    at weblogic.management.WebLogicObjectName.populate(WebLogicObjectName.java:851)
    at weblogic.management.WebLogicObjectName.<init>(WebLogicObjectName.java:328)
    at weblogic.management.WebLogicObjectName.<init>(WebLogicObjectName.java:822)
    at weblogic.management.jmx.MBeanServerInvocationHandler.getWebLogicObjectName(MBeanServerInvocationHandler.java:80)
    Somebody please could help me?
    Message was edited by:
    Denimar

    Have figured this out. Need to set the "Test Connections" settings under Configurations
    (Advanced Options) for the Connection Pool.
    Thanks for your help :)
    Joe Weinstein <[email protected]> wrote:
    Everbright wrote:
    Hi,
    I've just started working on the Avitek Tutorials.
    Encountered the following error message when testing the connectionpools for
    both the XA and non-XA connections.
    Warning! Connectivity to backend database not verified. This is eitherbecause
    required connection pool attributes "TestConnectionsOnReserve" or "TestConnectionsOnRelease"
    have not been enabled, or an invalid value has been specified for attribute"TestTableName".
    Please check the server log for more details..
    Any ideas what might be wrong?It is likely that some part of the information you specified about how
    to connect to
    your database was incorrect, so weblogic was unable to make a pool of
    connections.
    We will know more if you show us the server log file, which will contain
    messages
    about any errors it suffered during startup...
    Joe
    Thanks!

  • Sun applicationserver - connection pool , plz help !

    hi all,
    when i try to create a connection pool from oracle server it doesnt config
    correctly. i m new to this area. i suppose that the error is around my property seting in jdbc connection pool in app server
    here are my db properties which are normally using , so please catagorize thse in to jdbc properties properly.
    dbDriver ="oracle.jdbc.driver.OracleDriver"
    dbLogin = "icr";
    dbPassword = "icr02"
    dbURL= "jdbc:oracle:thin:@203.115.41.50:1521:ittest";
    when i configure the connection pool i used " oracle.jdbc.pool.OracleConnectionPoolDataSource "
    as the Datasource Classname.
    so at the properties what soul i include as
    serverName = ?
    datasourceName = ?
    i appriciate any comment from all of u
    thanks
    regards,
    nuwan

    http://docs.sun.com/app/docs/doc/819-2641/6n4trr8l0?a=view

  • Urgent help (on oracle connection pool)

    Hi ,
    I downloade oracle 8i thin drivers and i am using conenction pool in my application ...
    I executed that servlet program
    When i try to get conneciton using getDatabaseConnection() method in my jsp i am getting new connection each time ...............
    In the oracel doc i read some thing like logical connections and physical connections .............
    In my code i set maxLimit to 3 and i am getting connections more than 3 ( all are different).................
    When i refresh the browser i am getting different connections like:
    con======oracle.jdbc.driver.OracleConnection@338576
    con======oracle.jdbc.driver.OracleConnection@1691dec
    con======oracle.jdbc.driver.OracleConnection@63ceb4
    con======oracle.jdbc.driver.OracleConnection@1590f50
    con======oracle.jdbc.driver.OracleConnection@aeff82
    con======oracle.jdbc.driver.OracleConnection@906e5b
    con======oracle.jdbc.driver.OracleConnection@2403cf
    con======oracle.jdbc.driver.OracleConnection@17ab157
    See i set max limit as 3 and i got more than 3 connections and each diff ................
    What is wrong in my code ............
    Please help to me ..........
    Here is the code :
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.sql.*;
    import oracle.jdbc.driver.*;
    import oracle.jdbc.pool.*;
    public class PoolJdbc4 extends HttpServlet{
    private OracleConnectionPoolDataSource ocpds;
    private OracleConnectionCacheImpl ods;
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    try {
    ocpds =new OracleConnectionPoolDataSource();
    ocpds.setURL("jdbc:oracle:xxxxxxxxx");
    // ocpds.setUser("xxx");
    // ocpds.setPassword("xxx");
    // 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");
    try {
    con = ods.getConnection("xxxxx","xxx");
    System.out.println("con======="+con);
    // Turn on transactions
    con.setAutoCommit(false);
    Statement stmt=con.createStatement();
    ResultSet rs=stmt.executeQuery("select * from checkout_checkin");
    while(rs.next())
    out.println(rs.getString(1)+"<br>");
    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");
    }

    ketan reddy - I'm pretty sure you are not getting a new connection each time even though you are seeing a different connection identifier printed each time you get a new connection.
    If you have system privs, try looking at v$session while your servlet is running. I think you will see that you only have a single connection and it is being used each time.
    For another test, try commenting out your conn.close() call so that you do not free up connections. Your servlet should fail after 3 executions cause it will not be able to get any more connections - because you specified
    ods.setMaxLimit (3);
    ods.setCacheScheme (OracleConnectionCacheImpl.FIXED_RETURN_NULL_SCHEME);
    Good Luck
    tim

  • Connection pooling issue, urgent

    Hi,
    Our asp.net web application use sAP .net connector to make RFC call to sap CRM system. recently, I am trying to utilizing connection pooling, but assigning connection obtained from pool to proxy class , I did exactly the online help docs says, but, i got some very disappointment result, it cause iis worker process memory write proctection error. and very time, I reboot my machine, the problem does not go away, my O.S tells me that "Data Execution proctection" warning comes up and afterwords, iis worker process and etc, I am not sure what I did wrong, any body experience similar problem,
    after I uninstall .net connection, and I reboot my machine
    , this error went away. Please help.
    following is my configuration settings:
    <SAP>
           <Connector>
                 <ConnectionPool              
                   MaxOpenConnections="20"  
                                 MaxCapacity="20"
                           MaxIdleTime="10"
                           CleanupInterval="10" />                   
                          <Destinations Default="cd1">
                              <Entry
                                DestinationName="cd1"
                                AppServerHost="ASHOST=sapcrd01.bentley.com"
                                SystemNumber="00"
                                Username="ASPRFC"
                                Password="bentley"
                                Client="100"/>                        
                           </Destinations>
              </Connector>
         </SAP>
    following line of code is from myproxy constructor
         this.oCommonProxy.Connection=SAP.Connector.Connection.GetConnectionFromPool(GetConnectStringForUser(this.sRfcUser,this.sRfcPass));
    public void CloseConnection()
                                       SAP.Connector.Connection.ReturnConnection(this.oCommonProxy.Connection);
    Message was edited by: Yuwen Li
    Message was edited by: Yuwen Li

    Hm, sounds strange. Can you try to attach a debugger with both, managed and unmanged mode, turn on "first chance exception handling" for all exception types and check the call stack when the exception happens?

  • HELP:Problem in creating a temporary CLOB using JDBC connection pooling

    Hi All,
    i am inserting a large xml document in an xml type column by creating a temporary clob of this document
    tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);
    I am not having any success getting the following statement working using a JDBC connection pool rather than a hard coded URL connection
    it works with:
    "jdbc:oracle:thin:@server:port:dbname" connection
    Does NOT work with:
    datasource.getConnection()
    Does any one know how to successfully get this to work?
    urgently plz........

    Hi Dharmi
    Here is a quote of Dafna's post in [another thread in this forum|Re: Copy VC controls]
    CE7.1.1 will be released at September 2008 for ramp-up customers.
    There are many improvements and new capabilities in the new release of Visual Composer for CE7.1.1. Among the new features you can find:
    The missing features from Visual Composer 7.0 (Html view, portal Eventing support (EPCM), JDBC, Undo/Redo, and more..)
    Many layout & modeling improvements
    Additional ALV table functionality - export to Excel, switch to chart, configure ALV behavior at design time
    Integration of Visual Composer in Eclipse - additional entry point to the Visual Composer models from the NWDS. This integration provides the option to add a WD component (in case of missing functionality in Visual Composer), as a black box component to the Visual Composer model. Right-clicking the component will open the Web Dynpro perspective for creating/modifying the component.
    Regards,
       Shai

  • Oracle connection pool problem (dbcp binded with  jtom)

    Hi,
    my webserver is Tomcat5.0.18, I want to offer the connection pool and transaction management
    in my currently system
    I know in Tomcat5.0 version, we can use the DBCP to offer the database connection pool
    service, to apply the transaction management in my system, I adapt the JTOM
    now, my problem is
    to use DBCP, I setup the datasource factory to be
    org.apache.commons.dbcp.BasicDataSourceFactory, the connection pool is ok, but
    the transaction management offerred by JTOM will failure
    to make the tranaction management of JTOM succeed, I have to setup the datasource factory to be
    org.objectweb.jndi.DataSourceFactory, but the connection pool offerred by Tomcat will failure now
    it seems that these two datasource factory has conflict
    How can I do?, I don't want to use the connection pool offerred in JTOM
    Anyone can help me??
    Thanks in advance

    Hi,
    I don't know the solution for JOTM, but you could try this JTA and its connection pools:
    http://www.atomikos.com ships a JTA that integrates with Tomcat and also provides JDBC connection pooling. There is a GUI control panel so that you don't have to know the XML details for Tomcat's config files.
    Best,
    Guy

  • Connection pool not re-establishing connections, throwing exception instead

    Hello,
    I've just set up a connection pool on the sun java system application server 8 for a MySQL database using the official mysql-connector/j 5.0. Everything is working great, except when the connections timeout (or i kill them all manually from the database server) and then request a page that needs to use the DataSource object, the following exception is thrown:
    Exception thrown: com.mysql.jdbc.CommunicationsException -- Communications link failure due to underlying exception:
    ** BEGIN NESTED EXCEPTION **
    java.io.EOFException
    STACKTRACE:
    java.io.EOFException
         at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1913)
         at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2304)
         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2803)
         at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
         at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
         at com.mysql.jdbc.Connection.execSQL(Connection.java:3118)
         at com.mysql.jdbc.Connection.execSQL(Connection.java:3047)
         at com.mysql.jdbc.Statement.executeQuery(Statement.java:1166)
         at com.mysql.jdbc.jdbc2.optional.StatementWrapper.executeQuery(StatementWrapper.java:705)
         at beans.MySessionBean.businessMethod(MySessionBean.java:73)
         at org.apache.jsp.index_jsp._jspService(index_jsp.java:70)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:251)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
         at sun.reflect.GeneratedMethodAccessor98.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
         at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
         at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
         at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
         at java.security.AccessController.doPrivileged(Native Method)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:185)
         at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:653)
         at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:534)
         at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doTask(ProcessorTask.java:403)
         at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:55)
    ** END NESTED EXCEPTION **
    Last packet sent to the server was 16 ms ago.What could be wrong?
    Thank you.

    The code is here:
        public String businessMethod() {
            //TODO implement businessMethod
            try
                InitialContext ic = new InitialContext();
                Object obj = ic.lookup("jdbc/MyDS");
                System.out.println("Object is: " + obj + " | Class is: " + obj.getClass().getName());
                DataSource ds = (DataSource)obj;
                Connection conn = ds.getConnection();
                Statement stmt = conn.createStatement();
                ResultSet rs = stmt.executeQuery("SELECT a,b FROM test");
                String ret = "";
                while(rs.next())
                    ret += rs.getString(1) + " - " + rs.getString(2) + "<br/>";
                conn.close();
                return ret;
            catch(Exception e)
                return "Exception thrown: " + e.getClass().getName() + " -- " + e.getMessage();
        }On the server, it is set up as XADataSource. I don't really have a big need for distributed transactions, but does it hurt badly to use it anyways? Could it be causing this problem?

  • Problem in getting the database connection from a connection pool

    Hai All,
    I am facing a problem in getting the database connection from a connection pool created on weblogic server 8.1.
    I am using the Oracle database 8.1.7.
    I have configured my connection pool, datasource and JNDI in weblogic.
    In my java program i have the following code to retrieve the connection.
    import java.sql.*;    
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    class jdbcshp1 {
        public static void main(String[] args) {
         Connection connection = null;
         try {
               Hashtable ht = new Hashtable();
               ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");  // Wanna get rid of this.
               ht.put(Context.PROVIDER_URL,"t3://localhost:7001"); // wanna get rid of this.
               // Get a context for the JNDI look up
               Context ctx = new InitialContext(ht);
            javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("myjndi1");
              //Create a connection object
              connection = ds.getConnection();
         The above code is working fine but, the two ht.put statements are creating problem.
    The problem is, after converting the application into WAR file it can be deployed
    on any machine or different port on same machine. My application fails if its deployed on
    weglogicserver which is at different port.
    Is there any way that i can get rid of those ht.put statements or any other way to solve the problem.
    any help is appreciated.
    Thanks in advance
    Pooja.

    Hai All,
    Firstly, thanks for ur reply.
    Even i have seen some code which uses context constructor with out any parameter and works fine.
    i dont understand why its not working for my code.
    When i remove those ht.put code and use context constructor with out any parameter, it giving an error.
    Context ctx = new InitialContext();
    javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("ocjndi");
    connection = ds.getConnection();The error is as follows:
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    the above error is forcing me to include those code but if the port number is changed the code will not work. Plz let meknow if some setting have to be made.
    I appreciate all ur valuable help.
    Thanks once again.
    Pooja.

  • Database connection Pooling in TOMCAT

    I am trying Database connection Pooling in TOMCAT
    I am getting the following error
    org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
    My Web.xml in $CATALINA_HOME\conf\web.xml
    <resource-ref>
    <res-ref-name>WMSPREF</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    and my server.xml in
    $CATALINA_HOME\conf\server.xml
    <ResourceParams name="WMSPREF">
    <parameter>
    <name>factory</name>
    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
    <name>driverClassName</name>
    <value>oracle.jdbc.driver.OracleDriver</value>
    </parameter>
    <parameter>
    <name>url</name>
    <value>jdbc:oracle:thin:@10.94.100.148:1521:WMSPREF</value>
    </parameter>
    <parameter>
    <name>username</name>
    <value>wmsmigrate</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>abnwms</value>
    </parameter>
    <parameter>
    <name>maxActive</name>
    <value>20</value>
    </parameter>
    <parameter>
    <name>maxIdle</name>
    <value>10</value>
    </parameter>
    <parameter>
    <name>maxWait</name>
    <value>-1</value>
    </parameter>
    </ResourceParams>
    And my database.jsp : code
         Context ctx = new InitialContext();
         Context envContext = (Context)ctx.lookup("java:comp/env");
         DataSource ds = (DataSource)envContext.lookup("WMSPREF");
         conn = ds.getConnection();

    What version of Tomcat do you have? 4? 5? 5.5?
    Have you defined a Resource entry in server.xml as well as the ResourceParams?
    I have never had any luck configuring a datasource in the server.xml file.
    What HAS worked for me is putting the config into a myWebApp.xml file.
    My web context is "myWebApp"
    The name of the file is "myWebApp.xml"
    For Tomcat4 for this goes in the webapps directory
    For Tomcat5 this goes in the [TOMCAT_HOME]/conf/Catalina/localhost directory
    <?xml version='1.0' encoding='utf-8'?>
    <Context path="/myWebApp" docBase="myWebApp" debug="1" reloadable="true" crossContext="true" >
    <Resource name="WMSPREF" auth="Container"
                  type="javax.sql.DataSource">
    </Resource>
    <ResourceParams name="WMSPREF">
    <parameter>
      <name>factory</name>
      <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
      <name>driverClassName</name>
      <value>oracle.jdbc.driver.OracleDriver</value>
    </parameter>
    <parameter>
      <name>url</name>
      <value>jdbc:oracle:thin:@10.94.100.148:1521:WMSPREF</value>
    </parameter>
    <parameter>
      <name>username</name>
      <value>wmsmigrate</value>
    </parameter>
    <parameter>
      <name>password</name>
      <value>abnwms</value>
    </parameter>
    <parameter>
      <name>maxActive</name>
      <value>20</value>
    </parameter>
    <parameter>
      <name>maxIdle</name>
      <value>10</value>
    </parameter>
    <parameter>
      <name>maxWait</name>
      <value>-1</value>
    </parameter>
    </ResourceParams>
    </Context>Cheers,
    evnafets

Maybe you are looking for

  • Apple TV and Multiple iTune accounts

    I just got a new Apple TV and I was wondering if it is possible to sync two iTune accounts to it? Currently it looks like only one account can send movies to it. Please help.

  • Selection screen is missing when query is executed

    Hi Friends, I am running a query and it gets executed without showing the selection screen. Here it is how I am running the query: 1. Go to Business Explorer (3.x)-->Analyser(3.x) 2.  IT ask for SAP Log on 3. I choose system which is 7.0 then it runs

  • Premiere Pro CS6 and GTX 680

    I recently upgraded my video card from a GTX 580 to a GTX 680. At first, PP did not recognize the card and I had to manually add it to the config(?) file. My problem is that PP CS6 makes very poor use of my new card. My render times are slower than b

  • What does "start up disk has no space" mean?

    My iMac, version 10.6.8, all of a sudden has a pop up window that says 'your start up disk has no more space.  Please force quit these applications to continue.'  What does this mean? 

  • Why can i not sync my Ipod music?

    I purchased songs on my Ipod touch, but when i tried to sync it to my computer, it got rid of my songs (over 100) that i got from the itunes app. The app wont let me re-download the songs without paying for them agian. What is going on??