org.apache.ddlutils
Interface Platform

All Known Implementing Classes:
PlatformImplBase

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 $
Author:
Thomas Dudziak

Method Summary
 void alterTables(Connection connection, Database desiredDb, boolean doDrops, boolean modifyColumns, boolean continueOnError)
          Alters the database schema so that it match the given model.
 void alterTables(Connection connection, Database desiredDb, CreationParameters params, boolean doDrops, boolean modifyColumns, 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 doDrops, boolean modifyColumns, 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 doDrops, boolean modifyColumns, boolean continueOnError)
          Alters the database schema so that it match the given model.
 void alterTables(Database desiredDb, boolean doDrops, boolean modifyColumns, boolean continueOnError)
          Alters the database schema so that it match the given model.
 void alterTables(Database desiredDb, CreationParameters params, boolean doDrops, boolean modifyColumns, boolean continueOnError)
          Alters the database schema so that it match the given model.
 void alterTables(String catalog, String schema, String[] tableTypes, Database desiredDb, boolean doDrops, boolean modifyColumns, 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 doDrops, boolean modifyColumns, 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 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, boolean doDrops, boolean modifyColumns, boolean continueOnError)
          Returns the SQL for altering the database schema so that it match the given model.
 String getAlterTablesSql(Connection connection, Database desiredDb, CreationParameters params, boolean doDrops, boolean modifyColumns, boolean continueOnError)
          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, boolean doDrops, boolean modifyColumns, boolean continueOnError)
          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, boolean doDrops, boolean modifyColumns, boolean continueOnError)
          Returns the SQL for altering the database schema so that it match the given model.
 String getAlterTablesSql(Database desiredDb, boolean doDrops, boolean modifyColumns, boolean continueOnError)
          Returns the SQL for altering the database schema so that it match the given model.
 String getAlterTablesSql(Database desiredDb, CreationParameters params, boolean doDrops, boolean modifyColumns, boolean continueOnError)
          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, boolean doDrops, boolean modifyColumns, boolean continueOnError)
          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, boolean doDrops, boolean modifyColumns, boolean continueOnError)
          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 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.
 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 setPassword(String password)
          Sets the password that this platform shall use to access the database.
 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

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

Returns:
The name

getPlatformInfo

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

Returns:
The info object

getSqlBuilder

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

Returns:
The sql builder

getModelReader

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

Returns:
The model reader

getDataSource

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

Returns:
The data source

setDataSource

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

Parameters:
dataSource - The data source

getUsername

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

Returns:
The username

setUsername

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

Parameters:
username - The username

getPassword

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

Returns:
The password

setPassword

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

Parameters:
password - The password

borrowConnection

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

Returns:
The connection
Throws:
DynaSqlException

returnConnection

public 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

public int evaluateBatch(String sql,
                         boolean continueOnError)
                  throws DynaSqlException
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:
DynaSqlException

evaluateBatch

public int evaluateBatch(Connection connection,
                         String sql,
                         boolean continueOnError)
                  throws DynaSqlException
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:
DynaSqlException

shutdownDatabase

public void shutdownDatabase()
                      throws DynaSqlException
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:
DynaSqlException

shutdownDatabase

public void shutdownDatabase(Connection connection)
                      throws DynaSqlException
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:
DynaSqlException

createDatabase

public void createDatabase(String jdbcDriverClassName,
                           String connectionUrl,
                           String username,
                           String password,
                           Map parameters)
                    throws DynaSqlException,
                           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:
DynaSqlException
UnsupportedOperationException

dropDatabase

public void dropDatabase(String jdbcDriverClassName,
                         String connectionUrl,
                         String username,
                         String password)
                  throws DynaSqlException,
                         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:
DynaSqlException
UnsupportedOperationException

createTables

public void createTables(Database model,
                         boolean dropTablesFirst,
                         boolean continueOnError)
                  throws DynaSqlException
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:
DynaSqlException

createTables

public void createTables(Connection connection,
                         Database model,
                         boolean dropTablesFirst,
                         boolean continueOnError)
                  throws DynaSqlException
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:
DynaSqlException

getCreateTablesSql

public String getCreateTablesSql(Database model,
                                 boolean dropTablesFirst,
                                 boolean continueOnError)
                          throws DynaSqlException
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
Throws:
DynaSqlException

createTables

public void createTables(Database model,
                         CreationParameters params,
                         boolean dropTablesFirst,
                         boolean continueOnError)
                  throws DynaSqlException
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:
DynaSqlException

