Here you can find the source of getRows(final ResultSet rs)
Parameter | Description |
---|---|
rs | a parameter |
Parameter | Description |
---|---|
SQLException | an exception |
public static List<List<String>> getRows(final ResultSet rs) throws SQLException
//package com.java2s; //License from project: Open Source License import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; public class Main { /**//from w w w.ja va 2s . c o m * For SciDB, use getRowsSciDB instead * This does not work with SciDB because for SciDB's JDBC reference to "getObject" invariably returns null. * @param rs * @return * @throws SQLException */ public static List<List<String>> getRows(final ResultSet rs) throws SQLException { if (rs == null) { return null; } List<List<String>> rows = new ArrayList<>(); try { ResultSetMetaData rsmd = rs.getMetaData(); int NumOfCol = rsmd.getColumnCount(); while (rs.next()) { List<String> current_row = new ArrayList<String>(); for (int i = 1; i <= NumOfCol; i++) { Object value = rs.getObject(i); if (value == null) { current_row.add("null"); } else { current_row.add(value.toString()); } } rows.add(current_row); } return rows; } catch (SQLException e) { throw e; } } }