org.opengts.dbtools
Class DBProvider

java.lang.Object
  extended by org.opengts.dbtools.DBProvider

public class DBProvider
extends java.lang.Object

DBProvider specifies SQL database provider specific attributes.


Field Summary
static int[] DATATYPE_ARRAY
           
static int DATATYPE_BINARY
           
static int DATATYPE_BOOLEAN
           
static int DATATYPE_DATETIME
           
static int DATATYPE_DECIMAL
           
static int DATATYPE_NONE
           
static int DATATYPE_NUMERIC
           
static int DATATYPE_SIGNED
           
static int DATATYPE_STRING
           
static int DATATYPE_UNSIGNED
           
static int DB_DERBY
           
static int DB_MARIADB
           
static int DB_MYSQL
           
static int DB_ORACLEXE
           
static int DB_POSTGRESQL
           
static int DB_SQLSERVER
           
static java.lang.String DEFAULT_ALT_INDEX_NAME
           
static java.lang.String Derby_Name
           
protected static DBProvider Derby_Provider
           
static long FLAGS_LIMIT
           
static long FLAGS_NONE
           
static long FLAGS_OFFSET
           
static java.lang.String LIKE_WILDCARD
           
static java.lang.String MariaDB_Name
           
protected static DBProvider MariaDB_Provider
           
static java.lang.String MS_SQLServer_Name
           
protected static DBProvider MS_SQLServer_Provider
           
static java.lang.String MySQL_InnoDB_Name
           
protected static DBProvider MySQL_InnoDB_Provider
           
static java.lang.String MySQL_MyISAM_Name
           
protected static DBProvider MySQL_MyISAM_Provider
           
static java.lang.String MySQL_Old_Name
           
protected static DBProvider MySQL_Old_Provider
           
static java.lang.String Oracle_XE_Name
           
protected static DBProvider Oracle_XE_Provider
           
static java.lang.String PostgreSQL_Name
           
static java.lang.String PostgreSQL_Name_old
           
protected static DBProvider PostgreSQL_Provider
           
protected static DBProvider PostgreSQL_Provider_old
           
static java.lang.String PRIMARY_INDEX_NAME
           
static int SQL_BLOB
           
static int SQL_BOOLEAN
           
static int SQL_DATETIME
           
static int SQL_DOUBLE
           
static int SQL_FLOAT
           
static int SQL_INT16
           
static int SQL_INT32
           
static int SQL_INT64
           
static int SQL_INT8
           
static int SQL_MBLOB
           
static int SQL_SBLOB
           
static int SQL_TEXT
           
static int SQL_UINT16
           
static int SQL_UINT32
           
static int SQL_UINT64
           
static int SQL_UINT8
           
static int SQL_UNKNOWN
           
static int SQL_VARCHAR
           
static java.lang.String[] TYPE_ARRAY
           
static java.lang.String TYPE_BLOB
           
static java.lang.String TYPE_BOOLEAN
           
static java.lang.String TYPE_DATETIME
           
static java.lang.String TYPE_DOUBLE
           
static java.lang.String TYPE_FLOAT
           
static java.lang.String TYPE_INT16
           
static java.lang.String TYPE_INT32
           
static java.lang.String TYPE_INT64
           
static java.lang.String TYPE_INT8
           
static java.lang.String TYPE_MBLOB
           
static java.lang.String TYPE_SBLOB
           
static java.lang.String TYPE_STRING
           
static java.lang.String TYPE_TEXT
           
static java.lang.String TYPE_UINT16
           
static java.lang.String TYPE_UINT32
           
static java.lang.String TYPE_UINT64
           
static java.lang.String TYPE_UINT8
           
static java.lang.String TYPE_UNKNOWN
           
static java.lang.String UNIQUE_INDEX_NAME
           
 
Constructor Summary
DBProvider(java.lang.String name, int id, int dftPort, java.lang.String[] drivers, org.opengts.dbtools.DBProvider.NameFilter colNameFlt, org.opengts.dbtools.DBProvider.NameFilter ndxNameFlt, org.opengts.dbtools.DBProvider.NameFilter tblNameFlt, java.lang.String tblNdxType, long flags, java.lang.String[] dataTypes)
          Constructor
 
Method Summary
protected static int _getTypeIndex(java.lang.String localType, boolean isDefinedType)
          Returns the index of the specified SQL SQL datatype
static java.lang.String _preTranslateTableName(java.lang.String tn)
          Pre-translates table name for DB provider (used only in calls to "TABLE_NAME()")
static boolean areTypesEquivalent(java.lang.String defType, java.lang.String actType)
          Returns 'true' is the specified types are equivalent
static void createAlternateIndex(java.lang.String utableName, DBAlternateIndex altIndex)
          Create an alternate Index
static void createDatabase(java.lang.String rootUser, java.lang.String rootPass)
          Create the database specified by the Runtime config (needed for initialization only)
static void createPrimaryIndex(DBFactory dbFact)
          Create primary key Index (see createTable)
static void createTable(DBFactory factory)
          Create the backing table for the specified DBFactory
static void createTable(java.lang.String utableName, DBField[] flds, DBField[] priKeys, java.lang.String keyType, DBAlternateIndex[] altIndexes)
          Create the specified SQL table
static void dropTable(java.lang.String utableName)
          Drop (delete) the specified table
static java.lang.String FLD_COUNT()
           
static java.lang.String FLD_SUM(java.lang.String col)
           
static DBField[] getActualTableFields(java.lang.String utableName)
          Returns the existing fields in the specified table
static DBTableIndexMap getActualTableIndexMap(java.lang.String utableName)
          Returns a map of column names to index names
 org.opengts.dbtools.DBProvider.NameFilter getColumnNameFilter()
          Gets the column name filter
static java.lang.String getDataTypeFromSqlType(java.lang.String sqlType)
          Returns the defined local type for the specified SQL type
static int getDataTypeMask(java.lang.String localType)
          Get data type mask for type
static java.lang.String getDBHost()
          Returns the host name for the DBProvider server
static java.lang.String getDBName()
          Returns the database name
static java.lang.String getDBPassword()
          Returns the DB user password
static int getDBPort()
          Returns the port number for the DBProvider server
static java.lang.String getDBUri(boolean inclDBName)
          Returns the database access URI
static java.lang.String getDBUsername()
          Returns the DB user name
static java.lang.String getDefaultCharacterSet()
          Gets the database provider default character encoding.
 int getDefaultPort()
          Gets the default connection port.
 java.lang.String[] getDrivers()
          Gets the JDBC drivers
 long getFlags()
          Gets the JDBC flags
 int getID()
          Gets the JDBC ID
 java.lang.String getJDBCName()
          Gets the JDBC name
static int getLockLevel()
          Returns the current recursive lock level
static DBProvider getProvider()
          Returns the current DBProvider as defined in the Runtime configuration file (property "RTKey.DB_PROVIDER")
static DBProvider getProvider(java.lang.String dbpName)
          Returns the DBProvider forthe specified name
static java.lang.String getProviderIndexType()
          Returns the index type of the current DBProvider
static java.lang.String getProviderName()
          Returns the name of the current DBProvider
static java.lang.String getSQLType(int dataTypeNdx)
          Returns the local data type for the specified index
static java.lang.String getSqlTypeFromDataType(java.lang.String localType)
          Returns the SQL type for the defined specified local type
 java.lang.String[] getSQLTypes()
          Gets an array of the SQL datatypes
 java.lang.String getTableIndexType()
          Gets the table index type
 org.opengts.dbtools.DBProvider.NameFilter getTableNameFilter()
          Gets the table name filter
static void grantDBUser(java.lang.String rootUser, java.lang.String rootPass)
          Execute an SQL statement granting access to the DB user (needed for initialization only)
static boolean insertRecordIntoTable(DBRecord rec)
          Insert record into table
static boolean isDataTypeBinary(int typeNdx)
          Returns true if the specified data type is a Binary type
static boolean isDataTypeBinary(java.lang.String localType)
          Returns true if the specified data type is a Binary type
static boolean isDataTypeBoolean(int typeNdx)
          Returns true if the specified data type is a Boolean type
static boolean isDataTypeBoolean(java.lang.String localType)
           
static boolean isDataTypeDecimal(int typeNdx)
          Returns true if the specified data type is a floating point type
static boolean isDataTypeDecimal(java.lang.String localType)
           
static boolean isDataTypeNumeric(int typeNdx)
          Returns true if the specified data type is numeric
static boolean isDataTypeNumeric(java.lang.String localType)
           
static boolean isDataTypeString(int typeNdx)
          Returns true if the specified data type is a String type
static boolean isDataTypeString(java.lang.String localType)
          Returns true if the specified data type is a String type
