com.googlecode.flyway.core.dbsupport.h2
Class H2DbSupport

java.lang.Object
  extended by com.googlecode.flyway.core.dbsupport.DbSupport
      extended by com.googlecode.flyway.core.dbsupport.h2.H2DbSupport

public class H2DbSupport
extends DbSupport

H2 database specific support


Field Summary
 
Fields inherited from class com.googlecode.flyway.core.dbsupport.DbSupport
jdbcTemplate
 
Constructor Summary
H2DbSupport(java.sql.Connection connection)
          Creates a new instance.
 
Method Summary
 SqlScript createCleanScript(java.lang.String schema)
          Creates a new sql script which clean this schema, by dropping all objects.
 SqlScript createSqlScript(java.lang.String sqlScriptSource, PlaceholderReplacer placeholderReplacer)
          Creates a new sql script from this resource with these placeholders to replace.
 java.lang.String getBooleanFalse()
           
 java.lang.String getBooleanTrue()
           
 java.lang.String getCurrentSchema()
          Retrieves the current schema.
 java.lang.String getCurrentUserFunction()
           
 java.lang.String getScriptLocation()
          Returns the location on the classpath where the scripts for this database reside.
 boolean isSchemaEmpty(java.lang.String schema)
          Checks if this database schema is empty.
 void lockTable(java.lang.String schema, java.lang.String table)
          Locks this table in this schema using a read/write pessimistic lock until the end of the current transaction.
 boolean supportsDdlTransactions()
          Checks whether ddl transactions are supported for this database.
 boolean tableExists(java.lang.String schema, java.lang.String table)
          Checks whether this table is already present in the database.
 
Methods inherited from class com.googlecode.flyway.core.dbsupport.DbSupport
getJdbcTemplate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

H2DbSupport

public H2DbSupport(java.sql.Connection connection)
Creates a new instance.

Parameters:
connection - The connection to use.
Method Detail

getScriptLocation

public java.lang.String getScriptLocation()
Description copied from class: DbSupport
Returns the location on the classpath where the scripts for this database reside.

Specified by:
getScriptLocation in class DbSupport
Returns:
The folder on the classpath, including a trailing slash.

getCurrentUserFunction

public java.lang.String getCurrentUserFunction()
Specified by:
getCurrentUserFunction in class DbSupport
Returns:
The database function that returns the current user.

getCurrentSchema

public java.lang.String getCurrentSchema()
                                  throws java.sql.SQLException
Description copied from class: DbSupport
Retrieves the current schema.

Specified by:
getCurrentSchema in class DbSupport
Returns:
The current schema for this connection.
Throws:
java.sql.SQLException - when the current schema could not be retrieved.

isSchemaEmpty

public boolean isSchemaEmpty(java.lang.String schema)
                      throws java.sql.SQLException
Description copied from class: DbSupport
Checks if this database schema is empty.

Specified by:
isSchemaEmpty in class DbSupport
Parameters:
schema - The schema to check.
Returns:
true if it is empty, false if it is not.
Throws:
java.sql.SQLException - when there was an error checking whether the schema is empty.

tableExists

public boolean tableExists(java.lang.String schema,
                           java.lang.String table)
                    throws java.sql.SQLException
Description copied from class: DbSupport
Checks whether this table is already present in the database.

Specified by:
tableExists in class DbSupport
Parameters:
schema - The schema in which to look.
table - The table to look for.
Returns:
true if the table exists, false if it doesn't.
Throws:
java.sql.SQLException - when there was an error checking whether this table exists in this schema.

supportsDdlTransactions

public boolean supportsDdlTransactions()
Description copied from class: DbSupport
Checks whether ddl transactions are supported for this database.

Specified by:
supportsDdlTransactions in class DbSupport
Returns:
true if ddl transactions are supported, false if not.

lockTable

public void lockTable(java.lang.String schema,
                      java.lang.String table)
               throws java.sql.SQLException
Description copied from class: DbSupport
Locks this table in this schema using a read/write pessimistic lock until the end of the current transaction.

Specified by:
lockTable in class DbSupport
Parameters:
schema - The schema of the table to lock.
table - The table to lock.
Throws:
java.sql.SQLException - when this table in this schema could not be locked.

getBooleanTrue

public java.lang.String getBooleanTrue()
Specified by:
getBooleanTrue in class DbSupport
Returns:
The representation of the value true in a boolean column.

getBooleanFalse

public java.lang.String getBooleanFalse()
Specified by:
getBooleanFalse in class DbSupport
Returns:
The representation of the value false in a boolean column.

createSqlScript

public SqlScript createSqlScript(java.lang.String sqlScriptSource,
                                 PlaceholderReplacer placeholderReplacer)
Description copied from class: DbSupport
Creates a new sql script from this resource with these placeholders to replace.

Specified by:
createSqlScript in class DbSupport
Parameters:
sqlScriptSource - The sql script as a text block with all placeholders still present.
placeholderReplacer - The placeholder replacer to apply to sql migration scripts.
Returns:
A new sql script, containing the statements from this resource, with all placeholders replaced.

createCleanScript

public SqlScript createCleanScript(java.lang.String schema)
                            throws java.sql.SQLException
Description copied from class: DbSupport
Creates a new sql script which clean this schema, by dropping all objects.

Specified by:
createCleanScript in class DbSupport
Parameters:
schema - The schema to clean.
Returns:
A new sql script, containing drop statements for all objects
Throws:
java.sql.SQLException - when querying the database for generating the clean script failed.


Copyright © 2012. All Rights Reserved.