org.apache.ddlutils
Interface Platform

All Known Implementing Classes:
AxionPlatform, CloudscapePlatform, Db2Platform, Db2v8Platform, DerbyPlatform, FirebirdPlatform, HsqlDbPlatform, InterbasePlatform, MaxDbPlatform, MckoiPlatform, MSSqlPlatform, MySql50Platform, MySqlPlatform, Oracle10Platform, Oracle8Platform, Oracle9Platform, PlatformImplBase, PostgreSqlPlatform, SapDbPlatform, SybaseASE15Platform, SybasePlatform

public interface Platform

A platform encapsulates the database-related functionality such as performing queries and manipulations. It also contains an sql builder that is specific to this platform.

Version:
$Revision: 231110 $

Method Summary
 void alterTables(Connection connection, Database desiredDb, boolean continueOnError)
          Alters the database schema so that it match the given model.
 void alterTables(Connection connection, Database desiredDb, CreationParameters params, boolean continueOnError)
          Alters the database schema so that it match the given model.
 void alterTables(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredDb, boolean continueOnError)
          Alters the database schema so that it match the given model.
 void alterTables(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredDb, CreationParameters params, boolean continueOnError)
          Alters the database schema so that it match the given model.
 void alterTables(Database desiredDb, boolean continueOnError)
          Alters the database schema so that it match the given model.
 void alterTables(Database desiredDb, CreationParameters params, boolean continueOnError)
          Alters the database schema so that it match the given model.
 void alterTables(String catalog, String schema, String[] tableTypes, Database desiredDb, boolean continueOnError)
          Alters the database schema so that it match the given model.
 void alterTables(String catalog, String schema, String[] tableTypes, Database desiredDb, CreationParameters params, boolean continueOnError)
          Alters the database schema so that it match the given model.
 Connection borrowConnection()
          Returns a (new) JDBC connection from the data source.
 void createDatabase(String jdbcDriverClassName, String connectionUrl, String username, String password, Map parameters)
          Creates the database specified by the given parameters.
 void createTables(Connection connection, Database model, boolean dropTablesFirst, boolean continueOnError)
          Creates the tables defined in the database model.
 void createTables(Connection connection, Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError)
          Creates the tables defined in the database model.
 void createTables(Database model, boolean dropTablesFirst, boolean continueOnError)
          Creates the tables defined in the database model.
 void createTables(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError)
          Creates the tables defined in the database model.
 void delete(Connection connection, Database model, DynaBean dynaBean)
          Deletes the row which maps to the given bean from the database.
 void delete(Database model, DynaBean dynaBean)
          Deletes the given bean from the database, assuming the primary key values are specified.
 void dropDatabase(String jdbcDriverClassName, String connectionUrl, String username, String password)
          Drops the database specified by the given parameters.
 void dropTable(Connection connection, Database model, Table table, boolean continueOnError)
          Drops the specified table and all foreign keys pointing to it.
 void dropTable(Database model, Table table, boolean continueOnError)
          Drops the specified table and all foreign keys pointing to it.
 void dropTables(Connection connection, Database model, boolean continueOnError)
          Drops the tables defined in the given database.
 void dropTables(Database model, boolean continueOnError)
          Drops the tables defined in the given database.
 int evaluateBatch(Connection connection, String sql, boolean continueOnError)
          Executes a series of sql statements which must be seperated by the delimiter configured as PlatformInfo.getSqlCommandDelimiter() of the info object of this platform.
 int evaluateBatch(String sql, boolean continueOnError)
          Executes a series of sql statements which must be seperated by the delimiter configured as PlatformInfo.getSqlCommandDelimiter() of the info object of this platform.
 List fetch(Database model, String sql)
          Queries for a list of dyna beans representing rows of the given query.
 List fetch(Database model, String sql, Collection parameters)
          Queries for a list of dyna beans representing rows of the given query.
 List fetch(Database model, String sql, Collection parameters, int start, int end)
          Queries for a list of dyna beans representing rows of the given query.
 List fetch(Database model, String sql, Collection parameters, Table[] queryHints)
          Queries for a list of dyna beans representing rows of the given query.
 List fetch(Database model, String sql, Collection parameters, Table[] queryHints, int start, int end)
          Queries for a list of dyna beans representing rows of the given query.
 List fetch(Database model, String sql, int start, int end)
          Queries for a list of dyna beans representing rows of the given query.
 List fetch(Database model, String sql, Table[] queryHints)
          Queries for a list of dyna beans representing rows of the given query.
 List fetch(Database model, String sql, Table[] queryHints, int start, int end)
          Queries for a list of dyna beans representing rows of the given query.
 String getAlterTablesSql(Connection connection, Database desiredDb)
          Returns the SQL for altering the database schema so that it match the given model.
 String getAlterTablesSql(Connection connection, Database desiredDb, CreationParameters params)
          Returns the SQL for altering the database schema so that it match the given model.
 String getAlterTablesSql(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredDb)
          Returns the SQL for altering the database schema so that it match the given model.
 String getAlterTablesSql(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredDb, CreationParameters params)
          Returns the SQL for altering the database schema so that it match the given model.
 String getAlterTablesSql(Database desiredDb)
          Returns the SQL for altering the database schema so that it match the given model.
 String getAlterTablesSql(Database desiredDb, CreationParameters params)
          Returns the SQL for altering the database schema so that it match the given model.
 String getAlterTablesSql(String catalog, String schema, String[] tableTypes, Database desiredDb)
          Returns the SQL for altering the database schema so that it match the given model.
 String getAlterTablesSql(String catalog, String schema, String[] tableTypes, Database desiredDb, CreationParameters params)
          Returns the SQL for altering the database schema so that it match the given model.
 String getCreateTablesSql(Database model, boolean dropTablesFirst, boolean continueOnError)
          Returns the SQL for creating the tables defined in the database model.
 String getCreateTablesSql(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError)
          Returns the SQL for creating the tables defined in the database model.
 DataSource getDataSource()
          Returns the data source that this platform uses to access the database.
 String getDeleteSql(Database model, DynaBean dynaBean)
          Returns the sql for deleting the given bean from the database.
 String getDropTableSql(Database model, Table table, boolean continueOnError)
          Returns the SQL for dropping the given table and all foreign keys pointing to it.
 String getDropTablesSql(Database model, boolean continueOnError)
          Returns the SQL for dropping the tables defined in the given database.
 String getInsertSql(Database model, DynaBean dynaBean)
          Returns the sql for inserting the given bean.
 JdbcModelReader getModelReader()
          Returns the model reader (which reads a database model from a live database) for this platform.
 String getName()
          Returns the name of the database that this platform is for.
 String getPassword()
          Returns the password that this platform shall use to access the database.
 PlatformInfo getPlatformInfo()
          Returns the info object for this platform.
 SqlBuilder getSqlBuilder()
          Returns the sql builder for the this platform.
 String getUpdateSql(Database model, DynaBean dynaBean)
          Returns the sql for updating the given bean in the database.
 String getUsername()
          Returns the username that this platform shall use to access the database.
 void insert(Connection connection, Database model, Collection dynaBeans)
          Inserts the given beans.
 void insert(Connection connection, Database model, DynaBean dynaBean)
          Inserts the bean.
 void insert(Database model, Collection dynaBeans)
          Inserts the given beans in the database, assuming the primary key values are specified.
 void insert(Database model, DynaBean dynaBean)
          Inserts the given DynaBean in the database, assuming the primary key values are specified.
 boolean isDelimitedIdentifierModeOn()
          Determines whether delimited identifiers are used or normal SQL92 identifiers (which may only contain alphanumerical characters and the underscore, must start with a letter and cannot be a reserved keyword).
 boolean isForeignKeysSorted()
          Determines whether foreign keys of a table read from a live database are alphabetically sorted.
 boolean isIdentityOverrideOn()
          Determines whether SQL insert statements can specify values for identity columns.
 boolean isScriptModeOn()
          Determines whether script mode is on.
 boolean isSqlCommentsOn()
          Determines whether SQL comments are generated.
 Iterator query(Database model, String sql)
          Performs the given SQL query returning an iterator over the results.
 Iterator query(Database model, String sql, Collection parameters)
          Performs the given parameterized SQL query returning an iterator over the results.
 Iterator query(Database model, String sql, Collection parameters, Table[] queryHints)
          Performs the given parameterized SQL query returning an iterator over the results.
 Iterator query(Database model, String sql, Table[] queryHints)
          Performs the given SQL query returning an iterator over the results.
 Database readModelFromDatabase(Connection connection, String name)
          Reads the database model from the live database to which the given connection is pointing.
 Database readModelFromDatabase(Connection connection, String name, String catalog, String schema, String[] tableTypes)
          Reads the database model from the live database to which the given connection is pointing.
 Database readModelFromDatabase(String name)
          Reads the database model from the live database as specified by the data source set for this platform.
 Database readModelFromDatabase(String name, String catalog, String schema, String[] tableTypes)
          Reads the database model from the live database as specified by the data source set for this platform.
 void returnConnection(Connection connection)
          Closes the given JDBC connection (returns it back to the pool if the datasource is poolable).
 void setDataSource(DataSource dataSource)
          Sets the data source that this platform shall use to access the database.
 void setDelimitedIdentifierModeOn(boolean delimitedIdentifierModeOn)
          Specifies whether delimited identifiers are used or normal SQL92 identifiers.
 void setForeignKeysSorted(boolean foreignKeysSorted)
          Specifies whether foreign keys read from a live database, shall be alphabetically sorted.
 void setIdentityOverrideOn(boolean identityOverrideOn)
          Specifies whether SQL insert statements can specify values for identity columns.
 void setPassword(String password)
          Sets the password that this platform shall use to access the database.
 void setScriptModeOn(boolean scriptModeOn)
          Specifies whether script mode is on.
 void setSqlCommentsOn(boolean sqlCommentsOn)
          Specifies whether SQL comments shall be generated.
 void setUsername(String username)
          Sets the username that this platform shall use to access the database.
 void shutdownDatabase()
          Performs a shutdown at the database.
 void shutdownDatabase(Connection connection)
          Performs a shutdown at the database.
 void store(Database model, DynaBean dynaBean)
          Stores the given bean in the database, inserting it if there is no primary key otherwise the bean is updated in the database.
 void update(Connection connection, Database model, DynaBean dynaBean)
          Updates the row which maps to the given bean.
 void update(Database model, DynaBean dynaBean)
          Updates the given bean in the database, assuming the primary key values are specified.
 

