Skip navigation links

Oracle Database JDBC Java API Reference
11g Release 2

E13995-03


oracle.sql
Interface CustomDatum

All Superinterfaces:
oracle.jdbc.internal.ObjectData

public interface CustomDatum
extends oracle.jdbc.internal.ObjectData

This is an interface for encapsulating SQL Types into Java types of the user's choice. The user class can present a customized version of the SQL type. You can get and set values of the Java type as appropriate.

You can have lots of different classes implementing CustomDatum for a particular SQLType but generally each type implementing CustomDatum will be used for only a single SQLType.

The original motivation for this class is the jpub generator which examines SQL types (especially Object types) and creates "well typed" java versions. This includes Object types, Ref types and Array types.

It was also partially "inspired" by the jdbc2 SQLData interface.

For use as a SQLJ type a class that implements CustomDatum will contain static fields and methods declared as

  public static CustomDatumFactory getFactory() ...

  public static final int _SQLJ_TYPECODE = oracle.jdbc.driver.Types ....;

  // for STRUCT and ARRAY
  public static final String _SQLJ_name="O____" ;

  // for REF and ARRAY
  public static final String _SQLJ_BASETYPE = "...." ;
  

Typical use would be

  Emp e = ...
  OraclePreparedStatement stmt = .... ;
  stmt.setCustom(n, e);
  
See Also:
CustomDatumFactory, oracle.jdbc.driver.PreparedStatement, SQLData

Method Summary
 Datum toDatum(oracle.jdbc.driver.OracleConnection c)
          Called by setOracleObject to extract a Datum.

 

Method Detail

toDatum

Datum toDatum(oracle.jdbc.driver.OracleConnection c)
              throws java.sql.SQLException
Called by setOracleObject to extract a Datum. It is the CustomDatum's responsibility to be sure that it returns the correct category of Datum.

Most EmbedDatum's will ignore the connection, but it is occassionally needed. For example, if the class embeds CHAR's it may nees the connection to determine the database character set.

Parameters:
c - The connection into which the value is being sent.
Returns:
a Datum containg the value to be sent into the connection.
Throws:
java.sql.SQLException

Skip navigation links

Oracle Database JDBC Java API Reference
11g Release 2

E13995-03


Copyright © 2009, Oracle and/or its affiliates. All rights reserved.