org.javasimon.jdbcx
Class WrappingSimonDataSource

java.lang.Object
  extended by org.javasimon.jdbcx.AbstractSimonDataSource
      extended by 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

Field Summary
private  DataSource ds
           
 
Fields inherited from class org.javasimon.jdbcx.AbstractSimonDataSource
loginTimeout, logWriter, password, prefix, realDataSourceClassName, url, user
 
Constructor Summary
WrappingSimonDataSource()
           
 
Method Summary
 Connection getConnection()
          Attempts to establish a connection with the data source that this DataSource object represents.
 Connection getConnection(String user, String password)
          Attempts to establish a connection with the data source that this DataSource object represents.
 DataSource getDataSource()
           
 void setDataSource(DataSource ds)
           
 
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
 
Methods inherited from interface javax.sql.CommonDataSource
getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter
 
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
 

Field Detail

ds

private DataSource ds
Constructor Detail

WrappingSimonDataSource

public WrappingSimonDataSource()
Method Detail

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 made
password - the user's password
Returns:
a connection to the data source
Throws:
SQLException - if a database access error occurs


Copyright © 2011. All Rights Reserved.