static boolean isDataTypeUnsigned(int typeNdx)
          Returns true if the specified data type is unsigned
static boolean isDataTypeUnsigned(java.lang.String localType)
          Returns true if the specified data type is unsigned
static boolean isMySqlInnoDB()
          Returns true if the index type of the current DBProvider if MySQL "InnoDB"
static boolean isTableLockingEnabled()
          Returns true if table locking is enabled
static java.lang.String loadJDBCDriver()
          Loads the current DBProvider class drivers
static boolean lockTableForRead(java.lang.String utableName, boolean forceLock)
          Lock specified tables for read
static boolean lockTables(java.lang.String[] writeTables, java.lang.String[] readTables)
          Lock specified tables for write/read
 java.lang.String quoteColumnName(java.lang.String colName)
          Quotes the column name based on the requirements of the DBProvider
 java.lang.String quoteTableName(java.lang.String tblName)
          Quotes the table name based on the requirements of the DBProvider
static void removeAlternateIndex(java.lang.String utableName, java.lang.String indexName)
          Removes an alternate Index
static void removePrimaryIndex(java.lang.String utableName)
          Remove primary key Index
static boolean sendJdbcCommunicationExceptionNotification(java.lang.Throwable th)
          Sends a notification for CommunicationException errors
static java.lang.String SQL_VARCHAR(int size)
           
 boolean supportsLimit()
          Returns true if the DBProvider supports limits
 boolean supportsOffset()
          Returns true if the DBProvider supports offsets
static java.lang.String translateColumnName(java.lang.String cn)
          Translates column name for DB provider
static java.lang.String translateTableName(DBProvider dbprov, java.lang.String tn)
          Translates table name for DB provider
static java.lang.String translateTableName(java.lang.String tn)
          Translates table name for DB provider
static java.lang.String TYPE_INT(java.lang.String val)
           
static java.lang.String TYPE_STRING(int size)
           
static boolean unlockTables()
          Unlock locked tables
static boolean updateRecordInTable(DBRecord rec, java.util.Set<java.lang.String> updFldSet)
          Assemble an update statement (and execute) for the specified record and set of fields to update
static boolean updateRecordInTable(DBRecord rec, java.lang.String[] updFldArray)
          Assemble an update statement (and execute) for the specified record and array of fields to update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRIMARY_INDEX_NAME

public static final java.lang.String PRIMARY_INDEX_NAME
See Also:
Constant Field Values

UNIQUE_INDEX_NAME

public static final java.lang.String UNIQUE_INDEX_NAME
See Also:
Constant Field Values

DEFAULT_ALT_INDEX_NAME

public static final java.lang.String DEFAULT_ALT_INDEX_NAME
See Also:
Constant Field Values

LIKE_WILDCARD

public static final java.lang.String LIKE_WILDCARD
See Also:
Constant Field Values

TYPE_UNKNOWN

public static final java.lang.String TYPE_UNKNOWN
See Also:
Constant Field Values

TYPE_BOOLEAN

public static final java.lang.String TYPE_BOOLEAN
See Also:
Constant Field Values

TYPE_INT8

public static final java.lang.String TYPE_INT8
See Also:
Constant Field Values

TYPE_UINT8

public static final java.lang.String TYPE_UINT8
See Also:
Constant Field Values

TYPE_INT16

public static final java.lang.String TYPE_INT16
See Also:
Constant Field Values

TYPE_UINT16

public static final java.lang.String TYPE_UINT16
See Also:
Constant Field Values

TYPE_INT32

public static final java.lang.String TYPE_INT32
See Also:
Constant Field Values

TYPE_UINT32

public static final java.lang.String TYPE_UINT32
See Also:
Constant Field Values

TYPE_INT64

public static final java.lang.String TYPE_INT64
See Also:
Constant Field Values

TYPE_UINT64

public static final java.lang.String TYPE_UINT64
See Also:
Constant Field Values

TYPE_FLOAT

public static final java.lang.String TYPE_FLOAT
See Also:
Constant Field Values

TYPE_DOUBLE

public static final java.lang.String TYPE_DOUBLE
See Also:
Constant Field Values

TYPE_SBLOB

public static final java.lang.String TYPE_SBLOB
See Also:
Constant Field Values

TYPE_BLOB

public static final java.lang.String TYPE_BLOB
See Also:
Constant Field Values

TYPE_MBLOB

