当前位置: 技术问答>java相关
我想问的是,返回的 ResultSet 中的某个字段(int 型),如何放到一个 int[]数组里去。因为 ResultSet 不知道怎样取 size,我又不想用 vector, ResultSet的getArray()方法也是莫名其妙。
来源: 互联网 发布时间:2015-02-27
本文导语: | 把光标移到最后一条记录,rs.getRow()取得数组大小 把光标移到第一条记录,再写入int[]; | toArray() | Array getArray(int i) Returns the value of the designated column in t...
|
把光标移到最后一条记录,rs.getRow()取得数组大小
把光标移到第一条记录,再写入int[];
把光标移到第一条记录,再写入int[];
|
toArray()
|
Array getArray(int i)
Returns the value of the designated column in the current row of this ResultSet object as an Array object in the Java programming language.
Array getArray(String colName)
Returns the value of the designated column in the current row of this ResultSet object as an Array object in the Java programming language.
如果你的jdbc支持这个方法的话:
getFetchSize
public int getFetchSize()
throws SQLException
Returns the fetch size for this ResultSet object.
Returns:
the current fetch size for this ResultSet object
Throws:
SQLException - if a database access error occurs
Returns the value of the designated column in the current row of this ResultSet object as an Array object in the Java programming language.
Array getArray(String colName)
Returns the value of the designated column in the current row of this ResultSet object as an Array object in the Java programming language.
如果你的jdbc支持这个方法的话:
getFetchSize
public int getFetchSize()
throws SQLException
Returns the fetch size for this ResultSet object.
Returns:
the current fetch size for this ResultSet object
Throws:
SQLException - if a database access error occurs
|
用 vector的copyinto数组
|
遍历resultset,然后将字段值放到数组里面
|
size method:rs.getInt()