Ontimize 5.2071EN

com.ontimize.db.sql
Class AbstractSQLHandler

java.lang.Object
  extended bycom.ontimize.db.sql.AbstractSQLHandler
All Implemented Interfaces:
SQLHandler
Direct Known Subclasses:
AccessSQLHandler, HSQLDBSQLHandler, MySQLSQLHandler, OracleSQLHandler, PostgreSQLHandler, SQLServerSQLHandler

public abstract class AbstractSQLHandler
extends java.lang.Object
implements SQLHandler


Field Summary
protected static java.lang.String ADD
           
protected static java.lang.String ALTER_TABLE
           
protected static java.lang.String COLUMN
           
protected static java.lang.String CREATE_TABLE
           
static boolean DEBUG
           
protected static java.lang.String DEFAULT
           
protected static java.lang.String DROP
           
protected static java.lang.String DROP_TABLE
           
protected static java.lang.String NOT_NULL
           
 
Fields inherited from interface com.ontimize.db.sql.SQLHandler
CLOSE_PARENTHESIS, OPEN_PARENTHESIS
 
Constructor Summary
AbstractSQLHandler()
           
 
Method Summary
 ISQLInfo alterSQLTable(java.util.List sqlTables, java.sql.Connection connection)
          This method alters a database table.
 java.lang.String alterSQLTable(SQLTableAlter table, java.sql.Connection connection)
          Alter the table in the database using ANSI standard
 ISQLInfo alterSQLTableTransactional(java.util.List sqlTables, java.sql.Connection connection)
          This method alters a database table in transactional mode.
 ISQLInfo createSQLTable(java.util.List sqlTables, java.sql.Connection connection)
          This method creates a database table.
 java.lang.String createSQLTable(SQLTableCreation table, java.sql.Connection connection)
          Creates the table in the database using ANSI standard
 ISQLInfo createSQLTableTransactional(java.util.List sqlTables, java.sql.Connection connection)
          This method creates a database table in transactional mode.
 java.lang.String createStatementAlterTable(SQLTableAlter table)
          Return the SQL Statement to alter the table.
 java.lang.String createStatementCreateTable(SQLTableCreation table)
          Return the SQL Statement to create the table.
 java.lang.String createStatementDropTable(SQLTableDrop table)
          Return the SQL Statement to drop the table.
 ISQLInfo dropSQLTable(java.util.List sqlTables, java.sql.Connection connection)
          This method drops a database table.
 java.lang.String dropSQLTable(SQLTableDrop table, java.sql.Connection connection)
          Drop the table in the database using ANSI standard
 ISQLInfo dropSQLTableTransactional(java.util.List sqlTables, java.sql.Connection connection)
          This method drops a database table in transactional mode.
protected static void executeSQL(java.lang.String sql, java.sql.Connection con)
          Execute the SQL Statement.
 ISQLInfo executeSQLTable(java.util.List sqlTables, java.sql.Connection connection)
          This method executes a serial of SQL actions(create,drop or alter) over a database table.
 ISQLInfo executeSQLTableTransactional(java.util.List sqlTables, java.sql.Connection connection)
          This method executes a serial of SQL actions(create,drop or alter) over a database table in transactional mode.
 java.lang.String executeStatement(java.lang.String statement, java.sql.Connection connection)
           
 java.lang.String getCreateStatementAlterTableColumn(SQLTableAlterColumn table)
           
 java.lang.String getCreateStatementAlterTableConstraint(SQLTableAlterConstraint table)
           
protected  java.lang.String getDefinitionColumn(SQLColumn column, boolean includePrimaryKey)
           
protected  java.lang.String getStringDefaultValue(java.lang.Object value, SQLColumn column)
           
 java.lang.String isMultiplePrimaryKey(SQLTableCreation table)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ontimize.db.sql.SQLHandler
getSQLTypeName
 

Field Detail

DEBUG

public static boolean DEBUG

CREATE_TABLE

protected static final java.lang.String CREATE_TABLE
See Also:
Constant Field Values

DROP_TABLE

protected static final java.lang.String DROP_TABLE
See Also:
Constant Field Values

ALTER_TABLE

protected static final java.lang.String ALTER_TABLE
See Also:
Constant Field Values

DEFAULT

