List of utility methods to do SQL ResultSet
String[] | arrayOfResult(ResultSet rs) array Of Result ResultSetMetaData rsm = rs.getMetaData(); String ret[] = new String[rsm.getColumnCount()]; for (int i = 0; i < ret.length; i++) { ret[i] = rs.getString(i + 1); return ret; |
void | cleanupAfterQuery(final ResultSet rs, final Statement stmt) cleanup After Query if (rs != null) { rs.close(); if (stmt != null) { stmt.close(); |
void | cleanupConnection(ResultSet rs, Statement stmt, Connection conn) cleanup Connection if (rs != null) { try { rs.close(); } catch (SQLException ignore) { if (stmt != null) { try { ... |
void | cleanupJDBCResouce(ResultSet rs, Statement stmt, String oldCatalog, Connection conn) cleanup JDBC Resouce try { if (rs != null) rs.close(); } catch (SQLException e) { e.printStackTrace(); try { if (stmt != null) ... |
Object[][] | consume(ResultSet rs) consume ResultSetMetaData rsmd = rs.getMetaData(); ArrayList results = new ArrayList(); int colCount = rsmd.getColumnCount(); while (rs.next()) { Object[] row = new Object[colCount]; for (int i = 1; i <= colCount; ++i) { row[i - 1] = rs.getObject(i); results.add(row); return toOutArray(results, colCount); |
Map[] | consume2(ResultSet rs) consume ResultSetMetaData rsmd = rs.getMetaData(); ArrayList results = new ArrayList(); int colCount = rsmd.getColumnCount(); while (rs.next()) { Map row = new HashMap(); for (int i = 1; i <= colCount; ++i) { Object val = rs.getObject(i); row.put(rsmd.getColumnName(i), val); ... |
void | copyInt(ResultSet rs, int sourcePos, PreparedStatement stmt, int destPos) copy Int final int value = rs.getInt(sourcePos); if (rs.wasNull()) stmt.setNull(destPos, Types.INTEGER); else stmt.setInt(destPos, value); |
PreparedStatement | createLargeResultSetPreparedStatement(Connection conn, String sql) Returns a new prepared statement on the specified connection with the necessary options to avoid running out of memory when reading a large result set. PreparedStatement st = conn.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
st.setFetchSize(Integer.MIN_VALUE);
return st;
|
Statement | createLargeResultSetStatement(Connection conn) Returns a new statement on the specified connection with the necessary options to avoid running out of memory when reading a large result set. Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(Integer.MIN_VALUE);
return stmt;
|
TabularData | createTable(ResultSet rs) create Table ResultSetMetaData rsMetaData = rs.getMetaData(); int numCols = rsMetaData.getColumnCount(); String[] headers = new String[numCols]; OpenType[] allTypes = new OpenType[numCols]; Vector[] values = new Vector[numCols]; Object[] allValues = new Object[numCols]; for (int i = 0; i < numCols; i++) { headers[i] = rsMetaData.getColumnName(i + 1); ... |