question identify best practices on data access layer.
i want choose in between using data source or traditional driver manager load the connection on web applications. know following advantages
- flexibility of configuration
- in built connection pooling mechanism
but if can sacrifice advantage of flexibility configuration , have own connection pooling mechanism, other benefit out of data source. in other way around limitations or issues face while having application managed jdbc driver connection container managed.
i know question stupid should knowing advantage of takes care of handling connection application. rare scenario can't use datasource in web application. looking following things
- how better can design own connection pool self?
- is there thing else should take care when access connection through drivermanager api
note is possible programatically create datasource (backed connection pool) dynamically based on user input.
using apache commons-dbcp:
basicdatasource ds = new basicdatasource(); ds.setdriverclassname(database_driver_class); ds.setusername(database_username); ds.setpassword(database_password); ds.seturl(database_url); ds.setinitialsize(1); ds.setmaxactive(50); ds.setdefaultautocommit(false); so think question not between datasource , no-datasource, rather between container managed datasource , application managed datasource.
container managed datasources easier manage server-admin types. can tuned through app server web ui, etc. application managed datasources not have advantage.
Comments
Post a Comment