All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class oracle.sql.SQLUtil

java.lang.Object
   |
   +----oracle.sql.SQLUtil

public class SQLUtil
extends Object
SQL utility class. This class consists of a collection of static utility methods.


Constructor Index

 o SQLUtil()

Method Index

 o checkDatumType(Datum, int, String)
Check if the Datum is compatible with the specified SQL type.
 o get_internal_type(int)
 o getTypeDescriptor(String, OracleConnection)
Obtain the type descriptor associated with the specified type name.
 o implementsInterface(Class, Class)
Check if a class implements an interface.
 o JavaToSQL(OracleConnection, Object, int, String)
Convert a Java object to SQL data bytes.
 o main(String[])
 o makeDatum(OracleConnection, byte[], int, String)
Create a Datum object from the input SQL data.
 o makeDatum(OracleConnection, Object, int, String)
Create a Datum object from an input Java object.
 o makeOracleDatum(OracleConnection, Object, int, String)
Create a Datum object from an input Java object.
 o SQLToJava(OracleConnection, byte[], int, String, Class, Dictionary)
Convert SQL data bytes to a Java object.
 o SQLToJava(OracleConnection, byte[], int, String, CustomDatumFactory)
Convert SQL data bytes to a CustomDatum object.
 o SQLToJava(OracleConnection, Datum, Class, Dictionary)
Convert a Datum object to a Java object.

Constructors

 o SQLUtil
 public SQLUtil()

Methods

 o SQLToJava
 public static Object SQLToJava(OracleConnection connection,
                                byte sqlData[],
                                int sqlTypeCode,
                                String sqlTypeName,
                                Class javaClass,
                                Dictionary map) throws 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.dbaccess.DBType.
sqlTypeName specifies - the fully-qualified type name of the SQL data if sqlTypeCode is DBType.REF_TYPE or DBType.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 DBType.NAMED_TYPE. Use 'null' if the type map association with the specified connection is desired.
Returns:
the resulting Java object.
Throws: SQLException
if the conversion is illegal, or if an error occurred.
 o SQLToJava
 public static CustomDatum SQLToJava(OracleConnection connection,
                                     byte sqlData[],
                                     int sqlTypeCode,
                                     String sqlTypeName,
                                     CustomDatumFactory factory) throws 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.dbaccess.DBType.
sqlTypeName specifies - the fully-qualified type name of the SQL data if sqlTypeCode is DBType.REF_TYPE or DBType.NAMED_TYPE. This parameter is ignored for other type codes.
factory specifies - the factory to create the CustomDatum.
Returns:
the resulting Java object.
Throws: SQLException
if the conversion is illegal, or if an error occurred.
 o SQLToJava
 public static Object SQLToJava(OracleConnection connection,
                                Datum datum,
                                Class javaClass,
                                Dictionary map) throws 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: SQLException
if the conversion is illegal, or if an error occurred.
 o JavaToSQL
 public static byte[] JavaToSQL(OracleConnection connection,
                                Object inObject,
                                int sqlTypeCode,
                                String sqlTypeName) throws 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.dbaccess.DBType for the appropriate type codes.
sqlTypeName specifies - the fully-qualified type name if sqlTypeCode is DBType.REF_TYPE or DBType.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: SQLException
if the conversion is illegal, or if an error occurs.
 o makeDatum
 public static Datum makeDatum(OracleConnection connection,
                               byte sqlData[],
                               int sqlTypeCode,
                               String sqlTypeName) throws 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.dbaccess.DBType.
sqlTypeName specifies - the fully-qualified name of the SQL data if sqlTypeCode is DBType.REF_TYPE or DBType.NAMED_TYPE. This parameter is ignored for other type codes.
Returns:
the resulting Datum object.
Throws: SQLException
if failed to construct a Datum object from the specified input.
 o makeDatum
 public static Datum makeDatum(OracleConnection connection,
                               Object inObject,
                               int sqlTypeCode,
                               String sqlTypeName) throws 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.dbaccess.DBType.
sqlTypeName specifies - the fully-qualified name of the SQL data if sqlTypeCode is DBType.REF_TYPE or DBType.NAMED_TYPE. This parameter is ignored for other type codes.
Returns:
the resulting Datum object.
Throws: SQLException
if failed to construct a Datum object from the specified input.
 o getTypeDescriptor
 public static Object getTypeDescriptor(String name,
                                        OracleConnection conn) throws 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: SQLException
if the specified type does not exist, or if an error occurred.
 o checkDatumType
 public static boolean checkDatumType(Datum datum,
                                      int sqlType,
                                      String sqlTypeName) throws SQLException
Check if the Datum is compatible with the specified SQL type.

Parameters:
datum specifies - the Datum object to be tested.
sqlTypeCode specifies - the expected type of the input datum. Use type code defined in oracle.jdbc.dbaccess.DBType.
sqlTypeName specifies - the expected type name of the input datum if sqlTypeCode is DBType.REF_TYPE or DBType.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: SQLException
if errors occurred.
 o implementsInterface
 public static boolean implementsInterface(Class clazz,
                                           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.
 o makeOracleDatum
 public static Datum makeOracleDatum(OracleConnection connection,
                                     Object inObject,
                                     int typeCode,
                                     String sqlTypeName) throws 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.OracleTypes.
sqlTypeName specifies - the fully-qualified name of the SQL data if typeCode is OracleTypes.REF or OracleTypes.STRUCT or OracleTypes.ARRAY. This parameter is ignored for other type codes.
Returns:
the resulting Datum object.
Throws: SQLException
if failed to construct a Datum object from the specified input.
 o get_internal_type
 public static int get_internal_type(int external_type) throws SQLException
 o main
 public static void main(String args[]) throws SQLException

All Packages  Class Hierarchy  This Package  Previous  Next  Index