com.sibvisions.rad.persist.jdbc
Class MySQLDBAccess

java.lang.Object
  extended by com.sibvisions.rad.persist.jdbc.DBAccess
      extended by com.sibvisions.rad.persist.jdbc.MySQLDBAccess
All Implemented Interfaces:
IDBAccess, ICloseable

public class MySQLDBAccess
extends DBAccess

The MySQLDBAccess is the implementation for MySQL databases.

See Also:
DBAccess

Field Summary
static int TYPE_ENUM
          the enum datatype.
static int TYPE_SET
          the set datatype.
 
Fields inherited from class com.sibvisions.rad.persist.jdbc.DBAccess
LONGNVARCHAR, NCHAR, NCLOB, NVARCHAR, QUOTE, SQLXML
 
Constructor Summary
MySQLDBAccess()
          Constructs a new MySQLDBAccess Object.
 
Method Summary
protected  String[] extractValues(String pTypeDefinition)
          Extracts the values from a valuelist, separated with ,.
protected  Hashtable<String,com.sibvisions.rad.persist.jdbc.MySQLDBAccess.ColumnInfo> getColumnInfo(String pTableName)
          Get detailed column information for the given table.
protected  ServerColumnMetaData[] getColumnMetaDataIntern(String pFromClause, String[] pQueryColumns, String pBeforeQueryColumns, String pWhereClause, String pAfterWhereClause)
          Returns the meta data information for the specified query, and configures all columns with defaults.
protected  Map<String,Object> getDefaultValuesIntern(String pCatalog, String pSchema, String pTable)
          Gets all default column values of a specific table.
protected  List<ForeignKey> getForeignKeysIntern(String pCatalog, String pSchema, String pTable)
          Returns all Foreign Keys for the specified table.
protected  Key getPrimaryKeyIntern(String pCatalog, String pSchema, String pTable)
          It's gets all Primary Key columns and return it as String[].
protected  TableInfo getTableInfoIntern(String pWriteBackTable)
          Returns the meta data information for the specified query, and configures all columns with defaults.
protected  List<Key> getUniqueKeysIntern(String pCatalog, String pSchema, String pTable)
          It gets all columns for each Unique Key and return it.
 boolean isAutoQuote(String pName)
          It returns true if this name should be automated quoted.
 void open()
          It opens the database and stores the Connection object.
 void setUsername(String pUsername)
          Sets the user name to connect with.
 
Methods inherited from class com.sibvisions.rad.persist.jdbc.DBAccess
clearMetaData, clearMetaData, close, commit, convertDatabaseSpecificObjectToValue, convertValueToDatabaseSpecificObject, createIdentifier, createReplace, createWhereColumn, createWhereParam, debug, delete, error, executeFunction, executeProcedure, executeSql, executeStatement, executeUpdate, fetch, fetch, fetch, fetch, formatSQLException, formatSQLException, getAllowedValues, getAllowedValuesIntern, getAutomaticLinkColumnNameTranslation, getCloseQuoteCharacter, getColumnMetaData, getColumnName, getConnection, getDatabaseSpecificLockStatement, getDBAccess, getDBAccess, getDBAccess, getDBProperties, getDBProperty, getDefaultAllowedValues, getDefaultLargeObjectLimit, getDefaultSchema, getDefaultValues, getDriver, getForeignKeys, getIdentifier, getLargeObjectLimit, getMaxColumnLength, getMaxTime, getMetaDataCacheOption, getOpenQuoteCharacter, getParameter, getPassword, getPreparedStatement, getPrimaryKey, getQueryTimeOut, getSelectStatement, getSQL, getTableForSynonym, getTableForSynonymIntern, getTableInfo, getUniqueKeys, getUrl, getUsername, getWhereClause, info, insert, insertAnsiSQL, insertDatabaseSpecific, isAutoCommit, isJdbc, isLogEnabled, isMetaDataCacheEnabled, isModified, isOpen, isTypeEqual, lockRow, lockRowInternal, quote, quoteAllways, registerDBAccessClass, removeDBSpecificQuotes, removeQuotes, rollback, setAutoCommit, setAutomaticLinkColumnNameTranslation, setColumnsToStore, setConnection, setDatabaseSpecificType, setDBProperties, setDBProperty, setDefaultLargeObjectLimit, setDefaultSchema, setDriver, setLargeObjectLimit, setMaxTime, setMetaDataCacheOption, setModified, setPassword, setQueryTimeOut, setQuoteCharacters, setUrl, splitSchemaTable, supportsGetGeneratedKeys, toString, translateDefaultValue, translateQuotes, translateValue, update, updateAnsiSQL, updateDatabaseSpecific
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_ENUM

public static final int TYPE_ENUM
the enum datatype.

See Also:
Constant Field Values

TYPE_SET

public static final int TYPE_SET
the set datatype.

See Also:
Constant Field Values
Constructor Detail

MySQLDBAccess

