com.sibvisions.rad.persist.jdbc
Class HSQLDBAccess

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

public class HSQLDBAccess
extends DBAccess

The HSQLDBAccess is the implementation for Hypersonic SQL databases.

See Also:
DBAccess

Nested Class Summary
 
Nested classes/interfaces inherited from class com.sibvisions.rad.persist.jdbc.DBAccess
DBAccess.ColumnMetaDataInfo
 
Field Summary
 
Fields inherited from class com.sibvisions.rad.persist.jdbc.DBAccess
logger, LONGNVARCHAR, NCHAR, NCLOB, NVARCHAR, QUOTE, SQLXML
 
Constructor Summary
HSQLDBAccess()
          Constructs a new HSQLDBAccess Object.
 
Method Summary
 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 sCatalog, String sSchema, String pTable)
          Returns all Foreign Keys for the specified table.
 Key getPK(String sCatalog, String sSchema, String pTable)
          Gets all Primary Key columns and return it as list of Strings.
 List<Key> getUKs(String sCatalog, String sSchema, String pTable)
          It gets all columns for each Unique Key and return it.
 String getWritebackTable(String pWritebackTable)
          Returns the WritebackTable as toUpper, because of the meta data bug in HSQL.
 Object[] insertDatabaseSpecific(String pWritebackTable, String pInsertStatement, ServerMetaData pServerMetaData, Object[] pNewDataRow, String pDummyColumn)
          Returns the newly inserted row from an Database specific insert statement.
 void open()
          It opens the database and stores the Connection object.
protected  Object translateDefaultValue(String pColumnName, int pDataType, String pDefaultValue)
          Translates a default value from a column to the datatype object.
 
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, isAutoQuote, isOpen, isTypeEqual, lockRow, lockRowInternal, quote, quoteAllways, registerDBAccessClass, removeDBSpecificQuotes, removeQuotes, rollback, setAutomaticLinkColumnNameTranslation, setColumnsToStore, setConnection, setDatabaseSpecificType, setDBProperties, setDBProperty, setDefaultSchema, setDriver, setFilterParameter, setMaxTime, setPassword, setQueryTimeOut, setQuoteCharacters, setUrl, setUsername, splitSchemaTable, supportsGetGeneratedKeys, toString, translateQuotes, translateValue, update, updateAnsiSQL, updateDatabaseSpecific
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HSQLDBAccess

public HSQLDBAccess()
Constructs a new HSQLDBAccess 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

getPK

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

Overrides:
getPK in class DBAccess
Parameters:
sCatalog - the catalog to use
sSchema - 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 sCatalog,
                               String sSchema,
                               String pTable)
                        throws DataSourceException
Returns all Foreign Keys for the specified table.

Overrides:
getFKs in class DBAccess
Parameters:
sCatalog - the catalog to use
sSchema - 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 sCatalog,
                        String sSchema,
                        String pTable)
                 throws DataSourceException
It gets all columns for each Unique Key and return it.

Overrides:
getUKs in class DBAccess
Parameters:
sCatalog - the catalog to use
sSchema - 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.

getColumnMetaData

public DBAccess.ColumnMetaDataInfo getColumnMetaData(String pFromClause,
                                                     String[] pQueryColumns,
                                                     String pBeforeQueryColumns,
                                                     String pWhereClause,
                                                     String pAfterWhereClause,
                                                     String pWritebackTable,
                                                     String[] pWritebackColumns)
                                              throws DataSourceException
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

insertDatabaseSpecific

public Object[] insertDatabaseSpecific(String pWritebackTable,
                                       String pInsertStatement,
                                       ServerMetaData pServerMetaData,
                                       Object[] pNewDataRow,
                                       String pDummyColumn)
                                throws DataSourceException
Returns the newly inserted row from an Database specific insert statement.
Database specific derivations of DBAcces need to implement it database specific.

Overrides:
insertDatabaseSpecific in class DBAccess
Parameters:
pWritebackTable - the table to use for the insert
pInsertStatement - the SQL Statement to use for the insert
pServerMetaData - the meta data to use.
pNewDataRow - the new row (Object[]) with the values to insert
pDummyColumn - null, if all writeable columns are null, but for a correct INSERT it have to be minimum one column to use in the syntax.
Returns:
the newly inserted row from an Oracle Database.
Throws:
DataSourceException - if an Exception occur during insert to the storage

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

translateDefaultValue

protected Object translateDefaultValue(String pColumnName,
                                       int pDataType,
                                       String pDefaultValue)
                                throws Exception
Translates a default value from a column to the datatype object.

Overrides:
translateDefaultValue in class DBAccess
Parameters:
pColumnName - the column name to translate
pDataType - the datatype of the column
pDefaultValue - the original default value from the database
Returns:
the default value with the datatype of the column or null if the default value is not valid
Throws:
Exception - if the type translation causes an error or the datatype is not supported

getWritebackTable

public String getWritebackTable(String pWritebackTable)
Returns the WritebackTable as toUpper, because of the meta data bug in HSQL.

Parameters:
pWritebackTable - the write back tabel to use.
Returns:
the WritebackTable as toUpper, because of the meta data bug in HSQL.


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.