Get multiple value from ResultSet - Java JDBC

Java examples for JDBC:RowSet

Description

Get multiple value from ResultSet

Demo Code

import java.io.InputStream;
import java.math.BigDecimal;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Date;

public class Main {
  public void m() {
    try {// ww w  . j  a  va  2  s .  co  m
      Connection connection = null;
      Statement stmt = connection.createStatement();
      ResultSet rs = stmt.executeQuery("SELECT * FROM mysql_all_table");

      // Fetch each row from the result set
      while (rs.next()) {
        boolean bool = rs.getBoolean("col_boolean");
        byte b = rs.getByte("col_byte");
        short s = rs.getShort("col_short");
        int i = rs.getInt("col_int");
        long l = rs.getLong("col_long");
        float f = rs.getFloat("col_float");
        double d = rs.getDouble("col_double");
        BigDecimal bd = rs.getBigDecimal("col_bigdecimal");
        String str = rs.getString("col_string");
        Date date = rs.getDate("col_date");
        Time t = rs.getTime("col_time");
        Timestamp ts = rs.getTimestamp("col_timestamp");
        InputStream ais = rs.getAsciiStream("col_asciistream");
        InputStream bis = rs.getBinaryStream("col_binarystream");
        Blob blob = rs.getBlob("col_blob");
      }

    } catch (SQLException e) {
    }
  }
}

Related Tutorials