createTables

public void createTables(Connection connection,
                         Database model,
                         CreationParameters params,
                         boolean dropTablesFirst,
                         boolean continueOnError)
                  throws DynaSqlException
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:
DynaSqlException

getCreateTablesSql

public String getCreateTablesSql(Database model,
                                 CreationParameters params,
                                 boolean dropTablesFirst,
                                 boolean continueOnError)
                          throws DynaSqlException
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
Throws:
DynaSqlException

alterTables

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

Parameters:
desiredDb - The desired database schema
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DynaSqlException

getAlterTablesSql

public String getAlterTablesSql(Database desiredDb,
                                boolean doDrops,
                                boolean modifyColumns,
                                boolean continueOnError)
                         throws DynaSqlException
Returns the SQL for altering the database schema so that it match the given model.

Parameters:
desiredDb - The desired database schema
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

alterTables

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

Parameters:
desiredDb - The desired database schema
params - The parameters used in the creation
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DynaSqlException

getAlterTablesSql

public String getAlterTablesSql(Database desiredDb,
                                CreationParameters params,
                                boolean doDrops,
                                boolean modifyColumns,
                                boolean continueOnError)
                         throws DynaSqlException
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
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

alterTables

public void alterTables(String catalog,
                        String schema,
                        String[] tableTypes,
                        Database desiredDb,
                        boolean doDrops,
                        boolean modifyColumns,
                        boolean continueOnError)
                 throws DynaSqlException
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
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DynaSqlException

getAlterTablesSql

public String getAlterTablesSql(String catalog,
                                String schema,
                                String[] tableTypes,
                                Database desiredDb,
                                boolean doDrops,
                                boolean modifyColumns,
                                boolean continueOnError)
                         throws DynaSqlException
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
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

alterTables

public void alterTables(String catalog,
                        String schema,
                        String[] tableTypes,
                        Database desiredDb,
                        CreationParameters params,
                        boolean doDrops,
                        boolean modifyColumns,
                        boolean continueOnError)
                 throws DynaSqlException
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
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DynaSqlException

getAlterTablesSql

public String getAlterTablesSql(String catalog,
                                String schema,
                                String[] tableTypes,
                                Database desiredDb,
                                CreationParameters params,
                                boolean doDrops,
                                boolean modifyColumns,
                                boolean continueOnError)
                         throws DynaSqlException
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
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

alterTables

public void alterTables(Connection connection,
                        Database desiredDb,
                        boolean doDrops,
                        boolean modifyColumns,
                        boolean continueOnError)
                 throws DynaSqlException
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
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DynaSqlException

getAlterTablesSql

public String getAlterTablesSql(Connection connection,
                                Database desiredDb,
                                boolean doDrops,
                                boolean modifyColumns,
                                boolean continueOnError)
                         throws DynaSqlException
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
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

alterTables

public void alterTables(Connection connection,
                        Database desiredDb,
                        CreationParameters params,
                        boolean doDrops,
                        boolean modifyColumns,
                        boolean continueOnError)
                 throws DynaSqlException
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
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DynaSqlException

getAlterTablesSql

public String getAlterTablesSql(Connection connection,
                                Database desiredDb,
                                CreationParameters params,
                                boolean doDrops,
                                boolean modifyColumns,
                                boolean continueOnError)
                         throws DynaSqlException
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
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

alterTables

public void alterTables(Connection connection,
                        String catalog,
                        String schema,
                        String[] tableTypes,
                        Database desiredDb,
                        boolean doDrops,
                        boolean modifyColumns,
                        boolean continueOnError)
                 throws DynaSqlException
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
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DynaSqlException

getAlterTablesSql

public String getAlterTablesSql(Connection connection,
                                String catalog,
                                String schema,
                                String[] tableTypes,
                                Database desiredDb,
                                boolean doDrops,
                                boolean modifyColumns,
                                boolean continueOnError)
                         throws DynaSqlException
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
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

alterTables

public void alterTables(Connection connection,
                        String catalog,
                        String schema,
                        String[] tableTypes,
                        Database desiredDb,
                        CreationParameters params,
                        boolean doDrops,
                        boolean modifyColumns,
                        boolean continueOnError)
                 throws DynaSqlException
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
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DynaSqlException

getAlterTablesSql

