AW: AW: problem with connections not closing...

2002-06-12 Thread Ralph Einfeldt

A JDBC Realm is just a tool to authenticate and authorize
an user against a database. So it has nothing to do with
your problem.

As said earlier finalize() won't help you, as the time
when a servlet instance is destroyed is undetermined.
It might never be destroyed until tomcat is shut down.

How you can achieve your goal is not easy to say, as it 
requires more knowledge about your application. It's quite
unclear to me when and under which circumstances you want 
to close the connections.

The socke write error you reported indicates, that you 
keep the connection open to long.

 -Ursprüngliche Nachricht-
 Von: Christian J. Dechery [mailto:[EMAIL PROTECTED]]
 Gesendet: Dienstag, 11. Juni 2002 18:30
 An: [EMAIL PROTECTED]
 Betreff: Re: AW: problem with connections not closing...
 
 I was thinking of some type os static variable to control it 
 on the super DAO class. There is a super DAO class which all 
 the DAO inherit the connection object from, I wrote the 
 finalize() and cleanUp() code in there... I was thinking of a 
 solution that would use this class.
  
 But what about the JDBC Realm? I still don't know what it is, 
 and what it's for.


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




AW: problem with connections not closing...

2002-06-11 Thread Ralph Einfeldt

The finalize method migth not be called until tomcat is shut down.
Recommended actions:
- Use a connection pool
- Request the connection as close as possible to the usage
- Return the connection as soon as possible after the usage
- Always use a pattern like 
  Connection mCon = null;
  try {
mCon = mPool.getConnection(); 
// The exact code depends on the implemenation of the pool
  } catch (...) {
  } finally {
mPool.releaseConnection(mCon);
// The exact code depends on the implemenation of the pool
// if you have to catch Exception or to make shure that
// mCon != null and if you need transactions
  }

 -Ursprüngliche Nachricht-
 Von: Christian J. Dechery [mailto:[EMAIL PROTECTED]]
 Gesendet: Dienstag, 11. Juni 2002 15:33
 An: [EMAIL PROTECTED]
 Betreff: problem with connections not closing...
 
 I've even debugged it, there are some JSPs that opens like 4 
 connections, and in my finalize() method there's a 
 con.close() call, never all the 4 con.close() are 
 successfull, there's always at least one that fails and gives 
 an execption. I don't know why.

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




AW: problem with connections not closing...

2002-06-11 Thread Ralph Einfeldt

This kind of design will give you nothing but headache.
- The connection will be longer open than needed.
- You must do hard work to close the connections at all
- You have hardly control about the number of connections

I prefer to manage the connections outside of my dao's.
My DAO's get the connection as a parameter.

 -Ursprüngliche Nachricht-
 Von: Christian J. Dechery [mailto:[EMAIL PROTECTED]]
 Gesendet: Dienstag, 11. Juni 2002 16:42
 An: [EMAIL PROTECTED]
 Betreff: Re: problem with connections not closing...
 
 
 but I can't close the connection in each query... the 
 connection is used by other objects...
 I have a DAO for each class that needs access to the DB... 
 but some of these DAOs are Singletons, so several objects can 
 use one DAO and one connection to the db... so I can't just 
 close it whenever I want...
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: AW: problem with connections not closing...

2002-06-11 Thread Christian J. Dechery

yeah... I know what u mean, but now is kinda too late for me to change that... there 
are way too many JSPs accessing my beans (the ones who make calls to the DAOs)... so I 
want a better (simpler) solution to provide closure to all the connections?
 
I was thinking of some type os static variable to control it on the super DAO class. 
There is a super DAO class which all the DAO inherit the connection object from, I 
wrote the finalize() and cleanUp() code in there... I was thinking of a solution that 
would use this class.
 
But what about the JDBC Realm? I still don't know what it is, and what it's for.
 
Thanks
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 11/06/02 11:54  
This kind of design will give you nothing but headache. 
- The connection will be longer open than needed. 
- You must do hard work to close the connections at all 
- You have hardly control about the number of connections 

I prefer to manage the connections outside of my dao's. 
My DAO's get the connection as a parameter. 

 -Ursprüngliche Nachricht- 
 Von: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
 Gesendet: Dienstag, 11. Juni 2002 16:42 
 An: [EMAIL PROTECTED] 
 Betreff: Re: problem with connections not closing... 
 
 
 but I can't close the connection in each query... the 
 connection is used by other objects... 
 I have a DAO for each class that needs access to the DB... 
 but some of these DAOs are Singletons, so several objects can 
 use one DAO and one connection to the db... so I can't just 
 close it whenever I want... 
 

-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]