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

This code example shows how to use the following methods:getBytes, getLong, getString
	 
	public BootstrapEventProcessResult onEvent(ResultSet rs, DbusEventsStatisticsCollector statsCollector) throws BootstrapProcessingException
	{	 
	  try 
	  { 
		  rIds.add(rs.getLong(1));
		  sequences.add(rs.getLong(2));
		  srcKeys.add(rs.getString(3));
		  values.add(rs.getBytes(4));
	  } catch (Exception ex) {
		  throw new BootstrapProcessingException(ex);
	  } 
	   
	  return new BootstrapEventProcessResult(1, false, false); 
	} 
	 
	 
	public void reset() 
	{ 
		rIds.clear();
8
CodeRank
This code example shows how to use the following methods:getInt, getLong, getString, next
        assertThat(resultSet.next()).isTrue();
        assertThat(resultSet.getInt(1)).isEqualTo(2);
 
        statement = shadowOf(database).getConnection().createStatement();
        resultSet = statement.executeQuery("SELECT `id`, `name` ,`lastUsed` FROM `routine`");
        assertThat(resultSet.next()).isTrue();
        assertThat(resultSet.getInt(1)).isEqualTo(1);
        assertThat(resultSet.getString(2)).isEqualTo("Leg Press");
        assertThat(resultSet.getInt(3)).isEqualTo(0);
        assertThat(resultSet.next()).isTrue();
        assertThat(resultSet.getLong(1)).isEqualTo(2L);
        assertThat(resultSet.getString(2)).isEqualTo("Bench Press");
        assertThat(resultSet.getInt(3)).isEqualTo(1);
    } 
 
    @Test(expected = android.database.SQLException.class) 
    public void testExecSQLException() throws Exception { 
        database.execSQL("INSERT INTO table_name;");    // invalid SQL
    } 
 
