yjmyzz / sharding-jdbc-sample

25 stars 14 forks source link

使用druid数据源,sharding分库分表,批量插入出现如下错误,单笔是可以插入的,请帮忙分析下 #2

Open lsz-clark opened 6 years ago

lsz-clark commented 6 years ago

xception in thread "main" org.springframework.jdbc.UncategorizedSQLException:

Error updating database. Cause: java.sql.SQLException: sql injection violation, syntax error: syntax error, expect ')', pos 86, line 1, column 65, token EOF : INSERT INTO t_order_00(order_id,user_id,status,tmCreate)values

The error may involve com.frxs.web.demo.mapper.OrderMapper.insertBatch-Inline

The error occurred while setting parameters

SQL: INSERT INTO t_order(order_id,user_id,status,tmCreate)values (?,?,?,?) , (?,?,?,?) , (?,?,?,?) , (?,?,?,?) , (?,?,?,?) , (?,?,?,?) , (?,?,?,?)

Cause: java.sql.SQLException: sql injection violation, syntax error: syntax error, expect ')', pos 86, line 1, column 65, token EOF : INSERT INTO t_order_00(order_id,user_id,status,tmCreate)values

; uncategorized SQLException; SQL state [null]; error code [0]; sql injection violation, syntax error: syntax error, expect ')', pos 86, line 1, column 65, token EOF : INSERT INTO t_order_00(order_id,user_id,status,tmCreate)values

       ; nested exception is java.sql.SQLException: sql injection violation, syntax error: syntax error, expect ')', pos 86, line 1, column 65, token EOF : INSERT INTO t_order_00(order_id,user_id,`status`,tmCreate)values

xml:

INSERT INTO `t_order`(order_id,user_id,`status`,tmCreate)values (#{item.orderId,jdbcType=VARCHAR},#{item.userId,jdbcType=INTEGER},#{item.status,jdbcType=VARCHAR},#{item.tmCreate,jdbcType=TIMESTAMP})
hunterchen001 commented 6 years ago

注意版本:

compile group: 'com.dangdang', name: 'sharding-jdbc-core', version: '1.3.1'
compile group: 'com.dangdang', name: 'sharding-jdbc-transaction-storage', version: '1.3.1'
compile group: 'com.dangdang', name: 'sharding-jdbc-config-spring', version: '1.3.1'

我用demo里的1.3.1是可以, 用更高的版本就会出现批量插入出错.

lsz-clark commented 6 years ago

确实,但现在sharding-sphere是支持批量插入了

hunterchen001 commented 6 years ago

是的,我昨天试了. 用Sharding-sphere 纯JDBC和JPA的批量插入都没有问题.


发件人:clark·lee notifications@github.com 发送时间:2018年8月15日(星期三) 10:14 收件人:yjmyzz/sharding-jdbc-sample sharding-jdbc-sample@noreply.github.com 抄 送:Hunter Chen hunter.chen@valorosoltd.com; Comment comment@noreply.github.com 主 题:Re: [yjmyzz/sharding-jdbc-sample] 使用druid数据源,sharding分库分表,批量插入出现如下错误,单笔是可以插入的,请帮忙分析下 (#2)

确实,但现在sharding-sphere是支持批量插入了 — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.