public static final java.lang.String TYPE_MBLOB
See Also:
Constant Field Values

TYPE_TEXT

public static final java.lang.String TYPE_TEXT
See Also:
Constant Field Values

TYPE_STRING

public static final java.lang.String TYPE_STRING
See Also:
Constant Field Values

TYPE_DATETIME

public static final java.lang.String TYPE_DATETIME
See Also:
Constant Field Values

TYPE_ARRAY

public static final java.lang.String[] TYPE_ARRAY

SQL_UNKNOWN

public static final int SQL_UNKNOWN
See Also:
Constant Field Values

SQL_BOOLEAN

public static final int SQL_BOOLEAN
See Also:
Constant Field Values

SQL_INT8

public static final int SQL_INT8
See Also:
Constant Field Values

SQL_UINT8

public static final int SQL_UINT8
See Also:
Constant Field Values

SQL_INT16

public static final int SQL_INT16
See Also:
Constant Field Values

SQL_UINT16

public static final int SQL_UINT16
See Also:
Constant Field Values

SQL_INT32

public static final int SQL_INT32
See Also:
Constant Field Values

SQL_UINT32

public static final int SQL_UINT32
See Also:
Constant Field Values

SQL_INT64

public static final int SQL_INT64
See Also:
Constant Field Values

SQL_UINT64

public static final int SQL_UINT64
See Also:
Constant Field Values

SQL_FLOAT

public static final int SQL_FLOAT
See Also:
Constant Field Values

SQL_DOUBLE

public static final int SQL_DOUBLE
See Also:
Constant Field Values

SQL_SBLOB

public static final int SQL_SBLOB
See Also:
Constant Field Values

SQL_BLOB

public static final int SQL_BLOB
See Also:
Constant Field Values

SQL_MBLOB

public static final int SQL_MBLOB
See Also:
Constant Field Values

SQL_TEXT

public static final int SQL_TEXT
See Also:
Constant Field Values

SQL_VARCHAR

public static final int SQL_VARCHAR
See Also:
Constant Field Values

SQL_DATETIME

public static final int SQL_DATETIME
See Also:
Constant Field Values

DATATYPE_NONE

public static final int DATATYPE_NONE
See Also:
Constant Field Values

DATATYPE_BOOLEAN

public static final int DATATYPE_BOOLEAN
See Also:
Constant Field Values

DATATYPE_UNSIGNED

public static final int DATATYPE_UNSIGNED
See Also:
Constant Field Values

DATATYPE_SIGNED

public static final int DATATYPE_SIGNED
See Also:
Constant Field Values

DATATYPE_DECIMAL

public static final int DATATYPE_DECIMAL
See Also:
Constant Field Values

DATATYPE_STRING

public static final int DATATYPE_STRING
See Also:
Constant Field Values

DATATYPE_BINARY

public static final int DATATYPE_BINARY
See Also:
Constant Field Values

DATATYPE_DATETIME

public static final int DATATYPE_DATETIME
See Also:
Constant Field Values

DATATYPE_NUMERIC

public static final int DATATYPE_NUMERIC
See Also:
Constant Field Values

DATATYPE_ARRAY

public static final int[] DATATYPE_ARRAY

DB_MYSQL

public static final int DB_MYSQL
See Also:
Constant Field Values

DB_POSTGRESQL

public static final int DB_POSTGRESQL
See Also:
Constant Field Values

DB_DERBY

public static final int DB_DERBY
See Also:
Constant Field Values

DB_SQLSERVER

public static final int DB_SQLSERVER
See Also:
Constant Field Values

DB_ORACLEXE

public static final int DB_ORACLEXE
See Also:
Constant Field Values

DB_MARIADB

public static final int DB_MARIADB
See Also:
Constant Field Values

FLAGS_NONE

public static final long FLAGS_NONE
See Also:
Constant Field Values

FLAGS_LIMIT

public static final long FLAGS_LIMIT
See Also:
Constant Field Values

FLAGS_OFFSET

public static final long FLAGS_OFFSET
See Also:
Constant Field Values

MySQL_Old_Name

public static final java.lang.String MySQL_Old_Name
See Also:
Constant Field Values

MySQL_Old_Provider

protected static DBProvider MySQL_Old_Provider

MySQL_MyISAM_Name

public static final java.lang.String MySQL_MyISAM_Name
See Also:
Constant Field Values

MySQL_MyISAM_Provider

