A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Take Control of Upgrading to Yosemite
Take Control of Automating Your Mac
this week in the
connection already closed problem
Joined: Jun 21, 2001
Mar 15, 2005 09:57:00
I have below code.
Call to method b;
create new connection;
call to method c(
a, Connection con);
close connection object.
run the sql;
in the finally block close preparedStatement and connection;
I am getting connection already closed exception from the method c.
Can someone tell me what am I doing wrong?
Joined: Aug 13, 2004
Mar 15, 2005 11:46:00
your description is quite mixed, or i am not able to get it properly.
your method A calls B (in method B you are creating a connection)
after processing of B again you are creating a connection and sharing it with methdo C.
now question is why are you not sharing connection with B ???
create connection before calling method B and pass the connection in method B.
Then pass same connection to method C
and in finally block of A close one connection.
I can only guess that probably you are processing some resultset or anything else which is dependant of connection created in method B.
pasting actual code here will help
[ March 15, 2005: Message edited by: Shailesh Chandra ]
Gravitation cannot be held responsible for people falling in love ~
Joined: Apr 20, 2001
Mar 15, 2005 12:09:00
It's quite possible that method c() throws an exception and close the connection which may cause by many problems including db server is down or network has been dropped. You may need to handle this type of exception in mehod b().
subject: connection already closed problem
closing the database connection
Closing The connection (Database)
ora-0100 maximum number of cursors exceeds
resultset is not working properly
Queries regarding PreparedStatement
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014