Method Detail

getName

String getName()
Returns the name of the database that this platform is for.

Returns:
The name

getPlatformInfo

PlatformInfo getPlatformInfo()
Returns the info object for this platform.

Returns:
The info object

getSqlBuilder

SqlBuilder getSqlBuilder()
Returns the sql builder for the this platform.

Returns:
The sql builder

getModelReader

JdbcModelReader getModelReader()
Returns the model reader (which reads a database model from a live database) for this platform.

Returns:
The model reader

getDataSource

DataSource getDataSource()
Returns the data source that this platform uses to access the database.

Returns:
The data source

setDataSource

void setDataSource(DataSource dataSource)
Sets the data source that this platform shall use to access the database.

Parameters:
dataSource - The data source

getUsername

String getUsername()
Returns the username that this platform shall use to access the database.

Returns:
The username

setUsername

void setUsername(String username)
Sets the username that this platform shall use to access the database.

Parameters:
username - The username

getPassword

String getPassword()
Returns the password that this platform shall use to access the database.

Returns:
The password

setPassword

void setPassword(String password)
Sets the password that this platform shall use to access the database.

Parameters:
password - The password

isScriptModeOn

boolean isScriptModeOn()
Determines whether script mode is on. This means that the generated SQL is not intended to be sent directly to the database but rather to be saved in a SQL script file. Per default, script mode is off.

Returns:
true if script mode is on

setScriptModeOn

void setScriptModeOn(boolean scriptModeOn)
Specifies whether script mode is on. This means that the generated SQL is not intended to be sent directly to the database but rather to be saved in a SQL script file.

Parameters:
scriptModeOn - true if script mode is on

isDelimitedIdentifierModeOn

boolean isDelimitedIdentifierModeOn()
Determines whether delimited identifiers are used or normal SQL92 identifiers (which may only contain alphanumerical characters and the underscore, must start with a letter and cannot be a reserved keyword). Per default, delimited identifiers are not used

Returns:
true if delimited identifiers are used

setDelimitedIdentifierModeOn

void setDelimitedIdentifierModeOn(boolean delimitedIdentifierModeOn)
Specifies whether delimited identifiers are used or normal SQL92 identifiers.

Parameters:
delimitedIdentifierModeOn - true if delimited identifiers shall be used

isSqlCommentsOn

boolean isSqlCommentsOn()
Determines whether SQL comments are generated.

Returns:
true if SQL comments shall be generated

setSqlCommentsOn

void setSqlCommentsOn(boolean sqlCommentsOn)
Specifies whether SQL comments shall be generated.

Parameters:
sqlCommentsOn - true if SQL comments shall be generated

isIdentityOverrideOn

boolean isIdentityOverrideOn()
Determines whether SQL insert statements can specify values for identity columns. This setting is only relevant if the database supports it (PlatformInfo.isIdentityOverrideAllowed()). If this is off, then the insert methods will ignore values for identity columns.

Returns:
true if identity override is enabled (the default)

setIdentityOverrideOn

void setIdentityOverrideOn(boolean identityOverrideOn)
Specifies whether SQL insert statements can specify values for identity columns. This setting is only relevant if the database supports it (PlatformInfo.isIdentityOverrideAllowed()). If this is off, then the insert methods will ignore values for identity columns.

Parameters:
identityOverrideOn - true if identity override is enabled (the default)

isForeignKeysSorted

boolean isForeignKeysSorted()
Determines whether foreign keys of a table read from a live database are alphabetically sorted.

Returns:
true if read foreign keys are sorted

setForeignKeysSorted

void setForeignKeysSorted(boolean foreignKeysSorted)
Specifies whether foreign keys read from a live database, shall be alphabetically sorted.

Parameters:
foreignKeysSorted - true if read foreign keys shall be sorted

borrowConnection

Connection borrowConnection()
                            throws DatabaseOperationException
Returns a (new) JDBC connection from the data source.

Returns:
The connection
Throws:
DatabaseOperationException

returnConnection

void returnConnection(Connection connection)
Closes the given JDBC connection (returns it back to the pool if the datasource is poolable).

Parameters:
connection - The connection

evaluateBatch

int evaluateBatch(String sql,
                  boolean continueOnError)
                  throws DatabaseOperationException
Executes a series of sql statements which must be seperated by the delimiter configured as PlatformInfo.getSqlCommandDelimiter() of the info object of this platform.

Parameters:
sql - The sql statements to execute
continueOnError - Whether to continue executing the sql commands when an error occurred
Returns:
The number of errors
Throws:
DatabaseOperationException

evaluateBatch

int evaluateBatch(Connection connection,
                  String sql,
                  boolean continueOnError)
                  throws DatabaseOperationException
Executes a series of sql statements which must be seperated by the delimiter configured as PlatformInfo.getSqlCommandDelimiter() of the info object of this platform. TODO: consider outputting a collection of String or some kind of statement object from the SqlBuilder instead of having to parse strings here