public MySQLDBAccess()
Constructs a new MySQLDBAccess Object.

Method Detail

open

public void open()
          throws DataSourceException
It opens the database and stores the Connection object.

Overrides:
open in class DBAccess
Throws:
DataSourceException - if the database couldn't opened

isAutoQuote

public boolean isAutoQuote(String pName)
Description copied from class: DBAccess
It returns true if this name should be automated quoted. e.g. in Oracle default all isUppercase(), so if the name has one loweCase character, then AutoQuote is true to quote this name.

Overrides:
isAutoQuote in class DBAccess
Parameters:
pName - the name to quote.
Returns:
true if this name should be automated quoted.

getColumnMetaDataIntern

protected ServerColumnMetaData[] getColumnMetaDataIntern(String pFromClause,
                                                         String[] pQueryColumns,
                                                         String pBeforeQueryColumns,
                                                         String pWhereClause,
                                                         String pAfterWhereClause)
                                                  throws DataSourceException
Description copied from class: DBAccess
Returns the meta data information for the specified query, and configures all columns with defaults.

Overrides:
getColumnMetaDataIntern in class DBAccess
Parameters:
pFromClause - the from clause with query tables and join definitions
pQueryColumns - the query columns
pBeforeQueryColumns - the before query columns
pWhereClause - the last where condition in query
pAfterWhereClause - the after where clause in query
Returns:
the meta data for the specified query, and initials all columns.
Throws:
DataSourceException - if an Exception occur during getting the meta data or if the storage is not opened or if one columns SQL type is not supported

getTableInfoIntern

protected TableInfo getTableInfoIntern(String pWriteBackTable)
                                throws DataSourceException
Returns the meta data information for the specified query, and configures all columns with defaults.

Overrides:
getTableInfoIntern in class DBAccess
Parameters:
pWriteBackTable - the write back table to use for the isWriteable() state (Optional)
Returns:
the meta data for the specified query, and initials all columns.
Throws:
DataSourceException - if an Exception occur during getting the meta data or if the storage is not opened or if one columns SQL type is not supported

getPrimaryKeyIntern

protected Key getPrimaryKeyIntern(String pCatalog,
                                  String pSchema,
                                  String pTable)
                           throws DataSourceException
It's gets all Primary Key columns and return it as String[]. Gets all Primary Key columns and return it as list of Strings.

Overrides:
getPrimaryKeyIntern in class DBAccess
Parameters:
pCatalog - the catalog to use
pSchema - the schema to use
pTable - the table to use
Returns:
all Primary Key columns and return it as String[].
Throws:
DataSourceException - if an error occur during PK search process.

getForeignKeysIntern

protected List<ForeignKey> getForeignKeysIntern(String pCatalog,
                                                String pSchema,
                                                String pTable)
                                         throws DataSourceException
Returns all Foreign Keys for the specified table.

Overrides:
getForeignKeysIntern in class DBAccess
Parameters:
pCatalog - the catalog to use
pSchema - the schema to use
pTable - the table to use as base table.
Returns:
all Foreign Keys for the specified table.
Throws:
DataSourceException - if an error occur in determining the ForeignKeys.

getUniqueKeysIntern

protected List<Key> getUniqueKeysIntern(String pCatalog,
                                        String pSchema,
                                        String pTable)
                                 throws DataSourceException
It gets all columns for each Unique Key and return it.

Overrides:
getUniqueKeysIntern in class DBAccess
Parameters:
pCatalog - the catalog to use
pSchema - the schema to use
pTable - the table to use
Returns:
all columns for each Unique Key.
Throws:
DataSourceException - if an error occur during UK search process.

getDefaultValuesIntern

protected Map<String,Object> getDefaultValuesIntern(String pCatalog,
                                                    String pSchema,
                                                    String pTable)
                                             throws DataSourceException
Gets all default column values of a specific table.

Overrides:
getDefaultValuesIntern in class DBAccess
Parameters:
pCatalog - the catalog name
pSchema - the schema name
pTable - the table name
Returns:
a Hashtable with the column name as key and the default value as value. It only contains columns with a default value
Throws:
DataSourceException - if the database access throws an exception

setUsername

public void setUsername(String pUsername)
Description copied from class: DBAccess
Sets the user name to connect with.

Overrides:
setUsername in class DBAccess
Parameters:
pUsername - the user name

getColumnInfo

protected Hashtable<String,com.sibvisions.rad.persist.jdbc.MySQLDBAccess.ColumnInfo> getColumnInfo(String pTableName)
Get detailed column information for the given table. The column details contains the real data type and not the JDBC data type.

Parameters:
pTableName - the name of the table
Returns:
the information per column

extractValues

protected String[] extractValues(String pTypeDefinition)
Extracts the values from a valuelist, separated with ,.

Parameters:
pTypeDefinition - the data type definition e.g. enum ('y', 'n')
Returns:
an array with values


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.