jsp中怎样调用mysql的存储过程

igod 2006-07-17 01:40:11
rt,最好给出例子,谢谢
...全文
191 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lvsc 2007-04-28
  • 打赏
  • 举报
回复
baidu
kingdoom 2006-07-17
  • 打赏
  • 举报
回复
<%@ page language="java" contentType="text/html;charset=gb2312"%>
<%@page import="java.sql.*"%>
<html>
<body>
<table>
<%
String driver = "MYSQLDRIVER";
String strUrl = "mysqlurl";

Class.forName(driver);
Connection conn = DriverManager.getConnection(strUrl, "用户名", "密码");

String procedure = "{call 存储过程 (?) }";
CallableStatement cstmt = conn.prepareCall(procedure);
cstmt.set参数类型(1,参数);
cstmt.executeUpdate();

Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from t");

while(rs.next())
{
//
}

rs.close();
stmt.close();
conn.close();
%>
</table>
<p>
<%
out.print(conn.isClosed());
%>

</body>
</html>
</body>
</html>
nimeide1234567890 2006-07-17
  • 打赏
  • 举报
回复
ding
ranranhu 2006-07-17
  • 打赏
  • 举报
回复
关注

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