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

public class MySQLDBAccess
extends DBAccess

The MySQLDBAccess is the implementation for MySQL databases.

See Also:
DBAccess

Nested Class Summary
 
Nested classes/interfaces inherited from class com.sibvisions.rad.persist.jdbc.DBAccess
DBAccess.ColumnMetaDataInfo
 
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
logger, 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.
 DBAccess.ColumnMetaDataInfo getColumnMetaData(String pFromClause, String[] pQueryColumns, String pBeforeQueryColumns, String pWhereClause, String pAfterWhereClause, String pWritebackTable, String[] pWritebackColumns)
          Returns the meta data information for the specified query, and configures all columns with defaults.
 Hashtable<String,Object> getDefaultValues(String pCatalog, String pSchema, String pTable)
          Gets all default column values of a specific table.
 List<ForeignKey> getFKs(String pCatalog, String pSchema, String pTable)
          Returns all Foreign Keys for the specified table.
 Key getPK(String pCatalog, String pSchema, String pTable)
          Gets all Primary Key columns and return it as list of Strings.
 List<Key> getUKs(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
close, commit, convertDatabaseSpecificObjectToValue, convertValueToDatabaseSpecificObject, createReplace, createWhereColumn, createWhereParam, delete, executeFunction, executeProcedure, executeSql, executeStatement, executeUpdate, fetch, formatSQLException, formatSQLException, getAllowedValues, getAutomaticLinkColumnName, getAutomaticLinkColumnNameTranslation, getConnection, getDatabaseSpecificLockStatement, getDBAccess, getDBAccess, getDBAccess, getDBProperties, getDBProperty, getDefaultAllowedValues, getDefaultSchema, getDriver, getFromClause, getMaxTime, getPassword, getPreparedStatement, getQueryColumns, getSelectStatement, getTableForSynonym, getUrl, getUsername, getWHEREClause, insert, insertAnsiSQL, insertDatabaseSpecific, isOpen, isTypeEqual, lockRow, lockRowInternal, quote, quoteAllways, registerDBAccessClass, removeDBSpecificQuotes, removeQuotes, rollback, setAutomaticLinkColumnNameTranslation, setColumnsToStore, setConnection, setDatabaseSpecificType, setDBProperties, setDBProperty, setDefaultSchema, setDriver, setFilterParameter, setMaxTime, 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.

getColumnMetaData

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

Overrides:
getColumnMetaData 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
pWritebackTable - the write back table to use for the isWriteable() state (Optional)
pWritebackColumns - the write back columns 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

getPK

public Key getPK(String pCatalog,
                 String pSchema,
                 String pTable)
          throws DataSourceException
Gets all Primary Key columns and return it as list of Strings.

Overrides:
getPK 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.

getFKs

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

Overrides:
getFKs 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.

getUKs

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

Overrides:
getUKs 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.

getDefaultValues

public Hashtable<String,Object> getDefaultValues(String pCatalog,
                                                 String pSchema,
                                                 String pTable)
                                          throws DataSourceException
Gets all default column values of a specific table.

Overrides:
getDefaultValues 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.