Parameters:
connection - The connection to the database
sql - The sql statements to execute
continueOnError - Whether to continue executing the sql commands when an error occurred
Returns:
The number of errors
Throws:
DatabaseOperationException

shutdownDatabase

void shutdownDatabase()
                      throws DatabaseOperationException
Performs a shutdown at the database. This is necessary for some embedded databases which otherwise would be locked and thus would refuse other connections. Note that this does not change the database structure or data in it in any way.

Throws:
DatabaseOperationException

shutdownDatabase

void shutdownDatabase(Connection connection)
                      throws DatabaseOperationException
Performs a shutdown at the database. This is necessary for some embedded databases which otherwise would be locked and thus would refuse other connections. Note that this does not change the database structure or data in it in any way.

Parameters:
connection - The connection to the database
Throws:
DatabaseOperationException

createDatabase

void createDatabase(String jdbcDriverClassName,
                    String connectionUrl,
                    String username,
                    String password,
                    Map parameters)
                    throws DatabaseOperationException,
                           UnsupportedOperationException
Creates the database specified by the given parameters. Please note that this method does not use a data source set via setDataSource(DataSource) because it is not possible to retrieve the connection information from it without establishing a connection.
The given connection url is the url that you'd use to connect to the already-created database.
On some platforms, this method suppurts additional parameters. These are documented in the manual section for the individual platforms.

Parameters:
jdbcDriverClassName - The jdbc driver class name
connectionUrl - The url to connect to the database if it were already created
username - The username for creating the database
password - The password for creating the database
parameters - Additional parameters relevant to database creation (which are platform specific)
Throws:
DatabaseOperationException
UnsupportedOperationException

dropDatabase

void dropDatabase(String jdbcDriverClassName,
                  String connectionUrl,
                  String username,
                  String password)
                  throws DatabaseOperationException,
                         UnsupportedOperationException
Drops the database specified by the given parameters. Please note that this method does not use a data source set via setDataSource(DataSource) because it is not possible to retrieve the connection information from it without establishing a connection.

Parameters:
jdbcDriverClassName - The jdbc driver class name
connectionUrl - The url to connect to the database
username - The username for creating the database
password - The password for creating the database
Throws:
DatabaseOperationException
UnsupportedOperationException

createTables

void createTables(Database model,
                  boolean dropTablesFirst,
                  boolean continueOnError)
                  throws DatabaseOperationException
Creates the tables defined in the database model.

Parameters:
model - The database model
dropTablesFirst - Whether to drop the tables prior to creating them (anew)
continueOnError - Whether to continue executing the sql commands when an error occurred
Throws:
DatabaseOperationException

createTables

void createTables(Connection connection,
                  Database model,
                  boolean dropTablesFirst,
                  boolean continueOnError)
                  throws DatabaseOperationException
Creates the tables defined in the database model.

Parameters:
connection - The connection to the database
model - The database model
dropTablesFirst - Whether to drop the tables prior to creating them (anew)
continueOnError - Whether to continue executing the sql commands when an error occurred
Throws:
DatabaseOperationException

getCreateTablesSql

String getCreateTablesSql(Database model,
                          boolean dropTablesFirst,
                          boolean continueOnError)
Returns the SQL for creating the tables defined in the database model.

Parameters:
model - The database model
dropTablesFirst - Whether to drop the tables prior to creating them (anew)
continueOnError - Whether to continue executing the sql commands when an error occurred
Returns:
The SQL statements

createTables

void createTables(Database model,
                  CreationParameters params,
                  boolean dropTablesFirst,
                  boolean continueOnError)
                  throws DatabaseOperationException
Creates the tables defined in the database model.

Parameters:
model - The database model
params - The parameters used in the creation
dropTablesFirst - Whether to drop the tables prior to creating them (anew)
continueOnError - Whether to continue executing the sql commands when an error occurred
Throws:
DatabaseOperationException

createTables

void createTables(Connection connection,
                  Database model,
                  CreationParameters params,
                  boolean dropTablesFirst,
                  boolean continueOnError)
                  throws DatabaseOperationException
Creates the tables defined in the database model.

Parameters:
connection - The connection to the database
model - The database model
params - The parameters used in the creation
dropTablesFirst - Whether to drop the tables prior to creating them (anew)
continueOnError - Whether to continue executing the sql commands when an error occurred
Throws:
DatabaseOperationException

getCreateTablesSql

String getCreateTablesSql(Database model,
                          CreationParameters params,
                          boolean dropTablesFirst,
                          boolean continueOnError)
Returns the SQL for creating the tables defined in the database model.

Parameters:
model - The database model
params - The parameters used in the creation
dropTablesFirst - Whether to drop the tables prior to creating them (anew)
continueOnError - Whether to continue executing the sql commands when an error occurred
Returns:
The SQL statements

alterTables

void alterTables(Database desiredDb,
                 boolean continueOnError)
                 throws DatabaseOperationException
Alters the database schema so that it match the given model.

Parameters:
desiredDb - The desired database schema
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DatabaseOperationException

getAlterTablesSql

String getAlterTablesSql(Database desiredDb)
                         throws DatabaseOperationException
