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

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:getBoolean, getString
  public List<InputSplit> split(Configuration conf, ResultSet results, String colName)
      throws SQLException { 
 
    List<InputSplit> splits = new ArrayList<InputSplit>();
 
    if (results.getString(1) == null && results.getString(2) == null) {
      // Range is null to null. Return a null split accordingly. 
      splits.add(new DataDrivenDBInputFormat.DataDrivenDBInputSplit(
          colName + " IS NULL", colName + " IS NULL"));
      return splits;
    } 
 
    boolean minVal = results.getBoolean(1);
    boolean maxVal = results.getBoolean(2);
 
    // Use one or two splits. 
    if (!minVal) {
      splits.add(new DataDrivenDBInputFormat.DataDrivenDBInputSplit(
          colName + " = FALSE", colName + " = FALSE"));
    } 

8
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: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: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:getString
 
import org.springframework.jdbc.core.RowMapper; 
 
public class UserMapper implements RowMapper<User> { 
    public User mapRow(ResultSet rs, int rowNum) throws SQLException {
        return new User(rs.getString("username"), rs.getString("password"), rs.getString("email"));
    } 
} 
8
CodeRank
This code example shows how to use the following methods:getObject, getString, getTimestamp
public class ArticleMapper implements ResultSetMapper<Article> 
{ 
    @Override 
    public Article map(int index, ResultSet resultSet, StatementContext ctx) throws SQLException
    { 
        Article article = new Article((UUID) resultSet.getObject("id"));
        article.setPublicationDate(resultSet.getTimestamp("publication_date"));
        article.setTitle(resultSet.getString("title"));
        article.setContent(resultSet.getString("content"));
        article.setSlug(resultSet.getString("slug"));
        if (resultSet.getObject("published") != null) {
            article.setPublished(resultSet.getBoolean("published"));
        } 
        article.setFeaturedImageId((UUID) resultSet.getObject("featured_image_id"));
 
        return article;
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getBinaryStream, getObject, getString
{ 
    @Override 
    public Attachment map(int i, ResultSet resultSet, StatementContext statementContext) throws SQLException
    { 
        Attachment attachment = new Attachment();
        attachment.setId((UUID) resultSet.getObject("id"));
        attachment.setTitle(resultSet.getString("title"));
        attachment.setDescription(resultSet.getString("description"));
        attachment.setSlug(resultSet.getString("slug"));
        attachment.setData(resultSet.getBinaryStream("data"));
        attachment.setExtension(resultSet.getString("extension"));
        attachment.setParentId((UUID) resultSet.getObject("parent_id"));
        return attachment;
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getInt, getString, getTimestamp
        update(sql, info.getPath(), info.getComment(), info.getPlayCount(), info.getLastPlayed(), info.isEnabled(), info.getId());
    } 
 
    private static class MusicFileInfoRowMapper implements ParameterizedRowMapper<MusicFileInfo> { 
        public MusicFileInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
            return new MusicFileInfo(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getInt(4), rs.getTimestamp(5), rs.getBoolean(6));
        } 
    } 
 
} 
7
CodeRank

Related ResultSet getString Questions & Answers:

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