JDBCTEMPLATE IS THREADSAFE?

xiaoxiao2021-03-20  200

JDBCTEMPLATE IS THREADSAFE?

The cause of the problem is at this afternoon

Rod Johnson

"Professional Java Development with the Spring Framework"

When DAO Support and JDBC Framework, a sentence encountered "JDBCTemplate is a stateless and threadsafe class and you can Safely Instantiate a single instance to be used for each dao."

This problem is confused for a long time, spending more than half a night, there is no understanding of what is going on, from this class itself, it is a JavaBean because it contains multiple Accessor. Understand from the traditional multi-threaded perspective, the method that may modify the instance variable If there is no synchronization, then the method can be considered that the thread is unsafe; if there is a Class of it, if a class is stateless class, then The property should not contain attributes. All the external phenomena makes me very confused. It seems that it is still lacking on the foundation. All day is busy users' needs, project management, etc., Ignore many essential things.

Later, I saw an article about Spring transactions, I got some ideas, but I still didn't fully understand. Articles

Quote address.

I will think about this problem in the future, it is too late.

转载请注明原文地址:https://www.9cbs.com/read-130308.html

New Post(0)