8
CodeRank
This code example shows how to use the following methods:getBigDecimal, getLong, getString
    private static class ProductListItemRowMapper implements RowMapper<ProductListItemDto> { 
 
        @Override 
        public ProductListItemDto mapRow(ResultSet rs, int rowNum) throws SQLException {
            ProductListItemDto dto = new ProductListItemDto();
            dto.setProductId(rs.getLong("entityId"));
            dto.setDisplayedName(rs.getString("name"));
            dto.setPrice(new Money(rs.getBigDecimal("value"), Currency.getInstance(rs.getString("currencyCode"))));
            return dto;
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getDouble, getInt, getLong, getString, getTimestamp
import java.sql.Timestamp; 
 
public class ThesisUniqueMapper implements ParameterizedRowMapper<ThesisUnique> { 
    public ThesisUnique mapRow(ResultSet resultSet, int i) {
        try { 
            return new ThesisUnique(resultSet.getLong("id"), resultSet.getString("content"),
                                    resultSet.getInt("frequency"), resultSet.getTimestamp("last_scan"),
                                    resultSet.getDouble("positivity"), resultSet.getDouble("importance"));
        } catch (SQLException e) {
            // Something is wrong with the base, i.e. one of column labels isn't presented. 
            return new ThesisUnique(-1, "NOCONTENT", 0, new Timestamp(System.currentTimeMillis()), 0.0, 0.0);
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getLong, getString, next
        try { 
            con = DBUtils.getConn();
            PreparedStatement stmt = con.prepareStatement(sql);
            ResultSet rs = stmt.executeQuery();
 
            while (rs.next()) {
                PublicKey publicKey = new PublicKey();
                publicKey.setId(rs.getLong("id"));
                publicKey.setKeyNm(rs.getString("key_nm"));
                publicKey.setPublicKey(rs.getString("public_key"));
                publicKey.setProfile(ProfileDB.getProfile(con, rs.getLong("profile_id")));
                publicKeysList.add(publicKey);
 
            } 
            DBUtils.closeRs(rs);
            DBUtils.closeStmt(stmt);
 
        } catch (Exception e) {
            e.printStackTrace();
        } 
7
CodeRank
This code example shows how to use the following methods:getInt, getLong, getString
     
    private static class MetricsMapper implements RowMapper<Metrics> { 
        @Override 
        public Metrics mapRow(ResultSet rs, int rowNum) throws SQLException {
            Metrics m = new Metrics();
            m.setId( rs.getLong("id"));
            m.setWorkspace( rs.getString("workspace"));
            m.setNumSources( rs.getInt("num_sources"));
            m.setMaxSourceSize(rs.getInt("max_src_size"));
            m.setMinSourceSize(rs.getInt("min_src_size"));
            m.setMeanSourceSize(rs.getInt("mean_src_size"));
            m.setTotalSourcesSize(rs.getInt("total_src_size"));
            m.setTotalTimeCollating(rs.getLong("secs_collating"));
            m.setNumCollationsStarted(rs.getInt("started_collations"));
            m.setNumCollationsFinished(rs.getInt("finished_collations"));
            m.setMaxSetWitnesses(rs.getInt("max_set_witnesses"));
            m.setMinSetWitnesses(rs.getInt("min_set_witnesses"));
            m.setMeanSetWitnesses(rs.getInt("mean_set_witnesses"));
            return m;
        } 
7
CodeRank
This code example shows how to use the following methods:getLong, getString, next
        try { 
            PreparedStatement stmt = con.prepareStatement("select * from profiles where id=?");
            stmt.setLong(1, profileId);
            ResultSet rs = stmt.executeQuery();
 
            while (rs.next()) {
                profile = new Profile();
                profile.setId(rs.getLong("id"));
                profile.setNm(rs.getString("nm"));
                profile.setDesc(rs.getString("desc"));
                profile.setHostSystemList(ProfileSystemsDB.getSystemsByProfile(con, profileId));
 
            } 
            DBUtils.closeRs(rs);
            DBUtils.closeStmt(stmt);
 
        } catch (Exception e) {
            e.printStackTrace();
        } 
 
7
CodeRank
This code example shows how to use the following methods:getLong, next
        Long userId=null;
        try { 
            PreparedStatement stmt = con.prepareStatement("select * from users where enabled=true and auth_token like ?");
            stmt.setString(1, authToken);
            ResultSet rs = stmt.executeQuery();
            if (rs.next()) {
               userId=rs.getLong("id");
            } 
            DBUtils.closeRs(rs);
            DBUtils.closeStmt(stmt);
 
        } catch (Exception e) {
            e.printStackTrace();
        } 
 
 
        return userId;
 
    } 
    /** 
6
CodeRank
This code example shows how to use the following methods:getBlob, getClob, getDate, getLong, getString
        case Types.NUMERIC:
        case Types.DOUBLE:
        case Types.SMALLINT:
        case Types.TINYINT:
            try { 
                ival = rset.getLong (index);
            } catch (SQLException e) {
                ival = -1;
            } 
            break; 
        case Types.CHAR:
        case Types.VARCHAR:
        case Types.BLOB:
        case Types.CLOB:
            try { 
                if ((type == Types.CHAR) || (type == Types.VARCHAR)) {
                    sval = rset.getString (index);
                } else if (type == Types.BLOB) {
                    Blob    tmp = rset.getBlob (index);
 

6
CodeRank
This code example shows how to use the following methods:getInt, getLong, getString
 * Time: 5:51:19 
 */ 
public class QueryUniqueMapper implements ParameterizedRowMapper<QueryUnique> { 
        public QueryUnique mapRow(ResultSet resultSet, int i) {
        try { 
            return new QueryUnique(resultSet.getLong("id"),
                    resultSet.getString("text"),
                    resultSet.getLong("last_scan"),
                    resultSet.getInt("frequency"));
        } catch (SQLException e) {
            // Something is wrong with the base, i.e. one of column labels isn't presented. 
            return new QueryUnique(-1, "NOTEXT", System.currentTimeMillis(), 0);
        } 
    } 
} 
7
CodeRank
getLong Method Overview
Retrieves the value of the designated column in the current row of this ResultSet object as a long in the Java programming language.
See Code Examples for other Java 8 ResultSet Methods: