org.jboss.dna.common.jdbc.util
Class DatabaseUtil

java.lang.Object
  extended by org.jboss.dna.common.jdbc.util.DatabaseUtil

public class DatabaseUtil
extends Object

Database related utilities

Author:
Sergiy Litsenko

Method Summary
static BestRowIdentifierScopeType getBestRowIdentifierScopeType(Integer type)
          Returns BestRowIdentifierScopeType or null
static Boolean getBoolean(ResultSet resultSet, int columnIndex)
          Returns boolean with respect to NULL values (ResultSet.wasNull())
static Boolean getBoolean(ResultSet resultSet, int columnIndex, boolean failOnError)
          Returns boolean with respect to NULL values (ResultSet.wasNull())
static Boolean getBoolean(ResultSet resultSet, String columnName)
          Returns boolean with respect to NULL values (ResultSet.wasNull())
static Boolean getBoolean(ResultSet resultSet, String columnName, boolean failOnError)
          Returns boolean with respect to NULL values (ResultSet.wasNull())
static ColumnPseudoType getColumnPseudoType(Integer type)
          Returns ColumnPseudoType or null
static
<T> T
getDatabaseMetadataProperty(DatabaseMetaData instance, String methodName, Logger traceLog)
          Get simple database metadata for the getter method (no input parameters)
static Double getDouble(ResultSet resultSet, int columnIndex)
          Returns double with respect to NULL values (ResultSet.wasNull())
static Double getDouble(ResultSet resultSet, int columnIndex, boolean failOnError)
          Returns double with respect to NULL values (ResultSet.wasNull())
static Double getDouble(ResultSet resultSet, String columnName)
          Returns double with respect to NULL values (ResultSet.wasNull())
static Double getDouble(ResultSet resultSet, String columnName, boolean failOnError)
          Returns double with respect to NULL values (ResultSet.wasNull())
static IndexType getIndexType(Integer type)
          Returns IndexType or null
static Integer getInteger(ResultSet resultSet, int columnIndex)
          Returns integer with respect to NULL values (ResultSet.wasNull())
static Integer getInteger(ResultSet resultSet, int columnIndex, boolean failOnError)
          Returns integer with respect to NULL values (ResultSet.wasNull())
static Integer getInteger(ResultSet resultSet, String columnName)
          Returns integer with respect to NULL values (ResultSet.wasNull())
static Integer getInteger(ResultSet resultSet, String columnName, boolean failOnError)
          Returns integer with respect to NULL values (ResultSet.wasNull())
static KeyDeferrabilityType getKeyDeferrabilityType(Integer type)
          Returns KeyDeferrabilityType or null
static KeyModifyRuleType getKeyModifyRuleType(Integer type)
          Returns KeyModifyRuleType or null
static Long getLong(ResultSet resultSet, int columnIndex)
          Returns long with respect to NULL values (ResultSet.wasNull())
static Long getLong(ResultSet resultSet, int columnIndex, boolean failOnError)
          Returns long with respect to NULL values (ResultSet.wasNull())
static Long getLong(ResultSet resultSet, String columnName)
          Returns long with respect to NULL values (ResultSet.wasNull())
static Long getLong(ResultSet resultSet, String columnName, boolean failOnError)
          Returns long with respect to NULL values (ResultSet.wasNull())
static NullabilityType getNullabilityType(Integer type)
          Returns column nullability, or null
static ParameterIoType getParameterIoType(Integer type)
          Returns ParameterIoType based on type, or null
static PrivilegeType getPrivilegeType(String type)
          Returns PrivilegeType or null
static ResultSetConcurrencyType getResultSetConcurrencyType(Integer type)
          Returns ResultSetConcurrencyType or null
static ResultSetHoldabilityType getResultSetHoldabilityType(Integer type)
          Returns ResultSetHoldabilityType or null
static ResultSetType getResultSetType(Integer type)
          Returns ResultSetType or null
static SearchabilityType getSearchabilityType(Integer type)
          Returns SearchabilityType or null
static SortSequenceType getSortSequenceType(String type)
          Returns SortSequenceType or null
static SQLStateType getSqlStateType(Integer type)
          Returns SqlStateType based on type, or null
static SqlType getSqlType(Integer type)
          Returns SqlType based on data type, or null
static String getStandardUserDefinedTypes()
          Returns Standard UDT types as string
static StoredProcedureResultType getStoredProcedureResultType(Integer type)
          Returns SP result type based on PROCEDURE_TYPE
static String getString(ResultSet resultSet, int columnIndex)
          Returns String with respect to NULL values (ResultSet.wasNull())
static String getString(ResultSet resultSet, int columnIndex, boolean failOnError)
          Returns String with respect to NULL values (ResultSet.wasNull())
static String getString(ResultSet resultSet, String columnName)
          Returns String with respect to NULL values (ResultSet.wasNull())
static String getString(ResultSet resultSet, String columnName, boolean failOnError)
          Returns String with respect to NULL values (ResultSet.wasNull())
static TransactionIsolationLevelType getTransactionIsolationLevelType(Integer type)
          Returns transaction isolation level, or null
static int[] getUserDefinedTypes(String userDefinedTypes)
          Converts string array of UDT names to appropriate int array of UDT types specified in java.sql.Types
static BestRowIdentifier populateBestRowIdentifier(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database, Table table)
          Creates table best row identifier based on current record in result set; adds best row identifier to the table
static Catalog populateCatalog(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database)
          Creates catalog based on current record in result set; adds catalog to the database
static Set<ForeignKey> populateForeignKeys(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database, Table table)
          Creates table's foreign keys based on ALL records in result set; adds fk columns to the table's foreing key
static Set<Index> populateIndexes(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database, Table table)
          Creates table's indexes based on ALL records in result set; adds columns to the table's index
static PrimaryKey populatePrimaryKey(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database, Table table)
          Creates table's primary key based on ALL records in result set; adds pk columns to the table's primary key
static Schema populateSchema(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database)
          Creates schema based on current record in result set; adds schema to the database
static SqlTypeInfo populateSqlTypeInfo(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database)
          Creates SQL type info based on current record in result set; adds SQL type info to the database
static StoredProcedure populateStoredProcedure(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database)
          Creates stored procedure based on current record in result set; adds SP to the database
static Parameter populateStoredProcedureParameter(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database, StoredProcedure storedProcedure, int ordinalPosition)
          Creates stored procedure parameter based on current record in result set; adds SP parameter to the SP
static Table populateTable(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database)
          Creates table based on current record in result set; adds table to the database
static TableColumn populateTableColumn(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database, Table table)
          Creates table column based on current record in result set; adds column to the table
static Set<Privilege> populateTableColumnPrivileges(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database, Table table, TableColumn column)
          Creates table's column privileges based on ALL records in result set;
static Set<Privilege> populateTablePrivileges(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database, Table table)
          Creates table's privileges based on ALL records in result set;
static TableType populateTableType(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database)
          Creates table types based on current record in result set; adds table types to the database
static UserDefinedType populateUDT(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database)
          Creates UDT based on current record in result set; adds UDT to the database
static Attribute populateUDTAttribute(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database, UserDefinedType udt)
          Creates UDT attribute based on current record in result set; adds attribute to the UDT
static TableColumn populateVersionColumn(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database, Table table)
          Creates table's version column (if pseudo) based on current record in result set; adds column to the table
static void updateTableSuperTable(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database, Table table)
          Updates table super table info based on current record in result set
static void updateUDTSuperType(ModelFactory factory, ResultSet resultSet, Logger traceLog, boolean failOnError, Database database, UserDefinedType udt)
          Updates UDT super type info based on current record in result set
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getStandardUserDefinedTypes

public static String getStandardUserDefinedTypes()
Returns Standard UDT types as string

Returns:
Standard UDT types as string

getUserDefinedTypes

public static int[] getUserDefinedTypes(String userDefinedTypes)
Converts string array of UDT names to appropriate int array of UDT types specified in java.sql.Types

Parameters:
userDefinedTypes - the string array of UDT names
Returns:
int array of user defined types specified in java.sql.Types

getBoolean

public static Boolean getBoolean(ResultSet resultSet,
                                 String columnName)
                          throws SQLException
Returns boolean with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnName - the name of column
Returns:
boolean with respect to NULL values (could be null)
Throws:
SQLException

getBoolean

public static Boolean getBoolean(ResultSet resultSet,
                                 String columnName,
                                 boolean failOnError)
                          throws SQLException
Returns boolean with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnName - the name of column
failOnError - if true raises exception
Returns:
boolean with respect to NULL values (could be null)
Throws:
SQLException

getBoolean

public static Boolean getBoolean(ResultSet resultSet,
                                 int columnIndex)
                          throws SQLException
Returns boolean with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnIndex - the index of column
Returns:
boolean with respect to NULL values (could be null)
Throws:
SQLException

getBoolean

public static Boolean getBoolean(ResultSet resultSet,
                                 int columnIndex,
                                 boolean failOnError)
                          throws SQLException
Returns boolean with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnIndex - the index of column
failOnError - if true raises exception
Returns:
boolean with respect to NULL values (could be null)
Throws:
SQLException

getInteger

public static Integer getInteger(ResultSet resultSet,
                                 String columnName)
                          throws SQLException
Returns integer with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnName - the name of column
Returns:
integer with respect to NULL values (could be null)
Throws:
SQLException

getInteger

public static Integer getInteger(ResultSet resultSet,
                                 String columnName,
                                 boolean failOnError)
                          throws SQLException
Returns integer with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnName - the name of column
failOnError - if true raises exception
Returns:
integer with respect to NULL values (could be null)
Throws:
SQLException

getInteger

public static Integer getInteger(ResultSet resultSet,
                                 int columnIndex)
                          throws SQLException
Returns integer with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnIndex - the index of column
Returns:
integer with respect to NULL values (could be null)
Throws:
SQLException

getInteger

public static Integer getInteger(ResultSet resultSet,
                                 int columnIndex,
                                 boolean failOnError)
                          throws SQLException
Returns integer with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnIndex - the index of column
failOnError - if true raises exception
Returns:
integer with respect to NULL values (could be null)
Throws:
SQLException

getLong

public static Long getLong(ResultSet resultSet,
                           String columnName)
                    throws SQLException
Returns long with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnName - the name of column
Returns:
long with respect to NULL values (could be null)
Throws:
SQLException

getLong

public static Long getLong(ResultSet resultSet,
                           String columnName,
                           boolean failOnError)
                    throws SQLException
Returns long with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnName - the name of column
failOnError - if true raises exception
Returns:
long with respect to NULL values (could be null)
Throws:
SQLException

getLong

public static Long getLong(ResultSet resultSet,
                           int columnIndex)
                    throws SQLException
Returns long with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnIndex - the index of column
Returns:
long with respect to NULL values (could be null)
Throws:
SQLException

getLong

public static Long getLong(ResultSet resultSet,
                           int columnIndex,
                           boolean failOnError)
                    throws SQLException
Returns long with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnIndex - the index of column
failOnError - if true raises exception
Returns:
long with respect to NULL values (could be null)
Throws:
SQLException

getDouble

public static Double getDouble(ResultSet resultSet,
                               String columnName)
                        throws SQLException
Returns double with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnName - the name of column
Returns:
double with respect to NULL values (could be null)
Throws:
SQLException

getDouble

public static Double getDouble(ResultSet resultSet,
                               String columnName,
                               boolean failOnError)
                        throws SQLException
