Java 8 ResultSet - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ResultSet class.

This code example shows how to use the following methods: close
 
    public void close() { 
        if (result != null) {
            try { 
                next = null;
                result.close();
                result = null;
            } catch (SQLException ex) {
                result = null;
                throw new RuntimeException(ex);
            } 
        } 
    } 
 
    public static void close(Iterator<?> iterator) {
        if (iterator instanceof JdbcIterator<?>) ((JdbcIterator<?>)iterator).close();
    } 
 
 
    protected void load() { 
Full Snippet Info
10
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: close, getInt, next
 
        Statement statement = shadowOf(database).getConnection().createStatement();
        final String select = "SELECT COUNT(*) FROM table_name";
 
        ResultSet rs = statement.executeQuery(select);
        assertThat(rs.next()).isTrue();
        assertThat(rs.getInt(1)).isEqualTo(1);
        rs.close();
 
        assertThat(shDatabase.isTransactionSuccess()).isFalse();
        database.endTransaction();
 
        statement = shadowOf(database).getConnection().createStatement();
        rs = statement.executeQuery(select);
        assertThat(rs.next()).isTrue();
        assertThat(rs.getInt(1)).isEqualTo(0);
 
        assertThat(shDatabase.isTransactionSuccess()).isFalse();
    } 
 
Full Snippet Info
10
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: close, next
 
    public void close() { 
        if (result != null) {
            try { 
                next = null;
                result.close();
                result = null;
            } catch (SQLException ex) {
                result = null;
                throw new RuntimeException(ex);
            } 
        } 
    } 
 
    public static void close(Iterator<?> iterator) {
        if (iterator instanceof JdbcIterator<?>) ((JdbcIterator<?>) iterator).close();
    } 
 
 
    protected void load() { 

10
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: next
	  try 
	  { 
		  stmt = conn.createStatement();
		  rs = stmt.executeQuery(query);
 
		  if ( rs.next() )
		  { 
			  res = rs.getLong(1);
		  } 
	  } finally { 
		  DBHelper.close(rs,stmt,null);
	  } 
	  return res;
  } 
 
 
  /** 
   * 
   * @param query: that expects to return a single long 
   * @param defaultVal: value to be returned if there is an error in query or if a null result was found 
Full Snippet Info
10
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: close, getInt, next
    ResultSet res = tpch.execute("select 100 * sum(" +
        "case when p_type like 'PROMO%' then l_extendedprice else 0.0 end) / sum(l_extendedprice * (1 - l_discount)) " 
        + "as promo_revenue from lineitem, part where l_partkey = p_partkey"); 
 
    try { 
      assertTrue(res.next());
      assertEquals(33, res.getInt(1));
    } finally { 
      res.close();
    } 
  } 
} 
Full Snippet Info
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: close, next
 
		int newSeq = 0;
 
		PreparedStatement pstmt = conn.prepareStatement(query);
		ResultSet rs = pstmt.executeQuery();
		if (rs.next()) {
			newSeq = rs.getInt(1);
		} 
		pstmt.close();
		rs.close();
 
		return newSeq + 1;
	} 
	/** 
	 * fetch count number 
	 * @param conn 
	 * @param query 
	 * @return number 
	 * @throws SQLException 
	 */ 
Full Snippet Info
10
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: close
  { 
    if(obj != null)
    { 
      try 
      { 
        obj.close();
      } 
      catch(SQLException ex)
      { 
      } 
    } 
  } 
   
  /** 
   * Invokes a commit on the connection if auto-commit is turned off 
   */ 
  public static void commit(Connection conn)
  throws SQLException 
  { 
	  if (conn != null && !conn.isClosed())
Full Snippet Info
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getInt, next
        final PreparedStatement stmt = connection.prepareStatement(sql);
        final ResultSet rs;
        try { 
            rs = stmt.executeQuery();
            try { 
                rs.next();
                count = rs.getInt(1);
            } finally { 
                rs.close();
            } 
        } finally { 
            stmt.close();
        } 
    } 
 
    //////////////////////////////////////////////////////////////////////////////// 
    /////// END OF PUBLIC 
    //////////////////////////////////////////////////////////////////////////////// 
 
    private String tableName;
Full Snippet Info
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getInt, next
		try { 
			conn = ConnectionManager.getDataSource().getConnection();
			stat = conn.createStatement();
			rs = stat.executeQuery(sSqlQuery);
			 
			if (rs.next()) {
				this.iIdAdresse = rs.getInt(1);
				this.iIdAdresseType = rs.getInt(2);
				this.iIdTypeObjet = rs.getInt(3);
				this.iIdReferenceObjet = rs.getInt(4);
			} 
			else 
			{ 
				throw new CoinDatabaseLoadException ( "" + this.iIdAdresseObjet, sSqlQuery);
			} 
		} 
		catch(NamingException e)
		{ 
			throw e;
		} 
Full Snippet Info
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getInt, getString, next
      stmt.setString(1, typeOwner);
      stmt.setString(2, typeName);
      rs = stmt.executeQuery();
 
      // If there was no row then this is not a user type 
      if(!rs.next())
      { 
        throw new SQLException("Not a user type. (" + typeName + ")");
      } 
 
      // Build up the list of attributes (fields) in this user type 
      List<FieldInfo> fields = new ArrayList<FieldInfo>();
      do 
      { 
        String attrName = rs.getString(1);
        String attrTypeOwner = rs.getString(2);
        String attrTypeName = rs.getString(3);
        int attrPrecision = rs.getInt(4);
        int attrScale = rs.getInt(5);
 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Java 8 ResultSet Questions & Answers:

See Code Examples for Java 8 ResultSet Methods: