在Java中执行sql查询序列。可能吗?

时间:2021-09-06 15:47:08

When we create an SQL string dynamically in Java, is it possible to create queries to be executed one after another? E.g 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

当我们在Java中动态创建SQL字符串时,是否可以创建一个接一个地执行的查询? E.g query1; query2?我的问题是,在一个代码中,OpenJPA用于访问数据库,并且在创建SQL String的地方,我希望在此之前运行另一个SQL查询

1 个解决方案

#1


0  

This doesn't work out of the box, but you should be able to set allowMultiQueries in your connection string so it does. Temporary tables should live until the connection is closed though. Using separate statements is preferred.

这不是开箱即用的,但您应该能够在连接字符串中设置allowMultiQueries,以便它可以。临时表应该存在,直到连接关闭为止。使用单独的语句是首选。

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

#1


0  

This doesn't work out of the box, but you should be able to set allowMultiQueries in your connection string so it does. Temporary tables should live until the connection is closed though. Using separate statements is preferred.

这不是开箱即用的,但您应该能够在连接字符串中设置allowMultiQueries,以便它可以。临时表应该存在,直到连接关闭为止。使用单独的语句是首选。

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