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

时间:2013-12-06 18:06:59

标签: mysql sql mapping mybatis

尝试运行多个查询时:

 <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

设置

1 个答案:

答案 0 :(得分:0)

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

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