Basically I have:
String query = \"SELECT * FROM table WHERE UNIQUEID=? AND DIR IS NOT NULL AND NAME IS NOT NULL AND PAGETYPE IS NOT NULL\";
DBConnect Databa
A good approach is to use one try - finally block like this
String query = "SELECT * FROM table WHERE UNIQUEID=? AND DIR IS NOT NULL AND NAME IS NOT NULL AND PAGETYPE IS NOT NULL";
DBConnect Database = new DBConnect();
Connection con = null;
PreparedStatement ps = null;
ResultSet rs=null;
try {
con = Database.getcon();
ps = con.prepareStatement(query);
ps.setString(1, URI);
rs=ps.executeQuery();
if(rs.next()){
}
query = "SELECT COUNTCOMMENTS FROM videosinfos WHERE UNIQUEID=?";
ps = con.prepareStatement(query); // Getting error here
rs=ps.executeQuery();
ps.setString(1, URI);
rs=ps.executeQuery();
if(rs.next()){
comments = rs.getInt(1);
}
} finally {
if(ps != null)
ps.close();
if(rs != null)
rs.close();
if(con != null)
con.close();
}