当尝试运行多个查询时,例如:
<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');