JSP使用Sql Server存储过程
来源:互联网 发布:街景制作软件 编辑:程序博客网 时间:2024/04/28 09:53
可实现存储过程中的各种功能,和最简方法相比,它可以得到out参数和过程返回值。
?就是参数的占位符,一个问号代表有一个参数。
String proc = "{call procname (?,?)}";
CallableStatement stat = con.prepareCall(proc);
//第一个参数为in的话
stat.setString(1,'paravalue');//设置参数值
//第二个参数作out的话
stat.registerOutParameter(1,java.sql.Types.VARCHAR);//设置参数类型
stat.execute();
String paraValue = stat.getString(2);//得到out参数值
例如:
<%@page import="java.sql.*"%>
<%@page import="java.text.*"%>
<%@page contentType="text/html;charset=GB2312"%>
<%@include file="opendata.jsp"%>
<%
String strSQL = "{call pdrivertotal(?,?)}";
CallableStatement stmt = con.prepareCall(strSQL);
stmt.setString(1,"2005-08-20");
stmt.setString(2,"2005-10-01");
stmt.execute();
%>
2、存储过程的最简写法:
思路:将过程当作普通的sql语句去执行,也就是和查询、更新的写法是一样。可实现执行过程并且得到相关的数据集,但它不能得到过程的out输出参数,开发中90%的情况下皆适用。
String proc = "exec 过程名 "+参数1+","+参数2;
Statement stat = con.createStatement();
ResultSet rs = stat.executeQuery(proc);
例如:
//在JSP中使用
<%
Statement stat = con.createStatement();
ResultSet rs = stat.executeQuery("zyfproc 20 '姓名'");
//zyfproc为存储过程名 20为int型参数,姓名为varchar类参数
%>
//在使
用了jstl标签的jsp中使用
- JSP使用Sql Server存储过程
- JSP使用Sql Server存储过程
- JSP使用Sql Server存储过程
- JSP使用Sql Server存储过程
- JSP使用Sql Server存储过程
- JSP使用Sql Server存储过程
- JSP使用Sql Server存储过程
- JSP使用Sql Server存储过程
- JSP使用Sql Server存储过程
- JSP使用Sql Server存储过程
- JSP使用Sql Server存储过程
- JSP使用Sql Server存储过程
- JSP使用Sql Server存储过程
- JSP调用SQL server 2000存储过程
- Sql Server使用存储过程
- sql server使用存储过程
- SQL SERVER存储过程中使用事务
- SQL SERVER存储过程中使用事务
- ASP.NET上传文件面面观
- 与SQL Server补丁相关的问题
- 在C#中使用存储过程
- 客户端基于层的验证不用alert方式
- eclipse打开出错(eclipse与oracle9i冲突)
- JSP使用Sql Server存储过程
- Jpage通用分页
- Jpage分页——hibernate的通用分页程序
- SQL各种写法的效率问题
- 微软技术在金融行业的应用
- 工作流参考规范概述
- IntelliFlow.Net性能评测
- 用户体验式UI设计
- .Net平台开发的技术规范与实践精华总结