简体   繁体   English

在Java中执行SQL查询的顺序。 可能吗?

[英]Execute sequence of sql queries in Java. Is it possible?

When we create an SQL string dynamically in Java, is it possible to create queries to be executed one after another? 当我们使用Java动态创建SQL字符串时,是否可以创建要一个接一个执行的查询? Eg query1;query2 ? 例如query1;query2吗?
My problem is that in a code OpenJPA is used to access database and in a place where an SQL String is being created I would like to have another SQL query run just before this one 我的问题是,在代码OpenJPA用于访问数据库的地方以及正在创建SQL String的地方,我想在此之前运行另一个SQL查询。

This doesn't work out of the box, but you should be able to set allowMultiQueries in your connection string so it does. 这不是开箱即用的方法,但是您应该能够在连接字符串中设置allowMultiQueries ,这样就可以了。 Temporary tables should live until the connection is closed though. 临时表应该一直存在,直到关闭连接为止。 Using separate statements is preferred. 首选使用单独的语句。

http://dev.mysql.com/doc/refman/5.5/en/connector-j-reference-configuration-properties.html http://dev.mysql.com/doc/refman/5.5/zh-CN/connector-j-reference-configuration-properties.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM