callablestatement使用示例

上传人:xiao****1972 文档编号:84136637 上传时间:2019-03-02 格式:DOC 页数:4 大小:29.50KB
返回 下载 相关 举报
callablestatement使用示例_第1页
第1页 / 共4页
callablestatement使用示例_第2页
第2页 / 共4页
callablestatement使用示例_第3页
第3页 / 共4页
callablestatement使用示例_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《callablestatement使用示例》由会员分享,可在线阅读,更多相关《callablestatement使用示例(4页珍藏版)》请在金锄头文库上搜索。

1、Callablestatement使用示例:/ 第一个java调过程的例子,没有参数的过程public void callProWithoutPram()try CallableStatement casm = conn.prepareCall(call Test);casm.execute(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace(); / 第二个java调过程的例子,有 IN 参数的过程public void callProWithPram()try CallableStatem

2、ent casm = conn.prepareCall(call Test(?,?,?,?,?);casm.setInt(1, 4);casm.setInt(2, 1);casm.setString(3, 绿灯侠);casm.setString(4, 3D电影);casm.setDouble(5, 40.56);casm.executeUpdate(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace(); / 第二个java调过程的例子,有 IN 参数的带包名的过程public void ca

3、llProWithPramPack()try CallableStatement casm = conn.prepareCall(call product_package.update_product_price(?);casm.setInt(1, 2);casm.executeUpdate(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace(); / 第三个java调过程的例子,有 OUT 参数的过程public void callProWithPramOut()try CallableSt

4、atement casm = conn.prepareCall(call Test(?);casm.registerOutParameter(1, java.sql.Types.INTEGER);casm.execute();int num = casm.getInt(1);System.out.println(out parm :+num);casm.close(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace(); / 第四个java调函数的例子,无参数,返回游标对象public voi

5、d callFunWithoutPram()try CallableStatement casm = conn.prepareCall(?=call product_package.get_products_ref_cursor);casm.registerOutParameter(1, oracle.jdbc.OracleTypes.CURSOR);casm.execute(); rs = (ResultSet) casm.getObject(1); while (rs.next() System.out.println(t + rs.getString(1) + t + rs.getString(2) + t + rs.getString(3) + t); casm.close(); catch (SQLException e) / TODO Auto-generated catch blocke.printStackTrace();

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号