Returns double with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnName - the name of column
failOnError - if true raises exception
Returns:
double with respect to NULL values (could be null)
Throws:
SQLException

getDouble

public static Double getDouble(ResultSet resultSet,
                               int columnIndex)
                        throws SQLException
Returns double with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnIndex - the index of column
Returns:
double with respect to NULL values (could be null)
Throws:
SQLException

getDouble

public static Double getDouble(ResultSet resultSet,
                               int columnIndex,
                               boolean failOnError)
                        throws SQLException
Returns double with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnIndex - the index of column
failOnError - if true raises exception
Returns:
double with respect to NULL values (could be null)
Throws:
SQLException

getString

public static String getString(ResultSet resultSet,
                               String columnName)
                        throws SQLException
Returns String with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnName - the name of column
Returns:
double with respect to NULL values (could be null)
Throws:
SQLException

getString

public static String getString(ResultSet resultSet,
                               String columnName,
                               boolean failOnError)
                        throws SQLException
Returns String with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnName - the name of column
failOnError - if true raises exception
Returns:
double with respect to NULL values (could be null)
Throws:
SQLException

getString

public static String getString(ResultSet resultSet,
                               int columnIndex)
                        throws SQLException
Returns String with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnIndex - the index of column
Returns:
double with respect to NULL values (could be null)
Throws:
SQLException

getString

public static String getString(ResultSet resultSet,
                               int columnIndex,
                               boolean failOnError)
                        throws SQLException
Returns String with respect to NULL values (ResultSet.wasNull())

Parameters:
resultSet - the result set to fetch from
columnIndex - the index of column
failOnError - if true raises exception
Returns:
double with respect to NULL values (could be null)
Throws:
SQLException

getBestRowIdentifierScopeType

public static BestRowIdentifierScopeType getBestRowIdentifierScopeType(Integer type)
Returns BestRowIdentifierScopeType or null

Parameters:
type - the best row identifier
Returns:
BestRowIdentifierScopeType or null

getColumnPseudoType

public static ColumnPseudoType getColumnPseudoType(Integer type)
Returns ColumnPseudoType or null

Parameters:
type - the column pseudo type
Returns:
ColumnPseudoType or null

getIndexType

public static IndexType getIndexType(Integer type)
Returns IndexType or null

Parameters:
type - the index type
Returns:
IndexType or null

getKeyDeferrabilityType

public static KeyDeferrabilityType getKeyDeferrabilityType(Integer type)
Returns KeyDeferrabilityType or null

Parameters:
type - the key defferability type
Returns:
KeyDeferrabilityType or null

getKeyModifyRuleType

public static KeyModifyRuleType getKeyModifyRuleType(Integer type)
Returns KeyModifyRuleType or null

Parameters:
type - the key modify rule type
Returns:
KeyModifyRuleType or null

getNullabilityType

public static NullabilityType getNullabilityType(Integer type)
Returns column nullability, or null

Parameters:
type -
Returns:
NullabilityType

getParameterIoType

public static ParameterIoType getParameterIoType(Integer type)
Returns ParameterIoType based on type, or null

Parameters:
type - i/o type
Returns:
ParameterIoType based on type, or null

getPrivilegeType

public static PrivilegeType getPrivilegeType(String type)
Returns PrivilegeType or null

Parameters:
type - the privilege type
Returns:
PrivilegeType or null

getResultSetConcurrencyType

public static ResultSetConcurrencyType getResultSetConcurrencyType(Integer type)
Returns ResultSetConcurrencyType or null

Parameters:
type - the concurrency
Returns:
ResultSetConcurrencyType or null

getResultSetHoldabilityType

public static ResultSetHoldabilityType getResultSetHoldabilityType(Integer type)
Returns ResultSetHoldabilityType or null

Parameters:
type - the holdability
Returns:
ResultSetHoldabilityType or null

getResultSetType

