org.springbyexample.jdbc.datasource
Class InitializingDriverManagerDataSource

java.lang.Object
  extended by org.springframework.jdbc.datasource.AbstractDataSource
      extended by org.springframework.jdbc.datasource.AbstractDriverBasedDataSource
          extended by org.springframework.jdbc.datasource.SimpleDriverDataSource
              extended by org.springbyexample.jdbc.datasource.InitializingDriverManagerDataSource
All Implemented Interfaces:
DataSource, InitializingBean
Direct Known Subclasses:
HsqldbInitializingDriverManagerDataSource

public class InitializingDriverManagerDataSource
extends SimpleDriverDataSource
implements InitializingBean

Initializing version of DriverManagerDataSource. After the properties are set any database initialization scripts are run. This is very useful for unit testing.

Author:
David Winterfeldt
See Also:
SimpleDriverDataSource, SqlScriptProcessor

Field Summary
protected  String driverClassName
           
protected  SqlScriptProcessor sqlScriptProcessor
           
 
Fields inherited from class org.springframework.jdbc.datasource.AbstractDataSource
logger
 
Constructor Summary
InitializingDriverManagerDataSource()
           
 
Method Summary
 void afterPropertiesSet()
          Implementation of InitializingBean
 void setDriverClassName(String driverClassName)
          Sets driver class name.
 void setSqlScriptProcessor(SqlScriptProcessor sqlScriptProcessor)
          Sets SQL script processor.
 
Methods inherited from class org.springframework.jdbc.datasource.SimpleDriverDataSource
getConnectionFromDriver, getDriver, setDriver, setDriverClass
 
Methods inherited from class org.springframework.jdbc.datasource.AbstractDriverBasedDataSource
getConnection, getConnection, getConnectionFromDriver, getConnectionProperties, getPassword, getUrl, getUsername, setConnectionProperties, setPassword, setUrl, setUsername
 
Methods inherited from class org.springframework.jdbc.datasource.AbstractDataSource
getLoginTimeout, getLogWriter, isWrapperFor, setLoginTimeout, setLogWriter, unwrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

driverClassName

protected String driverClassName

sqlScriptProcessor

protected SqlScriptProcessor sqlScriptProcessor
Constructor Detail

InitializingDriverManagerDataSource

public InitializingDriverManagerDataSource()
Method Detail

setDriverClassName

public void setDriverClassName(String driverClassName)
Sets driver class name. The class should implement java.sql.Driver. This is a shortcut for calling setDriver(Driver driver) on the parent class.


setSqlScriptProcessor

public void setSqlScriptProcessor(SqlScriptProcessor sqlScriptProcessor)
Sets SQL script processor.


afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Implementation of InitializingBean

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception


Copyright © 2008 Spring by Example. All Rights Reserved.