Code example for Statement

Methods: executeQuerysetQueryTimeout

0
    try 
    { 
      stmt = conn.createStatement();
      if (timeoutSeconds > 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)
Stop searching for code, let great code find you!  Add Codota to your java IDE