ResultSetMetaData 對象可以用于查找 ResultSet 中的列的類型和特性。
接口 java.sql.ResultSetMetaData
- public interface ResultSetMetaData
變量索引
- columnNoNulls
- 不允許 NULL 值。
- columnNullable
- 允許 NULL 值。
- columnNullableUnknown
- 不知是否允許 NULL。
方法索引
- getCatalogName(int)
- 獲得列的表的目錄名。
- getColumnCount()
- 獲得 ResultSet 中的列數(shù)。
- getColumnDisplaySize(int)
- 獲得列的正常的最大字符寬度。
- getColumnLabel(int)
- 獲得打印輸出和顯示的建議列標題。
- getColumnName(int)
- 獲得列名。
- getColumnType(int)
- 獲得一個列的 SQL 類型。
- getColumnTypeName(int)
- 獲得一個列的數(shù)據(jù)源特定的類型名。
- getPrecision(int)
- 獲得一個列的十進制數(shù)字的位數(shù)。
- getScale(int)
- 獲得一個列的十進制小數(shù)點右面數(shù)字的位數(shù)。
- getSchemaName(int)
- 獲得一個列的表的模式。
- getTableName(int)
- 獲得列的表名。
- isAutoIncrement(int)
- 列是否自動計數(shù),因此它是只讀的。
- isCaseSensitive(int)
- 列是否區(qū)分大小寫。
- isCurrency(int)
- 列是否是通用的。
- isDefinitelyWritable(int)
- 對列的寫操作是否一定成功。
- isNullable(int)
- 在該列中是否可以放一個 NULL 值。
- isReadOnly(int)
- 列是否是不可寫的。
- isSearchable(int)
- 該列是否是可以查詢的。
- isSigned(int)
- 該列是否是有符號數(shù)。
- 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 中的列數(shù)。
- 返回值:
- 該數(shù)值
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
isAutoIncrement
public abstract boolean isAutoIncrement(int column) throws SQLException
- 列是否自動計數(shù),因此它是只讀的。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- 果真如此則為 true
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
isCaseSensitive
public abstract boolean isCaseSensitive(int column) throws SQLException
- 列是否區(qū)分大小寫。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- 確實如此則為 true
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
isSearchable
public abstract boolean isSearchable(int column) throws SQLException
- 該列能否用于一 where 子句?
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- 確實如此則為 true
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
isCurrency
public abstract boolean isCurrency(int column) throws SQLException
- 列是否是通用的。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- 確實如此則為 true
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
isNullable
public abstract int isNullable(int column) throws SQLException
- 在該列中是否可以放一個 NULL 值。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- columnNoNulls、columnNullable 或 columnNullableUnknown
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
isSigned
public abstract boolean isSigned(int column) throws SQLException
- 該列是否的有符號數(shù)。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- 確實如此則為 true
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
getColumnDisplaySize
public abstract int getColumnDisplaySize(int column) throws SQLException
- 獲得列的正常的最大字符寬度。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- 最大寬度
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
getColumnLabel
public abstract String getColumnLabel(int column) throws SQLException
- 獲得用于打印輸出和顯示的建議列標題。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- 確實如此則為 true
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
getColumnName
public abstract String
getColumnName(int column) throws SQLException
- 獲得列名。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- 列名
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
getSchemaName
public abstract String getSchemaName(int column) throws SQLException
- 獲得一個列的表的模式。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- 模式名,如果不可用則為 ""
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
getPrecision
public abstract int getPrecision(int column) throws
SQLException
- 獲得一個列的十進制數(shù)字的位數(shù)。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- 精度
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
getScale
public abstract int getScale(int column) throws
SQLException
- 獲得一個列的十進制小數(shù)點右面數(shù)字的位數(shù)。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- 小數(shù)位數(shù)
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
getTableName
public abstract String
getTableName(int column) throws SQLException
- 獲得列的表名。
- 返回值:
- 表名,如果不可用則為 ""
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
getCatalogName
public abstract String
getCatalogName(int column) throws SQLException
- 獲得列的表的目錄名。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- 列名,如果不可用則為 ""
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
getColumnType
public abstract int getColumnType(int column) throws
SQLException
- 獲得一個列的 SQL 類型。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- SQL 類型
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
- 參見:
- Types
getColumnTypeName
public abstract String
getColumnTypeName(int column) throws SQLException
- 獲得一個列的數(shù)據(jù)源特定的類型名。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- 類型名
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
isReadOnly
public abstract boolean isReadOnly(int column) throws
SQLException
- 列是否是不可寫的。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- 確實如此則為 true
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
isWritable
public abstract boolean isWritable(int column) throws
SQLException
- 對該列的寫操作是否會成功。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- 果真如此則為 true
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。
isDefinitelyWritable
public abstract boolean isDefinitelyWritable(int column) throws
SQLException
- 對列的寫操作是否一定成功。
- 參數(shù):
- column - 第一列是 1, 第二個列是 2, ...
- 返回值:
- 確實如此則為 true
- 拋出:
SQLException
- 如果發(fā)生了數(shù)據(jù)訪問錯誤。