Most visited

Recently visited

Added in API level 1

ResultSetMetaData

public interface ResultSetMetaData
implements Wrapper

java.sql.ResultSetMetaData
Known Indirect Subclasses


一个对象,可用于获取有关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);

 

摘要(Summary)

常量(Constants)

int columnNoNulls

该常数指示列不允许 NULL值。

int columnNullable

该常数表示列允许 NULL值。

int columnNullableUnknown

表示列值的可空性未知的常量。

公共方法(Public methods)

abstract String getCatalogName(int column)

获取指定列的表格的目录名称。

abstract String getColumnClassName(int column)

如果调用方法 ResultSet.getObject以从列中检索值,则返回实例制造的Java类的完全限定名称。

abstract int getColumnCount()

返回此 ResultSet对象中的列数。

abstract int getColumnDisplaySize(int column)

以字符表示指定列的正常最大宽度。

abstract String getColumnLabel(int column)

获取指定列的建议标题以用于打印输出和显示。

abstract String getColumnName(int column)

获取指定列的名称。

abstract int getColumnType(int column)

检索指定列的SQL类型。

abstract String getColumnTypeName(int column)

检索指定列的特定于数据库的类型名称。

abstract int getPrecision(int column)

获取指定列的指定列大小。

abstract int getScale(int column)

获取小数点右侧指定列的位数。

abstract String getSchemaName(int column)

获取指定列的表格模式。

abstract String getTableName(int column)

获取指定列的表名。

abstract boolean isAutoIncrement(int column)

指示指定的列是否自动编号。

abstract boolean isCaseSensitive(int column)

指示列的大小写是否重要。

abstract boolean isCurrency(int column)

指示指定的列是否为现金价值。

abstract boolean isDefinitelyWritable(int column)

指示指定列上的写入是否一定会成功。

abstract int isNullable(int column)

指示指定列中值的可空性。

abstract boolean isReadOnly(int column)

指示指定的列是否绝对不可写。

abstract boolean isSearchable(int column)

指示是否可以在where子句中使用指定的列。

abstract boolean isSigned(int column)

指示指定列中的值是否为有符号数字。

abstract boolean isWritable(int column)

指示指定列上的写入是否可以成功。

继承方法(Inherited methods)

From interface java.sql.Wrapper

常量(Constants)

columnNoNulls

Added in API level 1
int columnNoNulls

该常数指示列不允许 NULL值。

常量值:0(0x00000000)

columnNullable

Added in API level 1
int columnNullable

表示列允许 NULL值的常量。

常数值:1(0x00000001)

columnNullableUnknown

Added in API level 1
int columnNullableUnknown

表示列值的可空性未知的常量。

常量值:2(0x00000002)

公共方法(Public methods)

getCatalogName

Added in API level 1
String getCatalogName (int column)

获取指定列的表格的目录名称。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
String the name of the catalog for the table in which the given column appears or "" if not applicable
抛出异常(Throws)
SQLException if a database access error occurs

getColumnClassName

Added in API level 1
String getColumnClassName (int column)

如果调用方法ResultSet.getObject以从列中检索值,则返回实例制造的Java类的完全限定名称。 ResultSet.getObject可能会返回此方法返回的类的子类。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
String the fully-qualified name of the class in the Java programming language that would be used by the method ResultSet.getObject to retrieve the value in the specified column. This is the class name used for custom mapping.
抛出异常(Throws)
SQLException if a database access error occurs

getColumnCount

Added in API level 1
int getColumnCount ()

返回此 ResultSet对象中的列数。

返回(Returns)
int the number of columns
抛出异常(Throws)
SQLException if a database access error occurs

getColumnDisplaySize

Added in API level 1
int getColumnDisplaySize (int column)

以字符表示指定列的正常最大宽度。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
int the normal maximum number of characters allowed as the width of the designated column
抛出异常(Throws)
SQLException if a database access error occurs

getColumnLabel

Added in API level 1
String getColumnLabel (int column)

