org.eclipse.datatools.sqltools.core
Class DBHelper

java.lang.Object
  extended byorg.eclipse.datatools.sqltools.core.DBHelper

public class DBHelper
extends java.lang.Object

Vendors can subclass this class to provide database-specific utility methods.

Author:
Hui Cao

Constructor Summary
DBHelper()
           
 
Method Summary
 java.lang.String calculateTriggerTableName(ProcIdentifier procid)
          Given a trigger, returns the table name.
 int getCorrectParamType(int jdbcType)
          This method is for vendors to fix JDBC driver bugs.
 java.lang.String getExceptionChainMessage(java.sql.SQLException exception)
          Returns all error messages by following the exception chain.
 ProcIdentifier getProcIdentifier(DatabaseIdentifier databaseIdentifier, int dbObjectType, java.util.Map map)
          Returns a ProcIdentifer based on the profilename and object name & type.
 ProcIdentifier getProcIdentifier(DatabaseIdentifier databaseIdentifier, java.lang.String dbObjectName, int dbObjectType, java.lang.String tableName, java.lang.String ownerName)
          Returns a ProcIdentifer based on the profilename and object name & type
 ProcIdentifier getProcIdentifier(DatabaseIdentifier databaseIdentifier, java.lang.String dbObjectName, int dbObjectType, java.lang.String tableName, java.lang.String ownerName, java.lang.String tableOwnerName)
          Returns a ProcIdentifer based on the profilename and object name & type.
 ServerIdentifier getServerIdentifier(java.lang.String host, java.lang.String port, java.lang.String url, DatabaseVendorDefinitionId dbIdentifier)
          Returns a ServerIdentifier identifying a data server.
 java.lang.String[] getSysDatabaseNames(DatabaseIdentifier identifier)
           
 java.lang.String[] getSysOwnerNames()
          Gets all the system ownerName
 boolean isAdHocProc(ProcIdentifier procid)
          Tells whether the procedural object is "ADHOC", meaning we don't need to show stack frame and open editor for it.
 boolean justWarnings(java.sql.SQLException sqlexception)
           
 java.lang.String preprocessSQLScript(java.lang.String sqlScript)
          Default behavior is do nothing, and return the original sql script
 boolean supportsPlan(int procType)
           
 java.lang.String switchDatabase(DatabaseIdentifier databaseIdentifier, java.sql.Connection conn)
          Switches databases for the shared connection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBHelper

public DBHelper()
Method Detail

calculateTriggerTableName

public java.lang.String calculateTriggerTableName(ProcIdentifier procid)
Given a trigger, returns the table name. Default implementation simply return the table name defined in ProcIdentifier.

Parameters:
procid - trigger identifier
Returns:
table name

isAdHocProc

public boolean isAdHocProc(ProcIdentifier procid)
Tells whether the procedural object is "ADHOC", meaning we don't need to show stack frame and open editor for it. Usually this is the statement used to trigger the to-be-debugged routine.

Parameters:
procid - the routine identifier
Returns:
true if it is "ADHOC"

getProcIdentifier

public ProcIdentifier getProcIdentifier(DatabaseIdentifier databaseIdentifier,
                                        java.lang.String dbObjectName,
                                        int dbObjectType,
                                        java.lang.String tableName,
                                        java.lang.String ownerName)
Returns a ProcIdentifer based on the profilename and object name & type

Parameters:
databaseIdentifier -
dbObjectName -
dbObjectType - @see ProcIdentifier
Returns:
a ProcIdentifer object
See Also:
{@link #getProcIdentifier(DatabaseIdentifier, String, int, String, String, String)}

getProcIdentifier

public ProcIdentifier getProcIdentifier(DatabaseIdentifier databaseIdentifier,
                                        java.lang.String dbObjectName,
                                        int dbObjectType,
                                        java.lang.String tableName,
                                        java.lang.String ownerName,
                                        java.lang.String tableOwnerName)
Returns a ProcIdentifer based on the profilename and object name & type. Compared with the ealier version, it has an additional parameter specifying the table owner name. This is necessary when the database server supports creating triggers under another owner other than the subject table's owner.

Parameters:
databaseIdentifier -
dbObjectName -
dbObjectType - @see ProcIdentifier
tableOwnerName - the subject table's owner
Returns:
a ProcIdentifer object
Since:
1.5

getProcIdentifier

public ProcIdentifier getProcIdentifier(DatabaseIdentifier databaseIdentifier,
                                        int dbObjectType,
                                        java.util.Map map)
Returns a ProcIdentifer based on the profilename and object name & type.

Parameters:
databaseIdentifier -
dbObjectType - @see ProcIdentifier
map - all other information such as procedural object name, owner, etc
Returns:
a ProcIdentifer object
Since:
1.5

getServerIdentifier

public ServerIdentifier getServerIdentifier(java.lang.String host,
                                            java.lang.String port,
                                            java.lang.String url,
                                            DatabaseVendorDefinitionId dbIdentifier)
Returns a ServerIdentifier identifying a data server. Can be override to provide a customized ServerIdentifier which handles a specialized url format.

Parameters:
host -
port -
url -
dbIdentifier -
Returns:

justWarnings

public boolean justWarnings(java.sql.SQLException sqlexception)

getSysOwnerNames

public java.lang.String[] getSysOwnerNames()
Gets all the system ownerName

Returns:
owner name array

getCorrectParamType

public int getCorrectParamType(int jdbcType)
This method is for vendors to fix JDBC driver bugs. If the parameter type in a routine object returned by the JDBC driver is not correct, vendors should implement this method to provide the correct type.

Parameters:
jdbcType - the parameter type returned by the JDBC driver
Returns:
one of java.sql.ParameterMetadata.parameterModeIn,java.sql.ParameterMetadata.parameterModeOut, java.sql.ParameterMetadata.parameterModeInOut and java.sql.ParameterMetadata.parameterModeUnknown

supportsPlan

public boolean supportsPlan(int procType)

preprocessSQLScript

public java.lang.String preprocessSQLScript(java.lang.String sqlScript)
Default behavior is do nothing, and return the original sql script


getSysDatabaseNames

public java.lang.String[] getSysDatabaseNames(DatabaseIdentifier identifier)

switchDatabase

public java.lang.String switchDatabase(DatabaseIdentifier databaseIdentifier,
                                       java.sql.Connection conn)
Switches databases for the shared connection.

Parameters:
databaseIdentifier -
conn -
Returns:

getExceptionChainMessage

public java.lang.String getExceptionChainMessage(java.sql.SQLException exception)
Returns all error messages by following the exception chain.

Parameters:
exception -
Returns:


Copyright © 2007 Actuate, IBM Corporation, Sybase, Inc. and others. All rights reserved.