开发者

Using DataSource without app-server

开发者 https://www.devze.com 2023-04-05 05:56 出处:网络
My data access objects takes a DataSource as a parameter which works perfectly if they are deployed within an app server.

My data access objects takes a DataSource as a parameter which works perfectly if they are deployed within an app server.

I'm wondering how I can assemble a data source f开发者_开发技巧rom within a simple Java class. This might also be useful for unit testing?!


There's nothing magic about a DataSource. It's just an interface. Spring has a basic one for testing purposes if you're already using Spring. Apache DBCP is all about providing a pooling DataSource. Pretty much any other JDBC connection pooling library out there will also provide a DataSource implementation. Just instantiate it, set the properties, and run with it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号