gpt4 book ai didi

mysql - 使用myBatis在一个事务中运行多个sql语句

转载 作者:行者123 更新时间:2023-11-30 00:57:26 26 4
gpt4 key购买 nike

当尝试运行多个查询时,例如:

 <insert id="insertTest">
insert into table1 values('foo');
insert into table2 values('foo');
</insert>

使用 myBatis 时出现 sql 错误异常

You have an error in your SQL syntax ... at line 2

我尝试了以下设置的各种组合,都返回相同的结果。

## JDBC connection properties.
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/test_db?allowMultiQueries=true
username=root
password=********

# If set to true, each statement is isolated
# in its own transaction. Otherwise the entire
# script is executed in one transaction.
auto_commit=false

# This controls how statements are delimited.
# By default statements are delimited by an
# end of line semicolon. Some databases may
# (e.g. MS SQL Server) may require a full line
# delimiter such as GO.
delimiter=;
full_line_delimiter=false

# This ignores the line delimiters and
# simply sends the entire script at once.
# Use with JDBC drivers that can accept large
# blocks of delimited text at once.
send_full_script=true

来自question的设置

最佳答案

是否缺少要插入数据的列名?

insert into table1 (column_name) values('foo'); 

关于mysql - 使用myBatis在一个事务中运行多个sql语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20430665/

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