我想知道我将使用的结果集是否可滚动'
我发现我可以在语句上使用 getResultSetType
方法来查找。
我按以下方式使用:
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from studentinfo");
int rs_type=stmt.getResultSetType();
System.out.println(rs_type);
上面的实现方式是否正确,如果正确则返回rs_type as 1003这是什么意思?
最佳答案
来自 JavaSE API 文档:
int getResultSetType()
throws SQLException
Retrieves the result set type for ResultSet objects generated by this Statement object.
Returns: one of
ResultSet.TYPE_FORWARD_ONLY
,ResultSet.TYPE_SCROLL_INSENSITIVE
, orResultSet.TYPE_SCROLL_SENSITIVE
Throws:
SQLException
- if a database access error occurs or this method is called on a closed Statement
所以你应该将返回值与这些常量进行比较
关于java - 如何使用 getRestultSetType() 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43048615/