org.melati.poem.dbms
Class Oracle

Package class diagram package Oracle
java.lang.Object
  extended by org.melati.poem.dbms.AnsiStandard
      extended by org.melati.poem.dbms.Oracle
All Implemented Interfaces:
Dbms

public class Oracle
extends AnsiStandard

A Driver for Oracle (http://www.oracle.com/).

To do something:
Testing required, code has been added to keep up with the interface without testing.

Nested Class Summary
static class Oracle.OracleBooleanPoemType
          Translates an Oracle Boolean into a Poem BooleanPoemType.
static class Oracle.OracleStringPoemType
          Translates a Oracle String into a Poem StringPoemType.
 
Field Summary
static int oracleTextHack
          Oracle does not have a pleasant TEXT datatype, so we use an arbetary value in a VARCHAR.
 
Fields inherited from class org.melati.poem.dbms.AnsiStandard
schema
 
Constructor Summary
Oracle()
          Constructor.
 
Method Summary
 String booleanTrueExpression(Column booleanColumn)
          Accomodate lack of boolean types.
 PoemType canRepresent(PoemType storage, PoemType type)
          Enable one PoemType to represent another, for example a bit to represent a boolean.
 SQLPoemType defaultPoemTypeOfColumnMetaData(ResultSet md)
          The simplest POEM type corresponding to a JDBC description from the database.
 String getBinarySqlDefinition(int size)
          Accomodate different treatment of different sized binary data.
 String getForeignKeyDefinition(String tableName, String fieldName, String targetTableName, String targetTableFieldName, String fixName)
          If Foreign key definitions are part of field definitions, otherwise blank (silently unsupported).
 String getLongSqlDefinition()
          Accomodate Long / Bigint deviants.
 String getPrimaryKeyDefinition(String fieldName)
          Return the PRIMARY KEY definition string for this dbms.
 String getSchema()
          Get the user we are connected as and return that as the schema.
 String getSqlDefaultValue(SQLType sqlType)
          Used to set a not null value when creating a non nullable column.
 String getSqlDefinition(String sqlTypeName)
          Retrieve a SQL type keyword used by the DBMS for the given Melati type name.
 String getStringSqlDefinition(int size)
          Accomodate String / Text distinction.
 String melatiName(String name)
          Reverse the mapping in unreservedName.
 String sqlBooleanValueOfRaw(Object raw)
          Accomodate different true and false values.
 String unreservedName(String name)
          A pair of functions for getting around keywords which make your JDBC driver barf, as 'group' does for MySQL.
 
Methods inherited from class org.melati.poem.dbms.AnsiStandard
alterColumnNotNullableSQL, canBeIndexed, canDropColumns, canStoreBlobs, caseInsensitiveRegExpSQL, createTableOptionsSql, createTableSql, createTableTypeQualifierSql, exceptionForUpdate, exceptionForUpdate, getConnection, getDriverClassName, getDriverLoaded, getFixedPtSqlDefinition, getIndexLength, getJdbcMetadataName, getQuotedName, getQuotedValue, givesCapabilitySQL, loadDriver, preparedStatementPlaceholder, selectLimit, setDriverClassName, setDriverLoaded, shutdown, tableInitialisationSql, toString, unloadDriver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

oracleTextHack

public static int oracleTextHack
Oracle does not have a pleasant TEXT datatype, so we use an arbetary value in a VARCHAR.

Constructor Detail

Oracle

public Oracle()
Constructor.

Method Detail

getSchema

public String getSchema()
Get the user we are connected as and return that as the schema. The db schema name to use, if any. This is typically the JDBC connection URL User string.

Specified by:
getSchema in interface Dbms
Overrides:
getSchema in class AnsiStandard
Returns:
the schema to use or null if not required
See Also:
AnsiStandard.getSchema(), Dbms.getSchema()

getStringSqlDefinition

public String getStringSqlDefinition(int size)
                              throws SQLException
Accomodate String / Text distinction.

Specified by:
getStringSqlDefinition in interface Dbms
Overrides:
getStringSqlDefinition in class AnsiStandard
Parameters:
size - the string length (-1 means no limit)
Returns:
the SQL definition for a string of this size
Throws:
SQLException
See Also:
AnsiStandard.getStringSqlDefinition(int)

getLongSqlDefinition

public String getLongSqlDefinition()
Accomodate Long / Bigint deviants.

Specified by:
getLongSqlDefinition in interface Dbms
Overrides:
getLongSqlDefinition in class AnsiStandard
Returns:
the keyword to use.
See Also:
AnsiStandard.getLongSqlDefinition()

getSqlDefinition

public String getSqlDefinition(String sqlTypeName)
Retrieve a SQL type keyword used by the DBMS for the given Melati type name. Override this in non-Ansi standard dbms to handle variants.

Specified by:
getSqlDefinition in interface Dbms
Overrides:
getSqlDefinition in class AnsiStandard
Parameters:
sqlTypeName - the Melati internal type name
Returns:
this dbms specific type keyword
See Also:
AnsiStandard.getSqlDefinition(java.lang.String)

sqlBooleanValueOfRaw

public String sqlBooleanValueOfRaw(Object raw)
Accomodate different true and false values.

Specified by:
sqlBooleanValueOfRaw in interface Dbms
Overrides:
sqlBooleanValueOfRaw in class AnsiStandard
Returns:
the DBMS specific truth and false values
See Also:
AnsiStandard.sqlBooleanValueOfRaw(java.lang.Object)

getBinarySqlDefinition

public String getBinarySqlDefinition(int size)
                              throws SQLException
Accomodate different treatment of different sized binary data.

Specified by:
getBinarySqlDefinition in interface Dbms
Overrides:
getBinarySqlDefinition in class AnsiStandard
Parameters:
size - how big the field is
Returns:
the keyword to use
Throws:
SQLException
See Also:
AnsiStandard.getBinarySqlDefinition(int)

unreservedName

public String unreservedName(String name)
A pair of functions for getting around keywords which make your JDBC driver barf, as 'group' does for MySQL. Translate special names to non special ones.

Specified by:
unreservedName in interface Dbms
Overrides:
unreservedName in class AnsiStandard
Parameters:
name - the field or table name
Returns:
the name translated if necessary
See Also:
AnsiStandard.unreservedName(java.lang.String)

melatiName

public String melatiName(String name)
Reverse the mapping in unreservedName.

Specified by:
melatiName in interface Dbms
Overrides:
melatiName in class AnsiStandard
Parameters:
name - an SQL name
Returns:
the coresponding name to use within Melati
See Also:
AnsiStandard.melatiName(java.lang.String)

canRepresent

public PoemType canRepresent(PoemType storage,
                             PoemType type)
Enable one PoemType to represent another, for example a bit to represent a boolean.

Specified by:
canRepresent in interface Dbms
Overrides:
canRepresent in class AnsiStandard
Parameters:
storage - the POEM native type
type - the current type
Returns:
the PoemType to use
See Also:
(org.melati.poem.PoemType, org.melati.poem.PoemType)

defaultPoemTypeOfColumnMetaData

public SQLPoemType defaultPoemTypeOfColumnMetaData(ResultSet md)
                                            throws SQLException
The simplest POEM type corresponding to a JDBC description from the database.

Specified by:
defaultPoemTypeOfColumnMetaData in interface Dbms
Overrides:
defaultPoemTypeOfColumnMetaData in class AnsiStandard
Parameters:
md - the JDBC metadata
Returns:
the PoemType to use
Throws:
SQLException - potentially
See Also:
AnsiStandard.defaultPoemTypeOfColumnMetaData(java.sql.ResultSet)

getForeignKeyDefinition

public String getForeignKeyDefinition(String tableName,
                                      String fieldName,
                                      String targetTableName,
                                      String targetTableFieldName,
                                      String fixName)
If Foreign key definitions are part of field definitions, otherwise blank (silently unsupported).

Specified by:
getForeignKeyDefinition in interface Dbms
Overrides:
getForeignKeyDefinition in class AnsiStandard
Parameters:
tableName - the table that this column is in, unquoted
fieldName - often the name of the foreign table, unquoted
targetTableName - the table that this is a foreign key into, unquoted
targetTableFieldName - name of the primary key field of the foreign table, often id, unquoted
fixName - name of the IntegrityFix
Returns:
The definition string
See Also:
AnsiStandard.getForeignKeyDefinition(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

getPrimaryKeyDefinition

public String getPrimaryKeyDefinition(String fieldName)
Return the PRIMARY KEY definition string for this dbms.

Specified by:
getPrimaryKeyDefinition in interface Dbms
Overrides:
getPrimaryKeyDefinition in class AnsiStandard
Parameters:
fieldName - the table Troid column, often id, unquoted
Returns:
The definition string
See Also:
AnsiStandard.getPrimaryKeyDefinition(java.lang.String)

booleanTrueExpression

public String booleanTrueExpression(Column booleanColumn)
Accomodate lack of boolean types.

Specified by:
booleanTrueExpression in interface Dbms
Overrides:
booleanTrueExpression in class AnsiStandard
Returns:
an expresion that evaluates to True ie the column name or column name = 1
See Also:
Dbms.booleanTrueExpression(org.melati.poem.Column)

getSqlDefaultValue

public String getSqlDefaultValue(SQLType sqlType)
Used to set a not null value when creating a non nullable column.

Specified by:
getSqlDefaultValue in interface Dbms
Overrides:
getSqlDefaultValue in class AnsiStandard
Parameters:
sqlType - the type name
Returns:
a String suitable for substitution in UPDATE table SET field = ?
See Also:
AnsiStandard.getSqlDefaultValue(org.melati.poem.SQLType)


Copyright © 2000-2010 PanEris. All Rights Reserved.