What Method and class used for Connection pooling ?
Answers were Sorted based on User's Feedback
Answer / dsr
contex ic = new InitialContext();
DataSource sd = (datasource)ic.lookup("poolname");
Connection con = ds.getConnection();
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / ravikiran(aptech mumbai)
datasource.
getDatasource.getconnection();
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / qim2010
An application simply uses the DataSource.getConnection
method to get the pooled connection and uses it the same way
it uses any Connection object.
The classes and interfaces used for connection pooling are:
ConnectionPoolDataSource
PooledConnection
ConnectionEvent
ConnectionEventListener
The connection pool manager, a facility in the middle tier
of a three-tier architecture, uses these classes and
interfaces behind the scenes. When a
ConnectionPoolDataSource object is called on to create a
PooledConnection object, the connection pool manager will
register as a ConnectionEventListener object with the new
PooledConnection object. When the connection is closed or
there is an error, the connection pool manager (being a
listener) gets a notification that includes a
ConnectionEvent object.
Is This Answer Correct ? | 1 Yes | 0 No |
first to get the Context object by using given bellow
Context ic=new InitialContext();
And get DataSource object by using ic.lookup(conncetionpool
name)
your question is not proper way
DataSource Class & getConnection method is used
connection pool
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / deepak divvela
InitialContext ctx=new InitialContext();
Obj obj=ctx.lookup("jmdi provided alias name here");
javax.sql.DataSource ds=(javax.sql.DataSource)obj;
Connection con=ds.getConnection();
Is This Answer Correct ? | 0 Yes | 0 No |
Is multiple inheritance supported by java?
I want to re-reach and use an object once it has been garbage collected. How it's possible?
What is an arraylist in java?
What is the use of object and class classes?
What do you mean by inner class in java? Explain
Is an object null?
What is CardLayout?
Write a program to reverse array in place?
design an lru cache in java?
What is the difference between int and integer in java?
A non-static inner class may have object instances that are associated with instances of the class’s outer class. A static inner class does not have any object instances.
what do you mean by java annotations?