I am trying to execute following SQL with Spring JdbcTemplate:
INSERT INTO japan_wht.PIVOT_20427002(doc_header_text, value_date, total_amt, is_refund)
(SELECT
doc_header_text, DATE(value_date), SUM(LOCAL_CCY_AMT), is_refund
FROM
(SELECT
*
FROM
japan_wht.DATA_20427002
WHERE IS_REFUND in ('N')
) t
GROUP BY DATE(value_date) , doc_header_text, is_refund)
However, it does not insert anything into database table and no error is thrown.
When I tried to execute following SQL with JdbcTemplate, it works and inserts data in DB table:
INSERT INTO japan_wht.PIVOT_20427002(id, doc_header_text, value_date, total_amt, is_refund) values('1', '1', '2017-12-31', 3000, 'Y');
Below is my call to execute above SQLs:
jdbcTemplate.update(sqlString);
Not sure what is going wrong here.
I had to resort to plain JDBC and it worked:
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/mySchema?autoReconnect=true&useSSL=false&rewriteBatchedStatements=true",
"root", "root");
Statement stmt = conn.createStatement();
int flag = stmt.executeUpdate(sqlString);
LOGGER.info("Flag = {}", flag);
Not sure why Spring JdbcTemplate can not handle such thing!