开发者

Using DataSource without 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