List of utility methods to do SQL ResultSet Read
List
| getRows(final ResultSet rs) For SciDB, use getRowsSciDB instead This does not work with SciDB because for SciDB's JDBC reference to "getObject" invariably returns null. if (rs == null) { return null; List<List<String>> rows = new ArrayList<>(); try { ResultSetMetaData rsmd = rs.getMetaData(); int NumOfCol = rsmd.getColumnCount(); while (rs.next()) { ... |
int | getRows(ResultSet table) Get the number of rows in table. if (table == null) return 0; int rows; try { table.last(); rows = table.getRow(); } finally { table.beforeFirst(); ... |
String[] | getRsCloumns(ResultSet rs) get Rs Cloumns ResultSetMetaData rsm = rs.getMetaData(); String[] columns = new String[rsm.getColumnCount()]; for (int i = 0; i < columns.length; i++) { columns[i] = rsm.getColumnLabel(i + 1); return columns; |
Object | getRSData(ResultSet rs, String columnName, int jdbcType) get RS Data if (jdbcType == Types.BIT || jdbcType == Types.BOOLEAN) { return rs.getByte(columnName); } else { return rs.getObject(columnName); |
Statement | getStatement(ResultSet resultSet) get Statement try { return resultSet.getStatement(); } catch (SQLException e) { throw new RuntimeException("Error getting statement from result set", e); |
URI | getURI(ResultSet resultSet, String columnLabel) get URI return toURI(resultSet.getString(columnLabel));
|
URI | getURI(ResultSet rs, int col) get URI String o = rs.getString(col); if (o == null) { return null; try { return new URI((String) o); } catch (Throwable t) { throw new UnsupportedOperationException("converting " + o.getClass().getName() + " " + o + " to URI", ... |
UUID | getUUIDFromResultSet(ResultSet rset, String name) get UUID From Result Set String val = rset.getString(name); if (val != null && !val.isEmpty()) return UUID.fromString(rset.getString(name)); return null; |
Object | getValue(int type, ResultSet resultSet, int columnIndex) get Value switch (type) { case Types.BLOB: return resultSet.getBytes(columnIndex); case Types.CLOB: return resultSet.getString(columnIndex); default: return resultSet.getObject(columnIndex); |
String | getValue(ResultSet result, String strField) get Value String strValueReturn = result.getString(strField); if (result.wasNull()) strValueReturn = ""; return strValueReturn; |