I want to close statements automatically.
I want to achieve it using the technology of the following packages:
- Java 1.5
- Spring framework 2.5
It seems not to close statements automatically in the default settings, though I think that the transaction manager of Spring automatically shuts statements.
I do not want to call close()
of statement as much as possible in the method for maintainability.
Is there a method to ensure that the statement's closed? The amount of coding increases if coming for all the methods to have to call close() of statement, and there is a problem that the possibility that the omission is generated goes out.
Moreover, I am making the framework. It wants to make the restriction as much as possible by such a reason and to make a little method.
Moreover, is there an official site or document that shows the reason when there is no closing method? I'm Japanese, so please explain using simple statem开发者_高级运维ents.
I believe Spring will handle all this for you if you use the SimpleJdbcTemplate. I'd recommend it highly.
The Spring transaction manager is not closing the statement. That's a separate concern. After all, you'd still want the statement closed even if you didn't have an open transaction.
I would not write your own framework. I would bet that you'd be hard-pressed to improve on what Spring 2.5 is already giving you. Perhaps it's more a matter of training and understanding Spring's capabilities better.
精彩评论