Java Reference
In-Depth Information
// Returns the current status of the PooledConnection.
public boolean inUse() {
return inuse;
// Close the real JDBC Connection
public void close() {
try {
catch (SQLException sqle) {
Next we need to look at the doPost() / doGet() method of the servlet that initialized the
ConnectionPool . Whereas in the TitleListServlet you had to load the driver and call the
DriverManager.getConnection() method directly, here all you have to do is call the
ConnectionPool.getConnection() , which will iterate through its vector of connections until
it finds an available connection. If it cannot find an available connection, it will create one and
add it to the pool. It will then mark the connection as in use and return it. A sample doPost()
method follows:
//Process the HTTP Post request
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
Connection con = null;
try {
// Get a connection from the ConnectionPool
con = pool.getConnection();
if ( con != null ) {
Search WWH ::

Custom Search