protected static DBProvider MySQL_MyISAM_Provider

MySQL_InnoDB_Name

public static final java.lang.String MySQL_InnoDB_Name
See Also:
Constant Field Values

MySQL_InnoDB_Provider

protected static DBProvider MySQL_InnoDB_Provider

MariaDB_Name

public static final java.lang.String MariaDB_Name
See Also:
Constant Field Values

MariaDB_Provider

protected static DBProvider MariaDB_Provider

Oracle_XE_Name

public static final java.lang.String Oracle_XE_Name
See Also:
Constant Field Values

Oracle_XE_Provider

protected static DBProvider Oracle_XE_Provider

PostgreSQL_Name

public static final java.lang.String PostgreSQL_Name
See Also:
Constant Field Values

PostgreSQL_Provider

protected static DBProvider PostgreSQL_Provider

PostgreSQL_Name_old

public static final java.lang.String PostgreSQL_Name_old
See Also:
Constant Field Values

PostgreSQL_Provider_old

protected static DBProvider PostgreSQL_Provider_old

Derby_Name

public static final java.lang.String Derby_Name
See Also:
Constant Field Values

Derby_Provider

protected static DBProvider Derby_Provider

MS_SQLServer_Name

public static final java.lang.String MS_SQLServer_Name
See Also:
Constant Field Values

MS_SQLServer_Provider

protected static DBProvider MS_SQLServer_Provider
Constructor Detail

DBProvider

public DBProvider(java.lang.String name,
                  int id,
                  int dftPort,
                  java.lang.String[] drivers,
                  org.opengts.dbtools.DBProvider.NameFilter colNameFlt,
                  org.opengts.dbtools.DBProvider.NameFilter ndxNameFlt,
                  org.opengts.dbtools.DBProvider.NameFilter tblNameFlt,
                  java.lang.String tblNdxType,
                  long flags,
                  java.lang.String[] dataTypes)
Constructor

Parameters:
name - The JDBC name
id - The JDBC ID
dftPort - The default connection port
drivers - The JDBC drivers
colNameFlt - The column name filter
ndxNameFlt - The index name filter
tblNameFlt - The table name filter
tblNdxType - The table idex type ("CREATE TABLE" prefix)
flags - The JDBC flags
dataTypes - The array of data type names
Throws:
java.lang.RuntimeException - If dataTypes is not the correct length
Method Detail

FLD_COUNT

public static java.lang.String FLD_COUNT()

FLD_SUM

public static java.lang.String FLD_SUM(java.lang.String col)

TYPE_STRING

public static java.lang.String TYPE_STRING(int size)

TYPE_INT

public static java.lang.String TYPE_INT(java.lang.String val)

SQL_VARCHAR

public static java.lang.String SQL_VARCHAR(int size)

getProvider

public static DBProvider getProvider(java.lang.String dbpName)
Returns the DBProvider forthe specified name

Returns:
the DBProvider forthe specified name, or null if not found

getProvider

public static DBProvider getProvider()
Returns the current DBProvider as defined in the Runtime configuration file (property "RTKey.DB_PROVIDER")

Returns:
the current DBProvider

getProviderName

public static java.lang.String getProviderName()
Returns the name of the current DBProvider

Returns:
The current DBProvider name

getProviderIndexType

public static java.lang.String getProviderIndexType()
Returns the index type of the current DBProvider

Returns:
The current DBProvider index type (ie. "engine=MyISAM")

isMySqlInnoDB

public static boolean isMySqlInnoDB()
Returns true if the index type of the current DBProvider if MySQL "InnoDB"

Returns:
True if the index type of the current DBProvider if MySQL "InnoDB"

loadJDBCDriver

public static java.lang.String loadJDBCDriver()
Loads the current DBProvider class drivers

Returns:
the name of the loaded DBProvider class

sendJdbcCommunicationExceptionNotification

public static boolean sendJdbcCommunicationExceptionNotification(java.lang.Throwable th)
Sends a notification for CommunicationException errors


getDBHost

public static java.lang.String getDBHost()
Returns the host name for the DBProvider server

Returns:
The name of the host serving the database

getDBPort

public static int getDBPort()
Returns the port number for the DBProvider server

Returns:
The port number

getDBName

public static java.lang.String getDBName()
Returns the database name

Returns:
The database name

getDBUsername

public static java.lang.String getDBUsername()
Returns the DB user name

