Answer Posted / bhudeep
With servlets, opening a database connection is a major
bottleneck because we are creating and tearing down a new
connection for every page request and the time taken to
create connection will be more.
Creating a connection pool is an ideal approach for
a complicated servlet. With a connection pool, we can
duplicate only the resources we need to duplicate rather
than the entire servlet. A connection pool can also
intelligently manage the size of the pool and make sure each
connection remains valid. A number connection pool packages
are currently available. Some like DbConnectionBroker are
freely available from
Java Exchange Works by creating an object that dispenses
connections and connection Ids on request.
The Connection Pool class maintains a Hastable,
using Connection objects as keys and Boolean values as
stored values. The Boolean value indicates whether a
connection is in use or not. A program calls getConnection
( ) method of the ConnectionPool for getting Connection
object it can use; it calls returnConnection ( ) to give the
connection back to the pool.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
How can you use preparedstatement in jdbc?
How can I manage special characters when I execute an insert query?
Why do you use a data source object for a connection?
What is resultset in jdbc with example?
Which package is used for jdbc application?
How can I write to the log used by DriverManager and JDBC drivers?
Is jdbc faster than odbc?
What is com mysql jdbc driver?
How does a file store compare with a jdbc store?
What is jdbc type?
What is jdbc odbc?
What are the advantages of using preparedstatement in java?
How can we disable a constraint ?
What is JDBC Connection isolation levels?
What is JDBC Driver interface?