use of com.wplatform.ddal.result.SimpleResultSet in project jdbc-shards by wplatform.
the class ValueResultSet method getCopy.
/**
* Create a result set value for the given result set. The result set will
* be fully read in memory. The original result set is not closed.
*
* @param rs the result set
* @param maxrows the maximum number of rows to read (0 to just read the
* meta data)
* @return the value
*/
public static ValueResultSet getCopy(ResultSet rs, int maxrows) {
try {
ResultSetMetaData meta = rs.getMetaData();
int columnCount = meta.getColumnCount();
SimpleResultSet simple = new SimpleResultSet();
simple.setAutoClose(false);
ValueResultSet val = new ValueResultSet(simple);
for (int i = 0; i < columnCount; i++) {
String name = meta.getColumnLabel(i + 1);
int sqlType = meta.getColumnType(i + 1);
int precision = meta.getPrecision(i + 1);
int scale = meta.getScale(i + 1);
simple.addColumn(name, sqlType, precision, scale);
}
for (int i = 0; i < maxrows && rs.next(); i++) {
Object[] list = new Object[columnCount];
for (int j = 0; j < columnCount; j++) {
list[j] = rs.getObject(j + 1);
}
simple.addRow(list);
}
return val;
} catch (SQLException e) {
throw DbException.convert(e);
}
}
use of com.wplatform.ddal.result.SimpleResultSet in project jdbc-shards by wplatform.
the class CallableStatementTestCase method testCall.
/**
* This method is called via reflection from the database.
*
* @param conn the connection
* @param a the value a
* @param b the value b
* @param c the value c
* @param d the value d
* @return a result set
*/
public static ResultSet testCall(Connection conn, int a, String b, Timestamp c, Timestamp d) throws SQLException {
SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("A", Types.INTEGER, 0, 0);
rs.addColumn("B", Types.VARCHAR, 0, 0);
rs.addColumn("C", Types.TIMESTAMP, 0, 0);
rs.addColumn("D", Types.TIMESTAMP, 0, 0);
if ("jdbc:columnlist:connection".equals(conn.getMetaData().getURL())) {
return rs;
}
rs.addRow(a * 2, b.toUpperCase(), new Timestamp(c.getTime() + 1), d);
return rs;
}
Aggregations