具有多个 SQL 语句的 MySQL ConnectorJ

发布于 2025-01-04 08:18:55 字数 577 浏览 4 评论 0原文

另一位开发人员告诉我,有一个可以打开/关闭的 MySQL ConnectorJ 选项。该开发人员表示,将此 jdbc 选项设置为“on”后,我可以按以下形式运行 java jdbc 查询:

Connection jdbc = session.connection();
PreparedStatement pstmt = jdbc.prepareStatement("Update myTable set myField = 1 where myId = 1; Update myTable set anotherField = 2 where myId = 2");
pstmt.execute();

运行此准备好的语句背后的想法是,它在一次执行中运行两个 sql 查询。我查看了 mysql 文档< /a>,但我还没找到这个选项。开发人员不记得此设置的名称,但确信它存在。有谁知道哪个 mysql 选项控制这种行为?

Another developer tells me that there is a MySQL ConnectorJ option which can be turned on/off. This developer says that after turning this jdbc option to 'on', I can run a java jdbc query in the form:

Connection jdbc = session.connection();
PreparedStatement pstmt = jdbc.prepareStatement("Update myTable set myField = 1 where myId = 1; Update myTable set anotherField = 2 where myId = 2");
pstmt.execute();

The idea behind running this prepared statement is that it runs two sql queries in a single execution. I've looked at the mysql documentation, but I haven't been able to find this option. The developer does not recall the name of this setting, but is certain that it exists. Does anyone know which mysql option controls this behavior?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

原谅过去的我 2025-01-11 08:18:55

也许允许多重查询?

https://dev.mysql.com/connector-j-reference-configuration-properties.html mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html

允许使用“;”在一个语句中分隔多个查询
(true/false),默认为“false”,并且不影响 addBatch()
和executeBatch()方法,它依赖于
重写Batch语句。

Perhaps allowMultiQueries?

https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html

Allow the use of ';' to delimit multiple queries during one statement
(true/false), defaults to 'false', and does not affect the addBatch()
and executeBatch() methods, which instead rely on
rewriteBatchStatements.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文