ResultSet getInt - 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 getInt method.

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, 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: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;
9
CodeRank
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;
		} 
9
CodeRank
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
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:getInt, next
 
  @Test 
  public void testMaxLong() throws Exception { 
    ResultSet res = tpch.execute("select max(l_orderkey) as total_max from lineitem");
    try { 
      res.next();
      assertEquals(3, res.getInt(1));
    } finally { 
      res.close();
    } 
  } 
 
  @Test 
  public void testMinLong() throws Exception { 
    ResultSet res = tpch.execute("select min(l_orderkey) as total_min from lineitem");
    try { 
      res.next();
      assertEquals(1, res.getInt(1));
    } finally { 
      res.close();
9
CodeRank
This code example shows how to use the following methods:getInt, getString, next
      stmt.setString(1, ownerName);
      stmt.setString(2, typeName);
      rs = stmt.executeQuery();
 
      // If there was no row then this is not a collection type 
      if(!rs.next())
      { 
        throw new SQLException("Not a collection type. (" + typeName + ")");
      } 
 
      // Get the columns 
      String elementTypeOwner = rs.getString(1);
      String elementTypeName = rs.getString(2);
      int precision = rs.getInt(3);
      int scale = rs.getInt(4);
 
      // Build the type for the element type ("this is a collection of ...") 
      TypeInfo elementTypeInfo = getTypeInfo(con, elementTypeOwner, elementTypeName, precision, scale,"");
 
      // Construct and return the new CollectionTypeInfo 

8
CodeRank
This code example shows how to use the following methods:close, getInt, next
        try { 
            Statement st = cx.createStatement();
            try { 
                ResultSet rs = st.executeQuery("SELECT srid FROM sysspatial.spatial_ref_sys " 
                    + "WHERE auth_srid = 4326"); 
                rs.next();
                srid4326 = rs.getInt(1);
                rs.close();
            } 
            finally { 
                st.close();
            } 
        } 
        finally { 
            cx.close();
        } 
    } 
     
    protected void setUpDataStore(JDBCDataStore dataStore) {
        super.setUpDataStore(dataStore);
9
CodeRank
This code example shows how to use the following methods:getInt, next
			String error = "Insertion faild for the permission";
			log.error(error);
			throw new UserStoreException(error);
		} 
		res = stmt.getGeneratedKeys();
		if (res.next()) {
			setId(res.getInt(1));
		} 
 
	} 
 
	@Override 
	protected void update(Connection connection, boolean commit) throws UserStoreException {
		StringBuilder sql =
		                    new StringBuilder(
		                                      "UPDATE UM_ROLE_PERMISSION SET UM_IS_ALLOWED = ? WHERE "); 
		if (getId() > 0) { 
			sql.append(" UM_ID = ? ");
			DatabaseUtil.updateDatabase(connection, sql.toString(), isAuthorized(), getId());
		} else { 
9
CodeRank

Related ResultSet getInt Questions & Answers:

getInt Method Overview
Retrieves the value of the designated column in the current row of this ResultSet object as an int in the Java programming language.
See Code Examples for other Java 8 ResultSet Methods: