Statement,PreparedStatement和PreparedStatement的简介

a.Statement对象

1)Statement;(简单语句) addBatch() and executeBatch()方法

Statement stmt=conn.createStatement();

stmt.addBatch(“”);

stmt.addBatch(“”);

int []results=stmt.executeBatch();

2) 使用方法Connection.createStatement()得到一个Statement对象


b. PreparedStatement(继承自Statement); (预编译语句)

1) 调用ProparedStatement比statement更为高效;
2)   继承自StatredStatement

3)PreparedStatement pstm =connection.prepareStatement(“update mytable set name=?”+”where acctnum=123”);

pstm.setDate(1,sqlDate);


c.CallableStatement对象 (可调用语句)
1) 通过CallableStatement调用数据库中的存储过程;
2) 继承自PreparedStatement;
3) CallableStatement cstm = connection.prepareCall("{callreturn_student[?,?]}");
cstm.setString(1,"8623034");
cstm.registerOutparameter(2, Types.REAL);
cstm.execute();
float gpa = cstm.getFloat(2);



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值