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 do we call a stored procedure from jdbc?
What is sqlwarning and discuss the procedure of retrieving warnings?
Why is odbc needed?
What are the differences between statement and preparedstatement interface?
What is savepoint in jdbc?
How to test jdbc connection to sql server?
What is the difference between jdbc and jndi?
What is the query used to display all tables names in SQL Server (Query analyzer)?
Explain the process of creating tables using NetBeans IDE?
What are clob and blob data types in jdbc?
Why do we use jdbc?
What is a rollback in jdbc?
What do you understand by DDL and DML statements?
How can I use the JDBC API to access a desktop database like Microsoft Access over the network?
What are JDBC Best Practices?