Here you can find the source of getResult(ResultSet rs)
Parameter | Description |
---|---|
rs | Result set to process |
Parameter | Description |
---|---|
SQLException | if some error occurred while processing result set |
private static String[][] getResult(ResultSet rs) throws SQLException
//package com.java2s; /*L// ww w. jav a 2 s.c o m * Copyright Georgetown University, Washington University. * * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/cab2b/LICENSE.txt for details. */ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; public class Main { /** * @param rs Result set to process * @return String[][] created by getting all records of result set * @throws SQLException if some error occurred while processing result set */ private static String[][] getResult(ResultSet rs) throws SQLException { List<String[]> results = new ArrayList<String[]>(); int noOfColumns = rs.getMetaData().getColumnCount(); while (rs.next()) { String[] oneRow = new String[noOfColumns]; for (int i = 1; i <= noOfColumns; i++) { oneRow[i - 1] = rs.getString(i); } results.add(oneRow); } return results.toArray(new String[0][0]); } }