java - CURSOR and REF CURSOR as a JDBC data type -
many rdbms support "cursor" types of sort. types useful when returned stored procedures. example in oracle:
type t_cursor_type ref cursor; create procedure p (c out t_cursor_type);
when calling procedure using jdbc, oracletypes.cursor = -10
"jdbc" type should used. type not part of standard , not going part of jdbc 4.1 in java 7.
does know whether jsr guys consider adding type standard time in future? or if other rdbms have similar "vendor-specific type"?
support ref cursors added in java 8/jdbc 4.2. use type types.ref_cursor
cursor return types. can iterated through 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)); }
Comments
Post a Comment