Returns:
The DB user name

getDBPassword

public static java.lang.String getDBPassword()
Returns the DB user password

Returns:
The DB user password

getDBUri

public static java.lang.String getDBUri(boolean inclDBName)
Returns the database access URI

Parameters:
inclDBName - True to include the name of the database in the URI
Returns:
The database access URI

_getTypeIndex

protected static int _getTypeIndex(java.lang.String localType,
                                   boolean isDefinedType)
Returns the index of the specified SQL SQL datatype

Parameters:
localType - The local type
isDefinedType - Is a 'defined' type
Returns:
The type 'index'

areTypesEquivalent

public static boolean areTypesEquivalent(java.lang.String defType,
                                         java.lang.String actType)
Returns 'true' is the specified types are equivalent

Parameters:
defType - The defined type
actType - The actual tupe
Returns:
True if the types are equivalent

getSqlTypeFromDataType

public static java.lang.String getSqlTypeFromDataType(java.lang.String localType)
Returns the SQL type for the defined specified local type

Parameters:
localType - The local type
Returns:
The SQL type

getDataTypeFromSqlType

public static java.lang.String getDataTypeFromSqlType(java.lang.String sqlType)
Returns the defined local type for the specified SQL type

Parameters:
sqlType - The SQL type
Returns:
The defined local type

getSQLType

public static java.lang.String getSQLType(int dataTypeNdx)
Returns the local data type for the specified index

Parameters:
dataTypeNdx - The data type index (Note: NO BOUNDS CHEKCING IS PERFORMED!)
Returns:
The local data type definition

getActualTableFields

public static DBField[] getActualTableFields(java.lang.String utableName)
                                      throws DBException
Returns the existing fields in the specified table

Parameters:
utableName - The table name
Returns:
An array of fields
Throws:
DBException - if an error occured fetching the fields

getActualTableIndexMap

public static DBTableIndexMap getActualTableIndexMap(java.lang.String utableName)
                                              throws DBException
Returns a map of column names to index names

Parameters:
utableName - The untranslated table name
Returns:
A map of column names to index names
Throws:
DBException - if an error occured fetching the indexes

getDataTypeMask

public static int getDataTypeMask(java.lang.String localType)
Get data type mask for type

Parameters:
localType - The nocal type name
Returns:
The data type mask for type

isDataTypeBoolean

public static boolean isDataTypeBoolean(int typeNdx)
Returns true if the specified data type is a Boolean type

Parameters:
typeNdx - The data type mask for type
Returns:
True if the specified data type is a Boolean type

isDataTypeBoolean

public static boolean isDataTypeBoolean(java.lang.String localType)

isDataTypeNumeric

public static boolean isDataTypeNumeric(int typeNdx)
Returns true if the specified data type is numeric

Parameters:
typeNdx - The data type mask for type
Returns:
True if the specified data type is numeric

isDataTypeNumeric

public static boolean isDataTypeNumeric(java.lang.String localType)

isDataTypeDecimal

public static boolean isDataTypeDecimal(int typeNdx)
Returns true if the specified data type is a floating point type

Parameters:
typeNdx - The data type mask for type
Returns:
True if the specified data type is a floating point type

isDataTypeDecimal

public static boolean isDataTypeDecimal(java.lang.String localType)

isDataTypeUnsigned

public static boolean isDataTypeUnsigned(int typeNdx)
Returns true if the specified data type is unsigned

Parameters:
typeNdx - The data type mask for type
Returns:
True if the specified data type is unsigned

isDataTypeUnsigned

public static boolean isDataTypeUnsigned(java.lang.String localType)
Returns true if the specified data type is unsigned

Parameters:
localType - The local data type name
Returns:
True if the specified data type is a Boolean type

isDataTypeString

public static boolean isDataTypeString(int typeNdx)
Returns true if the specified data type is a String type

Parameters:
typeNdx - The data type mask for type
Returns:
True if the specified data type is a string

isDataTypeString

public static boolean isDataTypeString(java.lang.String localType)
Returns true if the specified data type is a String type

Parameters:
localType - The local data type name
Returns:
True if the specified data type is a String type

isDataTypeBinary

public static boolean isDataTypeBinary(int typeNdx)
Returns true if the specified data type is a Binary type

Parameters:
typeNdx - The data type mask for type mask for type
Returns:
True if the specified data type is a String type

isDataTypeBinary

