All Implemented Interfaces:
Serializable, Cloneable, CorePlatform<ConversionManager>, Platform
Direct Known Subclasses:
Oracle10Platform

public class Oracle9Platform extends Oracle8Platform

Purpose: Supports usage of certain Oracle JDBC specific APIs.

Supports binding NCHAR, NVARCHAR, NCLOB types as required by Oracle JDBC drivers.

Supports Oracle JDBC TIMESTAMP, TIMESTAMPTZ, TIMESTAMPLTZ types.

See Also:
  • Field Details

    • NCHAR

      public static final Class<NCharacter> NCHAR
    • NSTRING

      public static final Class<NString> NSTRING
    • NCLOB

      public static final Class<NClob> NCLOB
    • XMLTYPE

      public static final Class<XMLTypePlaceholder> XMLTYPE
    • driverVersion

      protected transient String driverVersion
    • shouldPrintCalendar

      protected transient boolean shouldPrintCalendar
    • isTimestampInGmt

      protected transient boolean isTimestampInGmt
    • isLtzTimestampInGmt

      protected transient boolean isLtzTimestampInGmt
    • isConnectionDataInitialized

      protected transient boolean isConnectionDataInitialized
    • shouldTruncateDate

      protected boolean shouldTruncateDate
      Indicates whether time component of java.sql.Date should be truncated (hours, minutes, seconds all set to zero) before been passed as a parameter to PreparedStatement. Starting with version 12.1 oracle jdbc Statement.setDate no longer zeroes sql.Date's entire time component (only milliseconds). Set this flag to true to make the platform to truncate days/hours/minutes before passing the date to Statement.setDate method.
  • Constructor Details

    • Oracle9Platform

      public Oracle9Platform()
  • Method Details

    • copyInto

      public void copyInto(Platform platform)
      Copy the state into the new platform.
      Specified by:
      copyInto in interface Platform
      Overrides:
      copyInto in class Oracle8Platform
    • getObjectFromResultSet

      public Object getObjectFromResultSet(ResultSet resultSet, int columnNumber, int type, AbstractSession session) throws SQLException
      INTERNAL: Get a timestamp value from a result set. Overrides the default behavior to specifically return a timestamp. Added to overcome an issue with the oracle 9.0.1.4 JDBC driver.
      Overrides:
      getObjectFromResultSet in class OraclePlatform
      Throws:
      SQLException
      See Also:
      • "org.eclipse.persistence.platform.database.oracle.Oracle9Plaform"
    • getTIMESTAMPTZFromResultSet

      public Object getTIMESTAMPTZFromResultSet(ResultSet resultSet, int columnNumber) throws SQLException
      INTERNAL: Get a TIMESTAMPTZ value from a result set.
      Throws:
      SQLException
    • getTIMESTAMPLTZFromResultSet

      public Object getTIMESTAMPLTZFromResultSet(ResultSet resultSet, int columnNumber, AbstractSession session) throws SQLException
      INTERNAL: Get a TIMESTAMPLTZ value from a result set.
      Throws:
      SQLException
    • shouldUseCustomModifyForCall

      public boolean shouldUseCustomModifyForCall(DatabaseField field)
      INTERNAL Used by SQLCall.appendModify(..) If the field should be passed to customModifyInDatabaseCall, retun true, otherwise false. Methods shouldCustomModifyInDatabaseCall and customModifyInDatabaseCall should be kept in sync: shouldCustomModifyInDatabaseCall should return true if and only if the field is handled by customModifyInDatabaseCall.
      Specified by:
      shouldUseCustomModifyForCall in interface Platform
      Overrides:
      shouldUseCustomModifyForCall in class Oracle8Platform
    • initializePlatformOperators

      protected void initializePlatformOperators()
      INTERNAL: Allow the use of XMLType operators on this platform.
      Overrides:
      initializePlatformOperators in class OraclePlatform
    • buildFieldTypes

      protected Hashtable<Class<?>,FieldTypeDefinition> buildFieldTypes()
      INTERNAL: Add XMLType as the default database type for org.w3c.dom.Documents. Add TIMESTAMP, TIMESTAMP WITH TIME ZONE and TIMESTAMP WITH LOCAL TIME ZONE
      Overrides:
      buildFieldTypes in class Oracle8Platform
    • buildFirstRowsHint

      protected String buildFirstRowsHint(int max)
      Build the hint string used for first rows. Allows it to be overridden
      Overrides:
      buildFirstRowsHint in class OraclePlatform
    • buildClassTypes

      protected Map<String,Class<?>> buildClassTypes()
      INTERNAL: Add TIMESTAMP, TIMESTAMP WITH TIME ZONE and TIMESTAMP WITH LOCAL TIME ZONE
      Overrides:
      buildClassTypes in class DatabasePlatform
    • clone

      public Object clone()
      Specified by:
      clone in interface Platform
      Overrides:
      clone in class DatasourcePlatform
    • convertObject

      public <T> T convertObject(Object sourceObject, Class<T> javaClass) throws ConversionException, DatabaseException
      INTERNAL: Allow for conversion from the Oracle type to the Java type.
      Specified by:
      convertObject in interface CorePlatform<ConversionManager>
      Specified by:
      convertObject in interface Platform
      Overrides:
      convertObject in class DatasourcePlatform
      Parameters:
      sourceObject - the object that must be converted
      javaClass - the class that the object must be converted to
      Returns:
      the newly converted object
      Throws:
      ConversionException - all exceptions will be thrown as this type.
      DatabaseException
    • appendTimestamp

      protected void appendTimestamp(Timestamp timestamp, Writer writer) throws IOException
      INTERNAL: Appends an Oracle specific Timestamp, if usesNativeSQL is true otherwise use the ODBC format. Native Format: to_timestamp ('1997-11-06 10:35:45.656' , 'yyyy-mm-dd hh:mm:ss.ff')
      Overrides:
      appendTimestamp in class OraclePlatform
      Throws:
      IOException
    • appendCalendar

      protected void appendCalendar(Calendar calendar, Writer writer) throws IOException
      INTERNAL: Appends an Oracle specific Timestamp with timezone and daylight time elements if usesNativeSQL is true, otherwise use the ODBC format. Native Format: (DST) to_timestamp_tz ('1997-11-06 10:35:45.345 America/Los_Angeles','yyyy-mm-dd hh:mm:ss.ff TZR TZD') (non-DST) to_timestamp_tz ('1997-11-06 10:35:45.345 America/Los_Angeles','yyyy-mm-dd hh:mm:ss.ff TZR')
      Overrides:
      appendCalendar in class OraclePlatform
      Throws:
      IOException
    • initializeConnectionData

      public void initializeConnectionData(Connection connection) throws SQLException
      INTERNAL:
      Overrides:
      initializeConnectionData in class OraclePlatform
      Throws:
      SQLException
    • clearConnectionData

      public void clearConnectionData()
    • clearOracleConnectionCache

      public void clearOracleConnectionCache(Connection conn)
      INTERNAL: Clears both implicit and explicit caches of OracleConnection
      Overrides:
      clearOracleConnectionCache in class OraclePlatform
    • setParameterValueInDatabaseCall

      public void setParameterValueInDatabaseCall(Object parameter, PreparedStatement statement, int index, AbstractSession session) throws SQLException
      INTERNAL: Note that index (not index+1) is used in statement.setObject(index, parameter) Binding starts with a 1 not 0, so make sure that index > 0. Treat Calendar separately. Bind Calendar as TIMESTAMPTZ.
      Overrides:
      setParameterValueInDatabaseCall in class DatabasePlatform
      Throws:
      SQLException
    • setParameterValueInDatabaseCall

      public void setParameterValueInDatabaseCall(Object parameter, CallableStatement statement, String name, AbstractSession session) throws SQLException
      INTERNAL: Note that index (not index+1) is used in statement.setObject(index, parameter) Binding starts with a 1 not 0, so make sure that index > 0. Treat Calendar separately. Bind Calendar as TIMESTAMPTZ.
      Overrides:
      setParameterValueInDatabaseCall in class DatabasePlatform
      Throws:
      SQLException
    • getTimestampFromServer

      public Timestamp getTimestampFromServer(AbstractSession session, String sessionName)
      INTERNAL: Answer the timestamp from the server. Convert TIMESTAMPTZ to Timestamp
      Specified by:
      getTimestampFromServer in interface Platform
      Overrides:
      getTimestampFromServer in class DatasourcePlatform
    • getTimestampQuery

      public ValueReadQuery getTimestampQuery()
      INTERNAL: This method returns the query to select the SYSTIMESTAMP as TIMESTAMPTZ from the server for Oracle9i.
      Specified by:
      getTimestampQuery in interface Platform
      Overrides:
      getTimestampQuery in class OraclePlatform
    • serverTimestampString

      public String serverTimestampString()
      INTERNAL: Return the current SYSTIMESTAMP as TIMESTAMPTZ from the server.
      Overrides:
      serverTimestampString in class OraclePlatform
    • buildToTIMESTAMPVec

      protected List<Class<?>> buildToTIMESTAMPVec()
    • buildToNStringCharVec

      protected List<Class<?>> buildToNStringCharVec()
    • buildToNClobVec

      protected List<Class<?>> buildToNClobVec()
    • getLobValueLimits

      public int getLobValueLimits()
      PUBLIC: Return the BLOB/CLOB value limits on thin driver. The default value is 0. If usesLocatorForLOBWrite is true, locator will be used in case the lob's size is larger than lobValueLimit.
      Overrides:
      getLobValueLimits in class Oracle8Platform
    • setLobValueLimits

      public void setLobValueLimits(int lobValueLimits)
      PUBLIC: Set the BLOB/CLOB value limits on thin driver. The default value is 0. If usesLocatorForLOBWrite is true, locator will be used in case the lob's size is larger than lobValueLimit.
      Overrides:
      setLobValueLimits in class Oracle8Platform
    • isOracle9Specific

      protected boolean isOracle9Specific(Class<?> type)
      INTERNAL: Return if the type is a special oracle type. bug 3325122 - just checking against the 4 classes is faster than isAssignableFrom MWN.
    • isClob

      protected boolean isClob(Class<?> type)
      INTERNAL: Used in write LOB method only to identify a CLOB.
      Overrides:
      isClob in class Oracle8Platform
    • getCustomModifyValueForCall

      public Object getCustomModifyValueForCall(Call call, Object value, DatabaseField field, boolean shouldBind)
      INTERNAL: Used by SQLCall.translate(..) The binding *must* be performed (NCHAR, NSTRING, NCLOB). In these special cases the method returns a wrapper object which knows whether it should be bound or appended and knows how to do that.
      Specified by:
      getCustomModifyValueForCall in interface Platform
      Overrides:
      getCustomModifyValueForCall in class Oracle8Platform
    • buildFromStringCharVec

      protected List buildFromStringCharVec(Class<?> javaClass)
    • getDataTypesConvertedFrom

      public List<Class<?>> getDataTypesConvertedFrom(Class<?> javaClass)
      INTERNAL: Return the list of Classes that can be converted to from the passed in javaClass. oracle.sql.TIMESTAMP and NCHAR types are added in some lists.
      Overrides:
      getDataTypesConvertedFrom in class DatasourcePlatform
      Parameters:
      javaClass - - the class that is converted from
      Returns:
      - a vector of classes
    • getDataTypesConvertedTo

      public List<Class<?>> getDataTypesConvertedTo(Class<?> javaClass)
      INTERNAL: Return the list of Classes that can be converted from to the passed in javaClass. A list is added for oracle.sql.TIMESTAMP and NCHAR types.
      Overrides:
      getDataTypesConvertedTo in class DatasourcePlatform
      Parameters:
      javaClass - - the class that is converted to
      Returns:
      - a vector of classes
    • getJDBCTypeForSetNull

      public int getJDBCTypeForSetNull(DatabaseField field)
      Return the JDBC type for the given database field to be passed to Statement.setNull The Oracle driver does not like the OPAQUE type so VARCHAR must be used.
      Overrides:
      getJDBCTypeForSetNull in class DatabasePlatform
    • getJDBCType

      public int getJDBCType(Class<?> javaType)
      Return the JDBC type for the Java type. The Oracle driver does not like the OPAQUE type so VARCHAR must be used.
      Overrides:
      getJDBCType in class DatabasePlatform
    • executeBatch

      public int executeBatch(Statement statement, boolean isStatementPrepared) throws SQLException
      INTERNAL: This gets called on each batch statement execution Needs to be implemented so that it returns the number of rows successfully modified by this statement for optimistic locking purposes (if useNativeBatchWriting is enabled, and the call uses optimistic locking).
      Overrides:
      executeBatch in class DatabasePlatform
      Parameters:
      isStatementPrepared - - flag is set to true if this statement is prepared
      Returns:
      - number of rows modified/deleted by this statement
      Throws:
      SQLException
    • addBatch

      public int addBatch(PreparedStatement statement) throws SQLException
      INTERNAL: This gets called on each iteration to add parameters to the batch Needs to be implemented so that it returns the number of rows successfully modified by this statement for optimistic locking purposes (if useNativeBatchWriting is enabled, and the call uses optimistic locking). Is used with parameterized SQL
      Overrides:
      addBatch in class DatabasePlatform
      Returns:
      - number of rows modified/deleted by this statement if it was executed (0 if it wasn't)
      Throws:
      SQLException
    • prepareBatchStatement

      public Statement prepareBatchStatement(Statement statement, int maxBatchWritingSize) throws SQLException
      INTERNAL: Allows setting the batch size on the statement Is used with parameterized SQL, and should only be passed in prepared statements
      Overrides:
      prepareBatchStatement in class DatabasePlatform
      Returns:
      - statement to be used for batch writing
      Throws:
      SQLException
    • getXMLTypeFactory

      protected XMLTypeFactory getXMLTypeFactory()
      INTERNAL: Lazy initialization of xmlTypeFactory allows to avoid loading xdb-dependent class XMLTypeFactoryImpl unless xdb is used.
      Returns:
      XMLTypeFactory
    • isXDBDocument

      public boolean isXDBDocument(Object obj)
      INTERNAL: Indicates whether the passed object is an instance of XDBDocument.
      Overrides:
      isXDBDocument in class DatabasePlatform
      Returns:
      boolean
    • canUnwrapOracleConnection

      public boolean canUnwrapOracleConnection()
      INTERNAL: Indicates whether this Oracle platform can unwrap Oracle connection.
      Overrides:
      canUnwrapOracleConnection in class OraclePlatform
    • unwrapOracleConnection

      public Connection unwrapOracleConnection(Connection connection)
      INTERNAL: If can unwrap returns unwrapped Oracle connection, otherwise original connection.
      Overrides:
      unwrapOracleConnection in class OraclePlatform
    • isOracle9

      public boolean isOracle9()
      PUBLIC: Return is this is the Oracle 9 platform.
      Specified by:
      isOracle9 in interface Platform
      Overrides:
      isOracle9 in class DatasourcePlatform
    • createConnectionCustomizer

      public ConnectionCustomizer createConnectionCustomizer(Accessor accessor, AbstractSession session)
      INTERNAL:
      Overrides:
      createConnectionCustomizer in class DatasourcePlatform
    • getDriverVersion

      public String getDriverVersion()
      INTERNAL: Return the driver version.
      Specified by:
      getDriverVersion in interface Platform
      Overrides:
      getDriverVersion in class DatasourcePlatform
    • isTimestampInGmt

      public boolean isTimestampInGmt()
      INTERNAL: Return if timestamps are returned in GMT by the driver.
    • isLtzTimestampInGmt

      public boolean isLtzTimestampInGmt()
      INTERNAL: Return if ltz timestamps are returned in GMT by the driver.
    • shouldTruncateDate

      public boolean shouldTruncateDate()
      PUBLIC: Indicates whether time component of java.sql.Date should be truncated (hours, minutes, seconds all set to zero) before been passed as a parameter to PreparedStatement. Starting with version 12.1 oracle jdbc Statement.setDate no longer zeroes sql.Date's entire time component (only milliseconds). "true" indicates that the platform truncates days/hours/minutes before passing the date to Statement.setDate method.
    • setShouldTruncateDate

      public void setShouldTruncateDate(boolean shouldTruncateDate)
      PUBLIC: Indicates whether time component of java.sql.Date should be truncated (hours, minutes, seconds all set to zero) before been passed as a parameter to PreparedStatement. Starting with version 12.1 oracle jdbc Statement.setDate no longer zeroes sql.Date's entire time component (only milliseconds). Set this flag to true to make the platform to truncate days/hours/minutes before passing the date to Statement.setDate method.
    • supportsConnectionUserName

      public boolean supportsConnectionUserName()
      INTERNAL: User name from JDBC connection is stored in initializeConnectionData(Connection).
      Overrides:
      supportsConnectionUserName in class DatabasePlatform
      Returns:
      Always returns true
    • getConnectionUserName

      public String getConnectionUserName()
      INTERNAL: Returns user name retrieved from JDBC connection. initializeConnectionData(Connection) shall be called before this method.
      Overrides:
      getConnectionUserName in class DatabasePlatform
      Returns:
      User name retrieved from JDBC connection.