org.javasimon.jdbcx
Class WrappingSimonDataSource
java.lang.Object
org.javasimon.jdbcx.AbstractSimonDataSource
org.javasimon.jdbcx.WrappingSimonDataSource
- All Implemented Interfaces:
- Wrapper, CommonDataSource, DataSource
public class WrappingSimonDataSource
- extends AbstractSimonDataSource
- implements DataSource
WrappingSimonDataSource allows to wrap existing datasource instead of providing
the Driver and URL information. For example - it can be used with Spring easily:
<bean id="dataSource" class="org.javasimon.jdbcx.WrappingSimonDataSource">
<property name="dataSource" ref="pooledDataSource"/>
<property name="prefix" value="sky.batchpricer.skydb"/>
</bean>
<p/>
<bean id="pooledDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="my.driver.class.Driver"/>
<property name="url" value="${mydb.url}"/>
<property name="initialSize" value="0"/>
<property name="maxActive" value="5"/>
<property name="maxIdle" value="2"/>
<property name="validationQuery" value="SELECT 1"/>
</bean>
- Since:
- 2.2
- Version:
- $Revision$ $Date$
- Author:
- diroussel
| Methods inherited from class org.javasimon.jdbcx.AbstractSimonDataSource |
getLoginTimeout, getLogWriter, getPassword, getPrefix, getRealDataSourceClassName, getUrl, getUser, setLoginTimeout, setLogWriter, setPassword, setPrefix, setRealDataSourceClassName, setUrl, setUser |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ds
private DataSource ds
WrappingSimonDataSource
public WrappingSimonDataSource()
getDataSource
public DataSource getDataSource()
setDataSource
public void setDataSource(DataSource ds)
getConnection
public Connection getConnection()
throws SQLException
Attempts to establish a connection with the data source that
this DataSource object represents.
- Specified by:
getConnection in interface DataSource
- Returns:
- a connection to the data source
- Throws:
SQLException - if a database access error occurs
getConnection
public Connection getConnection(String user,
String password)
throws SQLException
Attempts to establish a connection with the data source that
this DataSource object represents.
- Specified by:
getConnection in interface DataSource
- Parameters:
user - the database user on whose behalf the connection is being madepassword - the user's password
- Returns:
- a connection to the data source
- Throws:
SQLException - if a database access error occurs
Copyright © 2011. All Rights Reserved.