private Field<?> field(String columnLabel) throws SQLException { Field<?> field = result.field(columnLabel); if (field == null) throw new SQLException("Unknown column label : " + columnLabel); return field; }
@Override public int findColumn(String columnLabel) throws SQLException { checkNotClosed(); Field<?> field = result.field(columnLabel); if (field == null) throw new SQLException("No such column : " + columnLabel); return result.fieldsRow().indexOf(field) + 1; }
private Field<?> field(int columnIndex) throws SQLException { Field<?> field = result.field(columnIndex - 1); if (field == null) throw new SQLException("Unknown column index : " + columnIndex); return field; }
@Override public int findColumn(String columnLabel) throws SQLException { checkNotClosed(); Field<?> field = result.field(columnLabel); if (field == null) { throw new SQLException("No such column : " + columnLabel); } return result.fieldsRow().indexOf(field) + 1; }
private void checkField(int columnIndex) throws SQLException { if (result.field(columnIndex - 1) == null) { throw new SQLException("Unknown column index : " + columnIndex); } }
private void checkField(String columnLabel) throws SQLException { if (result.field(columnLabel) == null) { throw new SQLException("Unknown column label : " + columnLabel); } }
@Override public boolean isSigned(int column) throws SQLException { rs.checkNotClosed(); Field<?> field = rs.result.field(column - 1); Class<?> type = field.getType(); return Number.class.isAssignableFrom(type) && !UNumber.class.isAssignableFrom(type); }
@Override public boolean isSigned(int column) throws SQLException { rs.checkNotClosed(); Field<?> field = rs.result.field(column - 1); Class<?> type = field.getType(); return Number.class.isAssignableFrom(type) && !UNumber.class.isAssignableFrom(type); }
@Override public String getColumnClassName(int column) throws SQLException { rs.checkNotClosed(); return rs.result.field(column - 1).getType().getName(); } }
@Override public String getColumnClassName(int column) throws SQLException { rs.checkNotClosed(); return rs.result.field(column - 1).getType().getName(); } }
@Override public String getColumnName(int column) throws SQLException { rs.checkNotClosed(); return rs.result.field(column - 1).getName(); }
@Override public String getColumnName(int column) throws SQLException { rs.checkNotClosed(); return rs.result.field(column - 1).getName(); }
@SuppressWarnings("unchecked") private final Result<Record> getColumns(String schema, String table) { // SQLite JDBC's DatabaseMetaData.getColumns() can only return a single // table's columns if (columnCache == null && configuration.dialect() != SQLITE) { Result<Record> columns = getColumns0(schema, "%"); Field<String> tableCat = (Field<String>) columns.field(0); // TABLE_CAT Field<String> tableSchem = (Field<String>) columns.field(1); // TABLE_SCHEM Field<String> tableName = (Field<String>) columns.field(2); // TABLE_NAME Map<Record, Result<Record>> groups = columns.intoGroups(new Field[] { inverseSchemaCatalog ? tableCat : tableSchem, tableName }); columnCache = new LinkedHashMap<Name, Result<Record>>(); for (Entry<Record, Result<Record>> entry : groups.entrySet()) { Record key = entry.getKey(); Result<Record> value = entry.getValue(); columnCache.put(name(key.get(inverseSchemaCatalog ? tableCat : tableSchem), key.get(tableName)), value); } } if (columnCache != null) return columnCache.get(name(schema, table)); else return getColumns0(schema, table); }
@Override public int getColumnType(int column) throws SQLException { rs.checkNotClosed(); return rs.result.field(column - 1).getDataType().getSQLType(); }
@Override public String getColumnTypeName(int column) throws SQLException { rs.checkNotClosed(); return rs.result.field(column - 1).getDataType().getTypeName(); }
@Override public int getColumnType(int column) throws SQLException { rs.checkNotClosed(); return rs.result.field(column - 1).getDataType().getSQLType(); }
@Override public String getColumnTypeName(int column) throws SQLException { rs.checkNotClosed(); return rs.result.field(column - 1).getDataType().getTypeName(); }
@Override public String getTableName(int column) throws SQLException { rs.checkNotClosed(); Field<?> field = rs.result.field(column - 1); if (field instanceof TableField) { Table<?> table = ((TableField<?, ?>) field).getTable(); if (table != null) { return table.getName(); } } // By default, no table is available return ""; }
@Override public String getTableName(int column) throws SQLException { rs.checkNotClosed(); Field<?> field = rs.result.field(column - 1); if (field instanceof TableField) { Table<?> table = ((TableField<?, ?>) field).getTable(); if (table != null) { return table.getName(); } } // By default, no table is available return ""; }
@Override public String getSchemaName(int column) throws SQLException { rs.checkNotClosed(); Field<?> field = rs.result.field(column - 1); if (field instanceof TableField) { Table<?> table = ((TableField<?, ?>) field).getTable(); if (table != null) { Schema schema = table.getSchema(); if (schema != null) { Configuration configuration = rs.result.configuration(); Schema mapped = null; if (configuration != null) mapped = DSL.using(configuration).map(schema); if (mapped != null) return mapped.getName(); else return schema.getName(); } } } // By default, no schema is available return ""; }