【发布时间】:2013-03-14 04:51:24
【问题描述】:
我试图了解PreparedStatements 和CallableStatements 之间的区别,但我无法理解。所以请任何人都可以将sql Query 转换为CallableStatement。我知道如何将 Statement 转换为 PreparedStatement,但遇到 CallableStatements 的问题。
作为java.sql.Statement
SELECT * FROM Customer WHERE customerId = 'C001'
作为java.sql.PreparedStatement
SELECT * FROM Customer WHERE customerId = ? //set customerId using preparedStatement.setString(1,"C001")
如何在CallableStatements中编写同样的查询
提前致谢!
【问题讨论】:
-
用于 StoredProcedure 活动的 CAllablestatement。