* @see org.xooof.xooofoscope.dao.IUserDAO#exist(java.lang.Integer)
*/
public SUser fetchByPK(Integer userId) throws DAOException {
if (userId == null) {
throw new UserDAOException("userId cannot be null");
}
SUser user = null;
PreparedStatement statement = null;
ResultSet result;
Connection connection = DAOHelper.getDBConnection();
try {
try {
statement = connection.prepareStatement(FETCHBYPK_QRY);
statement.setInt(1, userId.intValue());
result = statement.executeQuery();
if (result.next()) {
user = new SUser();
user.setObjId(result.getString("id"));
user.setObjClass(SUser.class.getName());
user.setName(result.getString("name"));
if (result.next()) {
throw new UserDAOException(
"Multiple rows exists for userId " + userId.toString());
}
} else {
user = null;
}
} catch (SQLException exc) {
throw new UserDAOException(exc.getMessage());
} //End catch IOException
}
// This code is to be executed each time in order to release DB Connections
finally {
try {