六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 165|回复: 0

jsp常用数据访问方法:

[复制链接]

升级  15.33%

17

主题

17

主题

17

主题

秀才

Rank: 2

积分
73
 楼主| 发表于 2013-2-6 10:54:39 | 显示全部楼层 |阅读模式
jsp常用数据访问方法:
1\statement
statement statement=con.crateStatement();
resultset rs=statement.excuteQuery(sql)

//
while(rs.next()){
//业务处理
}
 
2\prepareStatement
prepareStatement mystatement=con.PrepareStatement(sql);
Resultset rs=mystatement.executeQuery();
带有参数的情况
String  s="update authors set lastname=? where authid=?"
prepareStatement a=con.preparestatement();

3\调用存储过程:
无参数
CallableStatement call=com.prepareCall("(call procedureName)");
resultset rs=call.excuteQuery();
代有参数
CallableStatement call=com.prepareCall("(call procedureName(?,?))");
call.setint(1,3);
call.setint(2,1999)
resultset rs=call.excuteQuery();


 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表