PreparedStatement或callableStatements [英] PreparedStatements or callableStatements

查看:106
本文介绍了PreparedStatement或callableStatements的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解PreparedStatements& CallableStatements,我听不懂.因此,任何人都可以将以下sql查询转换为CallableStatement.我知道如何将Statement转换为PreparedStatement,但是CallableStatements遇到问题.

I tried to understand the difference between PreparedStatements & CallableStatements and I couldn't get it. so please can anyone convert following sql Query to CallableStatement. I know how to convert Statement into a PreparedStatement but having problems with 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

提前谢谢!

推荐答案

用于执行SQL存储过程的接口.

The interface used to execute SQL stored procedures.

因此,它不能用于执行查询.

And as such, it can not be used to execute queries.

这篇关于PreparedStatement或callableStatements的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