/** * Returns the Java class name if this column. * * @param columnIndex (1,2,...) * @return the class name */ @Override public String getColumnClassName(int columnIndex) throws SQLException { int type = DataType.getValueTypeFromResultSet(this, columnIndex); return DataType.getTypeClassName(type); }
/** * Extracts expression columns from the given result set. * * @param session the session * @param rs the result set * @return an array of expression columns */ public static Expression[] getExpressionColumns(Session session, ResultSet rs) { try { ResultSetMetaData meta = rs.getMetaData(); int columnCount = meta.getColumnCount(); Expression[] expressions = new Expression[columnCount]; Database db = session == null ? null : session.getDatabase(); for (int i = 0; i < columnCount; i++) { String name = meta.getColumnLabel(i + 1); int type = DataType.getValueTypeFromResultSet(meta, i + 1); int precision = meta.getPrecision(i + 1); int scale = meta.getScale(i + 1); int displaySize = meta.getColumnDisplaySize(i + 1); Column col = new Column(name, type, precision, scale, displaySize); Expression expr = new ExpressionColumn(db, col); expressions[i] = expr; } return expressions; } catch (SQLException e) { throw DbException.convert(e); } }
@Override public String getString() { try { StatementBuilder buff = new StatementBuilder("("); result.beforeFirst(); ResultSetMetaData meta = result.getMetaData(); int columnCount = meta.getColumnCount(); for (int i = 0; result.next(); i++) { if (i > 0) { buff.append(", "); } buff.append('('); buff.resetCount(); for (int j = 0; j < columnCount; j++) { buff.appendExceptFirst(", "); int t = DataType.getValueTypeFromResultSet(meta, j + 1); Value v = DataType.readValue(result, j + 1, t); buff.append(v.getString()); } buff.append(')'); } result.beforeFirst(); return buff.append(')').toString(); } catch (SQLException e) { throw DbException.convert(e); } }
scale = convertScale(sqlType, scale); int displaySize = rsMeta.getColumnDisplaySize(i + 1); int type = DataType.getValueTypeFromResultSet(rsMeta, i + 1); Column col = new Column(n, type, precision, scale, displaySize); col.setTable(this, i++);
for (int i = 0; i < columnCount; i++) { cols[i] = new Column(meta.getColumnName(i + 1), DataType.getValueTypeFromResultSet(meta, i + 1), meta.getPrecision(i + 1), meta.getScale(i + 1), meta.getColumnDisplaySize(i + 1));