public static ResultSetType getResultSetType(Integer type)
Returns ResultSetType or null

Parameters:
type - the result set type
Returns:
ResultSetType or null

getSearchabilityType

public static SearchabilityType getSearchabilityType(Integer type)
Returns SearchabilityType or null

Parameters:
type - the searchability
Returns:
SearchabilityType or null

getSortSequenceType

public static SortSequenceType getSortSequenceType(String type)
Returns SortSequenceType or null

Parameters:
type - the sort sequence
Returns:
SortSequenceType or null

getSqlStateType

public static SQLStateType getSqlStateType(Integer type)
Returns SqlStateType based on type, or null

Parameters:
type - the SQL state type
Returns:
SqlStateType based on type, or null

getSqlType

public static SqlType getSqlType(Integer type)
Returns SqlType based on data type, or null

Parameters:
type - the SQL type
Returns:
SqlType based on data type, or null

getStoredProcedureResultType

public static StoredProcedureResultType getStoredProcedureResultType(Integer type)
Returns SP result type based on PROCEDURE_TYPE

Parameters:
type - the stored procedure result type
Returns:
SP result type based on PROCEDURE_TYPE, or null

getTransactionIsolationLevelType

public static TransactionIsolationLevelType getTransactionIsolationLevelType(Integer type)
Returns transaction isolation level, or null

Parameters:
type - the level type
Returns:
transaction isolation level, or null

populateCatalog

public static Catalog populateCatalog(ModelFactory factory,
                                      ResultSet resultSet,
                                      Logger traceLog,
                                      boolean failOnError,
                                      Database database)
                               throws Exception
Creates catalog based on current record in result set; adds catalog to the database

Parameters:
factory - the model factory to create table
resultSet - the table result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
Returns:
created catalog
Throws:
Exception - if any error occurs and failOnError is true then generates exception

populateSchema

public static Schema populateSchema(ModelFactory factory,
                                    ResultSet resultSet,
                                    Logger traceLog,
                                    boolean failOnError,
                                    Database database)
                             throws Exception
Creates schema based on current record in result set; adds schema to the database

Parameters:
factory - the model factory to create table
resultSet - the table result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
Returns:
created schema
Throws:
Exception - if any error occurs and failOnError is true then generates exception

populateTableType

public static TableType populateTableType(ModelFactory factory,
                                          ResultSet resultSet,
                                          Logger traceLog,
                                          boolean failOnError,
                                          Database database)
                                   throws Exception
Creates table types based on current record in result set; adds table types to the database

Parameters:
factory - the model factory to create table
resultSet - the table result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
Returns:
created schema
Throws:
Exception - if any error occurs and failOnError is true then generates exception

populateStoredProcedure

public static StoredProcedure populateStoredProcedure(ModelFactory factory,
                                                      ResultSet resultSet,
                                                      Logger traceLog,
                                                      boolean failOnError,
                                                      Database database)
                                               throws Exception
Creates stored procedure based on current record in result set; adds SP to the database

Parameters:
factory - the model factory to create SP
resultSet - the stored procedure result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
Returns:
created SP
Throws:
Exception - if any error occurs and failOnError is true then generates exception

populateStoredProcedureParameter

public static Parameter populateStoredProcedureParameter(ModelFactory factory,
                                                         ResultSet resultSet,
                                                         Logger traceLog,
                                                         boolean failOnError,
                                                         Database database,
                                                         StoredProcedure storedProcedure,
                                                         int ordinalPosition)
                                                  throws Exception
Creates stored procedure parameter based on current record in result set; adds SP parameter to the SP

Parameters:
factory - the model factory to create SP parameter
resultSet - the stored procedure parameter result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
storedProcedure - the owner stored procedure
ordinalPosition - the parameter ordinal position
Returns:
created SP parameter
Throws:
Exception - if any error occurs and failOnError is true then generates exception

populateTable

