CURSOR and REF CURSOR as a JDBC data type

萝らか妹 提交于 2019-12-04 12:53:33

Support for REF CURSORS was added in Java 8/JDBC 4.2. Use the type Types.REF_CURSOR for cursor return types. They can be iterated through the ResultSet interface. Example:

CallableStatement cstmt = conn.prepareCall("{callmySproc(?)}");
cstmt.registerOutParameter(1, Types.REF_CURSOR);
cstmt.executeQuery();
ResultSet cursor = cstmt.getObject(1, ResultSet.class);
while(cursor.next()) {
    System.out.println("Name = " + cursor.getString(1));
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!