Posted on 2010-09-26 17:18
asdtiang 阅读(469)
评论(0) 编辑 收藏 所属分类:
数据库
create or replace procedure s_get_all_point
(
ref_cursor out sys_refcursor
)as
begin
open ref_cursor for
select * from gwxx_t;
end;
try {
DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "@@@@", "@@@@");
// CallableStatement stmt = conn.prepareCall("BEGIN s_get_all_point(?); END;");
CallableStatement stmt = conn.prepareCall("{ call s_get_all_point(?) }");////这名执行速度要快点
stmt.registerOutParameter(1, oracle.jdbc.OracleTypes.CURSOR); //REF CURSOR(OracleTypes.CURSOR==-10)
stmt.execute();
ResultSet rs = (ResultSet) stmt.getObject(1);
while (rs.next()) {
System.out.println(rs.getString("gwbh"));
}
rs.close();
rs = null;
stmt.close();
stmt = null;
conn.close();
conn = null;
}
catch (SQLException e) {
System.out.println(e.getLocalizedMessage());
}
天苍苍,野茫茫,风吹草底见牛羊