Wrox Home  
Search P2P Archive for: Go

  Return to Index  

j2ee thread: RE: Connection Pooling.


Message #1 by Chanoch Wiggers <ChanochW@w...> on Thu, 14 Jun 2001 13:13:29 +0100
just pass the reference in to the bean, you will need a method that allows
you to do this. For example, some rough psuedo code

Connection conn = ConnectionPoolManager.getConnection();
// now conn holds the reference for you connection

// instantiate my helper class
MyBean myBean = new MyBean();

// pass the reference of the connection to the bean via a set method
Boolean success = myBean.setConnection(conn);

the method would then store the connection locally and can use it
subsequently. It might also be worth writing a setConnectionNull() method
for your bean that lets go of the reference before you return the connection
to the pool or otherwise you might have problems, for example in your jsp
you would call:

myBean.setConnectionNull(); // delete reference to connection

conn.close(); // release connection to pool

can I ask why the connection is being used in two different places? its
sounds sub optimal and leads to exactly these problems, sounds like C++
programming to me.

chanoch





-----Original Message-----
From: Lakshmeenarayana G G [mailto:lggoundalkar@h...]
Sent: 12 April 2001 07:38
To: Java 2 Enterprise Edition
Subject: [j2ee] Connection Pooling.


Hi.
I am using a connection pool manager class, i instantiate the connection 
pool manager object in my JSP.
Also i am using another bean which uses the databse connection.
I need to get the connection from the connection Pool manager in my 
another bean.
How to go about it.

How to pass the connection from the JSP by getting it from connection pool 
manager object in Application scope to the other bean in the page scope.

Thanks for the time.

Ragards.

  Return to Index