gpt4 book ai didi

MySQL、MyBatis、语法错误

转载 作者:行者123 更新时间:2023-11-29 01:58:12 27 4
gpt4 key购买 nike

我有一个使用 MyBatis 的应用程序,我正在尝试添加一个具有多个语句的选择 SQL。

<select id="getReleaseDetails" resultType="maingrid" statementType="STATEMENT">
DROP TEMPORARY TABLE IF EXISTS vrTmp;
DROP TEMPORARY TABLE IF EXISTS vrTmp2;

CREATE TEMPORARY TABLE vrTmp AS (
SELECT vr.*, v.Code

...等等

但是,我一直收到错误:

Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DROP TEMPORARY TABLE IF EXISTS vrTmp2;

CREATE TEMPORARY TABLE vrTmp AS (
S' at line 2
]
2014-03-11 12:48:20,069 [bio-8080-exec-3] DEBUG DataSourceUtils - Returning JDBC Connection to DataSource
2014-03-11 12:48:20,085 [bio-8080-exec-3] ERROR VRMService - Error in getDetails :
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DROP TEMPORARY TABLE IF EXISTS vrTmp2;

CREATE TEMPORARY TABLE vrTmp AS (
S' at line 2
The error may exist in mappings/mapping.xml

SQL 在 SQLYog 中运行良好,使用相同的数据库登录。

我错过了什么?它几乎就像它不喜欢“;”分隔各个语句。

谢谢

最佳答案

明白了:默认情况下,MySQL 连接不允许执行多个 SQL。它必须在 URL 中指定:

url="jdbc:mysql://ln-ct-dv-my1:3306/TestDB?allowMultiQueries=true"

...而且我不得不从映射文件中删除“StatementType”。

关于MySQL、MyBatis、语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22331477/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com