Returns the SQL for altering the database schema so that it match the given model.

Parameters:
desiredDb - The desired database schema
Returns:
The SQL statements
Throws:
DatabaseOperationException

alterTables

void alterTables(Database desiredDb,
                 CreationParameters params,
                 boolean continueOnError)
                 throws DatabaseOperationException
Alters the database schema so that it match the given model.

Parameters:
desiredDb - The desired database schema
params - The parameters used in the creation
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DatabaseOperationException

getAlterTablesSql

String getAlterTablesSql(Database desiredDb,
                         CreationParameters params)
                         throws DatabaseOperationException
Returns the SQL for altering the database schema so that it match the given model.

Parameters:
desiredDb - The desired database schema
params - The parameters used in the creation
Returns:
The SQL statements
Throws:
DatabaseOperationException

alterTables

void alterTables(String catalog,
                 String schema,
                 String[] tableTypes,
                 Database desiredDb,
                 boolean continueOnError)
                 throws DatabaseOperationException
Alters the database schema so that it match the given model.

Parameters:
catalog - The catalog in the existing database to read (can be a pattern); use null for the platform-specific default value
schema - The schema in the existing database to read (can be a pattern); use null for the platform-specific default value
tableTypes - The table types to read from the existing database; use null or an empty array for the platform-specific default value
desiredDb - The desired database schema
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DatabaseOperationException

getAlterTablesSql

String getAlterTablesSql(String catalog,
                         String schema,
                         String[] tableTypes,
                         Database desiredDb)
                         throws DatabaseOperationException
Returns the SQL for altering the database schema so that it match the given model.

Parameters:
catalog - The catalog in the existing database to read (can be a pattern); use null for the platform-specific default value
schema - The schema in the existing database to read (can be a pattern); use null for the platform-specific default value
tableTypes - The table types to read from the existing database; use null or an empty array for the platform-specific default value
desiredDb - The desired database schema
Returns:
The SQL statements
Throws:
DatabaseOperationException

alterTables

void alterTables(String catalog,
                 String schema,
                 String[] tableTypes,
                 Database desiredDb,
                 CreationParameters params,
                 boolean continueOnError)
                 throws DatabaseOperationException
Alters the database schema so that it match the given model.

Parameters:
catalog - The catalog in the existing database to read (can be a pattern); use null for the platform-specific default value
schema - The schema in the existing database to read (can be a pattern); use null for the platform-specific default value
tableTypes - The table types to read from the existing database; use null or an empty array for the platform-specific default value
desiredDb - The desired database schema
params - The parameters used in the creation
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DatabaseOperationException

getAlterTablesSql

String getAlterTablesSql(String catalog,
                         String schema,
                         String[] tableTypes,
                         Database desiredDb,
                         CreationParameters params)
                         throws DatabaseOperationException
Returns the SQL for altering the database schema so that it match the given model.

Parameters:
catalog - The catalog in the existing database to read (can be a pattern); use null for the platform-specific default value
schema - The schema in the existing database to read (can be a pattern); use null for the platform-specific default value
tableTypes - The table types to read from the existing database; use null or an empty array for the platform-specific default value
desiredDb - The desired database schema
params - The parameters used in the creation
Returns:
The SQL statements
Throws:
DatabaseOperationException

alterTables

void alterTables(Connection connection,
                 Database desiredDb,
                 boolean continueOnError)
                 throws DatabaseOperationException
Alters the database schema so that it match the given model.

Parameters:
connection - A connection to the existing database that shall be modified
desiredDb - The desired database schema
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DatabaseOperationException

getAlterTablesSql

String getAlterTablesSql(Connection connection,
                         Database desiredDb)
                         throws DatabaseOperationException
Returns the SQL for altering the database schema so that it match the given model.

Parameters:
connection - A connection to the existing database that shall be modified
desiredDb - The desired database schema
Returns:
The SQL statements
Throws:
DatabaseOperationException

alterTables

void alterTables(Connection connection,
                 Database desiredDb,
                 CreationParameters params,
                 boolean continueOnError)
                 throws DatabaseOperationException
Alters the database schema so that it match the given model.

Parameters:
connection - A connection to the existing database that shall be modified
desiredDb - The desired database schema
params - The parameters used in the creation
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DatabaseOperationException

getAlterTablesSql

String getAlterTablesSql(Connection connection,
                         Database desiredDb,
                         CreationParameters params)
                         throws DatabaseOperationException
Returns the SQL for altering the database schema so that it match the given model.

Parameters:
connection - A connection to the existing database that shall be modified
desiredDb - The desired database schema
params - The parameters used in the creation
Returns:
The SQL statements
Throws:
DatabaseOperationException

alterTables

void alterTables(Connection connection,
                 String catalog,
                 String schema,
                 String[] tableTypes,
                 Database desiredDb,
                 boolean continueOnError)
                 throws DatabaseOperationException
Alters the database schema so that it match the given model.

Parameters:
connection - A connection to the existing database that shall be modified
catalog - The catalog in the existing database to read (can be a pattern); use null for the platform-specific default value
schema - The schema in the existing database to read (can be a pattern); use null for the platform-specific default value
tableTypes - The table types to read from the existing database; use null or an empty array for the platform-specific default value
desiredDb - The desired database schema
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DatabaseOperationException