protected static final java.lang.String DEFAULT
See Also:
Constant Field Values

NOT_NULL

protected static final java.lang.String NOT_NULL
See Also:
Constant Field Values

ADD

protected static final java.lang.String ADD
See Also:
Constant Field Values

DROP

protected static final java.lang.String DROP
See Also:
Constant Field Values

COLUMN

protected static final java.lang.String COLUMN
See Also:
Constant Field Values
Constructor Detail

AbstractSQLHandler

public AbstractSQLHandler()
Method Detail

executeSQLTable

public ISQLInfo executeSQLTable(java.util.List sqlTables,
                                java.sql.Connection connection)
Description copied from interface: SQLHandler
This method executes a serial of SQL actions(create,drop or alter) over a database table. At first, autocommit mode in connection is fixed to false, then its SQL statements are grouped into transactions that are terminated by a call to either the method commit or the method rollback. Moreover, Exceptions are also managed by this method.

Call diagram of this method:

-connection.setAutoCommit(false);
...
...
-executeSQLTableTransactional
...
...
-connection.setAutoCommit(true);

Specified by:
executeSQLTable in interface SQLHandler
Parameters:
sqlTables - list with all sqlTables
connection - the connection

executeSQLTableTransactional

public ISQLInfo executeSQLTableTransactional(java.util.List sqlTables,
                                             java.sql.Connection connection)
                                      throws java.lang.Exception
Description copied from interface: SQLHandler
This method executes a serial of SQL actions(create,drop or alter) over a database table in transactional mode.

Specified by:
executeSQLTableTransactional in interface SQLHandler
Parameters:
sqlTables - list with all sqlTables
connection - the connection
Throws:
java.lang.Exception

createSQLTable

public ISQLInfo createSQLTable(java.util.List sqlTables,
                               java.sql.Connection connection)
Description copied from interface: SQLHandler
This method creates a database table. At first, autocommit mode in connection is fixed to false, then its SQL statements are grouped into transactions that are terminated by a call to either the method commit or the method rollback. Moreover, Exceptions are also managed by this method.

Call diagram of this method:

-connection.setAutoCommit(false);
...
...
-createSQLTableTransactional
...
...
-connection.setAutoCommit(true);

Specified by:
createSQLTable in interface SQLHandler
Parameters:
sqlTables - list with all sqlTables
connection - the connection

dropSQLTable

public ISQLInfo dropSQLTable(java.util.List sqlTables,
                             java.sql.Connection connection)
Description copied from interface: SQLHandler
This method drops a database table. At first, autocommit mode in connection is fixed to false, then its SQL statements are grouped into transactions that are terminated by a call to either the method commit or the method rollback. Moreover, Exceptions are also managed by this method.

Call diagram of this method:

-connection.setAutoCommit(false);
...
...
-dropSQLTableTransactional
...
...
-connection.setAutoCommit(true);

Specified by:
dropSQLTable in interface SQLHandler
Parameters:
sqlTables - list with all sqlTables
connection - the connection

alterSQLTable

public ISQLInfo alterSQLTable(java.util.List sqlTables,
                              java.sql.Connection connection)
Description copied from interface: SQLHandler
This method alters a database table. At first, autocommit mode in connection is fixed to false, then its SQL statements are grouped into transactions that are terminated by a call to either the method commit or the method rollback. Moreover, Exceptions are also managed by this method.

Call diagram of this method:

-connection.setAutoCommit(false);
...
...
-alterSQLTableTransactional
...
...
-connection.setAutoCommit(true);

Specified by:
alterSQLTable in interface SQLHandler
Parameters:
sqlTables - list with all sqlTables
connection - the connection

createSQLTableTransactional

public ISQLInfo createSQLTableTransactional(java.util.List sqlTables,
                                            java.sql.Connection connection)
                                     throws java.lang.Exception
Description copied from interface: SQLHandler
This method creates a database table in transactional mode.

Call diagram of this method:

-execute sql to create all tables

Specified by:
createSQLTableTransactional in interface SQLHandler
Parameters:
sqlTables - list with all sqlTables
connection - the connection
Throws:
java.lang.Exception

dropSQLTableTransactional

