I have a class which takes a database connection over constructor, as you can see from the sample code connCat = con_cat
(con_cat is being passed in).
Please let me know: do I need to explicitly close the connCat connection inside this class, so the connection will be released properly?
If it's missing, will it cause connection leakage?
Will having a finally clause and doing connCat.close();
and connCat = null;
be enough?
public class GenericDbProc extends DBProcessor {
Logger fileLogger = Logger.getLogger(GenericDbProc.class);
Connection connCat;
public GenericDbProc(Connection con_cat)
{
connCat = con_cat;
}
public List<MxsCustomParam> getServiceEndPointDetails(String module_name) {
StringBuffer sb = new StringBuffer();
PreparedStatement stmt = null;
ResultSet rs = null;
sb.append("select xxxxxxx ")
.append(" where module = ?");
List<MxsCustomParam> mxsCustomParamList = new ArrayList<MxsCustomParam>();
try {
stmt = connCat.prepareStatement(sb.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
stmt.setString(1, module_name);
rs = stmt.executeQuery();