EJB programming & troubleshooting: Returning Connection in the Pool

  1. Returning Connection in the Pool (3 messages)


    In weblogic, when you use connection pool, you look up the connection through DataSource. After using the connection, how do you return the connection to the pool?

    Like, you get the connection from pool by calling javax.sql.DataSource.getConnection(), but how to return the connection?

    Threaded Messages (3)

  2. Returning Connection in the Pool[ Go to top ]

    Call Connection.close(). It does not actually close the connection to the database, but just returns it to the pool.
  3. Returning Connection in the Pool[ Go to top ]

    Hi Ravi,

    Thanks for your reply.

    Since it is a java.sql.Connection object, calling close() method on the same, actually closes the connection in normal programming.

    How is it different in Weblogic Pool? How come it actually does not close?
  4. Returning Connection in the Pool[ Go to top ]

    because the connection you have is not a real physical connection to the database. The container gives you a handle to the real connection and the close() call ends up inside the container, which is handled by invalidating the connection object handle (from the clients prespective) and marking the pooled conncetion (inside the container) as free for reuse.

    This is the whole idea behind pooling, connections are kept open in the pool to avoid the overhead in acquireing them.