Quantcast
Channel: MySQL Forums - Connector/J, JDBC and Java
Viewing all articles
Browse latest Browse all 884

Spring JDBC template batchUpdate: multiple update statements (5 replies)

$
0
0
Hey, hope you are doing great.

I have the following question/doubt: I am using spring jdbctemplate batchUpdate method passing in a prepared statement and a batch of params. What it then does is to grab that update statement, iterate every entry on the batch and create multiple update statemens separated by ";".

e.g.
update abc set col1 = ? where id = ?
batch -> [[val1, id1], [val2, id2], [val3, id3], [val4, id4]]

the following statement is created and executed:
update abc set col1=val1 where id=id1;update abc set col1=val2 where id=id2;update abc set col1=val3 where id=id3;update abc set col1=val4 where id=id4;

I am facing the following exception:
Caused by: java.sql.SQLException: syntax error at position 6 near 'pdate'
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:130) ~[mysql-connector-j-8.1.0.jar:8.1.0]

but if I grab the statement and try to run it e.g. on dbeaver it works.

Can you tell me what am I doing wrong here?

Thanks in advance.

Viewing all articles
Browse latest Browse all 884

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>