Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing a connection???? can't be this hard!

Status
Not open for further replies.

RiazKhanmohamed

Programmer
Oct 30, 2002
115
I have a 3 tier architecture on a booking system I am developing in jsp/java/oracle. my database layer has multiple database mapper classes per table type, and a single connectionmanager class which each connects through.

However, I cannot kill a connection. my middle tier (problem domain) has no generic connection. each individual function creates an new instance of the database mappers required, runs processes, then closes, dropping the instances of the classes. However, it would appear that from the time I login, regardless of what I do, I have a single connection open to oracle that every function shares, until the connection times out on the server.

I have tried con.close() functions within the mappers that I run at the end of functions in the problem domain, but they fall over, saying that the connection is closed before it even runs the query 4 lines prior.

Any ideas/suggestions would be grand. the main problem this causes is that whoever connects to the system via the server uses this single connection because it just stays there. So if the connection times out, it's not just that user who is affected, but everyone.

I'm using JRUN because I can't get apache to work on my current system, but I don't believe it's related to this. However I will investigate anyway.

I look forward to any response that may solve this pain.
 
Couple of things to check :

1) Check that all ResultSet and Statement, PreparedStatement, and CallableStatement objects are closed before you close the connection.
2) Are you running shared server through port 1526 combined with Oracle Objects - we have found connection anomalies via this setup.
3) Are you using a Connection Pool, or some 3rd party tool to monitor or manage your connections ? If so, it is possible that this is creating a connection to the db that you are not *manually* controlling ...
 
Sorted thanks.

thanks for your help sedj, but i worked it out. Weren't any of those. I was creating the connection on creation of the instance of the mapper, so when i went to close it, it knew there was no way of creating a new connection. all i did was move this connection creation to it's own function and it's working fine.

Would consider a connection pool, but don't know how. will surf for some stuff on it later.

thanks again, took a night off staring a computer screen to work out as usual!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top