Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

which is better to use? connection.close() or connection = null

843859Jul 11 2007 — edited Jul 11 2007
Hi,


can anybody let me know what is the difference between the following statements when intended to end the usage of it?
finally{
try{
if(con != null){
con.close();
}
}catch(Exception e){
System.out.println("Error in closing connection");
}
}
OR
finally{
con =null;
}
also can i set NULL to Resultset or Prepared statement instead of close() method?
Please let me know what will be the difference in each case.

Thanks in Advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 8 2007
Added on Jul 11 2007
3 comments
234 views