ResultSetMetaData 对象可以用于查找 ResultSet 中的列的类型和特性。
接口 java.sql.ResultSetMetaData
- public interface ResultSetMetaData
变量索引
- columnNoNulls
- 不允许 NULL 值。
- columnNullable
- 允许 NULL 值。
- columnNullableUnknown
- 不知是否允许 NULL。
方法索引
- getCatalogName(int)
- 获得列的表的目录名。
- getColumnCount()
- 获得 ResultSet 中的列数。
- getColumnDisplaySize(int)
- 获得列的正常的最大字符宽度。
- getColumnLabel(int)
- 获得打印输出和显示的建议列标题。
- getColumnName(int)
- 获得列名。
- getColumnType(int)
- 获得一个列的 SQL 类型。
- getColumnTypeName(int)
- 获得一个列的数据源特定的类型名。
- getPrecision(int)
- 获得一个列的十进制数字的位数。
- getScale(int)
- 获得一个列的十进制小数点右面数字的位数。
- getSchemaName(int)
- 获得一个列的表的模式。
- getTableName(int)
- 获得列的表名。
- isAutoIncrement(int)
- 列是否自动计数,因此它是只读的。
- isCaseSensitive(int)
- 列是否区分大小写。
- isCurrency(int)
- 列是否是通用的。
- isDefinitelyWritable(int)
- 对列的写操作是否一定成功。
- isNullable(int)
- 在该列中是否可以放一个 NULL 值。
- isReadOnly(int)
- 列是否是不可写的。
- isSearchable(int)
- 该列是否是可以查询的。
- isSigned(int)
- 该列是否是有符号数。
- isWritable(int)
- 对该列的写操作是否会成功。
变量
columnNoNulls
public static final int columnNoNulls
- 不允许 NULL 值。
columnNullable
public static final int columnNullable
- 允许 NULL 值。
columnNullableUnknown
public static final int columnNullableUnknown
- 不知是否允许 NULL。
方法
getColumnCount
public abstract int getColumnCount() throws SQLException
- 获得 ResultSet 中的列数。
- 返回值:
- 该数值
- 抛出:
SQLException
- 如果发生了数据访问错误。
isAutoIncrement
public abstract boolean isAutoIncrement(int column) throws SQLException
- 列是否自动计数,因此它是只读的。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- 果真如此则为 true
- 抛出:
SQLException
- 如果发生了数据访问错误。
isCaseSensitive
public abstract boolean isCaseSensitive(int column) throws SQLException
- 列是否区分大小写。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- 确实如此则为 true
- 抛出:
SQLException
- 如果发生了数据访问错误。
isSearchable
public abstract boolean isSearchable(int column) throws SQLException
- 该列能否用于一 where 子句?
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- 确实如此则为 true
- 抛出:
SQLException
- 如果发生了数据访问错误。
isCurrency
public abstract boolean isCurrency(int column) throws SQLException
- 列是否是通用的。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- 确实如此则为 true
- 抛出:
SQLException
- 如果发生了数据访问错误。
isNullable
public abstract int isNullable(int column) throws SQLException
- 在该列中是否可以放一个 NULL 值。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- columnNoNulls、columnNullable 或 columnNullableUnknown
- 抛出:
SQLException
- 如果发生了数据访问错误。
isSigned
public abstract boolean isSigned(int column) throws SQLException
- 该列是否的有符号数。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- 确实如此则为 true
- 抛出:
SQLException
- 如果发生了数据访问错误。
getColumnDisplaySize
public abstract int getColumnDisplaySize(int column) throws SQLException
- 获得列的正常的最大字符宽度。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- 最大宽度
- 抛出:
SQLException
- 如果发生了数据访问错误。
getColumnLabel
public abstract String getColumnLabel(int column) throws SQLException
- 获得用于打印输出和显示的建议列标题。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- 确实如此则为 true
- 抛出:
SQLException
- 如果发生了数据访问错误。
getColumnName
public abstract String
getColumnName(int column) throws SQLException
- 获得列名。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- 列名
- 抛出:
SQLException
- 如果发生了数据访问错误。
getSchemaName
public abstract String getSchemaName(int column) throws SQLException
- 获得一个列的表的模式。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- 模式名,如果不可用则为 ""
- 抛出:
SQLException
- 如果发生了数据访问错误。
getPrecision
public abstract int getPrecision(int column) throws
SQLException
- 获得一个列的十进制数字的位数。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- 精度
- 抛出:
SQLException
- 如果发生了数据访问错误。
getScale
public abstract int getScale(int column) throws
SQLException
- 获得一个列的十进制小数点右面数字的位数。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- 小数位数
- 抛出:
SQLException
- 如果发生了数据访问错误。
getTableName
public abstract String
getTableName(int column) throws SQLException
- 获得列的表名。
- 返回值:
- 表名,如果不可用则为 ""
- 抛出:
SQLException
- 如果发生了数据访问错误。
getCatalogName
public abstract String
getCatalogName(int column) throws SQLException
- 获得列的表的目录名。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- 列名,如果不可用则为 ""
- 抛出:
SQLException
- 如果发生了数据访问错误。
getColumnType
public abstract int getColumnType(int column) throws
SQLException
- 获得一个列的 SQL 类型。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- SQL 类型
- 抛出:
SQLException
- 如果发生了数据访问错误。
- 参见:
- Types
getColumnTypeName
public abstract String
getColumnTypeName(int column) throws SQLException
- 获得一个列的数据源特定的类型名。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- 类型名
- 抛出:
SQLException
- 如果发生了数据访问错误。
isReadOnly
public abstract boolean isReadOnly(int column) throws
SQLException
- 列是否是不可写的。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- 确实如此则为 true
- 抛出:
SQLException
- 如果发生了数据访问错误。
isWritable
public abstract boolean isWritable(int column) throws
SQLException
- 对该列的写操作是否会成功。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- 果真如此则为 true
- 抛出:
SQLException
- 如果发生了数据访问错误。
isDefinitelyWritable
public abstract boolean isDefinitelyWritable(int column) throws
SQLException
- 对列的写操作是否一定成功。
- 参数:
- column - 第一列是 1, 第二个列是 2, ...
- 返回值:
- 确实如此则为 true
- 抛出:
SQLException
- 如果发生了数据访问错误。