public static boolean isDataTypeBinary(java.lang.String localType)
Returns true if the specified data type is a Binary type

Parameters:
localType - The local data type name
Returns:
True if the specified data type is a String type

createDatabase

public static void createDatabase(java.lang.String rootUser,
                                  java.lang.String rootPass)
                           throws DBException,
                                  java.sql.SQLException
Create the database specified by the Runtime config (needed for initialization only)

Parameters:
rootUser - The database root user account name
rootPass - The database root user password
Throws:
java.sql.SQLException - If an SQL error occurs
DBException - If a database error occurs

translateTableName

public static java.lang.String translateTableName(DBProvider dbprov,
                                                  java.lang.String tn)
Translates table name for DB provider

Parameters:
dbprov - The DBProvider instance
tn - The base table name
Returns:
The translated table name (table name prefixes added, etc.)

translateTableName

public static java.lang.String translateTableName(java.lang.String tn)
Translates table name for DB provider

Parameters:
tn - The base table name
Returns:
The translated table name (table name prefixes added, etc.)

_preTranslateTableName

public static java.lang.String _preTranslateTableName(java.lang.String tn)
Pre-translates table name for DB provider (used only in calls to "TABLE_NAME()")

Parameters:
tn - The base (untranslated) table name
Returns:
The pre-translated table name (before DBProvider dependent translation)

translateColumnName

public static java.lang.String translateColumnName(java.lang.String cn)
Translates column name for DB provider

Parameters:
cn - The base column name
Returns:
The translated column name (column name prefixes added, etc.)

createTable

public static void createTable(DBFactory factory)
                        throws java.sql.SQLException,
                               DBException
Create the backing table for the specified DBFactory

Parameters:
factory - The DBFactory
Throws:
java.sql.SQLException - If an SQL error occurs
DBException - If a database error occurs

createTable

public static void createTable(java.lang.String utableName,
                               DBField[] flds,
                               DBField[] priKeys,
                               java.lang.String keyType,
                               DBAlternateIndex[] altIndexes)
                        throws java.sql.SQLException,
                               DBException
Create the specified SQL table

Parameters:
utableName - The untranslated table name
flds - The table columns
priKeys - The table primary keys
keyType - The key type
altIndexes - The table alternate indexes
Throws:
java.sql.SQLException - If an SQL error occurs
DBException - If a database error occurs

createAlternateIndex

public static void createAlternateIndex(java.lang.String utableName,
                                        DBAlternateIndex altIndex)
                                 throws java.sql.SQLException,
                                        DBException
Create an alternate Index

Parameters:
utableName - The untranslated table name
altIndex - The alternate index
Throws:
java.sql.SQLException - If an SQL error occurs
DBException - If a database error occurs

removeAlternateIndex

public static void removeAlternateIndex(java.lang.String utableName,
                                        java.lang.String indexName)
                                 throws java.sql.SQLException,
                                        DBException
Removes an alternate Index

Parameters:
utableName - The untranslated table name
indexName - The alternate index name
Throws:
java.sql.SQLException - If an SQL error occurs
DBException - If a database error occurs

createPrimaryIndex

public static void createPrimaryIndex(DBFactory dbFact)
                               throws java.sql.SQLException,
                                      DBException
Create primary key Index (see createTable)

Parameters:
dbFact - The DBFactory
Throws:
java.sql.SQLException - If an SQL error occurs
DBException - If a database error occurs

removePrimaryIndex

public static void removePrimaryIndex(java.lang.String utableName)
                               throws java.sql.SQLException,
                                      DBException
Remove primary key Index

Parameters:
utableName - The untranslated table name
Throws:
java.sql.SQLException - If an SQL error occurs
DBException - If a database error occurs

dropTable

public static void dropTable(java.lang.String utableName)
                      throws java.sql.SQLException,
                             DBException
Drop (delete) the specified table

Parameters:
utableName - The untranslated table name
Throws:
java.sql.SQLException - If an SQL error occurs
DBException - If a database error occurs

insertRecordIntoTable

public static boolean insertRecordIntoTable(DBRecord rec)
                                     throws java.sql.SQLException,
                                            DBException
Insert record into table

Parameters:
rec - The record to insert
Throws:
java.sql.SQLException - If an SQL error occurs
DBException - If a database error occurs

updateRecordInTable

public static boolean updateRecordInTable(DBRecord rec,
                                          java.lang.String[] updFldArray)
                                   throws java.sql.SQLException,
                                          DBException
Assemble an update statement (and execute) for the specified record and array of fields to update

Parameters:
rec - The record to update
updFldArray - The array of fields to update
Throws:
java.sql.SQLException - If an SQL error occurs
DBException - If a database error occurs

updateRecordInTable

public static boolean updateRecordInTable(DBRecord rec,
                                          java.util.Set<java.lang.String> updFldSet)
                                   throws java.sql.SQLException,
                                          DBException
Assemble an update statement (and execute) for the specified record and set of fields to update

Parameters:
rec - The record to update
updFldSet - The set of fields to update
Throws:
java.sql.SQLException - If an SQL error occurs
DBException - If a database error occurs

grantDBUser

public static void grantDBUser(java.lang.String rootUser,
                               java.lang.String rootPass)
                        throws DBException,
                               java.sql.SQLException
Execute an SQL statement granting access to the DB user (needed for initialization only)

Parameters:
rootUser - The root user accoount
rootPass - The root user password
Throws:
java.sql.SQLException - If an SQL error occurs
DBException - If a database error occurs

getDefaultCharacterSet

public static java.lang.String getDefaultCharacterSet()
                                               throws DBException,
                                                      java.sql.SQLException
Gets the database provider default character encoding. The returned String has the format ">CharacterSet<[>Collation<]"

Returns:
The database provider default character encoding.
Throws:
java.sql.SQLException - If an SQL error occurs
DBException - If a database error occurs

isTableLockingEnabled

public static boolean isTableLockingEnabled()
Returns true if table locking is enabled

Returns:
True if table locking is enabled

getLockLevel

public static int getLockLevel()
Returns the current recursive lock level

Returns:
The current recursive lock level

lockTables

public static boolean lockTables(java.lang.String[] writeTables,
                                 java.lang.String[] readTables)
                          throws DBException
Lock specified tables for write/read

Parameters:
writeTables - The array of tables to lock for writing
readTables - The array of tables to lock for reading
Returns:
True if the query was successful
Throws:
DBException - If a database error occurs

lockTableForRead

public static boolean lockTableForRead(java.lang.String utableName,
                                       boolean forceLock)
                                throws DBException
Lock specified tables for read

Parameters:
utableName - The untranslated table to lock for reading
forceLock - If the lock query should be attemped whether or not locking is enabled
Returns:
True if the query was successful
Throws:
DBException - If a database error occurs

unlockTables

public static boolean unlockTables()
                            throws DBException
Unlock locked tables

Returns:
True if the query was successful
Throws:
DBException - If a database error occurs

getID

public int getID()
Gets the JDBC ID

Returns:
The JDBC ID

getJDBCName

public java.lang.String getJDBCName()
Gets the JDBC name

Returns:
The JDBC name

getDrivers

public java.lang.String[] getDrivers()
Gets the JDBC drivers

Returns:
The JDBC drivers

getDefaultPort

public int getDefaultPort()
Gets the default connection port. Returns the port from RTConfig, if defined; else returns the DBProvider's assigned default port

Returns:
The default connection port

getColumnNameFilter

public org.opengts.dbtools.DBProvider.NameFilter getColumnNameFilter()
Gets the column name filter

Returns:
The column name filter

getTableNameFilter

public org.opengts.dbtools.DBProvider.NameFilter getTableNameFilter()
Gets the table name filter

Returns:
The table name filter

getTableIndexType

public java.lang.String getTableIndexType()
Gets the table index type

Returns:
The table index type

getSQLTypes

public java.lang.String[] getSQLTypes()
Gets an array of the SQL datatypes

Returns:
An array of the SQL datatypes

getFlags

public long getFlags()
Gets the JDBC flags

Returns:
The JDBC flags

supportsLimit

public boolean supportsLimit()
Returns true if the DBProvider supports limits

Returns:
True if the DBProvider supports limits

supportsOffset

public boolean supportsOffset()
Returns true if the DBProvider supports offsets

Returns:
True if the DBProvider supports offsets

quoteColumnName

public java.lang.String quoteColumnName(java.lang.String colName)
Quotes the column name based on the requirements of the DBProvider

Parameters:
colName - The column name
Returns:
The quoted column name

quoteTableName

public java.lang.String quoteTableName(java.lang.String tblName)
Quotes the table name based on the requirements of the DBProvider

Parameters:
tblName - The column name
Returns:
The quoted column name