public static Table populateTable(ModelFactory factory,
                                  ResultSet resultSet,
                                  Logger traceLog,
                                  boolean failOnError,
                                  Database database)
                           throws Exception
Creates table based on current record in result set; adds table to the database

Parameters:
factory - the model factory to create table
resultSet - the table result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
Returns:
created table
Throws:
Exception - if any error occurs and failOnError is true then generates exception

populateTableColumn

public static TableColumn populateTableColumn(ModelFactory factory,
                                              ResultSet resultSet,
                                              Logger traceLog,
                                              boolean failOnError,
                                              Database database,
                                              Table table)
                                       throws Exception
Creates table column based on current record in result set; adds column to the table

Parameters:
factory - the model factory to create SP parameter
resultSet - the stored procedure parameter result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
table - the owner table
Returns:
created table column
Throws:
Exception - if any error occurs and failOnError is true then generates exception

populateBestRowIdentifier

public static BestRowIdentifier populateBestRowIdentifier(ModelFactory factory,
                                                          ResultSet resultSet,
                                                          Logger traceLog,
                                                          boolean failOnError,
                                                          Database database,
                                                          Table table)
                                                   throws Exception
Creates table best row identifier based on current record in result set; adds best row identifier to the table

Parameters:
factory - the model factory to create SP parameter
resultSet - the stored procedure parameter result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
table - the owner table
Returns:
created table best row identifier
Throws:
Exception - if any error occurs and failOnError is true then generates exception

populatePrimaryKey

public static PrimaryKey populatePrimaryKey(ModelFactory factory,
                                            ResultSet resultSet,
                                            Logger traceLog,
                                            boolean failOnError,
                                            Database database,
                                            Table table)
                                     throws Exception
Creates table's primary key based on ALL records in result set; adds pk columns to the table's primary key

Parameters:
factory - the model factory to create SP parameter
resultSet - the stored procedure parameter result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
table - the owner table
Returns:
created primary key
Throws:
Exception - if any error occurs and failOnError is true then generates exception

populateForeignKeys

public static Set<ForeignKey> populateForeignKeys(ModelFactory factory,
                                                  ResultSet resultSet,
                                                  Logger traceLog,
                                                  boolean failOnError,
                                                  Database database,
                                                  Table table)
                                           throws Exception
Creates table's foreign keys based on ALL records in result set; adds fk columns to the table's foreing key

Parameters:
factory - the model factory to create SP parameter
resultSet - the stored procedure parameter result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
table - the owner table
Returns:
created list of foreign keys
Throws:
Exception - if any error occurs and failOnError is true then generates exception

populateIndexes

public static Set<Index> populateIndexes(ModelFactory factory,
                                         ResultSet resultSet,
                                         Logger traceLog,
                                         boolean failOnError,
                                         Database database,
                                         Table table)
                                  throws Exception
Creates table's indexes based on ALL records in result set; adds columns to the table's index

Parameters:
factory - the model factory to create SP parameter
resultSet - the stored procedure parameter result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
table - the owner table
Returns:
created list of index
Throws:
Exception - if any error occurs and failOnError is true then generates exception

populateVersionColumn

public static TableColumn populateVersionColumn(ModelFactory factory,
                                                ResultSet resultSet,
                                                Logger traceLog,
                                                boolean failOnError,
                                                Database database,
                                                Table table)
                                         throws Exception
Creates table's version column (if pseudo) based on current record in result set; adds column to the table

Parameters:
factory - the model factory to create SP parameter
resultSet - the stored procedure parameter result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
table - the owner table
Returns:
created/updated version table column
Throws:
Exception - if any error occurs and failOnError is true then generates exception

populateTablePrivileges

public static Set<Privilege> populateTablePrivileges(ModelFactory factory,
                                                     ResultSet resultSet,
                                                     Logger traceLog,
                                                     boolean failOnError,
                                                     Database database,
                                                     Table table)
                                              throws Exception
