CallableStatement(返回值为cursor)
try {
Class.forName("oracle.jdbc.OracleDriver")
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "sa")
CallableStatement cs = con.prepareCall("{call getUser(?, ?, ?)}")
cs.setInt(1, 11)
cs.setInt(2, 20)
cs.registerOutParameter(3, OracleTypes.CURSOR)
cs.execute()
ResultSet rs = (ResultSet) cs.getObject(3)
while (rs.next()) {
System.out.println(rs.getString(2) + "\t" + rs.getString(3))
}
} catch (Exception e) {
e.printStackTrace()
}
}