spring - Singleton vs prototype JdbcTemplate -


in spring documentation recommended way use jdbctemplate create new template every class use in...

public class jdbccorporateeventdao implements corporateeventdao {      private jdbctemplate jdbctemplate;      public void setdatasource(datasource datasource) {         this.jdbctemplate = new jdbctemplate(datasource);     }  } 

i wondering, advantage of solution on define jdbctemplate singleton in context , directly inject in dao

 public class jdbccorporateeventdao implements corporateeventdao {         @autowired         private jdbctemplate jdbctemplate;          public void setjdbctemplate(jdbctemplate jdbctemplate) {             this.jdbctemplate = jdbctemplate;         }      } 

from class-level documentation of jdbctemplate:

 * can used within service implementation via direct instantiation  * datasource reference, or prepared in application context  * , given services bean reference. 

either ok. here have large application (50 daos, 100 concurrent users) , there 1 jdbctemplate object entire application, defined in spring context. works fine.


Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -