Extension SDK

oracle.jdeveloper.cm.ds.db
Class JdbcDatabase

java.lang.Object
  extended byoracle.jdeveloper.cm.ds.db.JdbcDatabase
All Implemented Interfaces:
Database

public abstract class JdbcDatabase
extends java.lang.Object
implements Database

Implementation of the Database interface for use with JDBC Connections, currently this implementation handles all three types of database types (DATABASE_TYPE_GENERIC, DATABASE_TYPE_ORACLE, and DATABASE_TYPE_ORACLE_LITE). In the future it may be required to refactor this class into one class per type, but since the variation is still minimal, this class serves for now.

See Also:
Database.DATABASE_TYPE_GENERIC, Database.DATABASE_TYPE_ORACLE, Database.DATABASE_TYPE_ORACLELITE

Field Summary
protected  java.sql.Connection _conn
          JDBC Connection to the database
protected  java.lang.String _connName
          Connection Manager name of the connection or null if not using cm
protected  java.util.List databaseObjectTypes
          List of database object types supported by this database
static java.lang.String SQLSTATE_NOT_IMPLEMENTED
           
 
Fields inherited from interface oracle.jdeveloper.cm.ds.db.Database
DATABASE_TYPE_GENERIC, DATABASE_TYPE_ORACLE, DATABASE_TYPE_ORACLELITE
 
Constructor Summary
protected JdbcDatabase(java.sql.Connection conn)
          Constructor - Created a JDBC Database and connection
protected JdbcDatabase(java.lang.String connName)
          Constructor - Created a JDBC Database and connection
protected JdbcDatabase(java.lang.String connName, java.sql.Connection conn)
          Constructor
 
Method Summary
protected  Table _createTable(java.lang.String schema, java.lang.String tableName)
           
protected  java.util.List _getColumns(java.lang.String schema, java.lang.String tableName)
           
protected  java.util.List _getConstraints(java.lang.String schema, java.lang.String tableName)
           
 void close()
          Close the Database Connection (and the supplied JDBC Connection)
 java.sql.ResultSet executeQuery(java.lang.String sqlStmt)
          Get a ResultSet from a query
This function may also set data returned by getLastResultString() or getLastErrorText().
abstract  boolean exists(java.lang.String schema, java.lang.String type, java.lang.String objectName)
          Checks for existance of a schema object named objectName.
 java.sql.Connection getConnection()
          Get the JDBC connection associated with this database
 java.lang.String getConnectionName()
          Get the Connection Manager connection name
 int getDatabaseType()
          Get the type of database.
protected  int getDatabaseTypeImpl()
           
 java.lang.String getIdentifierQuoteString()
          Returns the String to use to quote SQL identifiers with
 java.lang.String getLastErrorText()
          Get the last error text returned by executeQuery
 java.lang.String getLastResultString()
          Gets the last message returned by executeQuery when no ResultSet was returned.
 java.util.List getObjects(int dbObjectType, java.lang.String schema)
          Gets a list of the database objects for a given username and object type
 java.util.List getObjects(int dbObjectType, java.lang.String schema, java.lang.String ref)
          Gets a list of the database objects for a given username and object type associated with the refobject.
 java.util.Iterator getObjectTypes()
          Get the types of database objects supported.
 Sequence getSequence(java.lang.String schema, java.lang.String sequenceName)
          Creates a Sequence datamodel.
 Synonym getSynonym(java.lang.String schema, java.lang.String synonymName)
          Creates a Synonym datamodel.
 int getSynonymType(java.lang.String schema, java.lang.String synonymName)
          Gets the underlying type of a Synonym.
 Table getTable(java.lang.String schema, java.lang.String tableName)
          Creates a Table datamodel.
abstract  long getTimestamp(java.lang.String schema, java.lang.String type, java.lang.String objectName)
          Gets the timestamp of a PL/SQL Subprogram
 java.lang.String getUniqueObjectName(java.lang.String schema, int objectType, java.lang.String baseName)
          Retrieves a unique object name
 boolean isObjectValid(java.lang.String schemaName, java.lang.String objectName, int objectType)
          Determines whether the specified database object is in a valid state.
abstract  boolean isValidName(java.lang.String objectName)
          Checks the whether objectName is a valid name for a schema Object.
protected  java.util.List queryDmdTables(java.lang.String schema, java.lang.String catalog, java.lang.String[] tbl_types)
           
 boolean supportsDebugging()
          Determines whether this database instance supports debugging.
protected abstract  java.lang.String transformSQLStatement(java.lang.String sql)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface oracle.jdeveloper.cm.ds.db.Database
getFullVersion, getFullVersionString, getJavaObjects, getMajorVersion, getSource, isUserPrivileged
 

Field Detail

_conn

protected java.sql.Connection _conn
JDBC Connection to the database


_connName

protected java.lang.String _connName
Connection Manager name of the connection or null if not using cm


databaseObjectTypes

protected java.util.List databaseObjectTypes
List of database object types supported by this database


SQLSTATE_NOT_IMPLEMENTED

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

JdbcDatabase

protected JdbcDatabase(java.lang.String connName,
                       java.sql.Connection conn)
Constructor

Parameters:
connName - name of the ConnectionManager connection
conn - JDBC Connection object.

See Also:
ConnectionManager, Connection

JdbcDatabase

protected JdbcDatabase(java.lang.String connName)
Constructor - Created a JDBC Database and connection

Parameters:
connName - name of the ConnectionManager connection

See Also:
ConnectionManager, Connection

JdbcDatabase

protected JdbcDatabase(java.sql.Connection conn)
Constructor - Created a JDBC Database and connection

Parameters:
conn - JDBC Connection object.

See Also:
ConnectionManager, Connection
Method Detail

getConnection

public java.sql.Connection getConnection()
Description copied from interface: Database
Get the JDBC connection associated with this database

Specified by:
getConnection in interface Database
Returns:
Connection - The JDBC Connection owned by this database object.

See Also:
Connection

getConnectionName

public java.lang.String getConnectionName()
Description copied from interface: Database
Get the Connection Manager connection name

Specified by:
getConnectionName in interface Database
Returns:
String - The name of the JDeveloper Connection Manager connection owned by this database object.

See Also:
ConnectionManager

getDatabaseType

public int getDatabaseType()
Description copied from interface: Database
Get the type of database. This method uses JDBC metadata to determine the database type. The possible types are:

Specified by:
getDatabaseType in interface Database
See Also:
Database.DATABASE_TYPE_GENERIC, Database.DATABASE_TYPE_ORACLE, Database.DATABASE_TYPE_ORACLELITE, java.sql.DatabaseMetaData.getDatabaseProductName, Database, JdbcDatabase

getDatabaseTypeImpl

protected int getDatabaseTypeImpl()

getObjectTypes

public java.util.Iterator getObjectTypes()
Description copied from interface: Database
Get the types of database objects supported.

Specified by:
getObjectTypes in interface Database
Returns:
Iterator iterator for the list of types

getObjects

public java.util.List getObjects(int dbObjectType,
                                 java.lang.String schema)
Description copied from interface: Database
Gets a list of the database objects for a given username and object type

Specified by:
getObjects in interface Database
Parameters:
dbObjectType - Type of object.
schema - schema to query

Returns:
List list of objects contained.

getObjects

public java.util.List getObjects(int dbObjectType,
                                 java.lang.String schema,
                                 java.lang.String ref)
Description copied from interface: Database
Gets a list of the database objects for a given username and object type associated with the refobject. Example: getting all of the INDEX objects where the referenced Table is ref.

Specified by:
getObjects in interface Database
Parameters:
dbObjectType - Type of object.
schema - schema to query
ref - Object Referenced for the query.

Returns:
List list of objects contained.

queryDmdTables

protected java.util.List queryDmdTables(java.lang.String schema,
                                        java.lang.String catalog,
                                        java.lang.String[] tbl_types)
                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

close

public void close()
Description copied from interface: Database
Close the Database Connection (and the supplied JDBC Connection)

Specified by:
close in interface Database

getLastErrorText

public java.lang.String getLastErrorText()
Description copied from interface: Database
Get the last error text returned by executeQuery

Specified by:
getLastErrorText in interface Database
Returns:
String the text of the error, or null if there was no error on the last execution of a SQL statement.

getLastResultString

public java.lang.String getLastResultString()
Description copied from interface: Database
Gets the last message returned by executeQuery when no ResultSet was returned.

Specified by:
getLastResultString in interface Database
Returns:
the text returned, or null if no text was returned.
See Also:
ResultSet, Database.executeQuery(String)

transformSQLStatement

protected abstract java.lang.String transformSQLStatement(java.lang.String sql)

executeQuery

public java.sql.ResultSet executeQuery(java.lang.String sqlStmt)
Description copied from interface: Database
Get a ResultSet from a query
This function may also set data returned by getLastResultString() or getLastErrorText().

NOTE: The caller is responsible for closing the result set AND the statement associated with the result set.

Specified by:
executeQuery in interface Database
Parameters:
sqlStmt - The SQL Statement to execute

Returns:
ResultSet of the returned rows or null if not a query or the query failed.
See Also:
Database.getLastResultString(), Database.getLastErrorText(), ResultSet.getStatement()

getTable

public Table getTable(java.lang.String schema,
                      java.lang.String tableName)
Description copied from interface: Database
Creates a Table datamodel.

Specified by:
getTable in interface Database
Returns:
Table datamodel of tableName

_createTable

protected Table _createTable(java.lang.String schema,
                             java.lang.String tableName)

_getColumns

protected java.util.List _getColumns(java.lang.String schema,
                                     java.lang.String tableName)

_getConstraints

protected java.util.List _getConstraints(java.lang.String schema,
                                         java.lang.String tableName)

getSequence

public Sequence getSequence(java.lang.String schema,
                            java.lang.String sequenceName)
Description copied from interface: Database
Creates a Sequence datamodel.

Specified by:
getSequence in interface Database
Returns:
Sequence datamodel of sequenceName

exists

public abstract boolean exists(java.lang.String schema,
                               java.lang.String type,
                               java.lang.String objectName)
Description copied from interface: Database
Checks for existance of a schema object named objectName.

Specified by:
exists in interface Database
Parameters:
objectName - The name of the schema object.
Returns:
true if the object exists, false otherwise.

isValidName

public abstract boolean isValidName(java.lang.String objectName)
Description copied from interface: Database
Checks the whether objectName is a valid name for a schema Object. This function will make all reasonable non-destructive tests, but is not guaranteed to be 100% accurate.

Specified by:
isValidName in interface Database
Parameters:
objectName - The name of the schema object.
Returns:
true if the name is valid, false otherwise.

isObjectValid

public boolean isObjectValid(java.lang.String schemaName,
                             java.lang.String objectName,
                             int objectType)
Description copied from interface: Database
Determines whether the specified database object is in a valid state.

Specified by:
isObjectValid in interface Database
Parameters:
schemaName - the name of the schema containing the object
objectName - the name of the object
objectType - the type of the object.
See Also:
DatabaseObjectType

getIdentifierQuoteString

public java.lang.String getIdentifierQuoteString()
Description copied from interface: Database
Returns the String to use to quote SQL identifiers with

Specified by:
getIdentifierQuoteString in interface Database
Returns:
the String to use to quote an SQL identifier, or an empty String "", if the underlying database does not support this functionality.
See Also:
DatabaseMetaData.getIdentifierQuoteString()

getTimestamp

public abstract long getTimestamp(java.lang.String schema,
                                  java.lang.String type,
                                  java.lang.String objectName)
Description copied from interface: Database
Gets the timestamp of a PL/SQL Subprogram

Specified by:
getTimestamp in interface Database

getSynonymType

public int getSynonymType(java.lang.String schema,
                          java.lang.String synonymName)
Description copied from interface: Database
Gets the underlying type of a Synonym.

Specified by:
getSynonymType in interface Database

getSynonym

public Synonym getSynonym(java.lang.String schema,
                          java.lang.String synonymName)
Description copied from interface: Database
Creates a Synonym datamodel.

Specified by:
getSynonym in interface Database
Returns:
Synonym datamodel of synonymName, or null if the database does not support all the required functionality.

supportsDebugging

public boolean supportsDebugging()
Description copied from interface: Database
Determines whether this database instance supports debugging.

Specified by:
supportsDebugging in interface Database

getUniqueObjectName

public java.lang.String getUniqueObjectName(java.lang.String schema,
                                            int objectType,
                                            java.lang.String baseName)
Description copied from interface: Database
Retrieves a unique object name

Specified by:
getUniqueObjectName in interface Database
Parameters:
schema - the schema to check
objectType - the type of object
baseName - the base name to use

Extension SDK

 

Copyright ©1997, 2003, Oracle. All rights reserved.