ResultSet close - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ResultSet close method.

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() { 
10
CodeRank
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();
    } 
 
10
CodeRank
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
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();
    } 
  } 
} 
9
CodeRank
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 
	 */ 
10
CodeRank
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())
9
CodeRank
This code example shows how to use the following methods:close, getInt, next
		try { 
			Connection c=(Connection)intGetObject();
			Statement st=c.createStatement();
			st.setQueryTimeout(5);
			ResultSet rs=st.executeQuery("select 7");
			rs.next();
			int r=rs.getInt(1);
			// Set the value to true only if r==7 
			ret=(r==7);
			rs.close();
			st.close();
		} catch(Exception e) {
			// Turn off availability 
			setUnavailable(); 
		} 
		return(ret);
	} 
 
	/** 
	 * Overridden to deal with SQL Warnings. 
9
CodeRank
This code example shows how to use the following methods:close, getString, next
        ResultSet rs = null;
 
        try { 
            st = con.createStatement();
            rs = st.executeQuery(query);
            if (rs != null && rs.next())
                result = rs.getString(1);
        } catch (Throwable t) {
            fail("it's impossible to execute query:" + query);
            t.printStackTrace();
        } finally { 
            if (rs != null) {
                try { 
                    rs.close();
                } catch (SQLException ignore) {
                    // Ignore 
                } 
            } 
            if (st != null) {
                try { 
8
CodeRank
This code example shows how to use the following methods:close
  { 
    try 
    { 
      if(target != null)
      { 
        target.close();
      } 
    } 
    catch(SQLException ex)
    { 
      // Ignore this 
    } 
  } 
 
  public static final void close(Statement target)
  { 
    try 
    { 
      if(target != null)
      { 
9
CodeRank
This code example shows how to use the following methods:close, next
        stmt = getWindowScnStatement(applyLogId, srcid);
        stmt.setInt(1, tabRid);
      } 
 
      rs = stmt.executeQuery();
      if (rs.next())
      { 
        windowScn = rs.getLong(1);
      } 
    } catch (SQLException e)
    { 
      LOG.error("Error ocurred during getWindowScnforSource", e);
      throw e;
    } finally 
    { 
      if (null != rs)
      { 
        rs.close();
        rs = null;
      } 

9
CodeRank

Related ResultSet close Questions & Answers:

close Method Overview
Releases this ResultSet object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.
See Code Examples for other Java 8 ResultSet Methods: