oracle.sysman.dbTarget.db.changemgr.emo.docaccess
Class CMConnection

java.lang.Object
  extended by oracle.sysman.dbTarget.db.changemgr.emo.docaccess.CMConnection

public class CMConnection
extends java.lang.Object

CMConnection is a wrapper around an OracleConnection. In addition to providing the methods of OracleConnection, it maintains some information about the connection (such as the database version and compatible version) and supplies utility methods such as null-safe close() methods.


Constructor Summary
CMConnection(oracle.jdbc.OracleConnection conn)
          Creates a CMConnection.
 
Method Summary
 boolean canAccessDbaViews()
           
 void close()
          Closes the OracleConnection
static void close(java.sql.ResultSet rs)
          Closes a result set.
static void close(java.sql.Statement stmt)
          Closes a statement.
static void close(java.sql.Statement stmt, java.sql.ResultSet rs)
          Closes a statement and a result set.
 void commit()
          Commits a DML operation on the connection.
static int compareVersion(java.lang.String v1, java.lang.String v2)
          Shamelessly purloined from oracle.sysman.emSDK.core.util.jdk.VersionUtil.
 java.sql.Statement createStatement()
          Creates a Statement using the connection.
 boolean getAutoCommit()
          Sets the connection's auto-commit mode.
 java.lang.String getCompatibleVersion()
          Returns the compatible version of the database accessed by the connection.
 java.lang.String getDBVersion()
          Returns the version of the database accessed by the connection.
 oracle.jdbc.OracleConnection getUnWrappedConnection()
          Returns the OracleConnection that is wrapped by the CMConnection.
 boolean isVersionEqualOrHigher(java.lang.String v2)
          Indicates whether the version of the database accessed by this connection is equal to or higher than a specified database version.
 java.sql.CallableStatement prepareCall(java.lang.String sql)
          Creates a CallableStatement using the connection.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
          Creates a PreparedStatement using the connection.
 void rollback()
          Rolls back a DML operation on the connection.
 void setAutoCommit(boolean ac)
          Sets the connection's auto-commit mode.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CMConnection

public CMConnection(oracle.jdbc.OracleConnection conn)
Creates a CMConnection.

Parameters:
conn - the OracleConnection that is wrapped by the CMConnection.
Method Detail

getUnWrappedConnection

public oracle.jdbc.OracleConnection getUnWrappedConnection()
Returns the OracleConnection that is wrapped by the CMConnection.

Returns:
the OracleConnection.

close

public void close()
           throws java.sql.SQLException
Closes the OracleConnection

Throws:
java.sql.SQLException

setAutoCommit

public void setAutoCommit(boolean ac)
                   throws java.sql.SQLException
Sets the connection's auto-commit mode.

Parameters:
ac - true if the connection should be set to auto-commit mode, false if to manual commit.
Throws:
java.sql.SQLException

getAutoCommit

public boolean getAutoCommit()
                      throws java.sql.SQLException
Sets the connection's auto-commit mode.

Returns:
true if connection is in auto-commmit mode, false otherwise.
Throws:
java.sql.SQLException

commit

public void commit()
            throws java.sql.SQLException
Commits a DML operation on the connection.

Throws:
java.sql.SQLException

rollback

public void rollback()
              throws java.sql.SQLException
Rolls back a DML operation on the connection.

Throws:
java.sql.SQLException

createStatement

public java.sql.Statement createStatement()
                                   throws java.sql.SQLException
Creates a Statement using the connection.

Throws:
java.sql.SQLException

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                            throws java.sql.SQLException
Creates a PreparedStatement using the connection.

Parameters:
sql - The SQL to be executed by the PreparedStatement.
Throws:
java.sql.SQLException

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql)
                                       throws java.sql.SQLException
Creates a CallableStatement using the connection.

Parameters:
sql - The SQL to be executed by the CallableStatement.
Throws:
java.sql.SQLException

getDBVersion

public java.lang.String getDBVersion()
Returns the version of the database accessed by the connection.

Returns:
The database version

getCompatibleVersion

public java.lang.String getCompatibleVersion()
Returns the compatible version of the database accessed by the connection.

Returns:
The database compatible version

isVersionEqualOrHigher

public boolean isVersionEqualOrHigher(java.lang.String v2)
Indicates whether the version of the database accessed by this connection is equal to or higher than a specified database version.

Parameters:
v2 - database version string
Returns:
true if the version of the connected database is equal to or higher than v2; false otherwise

compareVersion

public static int compareVersion(java.lang.String v1,
                                 java.lang.String v2)
Shamelessly purloined from oracle.sysman.emSDK.core.util.jdk.VersionUtil. compareVersion compares 2 version numbers (v1 and v2) Note though that the match compares v1 to the number of significant digits in v2; for example, assume the v1 is 8.0.2.0.1:

Parameters:
v1 - a version number
v2 - a version number
Returns:
  • 1 if v1 is greater than v2
  • 0 if v1 is equal to v2
  • -1 if v1 is less than v2

close

public static void close(java.sql.Statement stmt,
                         java.sql.ResultSet rs)
Closes a statement and a result set. Does not throw any exceptions and does not fail if either argument is null.

Parameters:
stmt - a Statement
rs - a ResultSet

canAccessDbaViews

public boolean canAccessDbaViews()
                          throws java.sql.SQLException
Throws:
java.sql.SQLException

close

public static void close(java.sql.Statement stmt)
Closes a statement. Does not throw any exceptions and does not fail if its argument is null.

Parameters:
stmt - a Statement

close

public static void close(java.sql.ResultSet rs)
Closes a result set. Does not throw any exceptions and does not fail if its argument is null.

Parameters:
rs - a ResultSet