public ISQLInfo dropSQLTableTransactional(java.util.List sqlTables,
                                          java.sql.Connection connection)
                                   throws java.lang.Exception
Description copied from interface: SQLHandler
This method drops a database table in transactional mode.

Call diagram of this method:

-execute sql to drop all tables

Specified by:
dropSQLTableTransactional in interface SQLHandler
Parameters:
sqlTables - list with all sqlTables
connection - the connection
Throws:
java.lang.Exception

alterSQLTableTransactional

public ISQLInfo alterSQLTableTransactional(java.util.List sqlTables,
                                           java.sql.Connection connection)
                                    throws java.lang.Exception
Description copied from interface: SQLHandler
This method alters a database table in transactional mode.

Call diagram of this method:

-execute sql to alter all tables

Specified by:
alterSQLTableTransactional in interface SQLHandler
Parameters:
sqlTables - list with all sqlTables
connection - the connection
Throws:
java.lang.Exception

executeSQL

protected static void executeSQL(java.lang.String sql,
                                 java.sql.Connection con)
                          throws java.lang.Exception
Execute the SQL Statement.

Parameters:
sql - String which contains the SQL Statement.
con - The connection.
Throws:
java.lang.Exception

createSQLTable

public java.lang.String createSQLTable(SQLTableCreation table,
                                       java.sql.Connection connection)
                                throws java.lang.Exception
Creates the table in the database using ANSI standard

Parameters:
table -
connection -
Throws:
java.lang.Exception

dropSQLTable

public java.lang.String dropSQLTable(SQLTableDrop table,
                                     java.sql.Connection connection)
                              throws java.lang.Exception
Drop the table in the database using ANSI standard

Parameters:
table -
connection -
Throws:
java.lang.Exception

alterSQLTable

public java.lang.String alterSQLTable(SQLTableAlter table,
                                      java.sql.Connection connection)
                               throws java.lang.Exception
Alter the table in the database using ANSI standard

Parameters:
table -
connection -
Throws:
java.lang.Exception

executeStatement

public java.lang.String executeStatement(java.lang.String statement,
                                         java.sql.Connection connection)
                                  throws java.lang.Exception
Throws:
java.lang.Exception

createStatementCreateTable

public java.lang.String createStatementCreateTable(SQLTableCreation table)
                                            throws java.lang.Exception
Description copied from interface: SQLHandler
Return the SQL Statement to create the table.

Specified by:
createStatementCreateTable in interface SQLHandler
Parameters:
table - The SQLTableCreation table with whole information to create it.
Returns:
a String with the SQL statement
Throws:
java.lang.Exception

getDefinitionColumn

protected java.lang.String getDefinitionColumn(SQLColumn column,
                                               boolean includePrimaryKey)
                                        throws java.lang.Exception
Throws:
java.lang.Exception

getStringDefaultValue

protected java.lang.String getStringDefaultValue(java.lang.Object value,
                                                 SQLColumn column)

isMultiplePrimaryKey

public java.lang.String isMultiplePrimaryKey(SQLTableCreation table)

createStatementDropTable

public java.lang.String createStatementDropTable(SQLTableDrop table)
                                          throws java.lang.Exception
Description copied from interface: SQLHandler
Return the SQL Statement to drop the table.

Specified by:
createStatementDropTable in interface SQLHandler
Parameters:
table - The SQLTableDrop table with whole information to drop it.
Returns:
a String with the SQL statement
Throws:
java.lang.Exception

createStatementAlterTable

public java.lang.String createStatementAlterTable(SQLTableAlter table)
                                           throws java.lang.Exception
Description copied from interface: SQLHandler
Return the SQL Statement to alter the table.

Specified by:
createStatementAlterTable in interface SQLHandler
Parameters:
table - The SQLTableAlter table with whole information to alter it.
Returns:
a String with the SQL statement
Throws:
java.lang.Exception

getCreateStatementAlterTableColumn

public java.lang.String getCreateStatementAlterTableColumn(SQLTableAlterColumn table)
                                                    throws java.lang.Exception
Throws:
java.lang.Exception

getCreateStatementAlterTableConstraint

public java.lang.String getCreateStatementAlterTableConstraint(SQLTableAlterConstraint table)
                                                        throws java.lang.Exception
Throws:
java.lang.Exception

Ontimize