java操作数据库,请列出preparedstatement和callablestatement的区别,以及后者的常用方法示例;
这是使用callablestatement接口来实现,这些个函数自身都是啥意思,求大神给指点下,在线等```Stringsql="{callms_access_pkg.g...
这是使用callablestatement接口来实现,这些个函数自身都是啥意思,求大神给指点下,在线等```
String sql="{call ms_access_pkg.get_access(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}";
CallableStatement cstmt=conn.prepareCall(sql);
cstmt.setLong("p_retailer_id",Long.parseLong(request.getParameter("x_retailer_id"))); //终端id
cstmt.registerOutParameter("x_access_id", OracleTypes.NUMBER);//拜访Id
cstmt.registerOutParameter("x_record_id", OracleTypes.NUMBER);//----------------------2010-12-17---------
cstmt.registerOutParameter("x_retailer_name", OracleTypes.VARCHAR);//终端名称
cstmt.registerOutParameter("x_access_freq", OracleTypes.NUMBER);//拜访频次
cstmt.registerOutParameter("x_market_share", OracleTypes.NUMBER);//市场占用率
cstmt.registerOutParameter("x_agreement_flag", OracleTypes.VARCHAR);//协议是否有效
cstmt.registerOutParameter("x_date_from", OracleTypes.VARCHAR);//拜访时间
cstmt.registerOutParameter("x_date_to", OracleTypes.VARCHAR);//结束时间
cstmt.registerOutParameter("x_access_person", OracleTypes.VARCHAR);//拜访对象
cstmt.registerOutParameter("x_description", OracleTypes.VARCHAR);//过程记录
cstmt.registerOutParameter("x_valid_flag", OracleTypes.VARCHAR);//("Y"--有效拜访 "N"--无效拜访)
cstmt.registerOutParameter("x_return_status", OracleTypes.VARCHAR);//状态异常
cstmt.registerOutParameter("x_msg_data", OracleTypes.VARCHAR);
cstmt.registerOutParameter("x_agreement_num", OracleTypes.NUMBER);//正在执行的协议数
cstmt.execute();
String x_access_freq=cstmt.getString("x_access_freq");
String x_description=cstmt.getString("x_description");
String x_agreement_flag=cstmt.getString("x_agreement_flag");
String x_valid_flag=cstmt.getString("x_valid_flag");
String x_market_share=cstmt.getString("x_market_share"); 展开
String sql="{call ms_access_pkg.get_access(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}";
CallableStatement cstmt=conn.prepareCall(sql);
cstmt.setLong("p_retailer_id",Long.parseLong(request.getParameter("x_retailer_id"))); //终端id
cstmt.registerOutParameter("x_access_id", OracleTypes.NUMBER);//拜访Id
cstmt.registerOutParameter("x_record_id", OracleTypes.NUMBER);//----------------------2010-12-17---------
cstmt.registerOutParameter("x_retailer_name", OracleTypes.VARCHAR);//终端名称
cstmt.registerOutParameter("x_access_freq", OracleTypes.NUMBER);//拜访频次
cstmt.registerOutParameter("x_market_share", OracleTypes.NUMBER);//市场占用率
cstmt.registerOutParameter("x_agreement_flag", OracleTypes.VARCHAR);//协议是否有效
cstmt.registerOutParameter("x_date_from", OracleTypes.VARCHAR);//拜访时间
cstmt.registerOutParameter("x_date_to", OracleTypes.VARCHAR);//结束时间
cstmt.registerOutParameter("x_access_person", OracleTypes.VARCHAR);//拜访对象
cstmt.registerOutParameter("x_description", OracleTypes.VARCHAR);//过程记录
cstmt.registerOutParameter("x_valid_flag", OracleTypes.VARCHAR);//("Y"--有效拜访 "N"--无效拜访)
cstmt.registerOutParameter("x_return_status", OracleTypes.VARCHAR);//状态异常
cstmt.registerOutParameter("x_msg_data", OracleTypes.VARCHAR);
cstmt.registerOutParameter("x_agreement_num", OracleTypes.NUMBER);//正在执行的协议数
cstmt.execute();
String x_access_freq=cstmt.getString("x_access_freq");
String x_description=cstmt.getString("x_description");
String x_agreement_flag=cstmt.getString("x_agreement_flag");
String x_valid_flag=cstmt.getString("x_valid_flag");
String x_market_share=cstmt.getString("x_market_share"); 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询