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