niyue

DriverManagerDataSource in Spring Framework

In programming on 1月 29, 2005 at 3:38 下午

DriverManagerDataSource in Spring Framework

javax.sql Interface DataSource

今天看了一天的spring,想使用里面提供的JdbcTemplate,看上去非常酷的样子,不过其中涉及到了一个DataSource接口,不知道干嘛的,好不容易才找到了一个讲的比较清楚的解释。

Implementation of SmartDataSource that configures a plain old JDBC Driver via bean properties, and returns a new Connection every time.

Useful for test or standalone environments outside of a J2EE container, either as a DataSource bean in a respective ApplicationContext, or in conjunction with a simple JNDI environment. Pool-assuming Connection.close() calls will simply close the connection, so any DataSource-aware persistence code should work.

In a J2EE container, it is recommended to use a JNDI DataSource provided by the container. Such a DataSource can be exported as a DataSource bean in an ApplicationContext via JndiObjectFactoryBean, for seamless switching to and from a local DataSource bean like this class.

If you need a “real” connection pool outside of a J2EE container, consider Apache’s Jakarta Commons DBCP. Its BasicDataSource is a full connection pool bean, supporting the same basic properties as this class plus specific settings. It can be used as a replacement for an instance of this class just by changing the class name of the bean definition to “org.apache.commons.dbcp.BasicDataSource”.

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

您正在使用您的 WordPress.com 账号评论。 注销 /  更改 )

Twitter picture

您正在使用您的 Twitter 账号评论。 注销 /  更改 )

Facebook photo

您正在使用您的 Facebook 账号评论。 注销 /  更改 )

Connecting to %s

%d 博主赞过: