Oracle10g JDBC

oracle.jdbc.driver
Class SQLUtil

java.lang.Object
  extended byoracle.jdbc.driver.SQLUtil

public class SQLUtil
extends java.lang.Object

SQL utility class. This class consists of a collection of static utility methods.


Field Summary
static java.lang.String BUILD_DATE
           
static boolean PRIVATE_TRACE
           
static boolean TRACE
           
 
Constructor Summary
SQLUtil()
           
 
Method Summary
static boolean checkDatumType(Datum datum, int sqlType, java.lang.String sqlTypeName)
          Check if the Datum is compatible with the specified SQL type.
static int get_internal_type(int external_type)
           
static java.lang.Object getTypeDescriptor(java.lang.String name, oracle.jdbc.internal.OracleConnection conn)
          Obtain the type descriptor associated with the specified type name.
static boolean implementsInterface(java.lang.Class clazz, java.lang.Class interfaze)
          Check if a class implements an interface.
static byte[] JavaToSQL(oracle.jdbc.internal.OracleConnection connection, java.lang.Object inObject, int sqlTypeCode, java.lang.String sqlTypeName)
          Convert a Java object to SQL data bytes.
static Datum makeDatum(oracle.jdbc.internal.OracleConnection connection, byte[] sqlData, int sqlTypeCode, java.lang.String sqlTypeName, int maxLen)
          Create a Datum object from the input SQL data.
static Datum makeDatum(oracle.jdbc.internal.OracleConnection connection, java.lang.Object inObject, int sqlTypeCode, java.lang.String sqlTypeName)
          Create a Datum object from an input Java object.
static Datum makeNDatum(oracle.jdbc.internal.OracleConnection connection, byte[] sqlData, int sqlTypeCode, java.lang.String sqlTypeName, short form, int maxLen)
           
static Datum makeOracleDatum(oracle.jdbc.internal.OracleConnection connection, java.lang.Object inObject, int typeCode, java.lang.String sqlTypeName)
          Create a Datum object from an input Java object.
static java.lang.Object SQLToJava(oracle.jdbc.internal.OracleConnection connection, byte[] sqlData, int sqlTypeCode, java.lang.String sqlTypeName, java.lang.Class javaClass, java.util.Map map)
          Convert SQL data bytes to a Java object.
static CustomDatum SQLToJava(oracle.jdbc.internal.OracleConnection connection, byte[] sqlData, int sqlTypeCode, java.lang.String sqlTypeName, CustomDatumFactory factory)
          Convert SQL data bytes to a CustomDatum object.
static ORAData SQLToJava(oracle.jdbc.internal.OracleConnection connection, byte[] sqlData, int sqlTypeCode, java.lang.String sqlTypeName, ORADataFactory factory)
          Convert SQL data bytes to a ORAData object.
static java.lang.Object SQLToJava(oracle.jdbc.internal.OracleConnection connection, Datum datum, java.lang.Class javaClass, java.util.Map map)
          Convert a Datum object to a Java object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE

public static final boolean TRACE
See Also:
Constant Field Values

PRIVATE_TRACE

public static final boolean PRIVATE_TRACE
See Also:
Constant Field Values

BUILD_DATE

public static final java.lang.String BUILD_DATE
See Also:
Constant Field Values
Constructor Detail

SQLUtil

public SQLUtil()
Method Detail

SQLToJava

public static java.lang.Object SQLToJava(oracle.jdbc.internal.OracleConnection connection,
                                         byte[] sqlData,
                                         int sqlTypeCode,
                                         java.lang.String sqlTypeName,
                                         java.lang.Class javaClass,
                                         java.util.Map map)
                                  throws java.sql.SQLException
Convert SQL data bytes to a Java object. It first creates a Datum, and then converts the Datum to the appropriate Java object. This method does not handle the case of creating a CustomDatum. There is an overloaded method that takes a CustomDatumFactory (instead of a java class) for creating a CustomDatum.

Parameters:
connection - specifies the associated connection.
sqlData - specifies the input SQL data.
sqlTypeCode - specifies the type information of the input sqlData. Use type code defined in oracle.jdbc.driver.Accessor.
sqlTypeName - specifies the fully-qualified type name of the SQL data if sqlTypeCode is Accessor.REF_TYPE or Accessor.NAMED_TYPE. This parameter is ignored for other type codes.
javaClass - specifies the Java class to which sqlData is converted. CustomDatum is not supported. Use 'null' if the default mapping is desired.
map - specifies any type map to be used for a named-type. This argument is ignored if sqlTypeCode is not Accessor.NAMED_TYPE. Use 'null' if the type map association with the specified connection is desired.
Returns:
the resulting Java object.
Throws:
java.sql.SQLException - if the conversion is illegal, or if an error occurred.

SQLToJava

public static CustomDatum SQLToJava(oracle.jdbc.internal.OracleConnection connection,
                                    byte[] sqlData,
                                    int sqlTypeCode,
                                    java.lang.String sqlTypeName,
                                    CustomDatumFactory factory)
                             throws java.sql.SQLException
Convert SQL data bytes to a CustomDatum object.

Parameters:
connection - specifies the associated connection.
sqlData - specifies the input SQL data.
sqlTypeCode - specifies the type information of the input sqlData. Use type code defined in oracle.jdbc.driver.Accessor.
sqlTypeName - specifies the fully-qualified type name of the SQL data if sqlTypeCode is Accessor.REF_TYPE or Accessor.NAMED_TYPE. This parameter is ignored for other type codes.
factory - specifies the factory to create the CustomDatum.
Returns:
the resulting Java object.
Throws:
java.sql.SQLException - if the conversion is illegal, or if an error occurred.

SQLToJava

public static ORAData SQLToJava(oracle.jdbc.internal.OracleConnection connection,
                                byte[] sqlData,
                                int sqlTypeCode,
                                java.lang.String sqlTypeName,
                                ORADataFactory factory)
                         throws java.sql.SQLException
Convert SQL data bytes to a ORAData object.

Parameters:
connection - specifies the associated connection.
sqlData - specifies the input SQL data.
sqlTypeCode - specifies the type information of the input sqlData. Use type code defined in oracle.jdbc.driver.Accessor.
sqlTypeName - specifies the fully-qualified type name of the SQL data if sqlTypeCode is Accessor.REF_TYPE or Accessor.NAMED_TYPE. This parameter is ignored for other type codes.
factory - specifies the factory.
Returns:
the resulting Java object.
Throws:
java.sql.SQLException - if the conversion is illegal, or if an error occurred.

SQLToJava

public static java.lang.Object SQLToJava(oracle.jdbc.internal.OracleConnection connection,
                                         Datum datum,
                                         java.lang.Class javaClass,
                                         java.util.Map map)
                                  throws java.sql.SQLException
Convert a Datum object to a Java object. For the most part, it utilizes the conversion methods built into the Datum classes. This method does not handle the case of creating a CustomDatum. There is an overloaded method that takes a CustomDatumFactory (instead of a java class) for creating a CustomDatum.

Parameters:
connection - specifies the associated connection.
datum - specifies the input Datum object.
javaClass - specifies the Java class to which datum is converted. CustomDatum is not supported. Use 'null' if the default mapping is desired.
map - specifies any type map to be used for a STRUCT datum. This argument is ignored if 'datum' is not a STRUCT. Use 'null' if the type map association with the specified connection is desired.
Returns:
the resulting Java object.
Throws:
java.sql.SQLException - if the conversion is illegal, or if an error occurred.

JavaToSQL

public static byte[] JavaToSQL(oracle.jdbc.internal.OracleConnection connection,
                               java.lang.Object inObject,
                               int sqlTypeCode,
                               java.lang.String sqlTypeName)
                        throws java.sql.SQLException
Convert a Java object to SQL data bytes. For the most part, it utilizes the conversion capabilities built into the CustomDatum and Datum classes.

Parameters:
connection - specifies the associated connection.
inObject - specifies the input Java object.
sqlTypeCode - specifies the SQL type to which the input object is converted. See oracle.jdbc.driver.Accessor for the appropriate type codes.
sqlTypeName - specifies the fully-qualified type name if sqlTypeCode is Accessor.REF_TYPE or Accessor.NAMED_TYPE. This parameter is ignored for other type codes.
Returns:
the resulting SQL data bytes, or null if the input object is null.
Throws:
java.sql.SQLException - if the conversion is illegal, or if an error occurs.

makeDatum

public static Datum makeDatum(oracle.jdbc.internal.OracleConnection connection,
                              byte[] sqlData,
                              int sqlTypeCode,
                              java.lang.String sqlTypeName,
                              int maxLen)
                       throws java.sql.SQLException
Create a Datum object from the input SQL data.

Parameters:
connection - specifies the associated connection.
sqlData - specifies the input SQL data.
sqlTypeCode - specifies the type information of the input sqlData. Use type code defined in oracle.jdbc.driver.Accessor.
sqlTypeName - specifies the fully-qualified name of the SQL data if sqlTypeCode is Accessor.REF_TYPE or Accessor.NAMED_TYPE. This parameter is ignored for other type codes.
maxLen - if the type is Accessor.CHAR and maxLen is non-zero, the resulting Datum object (which will be a CHAR) will be have a maximum length set to this value rather than sqlData.length.
Returns:
the resulting Datum object.
Throws:
java.sql.SQLException - if failed to construct a Datum object from the specified input.

makeNDatum

public static Datum makeNDatum(oracle.jdbc.internal.OracleConnection connection,
                               byte[] sqlData,
                               int sqlTypeCode,
                               java.lang.String sqlTypeName,
                               short form,
                               int maxLen)
                        throws java.sql.SQLException
Throws:
java.sql.SQLException

makeDatum

public static Datum makeDatum(oracle.jdbc.internal.OracleConnection connection,
                              java.lang.Object inObject,
                              int sqlTypeCode,
                              java.lang.String sqlTypeName)
                       throws java.sql.SQLException
Create a Datum object from an input Java object.

Parameters:
connection - specifies the associated connection.
inObject - specifies the input object.
sqlTypeCode - specifies the type information of the input sqlData. Use type code defined in oracle.jdbc.driver.Accessor.
sqlTypeName - specifies the fully-qualified name of the SQL data if sqlTypeCode is Accessor.REF_TYPE or Accessor.NAMED_TYPE. This parameter is ignored for other type codes.
Returns:
the resulting Datum object.
Throws:
java.sql.SQLException - if failed to construct a Datum object from the specified input.

getTypeDescriptor

public static java.lang.Object getTypeDescriptor(java.lang.String name,
                                                 oracle.jdbc.internal.OracleConnection conn)
                                          throws java.sql.SQLException
Obtain the type descriptor associated with the specified type name.

Parameters:
name - specifies the type name.
conn - specifies the associated connection.
Returns:
the appropriate descriptor for Array or Struct depending on the type name.
Throws:
java.sql.SQLException - if the specified type does not exist, or if an error occurred.

checkDatumType

public static boolean checkDatumType(Datum datum,
                                     int sqlType,
                                     java.lang.String sqlTypeName)
                              throws java.sql.SQLException
Check if the Datum is compatible with the specified SQL type.

Parameters:
datum - specifies the Datum object to be tested.
sqlTypeName - specifies the expected type name of the input datum if sqlTypeCode is Accessor.REF_TYPE or Accessor.NAMED_TYPE. This parameter is ignored for other type codes.
Returns:
true if Datum is compatible with the specified SQL type, or false if not.
Throws:
java.sql.SQLException - if errors occurred.

implementsInterface

public static boolean implementsInterface(java.lang.Class clazz,
                                          java.lang.Class interfaze)
Check if a class implements an interface.

Parameters:
clazz - specifies the class to be tested.
interfaze - specifies the interface.
Returns:
true if clazz implements interfaze, or false if not.

makeOracleDatum

public static Datum makeOracleDatum(oracle.jdbc.internal.OracleConnection connection,
                                    java.lang.Object inObject,
                                    int typeCode,
                                    java.lang.String sqlTypeName)
                             throws java.sql.SQLException
Create a Datum object from an input Java object.

Parameters:
connection - specifies the associated connection.
inObject - specifies the input object.
typeCode - specifies the type information to be converted to. Use type code defined in java.jdbc.driver.oracle.jdbc.internal.OracleTypes.
sqlTypeName - specifies the fully-qualified name of the SQL data if typeCode is oracle.jdbc.internal.OracleTypes.REF or oracle.jdbc.internal.OracleTypes.STRUCT or oracle.jdbc.internal.OracleTypes.ARRAY. This parameter is ignored for other type codes.
Returns:
the resulting Datum object.
Throws:
java.sql.SQLException - if failed to construct a Datum object from the specified input.

get_internal_type

public static int get_internal_type(int external_type)
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

Oracle10g JDBC

Copyright © 1998,2004, Oracle. All rights reserved