JSP调用存储过程

实现的一个搜索的功能:
把代码记录一下
存储过程的其中之一:
CREATE PROCEDURE SelJishu
@SelStr nvarchar(4000)

AS
select edaic from tb_jishuwenzhang where edaic like '%'+@SelStr+'%'
union
select gongyi from tb_jishuwenzhang where gongyi like '%'+@SelStr+'%'
union
select ceshi from tb_jishuwenzhang where ceshi like '%'+@SelStr+'%'
union
select chuangan from tb_jishuwenzhang where chuangan like '%'+@SelStr+'%'
union
select fangda from tb_jishuwenzhang where fangda like '%'+@SelStr+'%'
union
select rf from tb_jishuwenzhang where rf like '%'+@SelStr+'%'
union
select shuzi from tb_jishuwenzhang where shuzi like '%'+@SelStr+'%'
union
select kongzhi from tb_jishuwenzhang where kongzhi like '%'+@SelStr+'%'
union
select wangluo from tb_jishuwenzhang where wangluo like '%'+@SelStr+'%'
union
select jiekou from tb_jishuwenzhang where jiekou like '%'+@SelStr+'%'
union
select huanchong from tb_jishuwenzhang where huanchong like '%'+@SelStr+'%'
union
select gonglv from tb_jishuwenzhang where gonglv like '%'+@SelStr+'%'
union
select emiemc from tb_jishuwenzhang where emiemc like '%'+@SelStr+'%'
union
select guangdian from tb_jishuwenzhang where guangdian like '%'+@SelStr+'%'
union
select qianru from tb_jishuwenzhang where qianru like '%'+@SelStr+'%'
union
select kebian from tb_jishuwenzhang where kebian like '%'+@SelStr+'%'
union
select anquan from tb_jishuwenzhang where anquan like '%'+@SelStr+'%'
GO

JSP页面里的调用:
Condata con=new Condata();
Connection conn=con.getConnection();
CallableStatement cmt=conn.prepareCall("{call SelJishu(?)}");
cmt.setString(1,s);
ResultSet rs= cmt.executeQuery();
while(rs.next())
{
  out.print("&nbsp;"+"1."+rs.getString("EDAIC")+"<br>");
}
rs.close();
cmt.close();
conn.close();



我用连接池连的数据库,代码挺多就不放了。

还有一件事,写程序一定要注意多保存文件。

一定要注意!

你可能感兴趣的:(jsp,Go)