getAlterTablesSql

String getAlterTablesSql(Connection connection,
                         String catalog,
                         String schema,
                         String[] tableTypes,
                         Database desiredDb)
                         throws DatabaseOperationException
Returns the SQL for altering the database schema so that it match the given model.

Parameters:
connection - A connection to the existing database that shall be modified
catalog - The catalog in the existing database to read (can be a pattern); use null for the platform-specific default value
schema - The schema in the existing database to read (can be a pattern); use null for the platform-specific default value
tableTypes - The table types to read from the existing database; use null or an empty array for the platform-specific default value
desiredDb - The desired database schema
Returns:
The SQL statements
Throws:
DatabaseOperationException

alterTables

void alterTables(Connection connection,
                 String catalog,
                 String schema,
                 String[] tableTypes,
                 Database desiredDb,
                 CreationParameters params,
                 boolean continueOnError)
                 throws DatabaseOperationException
Alters the database schema so that it match the given model.

Parameters:
connection - A connection to the existing database that shall be modified
catalog - The catalog in the existing database to read (can be a pattern); use null for the platform-specific default value
schema - The schema in the existing database to read (can be a pattern); use null for the platform-specific default value
tableTypes - The table types to read from the existing database; use null or an empty array for the platform-specific default value
desiredDb - The desired database schema
params - The parameters used in the creation
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DatabaseOperationException

getAlterTablesSql

String getAlterTablesSql(Connection connection,
                         String catalog,
                         String schema,
                         String[] tableTypes,
                         Database desiredDb,
                         CreationParameters params)
                         throws DatabaseOperationException
Returns the SQL for altering the database schema so that it match the given model.

Parameters:
connection - A connection to the existing database that shall be modified
catalog - The catalog in the existing database to read (can be a pattern); use null for the platform-specific default value
schema - The schema in the existing database to read (can be a pattern); use null for the platform-specific default value
tableTypes - The table types to read from the existing database; use null or an empty array for the platform-specific default value
desiredDb - The desired database schema
params - The parameters used in the creation
Returns:
The SQL statements
Throws:
DatabaseOperationException

dropTable

void dropTable(Database model,
               Table table,
               boolean continueOnError)
               throws DatabaseOperationException
Drops the specified table and all foreign keys pointing to it.

Parameters:
model - The database model
table - The table to drop
continueOnError - Whether to continue executing the sql commands when an error occurred
Throws:
DatabaseOperationException

getDropTableSql

String getDropTableSql(Database model,
                       Table table,
                       boolean continueOnError)
Returns the SQL for dropping the given table and all foreign keys pointing to it.

Parameters:
model - The database model
table - The table to drop
continueOnError - Whether to continue executing the sql commands when an error occurred
Returns:
The SQL statements

dropTable

void dropTable(Connection connection,
               Database model,
               Table table,
               boolean continueOnError)
               throws DatabaseOperationException
Drops the specified table and all foreign keys pointing to it.

Parameters:
connection - The connection to the database
model - The database model
table - The table to drop
continueOnError - Whether to continue executing the sql commands when an error occurred
Throws:
DatabaseOperationException

dropTables

void dropTables(Database model,
                boolean continueOnError)
                throws DatabaseOperationException
Drops the tables defined in the given database.

Parameters:
model - The database model
continueOnError - Whether to continue executing the sql commands when an error occurred
Throws:
DatabaseOperationException

getDropTablesSql

String getDropTablesSql(Database model,
                        boolean continueOnError)
Returns the SQL for dropping the tables defined in the given database.

Parameters:
model - The database model
continueOnError - Whether to continue executing the sql commands when an error occurred
Returns:
The SQL statements

dropTables

void dropTables(Connection connection,
                Database model,
                boolean continueOnError)
                throws DatabaseOperationException
Drops the tables defined in the given database.

Parameters:
connection - The connection to the database
model - The database model
continueOnError - Whether to continue executing the sql commands when an error occurred
Throws:
DatabaseOperationException

query

Iterator query(Database model,
               String sql)
               throws DatabaseOperationException
Performs the given SQL query returning an iterator over the results.

Parameters:
model - The database model to use
sql - The sql query to perform
Returns:
An iterator for the dyna beans resulting from the query
Throws:
DatabaseOperationException

query

Iterator query(Database model,
               String sql,
               Collection parameters)
               throws DatabaseOperationException
Performs the given parameterized SQL query returning an iterator over the results.

Parameters:
model - The database model to use
sql - The sql query to perform
parameters - The query parameter values
Returns:
An iterator for the dyna beans resulting from the query
Throws:
DatabaseOperationException

query

Iterator query(Database model,
               String sql,
               Table[] queryHints)
               throws DatabaseOperationException
Performs the given SQL query returning an iterator over the results.

Parameters:
model - The database model to use
sql - The sql query to perform
queryHints - The tables that are queried (optional)
Returns:
An iterator for the dyna beans resulting from the query
Throws:
DatabaseOperationException

query

Iterator query(Database model,
               String sql,
               Collection parameters,
               Table[] queryHints)
               throws DatabaseOperationException
