|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sibvisions.rad.persist.jdbc.DBAccess
com.sibvisions.rad.persist.jdbc.MySQLDBAccess
public class MySQLDBAccess
The MySQLDBAccess
is the implementation for MySQL databases.
DBAccess
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.sibvisions.rad.persist.jdbc.DBAccess |
---|
DBAccess.BlobFileHandle, DBAccess.ParameterizedStatement |
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 |
---|
BFILE, LONGNVARCHAR, NCHAR, NCLOB, NVARCHAR, QUOTE, SQLXML, TIMESTAMPWITHLOCALTIMEZONE, TIMESTAMPWITHTIMEZONE |
Constructor Summary | |
---|---|
MySQLDBAccess()
Constructs a new MySQLDBAccess Object. |
Method Summary | |
---|---|
protected int |
calculateAdditionalFetchRowCount(int pFetchedRowCount,
long pFetchTimeInMilliSeconds)
Calculates the amount of rows to fetch additionally to an already happened fetch. |
protected java.lang.String[] |
extractValues(java.lang.String pTypeDefinition)
Extracts the values from a valuelist, separated with , . |
java.util.List<java.lang.Object[]> |
fetch(ServerMetaData pServerMetaData,
java.lang.String pBeforeQueryColumns,
java.lang.String[] pQueryColumns,
java.lang.String pFromClause,
ICondition pFilter,
java.lang.String pWhereCondition,
java.lang.String pAfterWhereClause,
SortDefinition pSort,
java.lang.String pOrderByClause,
int pFromRow,
int pMinimumRowCount,
boolean pAllowLazyFetch)
Mostly same as DBAccess.fetch(ServerMetaData, String, String[], String, ICondition, String, String, SortDefinition, int, int) . |
protected java.util.Hashtable<java.lang.String,com.sibvisions.rad.persist.jdbc.MySQLDBAccess.ColumnInfo> |
getColumnInfo(java.lang.String pTableName)
Get detailed column information for the given table. |
protected ServerColumnMetaData[] |
getColumnMetaDataIntern(java.lang.String pFromClause,
java.lang.String[] pQueryColumns,
java.lang.String pBeforeQueryColumns,
java.lang.String pWhereClause,
java.lang.String pAfterWhereClause)
Returns the meta data information for the specified query, and configures all columns with defaults. |
static int |
getDefaultMaximumAdditionalFetchAmount()
Gets the default maximum amount of additional rows to fetch. |
protected java.util.Map<java.lang.String,java.lang.Object> |
getDefaultValuesIntern(java.lang.String pCatalog,
java.lang.String pSchema,
java.lang.String pTable)
Gets all default column values of a specific table. |
protected int |
getDiscardRowCount(int pFromRow,
int pMinimumRowCount)
Gets how many rows should be discarded based on the given values. |
protected java.util.List<ForeignKey> |
getForeignKeysIntern(java.lang.String pCatalog,
java.lang.String pSchema,
java.lang.String pTable)
Returns all Foreign Keys for the specified table. |
int |
getMaximumAdditionalFetchAmount()
Gets the maximum amount of additional rows to fetch. |
DBAccess.ParameterizedStatement |
getParameterizedSelectStatement(ServerMetaData pServerMetaData,
java.lang.String pBeforeQueryColumns,
java.lang.String[] pQueryColumns,
java.lang.String pFromClause,
ICondition pFilter,
java.lang.String pWhereClause,
java.lang.String pAfterWhereClause,
SortDefinition pSort,
java.lang.String pOrderByClause,
int pFromRow,
int pMinimumRowCount)
Creates the DBAccess.ParameterizedStatement and returns it. |
protected Key |
getPrimaryKeyIntern(java.lang.String pCatalog,
java.lang.String pSchema,
java.lang.String pTable)
It's gets all Primary Key columns and return it as String[]. |
protected TableInfo |
getTableInfoIntern(java.lang.String pWriteBackTable)
Returns the meta data information for the specified query, and configures all columns with defaults. |
protected java.util.List<Key> |
getUniqueKeysIntern(java.lang.String pCatalog,
java.lang.String pSchema,
java.lang.String pTable)
It gets all columns for each Unique Key and return it. |
boolean |
isAutoQuote(java.lang.String pName)
It returns true if this name should be automated quoted. |
void |
open()
It opens the database and stores the Connection object. |
static void |
setDefaultMaximumAdditionalFetchAmount(int pDefaultMaximumAdditionalFetchAmount)
Sets the default maximum amount of additional rows to fetch. |
void |
setMaximumAdditionalFetchAmount(int pMaximumAdditionalFetchAmount)
Sets the maximum amount of additional rows to fetch. |
void |
setUsername(java.lang.String pUsername)
Sets the user name to connect with. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int TYPE_ENUM
public static final int TYPE_SET
Constructor Detail |
---|
public MySQLDBAccess()
Method Detail |
---|
public void open() throws DataSourceException
Connection
object.
open
in class DBAccess
DataSourceException
- if the database couldn't openedpublic boolean isAutoQuote(java.lang.String pName)
DBAccess
isAutoQuote
in class DBAccess
pName
- the name to quote.
protected ServerColumnMetaData[] getColumnMetaDataIntern(java.lang.String pFromClause, java.lang.String[] pQueryColumns, java.lang.String pBeforeQueryColumns, java.lang.String pWhereClause, java.lang.String pAfterWhereClause) throws DataSourceException
DBAccess
getColumnMetaDataIntern
in class DBAccess
pFromClause
- the from clause with query tables and join definitionspQueryColumns
- the query columnspBeforeQueryColumns
- the before query columnspWhereClause
- the last where condition in querypAfterWhereClause
- the after where clause in query
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 supportedprotected TableInfo getTableInfoIntern(java.lang.String pWriteBackTable) throws DataSourceException
getTableInfoIntern
in class DBAccess
pWriteBackTable
- the write back table to use for the isWriteable() state (Optional)
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 supportedprotected Key getPrimaryKeyIntern(java.lang.String pCatalog, java.lang.String pSchema, java.lang.String pTable) throws DataSourceException
getPrimaryKeyIntern
in class DBAccess
pCatalog
- the catalog to usepSchema
- the schema to usepTable
- the table to use
DataSourceException
- if an error occur during PK search process.protected java.util.List<ForeignKey> getForeignKeysIntern(java.lang.String pCatalog, java.lang.String pSchema, java.lang.String pTable) throws DataSourceException
getForeignKeysIntern
in class DBAccess
pCatalog
- the catalog to usepSchema
- the schema to usepTable
- the table to use as base table.
DataSourceException
- if an error occur in determining the ForeignKeys.protected java.util.List<Key> getUniqueKeysIntern(java.lang.String pCatalog, java.lang.String pSchema, java.lang.String pTable) throws DataSourceException
getUniqueKeysIntern
in class DBAccess
pCatalog
- the catalog to usepSchema
- the schema to usepTable
- the table to use
DataSourceException
- if an error occur during UK search process.protected java.util.Map<java.lang.String,java.lang.Object> getDefaultValuesIntern(java.lang.String pCatalog, java.lang.String pSchema, java.lang.String pTable) throws DataSourceException
getDefaultValuesIntern
in class DBAccess
pCatalog
- the catalog namepSchema
- the schema namepTable
- the table name
Hashtable
with the column name as key and the default value as value. It only contains columns
with a default value
DataSourceException
- if the database access throws an exceptionpublic void setUsername(java.lang.String pUsername)
DBAccess
setUsername
in class DBAccess
pUsername
- the user namepublic java.util.List<java.lang.Object[]> fetch(ServerMetaData pServerMetaData, java.lang.String pBeforeQueryColumns, java.lang.String[] pQueryColumns, java.lang.String pFromClause, ICondition pFilter, java.lang.String pWhereCondition, java.lang.String pAfterWhereClause, SortDefinition pSort, java.lang.String pOrderByClause, int pFromRow, int pMinimumRowCount, boolean pAllowLazyFetch) throws DataSourceException
DBAccess.fetch(ServerMetaData, String, String[], String, ICondition, String, String, SortDefinition, int, int)
.
This fetch does accept an additional order by clause which will be used
if the given default sort is null.
fetch
in class DBAccess
pServerMetaData
- the MetaDataColumn array to use.pBeforeQueryColumns
- the before query columnspQueryColumns
- the query columnspFromClause
- the from clause with query tables and join definitionspFilter
- the filter to usepWhereCondition
- the last where condition in querypAfterWhereClause
- the after where clause in querypSort
- the sort order to usepOrderByClause
- the order by clausepFromRow
- the row index from to fetchpMinimumRowCount
- the minimum count row to fetchpAllowLazyFetch
- if lazy fetch should be allowed.
DataSourceException
- if the fetch fails.public DBAccess.ParameterizedStatement getParameterizedSelectStatement(ServerMetaData pServerMetaData, java.lang.String pBeforeQueryColumns, java.lang.String[] pQueryColumns, java.lang.String pFromClause, ICondition pFilter, java.lang.String pWhereClause, java.lang.String pAfterWhereClause, SortDefinition pSort, java.lang.String pOrderByClause, int pFromRow, int pMinimumRowCount) throws DataSourceException
DBAccess.ParameterizedStatement
and returns it.
Note that this function is subject to be changed in a future version, and can there for not be considered stable.
getParameterizedSelectStatement
in class DBAccess
pServerMetaData
- the MetaDataColumn array to use.pBeforeQueryColumns
- the string to place in the SELECT statement between the SELECT and the first query column.pQueryColumns
- the list of query columns to use in the SELECT statement.pFromClause
- the list of query tables to use in the SELECT statement.pFilter
- the Filter
to usepWhereClause
- the string to place in the SELECT statement after the last WHERE condition from the
Filter or MasterReference (Master-Detail Condition).pAfterWhereClause
- the string to place in the SELECT statement after the WHERE clause and before the ORDER BY clause.pSort
- the sort definition.pOrderByClause
- the order by clause.pFromRow
- the row index from to fetchpMinimumRowCount
- the minimum count row to fetch
DataSourceException
- if it's not possible to build the select statement in fact of missing elementsprotected int getDiscardRowCount(int pFromRow, int pMinimumRowCount)
getDiscardRowCount
in class DBAccess
pFromRow
- the row index from to fetchpMinimumRowCount
- the minimum count row to fetch
public static int getDefaultMaximumAdditionalFetchAmount()
setMaximumAdditionalFetchAmount(int)
public static void setDefaultMaximumAdditionalFetchAmount(int pDefaultMaximumAdditionalFetchAmount)
If a fetch took less than DBAccess.getMaxTime()
, there will be
a second, additional fetch issues to fetch more data. This allows
to set an upper limit on that second, additional fetch.
When set to 0
, no additional data will be fetched. When
set to -1
or less, there will be no limit imposed.
pDefaultMaximumAdditionalFetchAmount
- the default maximum amount for
the additional fetch to fetch.getMaximumAdditionalFetchAmount()
public int getMaximumAdditionalFetchAmount()
setMaximumAdditionalFetchAmount(int)
public void setMaximumAdditionalFetchAmount(int pMaximumAdditionalFetchAmount)
If a fetch took less than DBAccess.getMaxTime()
, there will be
a second, additional fetch issues to fetch more data. This allows
to set an upper limit on that second, additional fetch.
When set to 0
, no additional data will be fetched. When
set to -1
or less, there will be no limit imposed.
pMaximumAdditionalFetchAmount
- the maximum amount for the additional
fetch to fetch.getMaximumAdditionalFetchAmount()
protected java.util.Hashtable<java.lang.String,com.sibvisions.rad.persist.jdbc.MySQLDBAccess.ColumnInfo> getColumnInfo(java.lang.String pTableName)
pTableName
- the name of the table
protected java.lang.String[] extractValues(java.lang.String pTypeDefinition)
,
.
pTypeDefinition
- the data type definition e.g. enum ('y', 'n')
protected int calculateAdditionalFetchRowCount(int pFetchedRowCount, long pFetchTimeInMilliSeconds)
pFetchedRowCount
- the already fetched row count.pFetchTimeInMilliSeconds
- the time the fetch took, in milliseconds.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |