public int getCount() {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
int count = -1;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(SQL);
rs = pstmt.executeQuery();
if (rs.next()) {
count = rs.getInt(1);
} else {
count = 0;
}
} catch (SQLException sqle) {
Log.error(sqle.getMessage(), sqle);
return 0;
} finally {
DbConnectionManager.closeConnection(pstmt, con);
try {
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return count;
}