Performs the given parameterized SQL query returning an iterator over the results.

Parameters:
model - The database model to use
sql - The sql query to perform
parameters - The query parameter values
queryHints - The tables that are queried (optional)
Returns:
An iterator for the dyna beans resulting from the query
Throws:
DatabaseOperationException

fetch

List fetch(Database model,
           String sql)
           throws DatabaseOperationException
Queries for a list of dyna beans representing rows of the given query. In contrast to the query(Database, String) method all beans will be materialized and the connection will be closed before returning the beans.

Parameters:
model - The database model to use
sql - The sql query
Returns:
The dyna beans resulting from the query
Throws:
DatabaseOperationException

fetch

List fetch(Database model,
           String sql,
           Collection parameters)
           throws DatabaseOperationException
Queries for a list of dyna beans representing rows of the given query. In contrast to the query(Database, String, Collection) method all beans will be materialized and the connection will be closed before returning the beans.

Parameters:
model - The database model to use
sql - The parameterized query
parameters - The parameter values
Returns:
The dyna beans resulting from the query
Throws:
DatabaseOperationException

fetch

List fetch(Database model,
           String sql,
           Table[] queryHints)
           throws DatabaseOperationException
Queries for a list of dyna beans representing rows of the given query. In contrast to the query(Database, String) method all beans will be materialized and the connection will be closed before returning the beans.

Parameters:
model - The database model to use
sql - The sql query
queryHints - The tables that are queried (optional)
Returns:
The dyna beans resulting from the query
Throws:
DatabaseOperationException

fetch

List fetch(Database model,
           String sql,
           Collection parameters,
           Table[] queryHints)
           throws DatabaseOperationException
Queries for a list of dyna beans representing rows of the given query. In contrast to the query(Database, String, Collection) method all beans will be materialized and the connection will be closed before returning the beans.

Parameters:
model - The database model to use
sql - The parameterized query
parameters - The parameter values
queryHints - The tables that are queried (optional)
Returns:
The dyna beans resulting from the query
Throws:
DatabaseOperationException

fetch

List fetch(Database model,
           String sql,
           int start,
           int end)
           throws DatabaseOperationException
Queries for a list of dyna beans representing rows of the given query. In contrast to the query(Database, String) method all beans will be materialized and the connection will be closed before returning the beans. Also, the two int parameters specify which rows of the result set to use. If there are more rows than desired, they will be ignored (and not read from the database).

Parameters:
model - The database model to use
sql - The sql query
start - Row number to start from (0 for first row)
end - Row number to stop at (inclusively; -1 for last row)
Returns:
The dyna beans resulting from the query
Throws:
DatabaseOperationException

fetch

List fetch(Database model,
           String sql,
           Collection parameters,
           int start,
           int end)
           throws DatabaseOperationException
Queries for a list of dyna beans representing rows of the given query. In contrast to the query(Database, String, Collection) method all beans will be materialized and the connection will be closed before returning the beans. Also, the two int parameters specify which rows of the result set to use. If there are more rows than desired, they will be ignored (and not read from the database).

Parameters:
model - The database model to use
sql - The parameterized sql query
parameters - The parameter values
start - Row number to start from (0 for first row)
end - Row number to stop at (inclusively; -1 for last row)
Returns:
The dyna beans resulting from the query
Throws:
DatabaseOperationException

fetch

List fetch(Database model,
           String sql,
           Table[] queryHints,
           int start,
           int end)
           throws DatabaseOperationException
Queries for a list of dyna beans representing rows of the given query. In contrast to the query(Database, String, Table[]) method all beans will be materialized and the connection will be closed before returning the beans. Also, the two int parameters specify which rows of the result set to use. If there are more rows than desired, they will be ignored (and not read from the database).

Parameters:
model - The database model to use
sql - The sql query
queryHints - The tables that are queried (optional)
start - Row number to start from (0 for first row)
end - Row number to stop at (inclusively; -1 for last row)
Returns:
The dyna beans resulting from the query
Throws:
DatabaseOperationException

fetch

List fetch(Database model,
           String sql,
           Collection parameters,
           Table[] queryHints,
           int start,
           int end)
           throws DatabaseOperationException
Queries for a list of dyna beans representing rows of the given query. In contrast to the query(Database, String, Collection, Table[]) method all beans will be materialized and the connection will be closed before returning the beans. Also, the two int parameters specify which rows of the result set to use. If there are more rows than desired, they will be ignored (and not read from the database).

Parameters:
model - The database model to use
sql - The parameterized sql query
parameters - The parameter values
queryHints - The tables that are queried (optional)
start - Row number to start from (0 for first row)
end - Row number to stop at (inclusively; -1 for last row)
Returns:
The dyna beans resulting from the query
Throws:
DatabaseOperationException

store

void store(Database model,
           DynaBean dynaBean)
           throws DatabaseOperationException
Stores the given bean in the database, inserting it if there is no primary key otherwise the bean is updated in the database.

Parameters:
model - The database model to use
dynaBean - The bean to store
Throws:
DatabaseOperationException

getInsertSql

String getInsertSql(Database model,
                    DynaBean dynaBean)
Returns the sql for inserting the given bean.

