Instances of the JdbcTemplate class are threadsafe once configured. This is important because it means that you can configure a single instance of a JdbcTemplate and then safely inject this shared reference into multiple DAOs (or repositories). The JdbcTemplate is stateful, in that it maintains a reference to a DataSource, but this state is not conversational state.
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
a. List<String> splittedRecords = splitRecords(fullRecords); - should be outside the loop. you don't need to run it 10 times.
b. JDBC template is thread safe once instantiated.
Note that the threads will not be able to share a transaction. Each thread will have tok open it's own connection to db and each connection will have its own transaction
b. JDBC template is thread safe once instantiated.
You are right. That is one reason i kept the JdbcTemplate creation outside of all threads. But seems like the point given by Jayesh contradicts with this.
Note that the threads will not be able to share a transaction. Each thread will have tok open it's own connection to db and each connection will have its own transaction
@Jayesh By opening so much connection, is it possible that it can consume most of the connections in the DB2 connection pool?
@Saifuddin What's your thought? if we use a single JdbcTemplate, i think it will take the same amount of time as that of executing single batch at a time.
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Renjith Panikar wrote:One more question.
What about using Spring's 'ThreadPoolTaskExecutor', there we can handle the Queue size?
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog