Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

oracle.adfnmc.model.util
Class DatabaseUtils

java.lang.Object
  extended by oracle.adfnmc.model.util.DatabaseUtils

public final class DatabaseUtils
extends java.lang.Object


Field Summary
static java.lang.Class CLASS_INSTANCE
           
static java.lang.String DBSEQUENCE
           
static int DBTYPE_HSQL
           
static int DBTYPE_OLITE
           
static int DBTYPE_POINTBASE
           
static int DBTYPE_SQLITE
           
static int DBTYPE_UNKNOWN
           
static java.lang.String HSQL_DBCLASSNAME
           
static java.lang.String OLITE_DBCLASSNAME
           
static java.lang.String OLITE_PRODUCTNAME
           
static java.lang.String POINTBASE_DBCLASSNAME
           
static java.lang.String POINTBASE_PRODUCTNAME
           
static java.lang.String SECURITY_CONTEXT_NAME
           
static java.lang.String SQLITE_DBCLASSNAME
           
static java.lang.String SQLITE_PRODUCTNAME
           
 
Method Summary
static java.lang.String buildXMLParametersForTRS(java.lang.String[] types, java.util.Vector values)
          Build a String for the PARAMS attribute of an entry in the REPLAY_ITEM table for TRS.
static void closeAllDBConnections()
          Close ALL Connection's.
static void closeSilently(Connection c)
          Close a Connection object silently, i.e.
static void closeSilently(ResultSet rs)
          Close a ResultSet object silently, ignoring any Exceptions that may be thrown.
static void closeSilently(Statement s)
          Close a statement object silently, i.e.
static java.lang.Class createJavaType(java.lang.String value)
          Attempt to convert the fully-qualified string value to a Class object.
static void deleteDatabaseIfNecessary(ConnectionDetails details)
           
static void describeTable(Connection conn, java.lang.String tableName, java.lang.String logName)
          Print a description of the named table to the specified logger.
static void dropAllTables(Connection conn)
          Delete all tables and associated data from the specified Connection object
static void dropAllTablesExcept(Connection conn, java.lang.String[] keepTables)
           
static void dumpAllTables(Connection conn)
          Prints the contents of all tables in this database via the Trace facility.
static void dumpTableContents(Connection conn, java.lang.String tableName)
          Prints the contents of the named table via the Trace facility.
static void dumpTableContents(Connection conn, java.lang.String tableName, java.lang.String logName)
          Prints the contents of a particular table to the specified log channel
static void executeScriptFromFile(Connection conn, java.lang.String fileName)
          Execute a SQL script stored in the provided resource filename
static void executeScriptFromString(Connection conn, java.lang.String sql)
          Execute a SQL script stored in the provided String
static java.lang.String getConnectionClassName()
          Get the fully-qualified name of the Connection implementation to use
static java.lang.String getConnectionURL(ConnectionDetails details)
           
static int getCurrentDBType()
          Returns an integer value representing the type of database currently in use, e.g.
static int getDBType(Connection conn)
           
static java.lang.Object getNativeDBHandle(Connection conn)
          Given a generic Connection object, attempt to return the underlying native implementation of that Connection object.
static java.lang.Object getResultSetDatumByColumnType(ResultSet resultSet, int index, java.lang.String rsColumnType)
          Get an attribute value from the provided ResultSet as the specified Column type
static java.lang.Object getResultSetDatumByJavaType(ResultSet resultSet, int index, java.lang.String javaType)
          Get an attribute value from the provided ResultSet as the specified Java type
static java.lang.String[] getTableNames(Connection conn)
          Gets a list of all the table names in the database specified by the Connection
static void init()
          Entry point for startup code in the Model layer
static boolean isBlackberrySQLite()
           
static void registerNativeDBHandleProvider(NativeDBHandleProvider provider)
           
static void reinitializeDatabaseFromScript(ConnectionDetails dbCredentials)
           
static void reinitializeDatabaseFromScripts(ConnectionDetails dbCredentials, java.lang.String[] scriptNames, boolean dropAllTablesFirst)
           
static void setPreparedStatementDatum(PreparedStatement statement, int index, java.lang.Object value)
          Set the specified attribute value in the provided PreparedStatement
static void shutdown()
          Entry point for cleanup code in the Model layer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_INSTANCE

public static final java.lang.Class CLASS_INSTANCE

POINTBASE_DBCLASSNAME

public static final java.lang.String POINTBASE_DBCLASSNAME
See Also:
Constant Field Values

POINTBASE_PRODUCTNAME

public static final java.lang.String POINTBASE_PRODUCTNAME
See Also:
Constant Field Values

OLITE_DBCLASSNAME

public static final java.lang.String OLITE_DBCLASSNAME
See Also:
Constant Field Values

OLITE_PRODUCTNAME

public static final java.lang.String OLITE_PRODUCTNAME
See Also:
Constant Field Values

HSQL_DBCLASSNAME

public static final java.lang.String HSQL_DBCLASSNAME
See Also:
Constant Field Values

SQLITE_DBCLASSNAME

public static final java.lang.String SQLITE_DBCLASSNAME
See Also:
Constant Field Values

SQLITE_PRODUCTNAME

public static final java.lang.String SQLITE_PRODUCTNAME
See Also:
Constant Field Values

DBSEQUENCE

public static final java.lang.String DBSEQUENCE
See Also:
Constant Field Values

DBTYPE_UNKNOWN

public static final int DBTYPE_UNKNOWN
See Also:
Constant Field Values

DBTYPE_POINTBASE

public static final int DBTYPE_POINTBASE
See Also:
Constant Field Values

DBTYPE_OLITE

public static final int DBTYPE_OLITE
See Also:
Constant Field Values

DBTYPE_SQLITE

public static final int DBTYPE_SQLITE
See Also:
Constant Field Values

DBTYPE_HSQL

public static final int DBTYPE_HSQL
See Also:
Constant Field Values

SECURITY_CONTEXT_NAME

public static final java.lang.String SECURITY_CONTEXT_NAME
See Also:
Constant Field Values
Method Detail

getTableNames

public static final java.lang.String[] getTableNames(Connection conn)
                                              throws SQLException
Gets a list of all the table names in the database specified by the Connection

Parameters:
conn - Connection to retrieve tables for
Returns:
An array of table names. An empty, 0-length array is returned if there are no tables
Throws:
SQLException

dumpAllTables

public static final void dumpAllTables(Connection conn)
Prints the contents of all tables in this database via the Trace facility. Useful for debugging.

Parameters:
conn - Connection to dump table data for

describeTable

public static final void describeTable(Connection conn,
                                       java.lang.String tableName,
                                       java.lang.String logName)
                                throws SQLException
Print a description of the named table to the specified logger. This description contains the name of each column in the table, as well as the data type of that column.

Parameters:
conn -
tableName -
logName -
Throws:
SQLException

dumpTableContents

public static final void dumpTableContents(Connection conn,
                                           java.lang.String tableName,
                                           java.lang.String logName)
                                    throws SQLException
Prints the contents of a particular table to the specified log channel

Parameters:
conn -
tableName -
logName -
Throws:
SQLException

dumpTableContents

public static final void dumpTableContents(Connection conn,
                                           java.lang.String tableName)
                                    throws SQLException
Prints the contents of the named table via the Trace facility. Useful for debugging.

Parameters:
conn - Connection that holds the named table
tableName - Name of table to dump
Throws:
SQLException

dropAllTables

public static final void dropAllTables(Connection conn)
                                throws SQLException
Delete all tables and associated data from the specified Connection object

Parameters:
conn - Connection for which tables should be dropped
Throws:
SQLException

dropAllTablesExcept

public static final void dropAllTablesExcept(Connection conn,
                                             java.lang.String[] keepTables)

executeScriptFromString

public static final void executeScriptFromString(Connection conn,
                                                 java.lang.String sql)
                                          throws SQLException
Execute a SQL script stored in the provided String

Parameters:
conn -
sql -
Throws:
SQLException

executeScriptFromFile

public static final void executeScriptFromFile(Connection conn,
                                               java.lang.String fileName)
                                        throws SQLException
Execute a SQL script stored in the provided resource filename

Parameters:
conn -
fileName -
Throws:
SQLException

getResultSetDatumByJavaType

public static final java.lang.Object getResultSetDatumByJavaType(ResultSet resultSet,
                                                                 int index,
                                                                 java.lang.String javaType)
                                                          throws SQLException
Get an attribute value from the provided ResultSet as the specified Java type

Parameters:
resultSet - ResultSet object
index - 1-based index of attribute to retrieve
javaType - Name of Java object to return datum as
Returns:
A object of the specified type containing the value in the ResultSet at the specified index
Throws:
SQLException

setPreparedStatementDatum

public static final void setPreparedStatementDatum(PreparedStatement statement,
                                                   int index,
                                                   java.lang.Object value)
Set the specified attribute value in the provided PreparedStatement

Parameters:
statement -
index -
value -

getResultSetDatumByColumnType

public static final java.lang.Object getResultSetDatumByColumnType(ResultSet resultSet,
                                                                   int index,
                                                                   java.lang.String rsColumnType)
                                                            throws SQLException
Get an attribute value from the provided ResultSet as the specified Column type

Parameters:
resultSet - ResultSet object
index - 1-based index of attribute to retrieve
rsColumnType - Name of desired Column type
Returns:
Throws:
SQLException

closeSilently

public static final void closeSilently(Connection c)
Close a Connection object silently, i.e. ignore any errors that are thrown.

Parameters:
c - Connection to close

closeSilently

public static final void closeSilently(Statement s)
Close a statement object silently, i.e. ignore any Exceptions that are thrown

Parameters:
s -

closeSilently

public static final void closeSilently(ResultSet rs)
Close a ResultSet object silently, ignoring any Exceptions that may be thrown.

Parameters:
rs -

closeAllDBConnections

public static final void closeAllDBConnections()
Close ALL Connection's. This method exists to support PointBase, which does not do well in the face of a connection that was not closed prior to the application exiting.


createJavaType

public static final java.lang.Class createJavaType(java.lang.String value)
                                            throws java.lang.ClassNotFoundException
Attempt to convert the fully-qualified string value to a Class object. We do not simply call Class.forName, as there are some values for which we have alternative implementations

Returns:
A Class object representing the specified type
Throws:
java.lang.ClassNotFoundException

getConnectionClassName

public static final java.lang.String getConnectionClassName()
Get the fully-qualified name of the Connection implementation to use

Returns:

getConnectionURL

public static final java.lang.String getConnectionURL(ConnectionDetails details)

buildXMLParametersForTRS

public static final java.lang.String buildXMLParametersForTRS(java.lang.String[] types,
                                                              java.util.Vector values)
Build a String for the PARAMS attribute of an entry in the REPLAY_ITEM table for TRS.

Parameters:
types -
values -
Returns:

init

public static final void init()
Entry point for startup code in the Model layer


shutdown

public static final void shutdown()
Entry point for cleanup code in the Model layer


reinitializeDatabaseFromScript

public static final void reinitializeDatabaseFromScript(ConnectionDetails dbCredentials)

reinitializeDatabaseFromScripts

public static final void reinitializeDatabaseFromScripts(ConnectionDetails dbCredentials,
                                                         java.lang.String[] scriptNames,
                                                         boolean dropAllTablesFirst)

isBlackberrySQLite

public static boolean isBlackberrySQLite()

deleteDatabaseIfNecessary

public static void deleteDatabaseIfNecessary(ConnectionDetails details)

getCurrentDBType

public static int getCurrentDBType()
Returns an integer value representing the type of database currently in use, e.g. OLite, SQLite, PointBase

Returns:

getDBType

public static int getDBType(Connection conn)

registerNativeDBHandleProvider

public static void registerNativeDBHandleProvider(NativeDBHandleProvider provider)

getNativeDBHandle

public static java.lang.Object getNativeDBHandle(Connection conn)
Given a generic Connection object, attempt to return the underlying native implementation of that Connection object. This is required for sharing a connection with OpenSync.

Parameters:
conn -
Returns:

Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

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