获取指定列的建议标题以用于打印输出和显示。 建议的标题通常由SQL AS子句指定。 如果未指定SQL AS ,则从getColumnLabel返回的值将与由getColumnName方法返回的值相同。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
String the suggested column title
抛出异常(Throws)
SQLException if a database access error occurs

getColumnName

Added in API level 1
String getColumnName (int column)

获取指定列的名称。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
String column name
抛出异常(Throws)
SQLException if a database access error occurs

getColumnType

Added in API level 1
int getColumnType (int column)

检索指定列的SQL类型。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
int SQL type from java.sql.Types
抛出异常(Throws)
SQLException if a database access error occurs

也可以看看:

getColumnTypeName

Added in API level 1
String getColumnTypeName (int column)

检索指定列的特定于数据库的类型名称。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
String type name used by the database. If the column type is a user-defined type, then a fully-qualified type name is returned.
抛出异常(Throws)
SQLException if a database access error occurs

getPrecision

Added in API level 1
int getPrecision (int column)

获取指定列的指定列大小。 对于数字数据,这是最高精度。 对于字符数据,这是以字符为单位的长度。 对于datetime数据类型,这是字符串表示的字符长度(假设小数秒组件的最大允许精度)。 对于二进制数据,这是以字节为单位的长度。 对于ROWID数据类型,这是以字节为单位的长度。 对于列大小不适用的数据类型,返回0。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
int precision
抛出异常(Throws)
SQLException if a database access error occurs

getScale

Added in API level 1
int getScale (int column)

获取小数点右侧指定列的位数。 针对比例不适用的数据类型返回0。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
int scale
抛出异常(Throws)
SQLException if a database access error occurs

getSchemaName

Added in API level 1
String getSchemaName (int column)

获取指定列的表格模式。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
String schema name or "" if not applicable
抛出异常(Throws)
SQLException if a database access error occurs

getTableName

Added in API level 1
String getTableName (int column)

获取指定列的表名。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
String table name or "" if not applicable
抛出异常(Throws)
SQLException if a database access error occurs

isAutoIncrement

Added in API level 1
boolean isAutoIncrement (int column)

指示指定的列是否自动编号。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
boolean true if so; false otherwise
抛出异常(Throws)
SQLException if a database access error occurs

isCaseSensitive

Added in API level 1
boolean isCaseSensitive (int column)

指示列的大小写是否重要。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
boolean true if so; false otherwise
抛出异常(Throws)
SQLException if a database access error occurs

isCurrency

Added in API level 1
boolean isCurrency (int column)

指示指定的列是否为现金价值。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
boolean true if so; false otherwise
抛出异常(Throws)
SQLException if a database access error occurs

isDefinitelyWritable

Added in API level 1
boolean isDefinitelyWritable (int column)

指示指定列上的写入是否一定会成功。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
boolean true if so; false otherwise
抛出异常(Throws)
SQLException if a database access error occurs

isNullable

Added in API level 1
int isNullable (int column)

指示指定列中值的可空性。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
int the nullability status of the given column; one of columnNoNulls, columnNullable or columnNullableUnknown
抛出异常(Throws)
SQLException if a database access error occurs

isReadOnly

Added in API level 1
boolean isReadOnly (int column)

指示指定的列是否绝对不可写。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
boolean true if so; false otherwise
抛出异常(Throws)
SQLException if a database access error occurs

isSearchable

Added in API level 1
boolean isSearchable (int column)

指示是否可以在where子句中使用指定的列。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
boolean true if so; false otherwise
抛出异常(Throws)
SQLException if a database access error occurs

isSigned

Added in API level 1
boolean isSigned (int column)

指示指定列中的值是否为有符号数字。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
boolean true if so; false otherwise
抛出异常(Throws)
SQLException if a database access error occurs

isWritable

Added in API level 1
boolean isWritable (int column)

指示指定列上的写入是否可以成功。

参数(Parameters)
column int: the first column is 1, the second is 2, ...
返回(Returns)
boolean true if so; false otherwise
抛出异常(Throws)
SQLException if a database access error occurs

Hooray!