| |||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |
java.sql
接口 ResultSetMetaData
- 所有已知子接口:
- RowSetMetaData
- 所有已知实现类:
- RowSetMetaDataImpl
public interface ResultSetMetaData
可用于获取关于 ResultSet
对象中列的类型和属性信息的对象。以下代码片段创建 ResultSet
对象 rs,创建 ResultSetMetaData
对象 rsmd,并使用 rsmd 查找 rs 有多少列,以及 rs 中的第一列是否可以在 WHERE
子句中使用。
ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM TABLE2"); ResultSetMetaData rsmd = rs.getMetaData(); int numberOfColumns = rsmd.getColumnCount(); boolean b = rsmd.isSearchable(1);
字段摘要 | |
---|---|
static int | columnNoNulls 指示列不允许使用 NULL 值的常量。 |
static int | columnNullable 指示列允许使用 NULL 值的常量。 |
static int | columnNullableUnknown 指示不知道列的值是否可为 null 的常量。 |
方法摘要 | |
---|---|
String | getCatalogName(int column) 获取指定列的表目录名称。 |
String | getColumnClassName(int column) 如果调用方法 ResultSet.getObject 从列中检索值,则返回构造其实例的 Java 类的完全限定名称。 |
int | getColumnCount() 返回此 ResultSet 对象中的列数。 |
int | getColumnDisplaySize(int column) 指示指定列的最大标准宽度,以字符为单位。 |
String | getColumnLabel(int column) 获取用于打印输出和显示的指定列的建议标题。 |
String | getColumnName(int column) 获取指定列的名称。 |
int | getColumnType(int column) 检索指定列的 SQL 类型。 |
String | getColumnTypeName(int column) 检索指定列的数据库特定的类型名称。 |
int | getPrecision(int column) 获取指定列的小数位数。 |
int | getScale(int column) 获取指定列的小数点右边的位数。 |
String | getSchemaName(int column) 获取指定列的表模式。 |
String | getTableName(int column) 获取指定列的名称。 |
boolean | isAutoIncrement(int column) 指示是否自动为指定列进行编号,这样这些列仍然是只读的。 |
boolean | isCaseSensitive(int column) 指示列的大小写是否有关系。 |
boolean | isCurrency(int column) 指示指定的列是否是一个哈希代码值。 |
boolean | isDefinitelyWritable(int column) 指示在指定的列上进行写操作是否明确可以获得成功。 |
int | isNullable(int column) 指示指定列中的值是否可以为 null。 |
boolean | isReadOnly(int column) 指示指定的列是否明确不可写入。 |
boolean | isSearchable(int column) 指示是否可以在 where 子句中使用指定的列。 |
boolean | isSigned(int column) 指示指定列中的值是否带正负号。 |
boolean | isWritable(int column) 指示在指定的列上进行写操作是否可以获得成功。 |
字段详细信息 |
---|
columnNoNulls
static final int columnNoNulls
- 指示列不允许使用
NULL
值的常量。- 另请参见:
- 常量字段值
columnNullable
static final int columnNullable
- 指示列允许使用
NULL
值的常量。- 另请参见:
- 常量字段值
columnNullableUnknown
static final int columnNullableUnknown
- 指示不知道列的值是否可为 null 的常量。
- 另请参见:
- 常量字段值
方法详细信息 |
---|
getColumnCount
int getColumnCount() throws SQLException
- 返回此
ResultSet
对象中的列数。 - 返回:
- 列数
- 抛出:
SQLException
- 如果发生数据库访问错误
isAutoIncrement
boolean isAutoIncrement(int column) throws SQLException
- 指示是否自动为指定列进行编号,这样这些列仍然是只读的。
- 参数:
column
- 第一列是 1,第二个列是 2,……- 返回:
- 如果是这样,则返回
true
;否则返回false
- 抛出:
SQLException
- 如果发生数据库访问错误
isCaseSensitive
boolean isCaseSensitive(int column) throws SQLException
- 指示列的大小写是否有关系。
- 参数:
column
- 第一列是 1,第二个列是 2,……- 返回:
- 如果是这样,则返回
true
;否则返回false
- 抛出:
SQLException
- 如果发生数据库访问错误
isSearchable
boolean isSearchable(int column) throws SQLException
- 指示是否可以在 where 子句中使用指定的列。
- 参数:
column
- 第一列是 1,第二个列是 2,……- 返回:
- 如果是这样,则返回
true
;否则返回false
- 抛出:
SQLException
- 如果发生数据库访问错误
isCurrency
boolean isCurrency(int column) throws SQLException
- 指示指定的列是否是一个哈希代码值。
- 参数:
column
- 第一列是 1,第二个列是 2,……- 返回:
- 如果是这样,则返回
true
;否则返回false
- 抛出:
SQLException
- 如果发生数据库访问错误