org.lexevs.dao.database.utility
Class DefaultDatabaseUtility

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.jdbc.core.support.JdbcDaoSupport
          extended by org.lexevs.dao.database.utility.DefaultDatabaseUtility
All Implemented Interfaces:
DatabaseUtility, org.springframework.beans.factory.InitializingBean

public class DefaultDatabaseUtility
extends org.springframework.jdbc.core.support.JdbcDaoSupport
implements DatabaseUtility

Spring JDBC implementation of DefaultDatabaseUtility.

Author:
Kevin Peterson

Field Summary
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
DefaultDatabaseUtility()
           
 
Method Summary
protected  java.lang.String adjustForCommonAndTableSetPrefixes(java.lang.String script, java.lang.String commonPrefix, java.lang.String tableSetPrefix)
          Adjust for prefix.
protected  java.lang.String adjustForPrefix(java.lang.String script, java.lang.String prefix)
           
static java.lang.String convertResourceToString(org.springframework.core.io.Resource resource)
          Convert resource to string.
 boolean doesTableExist(java.lang.String tableName)
          Does table exist.
 void dropDatabase(java.lang.String databaseName)
          Drop database.
 void executeScript(org.springframework.core.io.Resource creationScript)
          Execute script.
 void executeScript(org.springframework.core.io.Resource creationScript, java.lang.String tableSetPrefix)
           
 void executeScript(org.springframework.core.io.Resource creationScript, java.lang.String defaultPrefix, java.lang.String tableSetPrefix)
          Execute script.
 void executeScript(java.lang.String script)
          Execute script.
 void executeScript(java.lang.String script, java.lang.String tableSetPrefix)
           
 void executeScript(java.lang.String script, java.lang.String defaultPrefix, java.lang.String tableSetPrefix)
           
 void truncateTable(java.lang.String tableName)
          Truncate table.
 
Methods inherited from class org.springframework.jdbc.core.support.JdbcDaoSupport
checkDaoConfig, createJdbcTemplate, getConnection, getDataSource, getExceptionTranslator, getJdbcTemplate, initTemplateConfig, releaseConnection, setDataSource, setJdbcTemplate
 
Methods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet, initDao
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDatabaseUtility

public DefaultDatabaseUtility()
Method Detail

dropDatabase

public void dropDatabase(java.lang.String databaseName)
Description copied from interface: DatabaseUtility
Drop database.

Specified by:
dropDatabase in interface DatabaseUtility
Parameters:
databaseName - the database name

executeScript

public void executeScript(org.springframework.core.io.Resource creationScript)
                   throws java.lang.Exception
Description copied from interface: DatabaseUtility
Execute script.

Specified by:
executeScript in interface DatabaseUtility
Parameters:
creationScript - the creation script
Throws:
java.lang.Exception - the exception

executeScript

public void executeScript(org.springframework.core.io.Resource creationScript,
                          java.lang.String defaultPrefix,
                          java.lang.String tableSetPrefix)
                   throws java.lang.Exception
Description copied from interface: DatabaseUtility
Execute script.

Specified by:
executeScript in interface DatabaseUtility
Parameters:
creationScript - the creation script
Throws:
java.lang.Exception - the exception

executeScript

public void executeScript(org.springframework.core.io.Resource creationScript,
                          java.lang.String tableSetPrefix)
                   throws java.lang.Exception
Specified by:
executeScript in interface DatabaseUtility
Throws:
java.lang.Exception

executeScript

public void executeScript(java.lang.String script,
                          java.lang.String tableSetPrefix)
                   throws java.lang.Exception
Specified by:
executeScript in interface DatabaseUtility
Throws:
java.lang.Exception

executeScript

public void executeScript(java.lang.String script,
                          java.lang.String defaultPrefix,
                          java.lang.String tableSetPrefix)
                   throws java.lang.Exception
Specified by:
executeScript in interface DatabaseUtility
Throws:
java.lang.Exception

executeScript

public void executeScript(java.lang.String script)
                   throws java.lang.Exception
Description copied from interface: DatabaseUtility
Execute script.

Specified by:
executeScript in interface DatabaseUtility
Parameters:
script - the creation script
Throws:
java.lang.Exception - the exception

convertResourceToString

public static java.lang.String convertResourceToString(org.springframework.core.io.Resource resource)
Convert resource to string.

Parameters:
resource - the resource
Returns:
the string

adjustForCommonAndTableSetPrefixes

protected java.lang.String adjustForCommonAndTableSetPrefixes(java.lang.String script,
                                                              java.lang.String commonPrefix,
                                                              java.lang.String tableSetPrefix)
Adjust for prefix.

Parameters:
script - the script
prefix - the prefix
Returns:
the string

adjustForPrefix

protected java.lang.String adjustForPrefix(java.lang.String script,
                                           java.lang.String prefix)

truncateTable

public void truncateTable(java.lang.String tableName)
                   throws java.lang.Exception
Description copied from interface: DatabaseUtility
Truncate table.

Specified by:
truncateTable in interface DatabaseUtility
Parameters:
tableName - the table name
Throws:
java.lang.Exception - the exception

doesTableExist

public boolean doesTableExist(java.lang.String tableName)
Description copied from interface: DatabaseUtility
Does table exist.

Specified by:
doesTableExist in interface DatabaseUtility
Parameters:
tableName - the table name
Returns:
true, if successful

Copyright: (c) 2004-2006 Mayo Foundation for Medical Education and Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the triple-shield Mayo logo are trademarks and service marks of MFMER.