I am new to swing. I have a basic question. My bean definition xml is as below. I am using a jndi connection pool.
Is jdbctemplate by default, closing my connection ? Or I have to explicitly call jdbcTemplate.getDataSource().getConnection().close() every time I use jdbTemplate?
JDBC template will take care of closing your connections automatically. If the connection is determined to be bound to the thread by Springs Transactional facilities it will be released by its internal connectionHandler mechanism but not closed. This allows the connection to be made available to other operations sharing the same transaction.
In short no you should not need to close connections.
Thanks Bill for your help. I appreciate it greatly.
Continuing to think... loudly
Therefore, to get similar effect of commit and rollback of java:comp/UserTransaction, in Spring I can use PlatformTransactionManager.commit(TransactionStatus) or rollback(Tstatus) on top of JdbcTemplate. JDBCTemplate will release the connection from PlatformTransaction and close it (or reuse it ? Can it reuse it ?).
You can use the PlatformTransactionManager, however transactions are a cross cutting concern which makes them a good candidate for AOP. Spring has a very elegant solution for this with their @Transactional annotation. I would make use of it, with a few lines of XML or a an annotation(if you are using java config) you can configure Annotation based transactional support, and then simply annotate your methods with @Transactional. This will automatically start the transaction when you enter and commit the transaction rolling back if any runtime exception is thrown out when you exit. It can be configured to roll back for checked exceptions as well.
Take a look around the forums here or in the Spring reference documentations for some examples.