通过JDBC API 更新数据库
Connection con = session.connection();
PrepareStatement stmt = con.prepareStatement("update employee set age=age+1 where age>0");
stmt.executeUpdate();-
调存储过程
CREATE OR REPLACE PROCEDURE updateEmployee() is
begin
update employee set age=age+1 where age>0;
end;String procedure = "{call updateEmployee()}";
Connection con = session.connection();
CallableStatement stmt = con.prepareCall(procedure);
stmt.
为什么第二种方式比第一种方式要快?
在我看来,两者都是执行update语句。是因为oracle本身的机制,存储过程比执行sql语句效率高?