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);