Code example for ResultSet

Methods: getLong, next, wasNull

0
stmt.setQueryTimeout(timeoutSeconds);
      } 
      rs = stmt.executeQuery(query);
 
      if (rs.next())
      { 
        res = rs.getLong(1);
        // NULL result is interpreted as 0 with getLong() 
        if (rs.wasNull())
        { 
          res = defaultVal;
        } 
      } 
    } 
    catch (SQLException e)
    { 
      LOG.warn("Error executing query : " + query  + " Exception=" + e.getMessage() );
      LOG.warn("Returning default value: " + defaultVal);
    } 
    finally