public String getAlterTablesSql(Connection connection,
                                String catalog,
                                String schema,
                                String[] tableTypes,
                                Database desiredDb,
                                CreationParameters params,
                                boolean doDrops,
                                boolean modifyColumns,
                                boolean continueOnError)
                         throws DynaSqlException
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
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

dropTables

public void dropTables(Database model,
                       boolean continueOnError)
                throws DynaSqlException
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:
DynaSqlException

getDropTablesSql

public String getDropTablesSql(Database model,
                               boolean continueOnError)
                        throws DynaSqlException
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
Throws:
DynaSqlException

dropTables

public void dropTables(Connection connection,
                       Database model,
                       boolean continueOnError)
                throws DynaSqlException
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:
DynaSqlException

query

public Iterator query(Database model,
                      String sql)
               throws DynaSqlException
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:
DynaSqlException

query

public Iterator query(Database model,
                      String sql,
                      Collection parameters)
               throws DynaSqlException
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:
DynaSqlException

query

public Iterator query(Database model,
                      String sql,
                      Table[] queryHints)
               throws DynaSqlException
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:
DynaSqlException

query

public Iterator query(Database model,
                      String sql,
                      Collection parameters,
                      Table[] queryHints)
               throws DynaSqlException
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:
DynaSqlException

fetch

public List fetch(Database model,
                  String sql)
           throws DynaSqlException
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:
DynaSqlException

fetch

public List fetch(Database model,
                  String sql,
                  Collection parameters)
           throws DynaSqlException
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:
DynaSqlException

fetch

public List fetch(Database model,
                  String sql,
                  Table[] queryHints)
           throws DynaSqlException
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:
DynaSqlException

fetch

public List fetch(Database model,
                  String sql,
                  Collection parameters,
                  Table[] queryHints)
           throws DynaSqlException
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:
DynaSqlException

fetch

public List fetch(Database model,
                  String sql,
                  int start,
                  int end)
           throws DynaSqlException
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:
DynaSqlException

fetch

public List fetch(Database model,
                  String sql,
                  Collection parameters,
                  int start,
                  int end)
           throws DynaSqlException
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:
DynaSqlException

fetch

public List fetch(Database model,
                  String sql,
                  Table[] queryHints,
                  int start,
                  int end)
           throws DynaSqlException
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:
DynaSqlException

fetch

public List fetch(Database model,
                  String sql,
                  Collection parameters,
                  Table[] queryHints,
                  int start,
                  int end)
           throws DynaSqlException
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:
DynaSqlException

store

public void store(Database model,
                  DynaBean dynaBean)
           throws DynaSqlException
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:
DynaSqlException

getInsertSql

public 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

public void insert(Database model,
                   DynaBean dynaBean)
            throws DynaSqlException
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:
DynaSqlException

insert

public void insert(Connection connection,
                   Database model,
                   DynaBean dynaBean)
            throws DynaSqlException
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:
DynaSqlException

insert

public void insert(Database model,
                   Collection dynaBeans)
            throws DynaSqlException
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:
DynaSqlException

insert

public void insert(Connection connection,
                   Database model,
                   Collection dynaBeans)
            throws DynaSqlException
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:
DynaSqlException

getUpdateSql

public 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

public void update(Database model,
                   DynaBean dynaBean)
            throws DynaSqlException
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:
DynaSqlException

update

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

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

getDeleteSql

public 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

public void delete(Database model,
                   DynaBean dynaBean)
            throws DynaSqlException
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:
DynaSqlException

delete

public void delete(Connection connection,
                   Database model,
                   DynaBean dynaBean)
            throws DynaSqlException
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:
DynaSqlException

readModelFromDatabase

public Database readModelFromDatabase(String name)
                               throws DynaSqlException
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:
DynaSqlException - If an error occurred during reading the model

readModelFromDatabase

public Database readModelFromDatabase(String name,
                                      String catalog,
                                      String schema,
                                      String[] tableTypes)
                               throws DynaSqlException
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:
DynaSqlException - If an error occurred during reading the model

readModelFromDatabase

public Database readModelFromDatabase(Connection connection,
                                      String name)
                               throws DynaSqlException
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:
DynaSqlException - If an error occurred during reading the model

readModelFromDatabase

public Database readModelFromDatabase(Connection connection,
                                      String name,
                                      String catalog,
                                      String schema,
                                      String[] tableTypes)
                               throws DynaSqlException
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:
DynaSqlException - If an error occurred during reading the model


Copyright © 2005 Apache Software Foundation. All Rights Reserved.