Creates table's privileges based on ALL records in result set;

Parameters:
factory - the model factory to create SP parameter
resultSet - the stored procedure parameter result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
table - the owner table
Returns:
created list of privileges
Throws:
Exception - if any error occurs and failOnError is true then generates exception

populateTableColumnPrivileges

public static Set<Privilege> populateTableColumnPrivileges(ModelFactory factory,
                                                           ResultSet resultSet,
                                                           Logger traceLog,
                                                           boolean failOnError,
                                                           Database database,
                                                           Table table,
                                                           TableColumn column)
                                                    throws Exception
Creates table's column privileges based on ALL records in result set;

Parameters:
factory - the model factory to create SP parameter
resultSet - the stored procedure parameter result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
table - the owner table
column - the table column
Returns:
created list of privileges
Throws:
Exception - if any error occurs and failOnError is true then generates exception

populateSqlTypeInfo

public static SqlTypeInfo populateSqlTypeInfo(ModelFactory factory,
                                              ResultSet resultSet,
                                              Logger traceLog,
                                              boolean failOnError,
                                              Database database)
                                       throws Exception
Creates SQL type info based on current record in result set; adds SQL type info to the database

Parameters:
factory - the model factory to create table
resultSet - the table result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
Returns:
created SQL type info
Throws:
Exception - if any error occurs and failOnError is true then generates exception

populateUDT

public static UserDefinedType populateUDT(ModelFactory factory,
                                          ResultSet resultSet,
                                          Logger traceLog,
                                          boolean failOnError,
                                          Database database)
                                   throws Exception
Creates UDT based on current record in result set; adds UDT to the database

Parameters:
factory - the model factory to create table
resultSet - the table result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
Returns:
created UDT
Throws:
Exception - if any error occurs and failOnError is true then generates exception

populateUDTAttribute

public static Attribute populateUDTAttribute(ModelFactory factory,
                                             ResultSet resultSet,
                                             Logger traceLog,
                                             boolean failOnError,
                                             Database database,
                                             UserDefinedType udt)
                                      throws Exception
Creates UDT attribute based on current record in result set; adds attribute to the UDT

Parameters:
factory - the model factory to create SP parameter
resultSet - the stored procedure parameter result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
udt - the owner UDT
Returns:
created UDT attribute
Throws:
Exception - if any error occurs and failOnError is true then generates exception

updateUDTSuperType

public static void updateUDTSuperType(ModelFactory factory,
                                      ResultSet resultSet,
                                      Logger traceLog,
                                      boolean failOnError,
                                      Database database,
                                      UserDefinedType udt)
                               throws Exception
Updates UDT super type info based on current record in result set

Parameters:
factory - the model factory to create SP parameter
resultSet - the stored procedure parameter result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
udt - the UDT to update
Throws:
Exception - if any error occurs and failOnError is true then generates exception

updateTableSuperTable

public static void updateTableSuperTable(ModelFactory factory,
                                         ResultSet resultSet,
                                         Logger traceLog,
                                         boolean failOnError,
                                         Database database,
                                         Table table)
                                  throws Exception
Updates table super table info based on current record in result set

Parameters:
factory - the model factory to create SP parameter
resultSet - the stored procedure parameter result set from DatabaseMetadata
traceLog - the log to write if any
failOnError -
database - the owner database
table - the table to update
Throws:
Exception - if any error occurs and failOnError is true then generates exception

getDatabaseMetadataProperty

public static <T> T getDatabaseMetadataProperty(DatabaseMetaData instance,
                                                String methodName,
                                                Logger traceLog)
Get simple database metadata for the getter method (no input parameters)

Type Parameters:
T - the return type
Parameters:
instance - the instance of database metadata implementation
methodName - the full name of a getter method to execute
traceLog - the log
Returns:
simple database metadata for the getter method


Copyright © 2008-Present JBoss a division of Red Hat. All Rights Reserved.