Parameters:
model - The database model to use
dynaBean - The bean
Returns:
The insert sql

insert

void insert(Database model,
            DynaBean dynaBean)
            throws DatabaseOperationException
Inserts the given DynaBean in the database, assuming the primary key values are specified.

Parameters:
model - The database model to use
dynaBean - The bean to insert
Throws:
DatabaseOperationException

insert

void insert(Connection connection,
            Database model,
            DynaBean dynaBean)
            throws DatabaseOperationException
Inserts the bean. If one of the columns is an auto-incremented column, then the bean will also be updated with the column value generated by the database. Note that the connection will not be closed by this method.

Parameters:
connection - The database connection
model - The database model to use
dynaBean - The bean
Throws:
DatabaseOperationException

insert

void insert(Database model,
            Collection dynaBeans)
            throws DatabaseOperationException
Inserts the given beans in the database, assuming the primary key values are specified. Note that a batch insert is used for subsequent beans of the same type. Also the properties for the primary keys are not updated in the beans. Hence you should not use this method when the primary key values are defined by the database (via a sequence or identity constraint).

Parameters:
model - The database model to use
dynaBeans - The beans to insert
Throws:
DatabaseOperationException

insert

void insert(Connection connection,
            Database model,
            Collection dynaBeans)
            throws DatabaseOperationException
Inserts the given beans. Note that a batch insert is used for subsequent beans of the same type. Also the properties for the primary keys are not updated in the beans. Hence you should not use this method when the primary key values are defined by the database (via a sequence or identity constraint). This method does not close the connection.

Parameters:
connection - The database connection
model - The database model to use
dynaBeans - The beans
Throws:
DatabaseOperationException

getUpdateSql

String getUpdateSql(Database model,
                    DynaBean dynaBean)
Returns the sql for updating the given bean in the database.

Parameters:
model - The database model to use
dynaBean - The bean
Returns:
The update sql

update

void update(Database model,
            DynaBean dynaBean)
            throws DatabaseOperationException
Updates the given bean in the database, assuming the primary key values are specified.

Parameters:
model - The database model to use
dynaBean - The bean
Throws:
DatabaseOperationException

update

void update(Connection connection,
            Database model,
            DynaBean dynaBean)
            throws DatabaseOperationException
Updates the row which maps to the given bean.

Parameters:
connection - The database connection
model - The database model to use
dynaBean - The bean
Throws:
DatabaseOperationException

getDeleteSql

String getDeleteSql(Database model,
                    DynaBean dynaBean)
Returns the sql for deleting the given bean from the database.

Parameters:
model - The database model to use
dynaBean - The bean
Returns:
The sql

delete

void delete(Database model,
            DynaBean dynaBean)
            throws DatabaseOperationException
Deletes the given bean from the database, assuming the primary key values are specified.

Parameters:
model - The database model to use
dynaBean - The bean to delete
Throws:
DatabaseOperationException

delete

void delete(Connection connection,
            Database model,
            DynaBean dynaBean)
            throws DatabaseOperationException
Deletes the row which maps to the given bean from the database.

Parameters:
model - The database model to use
dynaBean - The bean
connection - The database connection
Throws:
DatabaseOperationException

readModelFromDatabase

Database readModelFromDatabase(String name)
                               throws DatabaseOperationException
Reads the database model from the live database as specified by the data source set for this platform.

Parameters:
name - The name of the resulting database; null when the default name (the catalog) is desired which might be null itself though
Returns:
The database model
Throws:
DatabaseOperationException - If an error occurred during reading the model

readModelFromDatabase

Database readModelFromDatabase(String name,
                               String catalog,
                               String schema,
                               String[] tableTypes)
                               throws DatabaseOperationException
Reads the database model from the live database as specified by the data source set for this platform.

Parameters:
name - The name of the resulting database; null when the default name (the catalog) is desired which might be null itself though
catalog - The catalog to access in the database; use null for the default value
schema - The schema to access in the database; use null for the default value
tableTypes - The table types to process; use null or an empty list for the default ones
Returns:
The database model
Throws:
DatabaseOperationException - If an error occurred during reading the model

readModelFromDatabase

Database readModelFromDatabase(Connection connection,
                               String name)
                               throws DatabaseOperationException
Reads the database model from the live database to which the given connection is pointing.

Parameters:
connection - The connection to the database
name - The name of the resulting database; null when the default name (the catalog) is desired which might be null itself though
Returns:
The database model
Throws:
DatabaseOperationException - If an error occurred during reading the model

readModelFromDatabase

Database readModelFromDatabase(Connection connection,
                               String name,
                               String catalog,
                               String schema,
                               String[] tableTypes)
                               throws DatabaseOperationException
Reads the database model from the live database to which the given connection is pointing.

Parameters:
connection - The connection to the database
name - The name of the resulting database; null when the default name (the catalog) is desired which might be null itself though
catalog - The catalog to access in the database; use null for the default value
schema - The schema to access in the database; use null for the default value
tableTypes - The table types to process; use null or an empty list for the default ones
Returns:
The database model
Throws:
DatabaseOperationException - If an error occurred during reading the model


Copyright © 2005-2007 Apache Software Foundation. All Rights Reserved.