Click here to Skip to main content
15,911,789 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear,

how to catch databaseobject not closed exception
Posted

Java
try
{
    con.open();  //Opening DB Connection

    // some code
}
catch(Exception ex)
{
    // some code
}
finally
{
    con.close();  // Closing DB Connection
}


even though exception is thrown, finally block always executed.
I think you might want to see this[^].
 
Share this answer
 
Better you write finally block and within it con.close() every where wherere you used try catch blocks.

refer:-
http://stackoverflow.com/questions/13343236/the-connection-was-not-closed-the-connections-current-state-is-open[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900