Spring JdbcTemplate stuck on INSERT INTO...SELECT query
Asked Answered
A

0

6

Hi I am using Spring Boot 1.3.5.RELEASE. I have a situation where I need to fire

INSERT INTO someTable1 (col1, col2, col3) 
SELECT (10346, someTable2Id, 1048) FROM someTable2. 

I am using Spring JdbcTemplate.

String sql = "INSERT INTO someTable1( col1, col2, col3 ) 
                   SELECT 10346, someTable2Id, 1048 
                     FROM someTable2";
             jdbcTemplate.update(sql);

While executing this statement, it got stuck on jdbcTemplate.update(sql) line. It seems JdbcTemplate is not responding well to INSERT INTO...SELECT Statement. Same query is working fine from Database Editors.

Amyl answered 9/11, 2016 at 6:36 Comment(6)
Is it possible that someTable2 can have too much records ? Can you try the same for only 1 record from someTable2 by adding a WHERE statement. Can you provide the type of jdbcTemplate are you using NamedParameterJdbcTemplate ? And lastly are other calls from the BE to the DB working ?Ligetti
@lazarov, I tried the same query with sql developer. It is working there. I tried both JdbcTemplate and NamedParameterJdbcTemplate. It is giving me no error. But when I call jdbcTemplate.update(sql), execution hangs there. Then I tried with normal JDBC program, still no error but execution hangs there. someTable2 has nearly 700 records.Amyl
Did you get answer to this? If yes, can you please post here and help others? thanks :)Turbosupercharger
@AkshayLokur, I did not get any solution for this. I completely excluded INSERT INTO...SELECT from my application.Amyl
Use jdbctemplate.execute()Allover
jdbctemplate.execute() is also stuck anyone got fix for this?Transpacific

© 2022 - 2024 — McMap. All rights reserved.