org.eclipse.datatools.sqltools.core.services
Class ConnectionService

java.lang.Object
  extended byorg.eclipse.datatools.sqltools.core.services.ConnectionService

public class ConnectionService
extends java.lang.Object

A connection related service specific to a database definition.

Author:
Hui Cao

Nested Class Summary
static interface ConnectionService.ConnectionProcessor
          This interface can be implemented to do vendor-specific processing of the connection, e.g.
 
Constructor Summary
ConnectionService()
           
 
Method Summary
 void closeConnection(java.sql.Connection connection, int connId, DatabaseIdentifier databaseIdentifier)
          Closes the connection object.
 java.sql.Connection createConnection(DatabaseIdentifier databaseIdentifier, boolean usePool)
          Returns a connection for caller to use.
 java.sql.Connection createConnection(java.lang.String profileName, java.lang.String dbName)
          Creates a jdbc connection from the given connection profile name and database name.
 IControlConnection createControlConnection(DatabaseIdentifier databaseIdentifier)
          Returns an IControlConnection object which is used for all shared usage to that particular database.
 int getConnectionId(DatabaseIdentifier databaseIdentifier, java.sql.Connection conn)
          Returns an identifier for the connection.
 IConnectionInitializer getConnectionInitializer()
          Returns a IConnectionInitializer object which is used to initialize connection to proper state.
 java.lang.Runnable getConnectionKiller(DatabaseIdentifier databaseIdentifier, java.sql.Connection conn)
          Returns a Runnable which can be used to kill the connection.
 ConnectionService.ConnectionProcessor getConnectionProcessor(DatabaseIdentifier databaseIdentifier)
          Get an ConnectionProcessor
 java.util.Properties getDefaultConnectionProperties(java.lang.String profileName)
          Returns the default properties of the given profile for creating a connection to that profile
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionService

public ConnectionService()
Method Detail

getConnectionKiller

public java.lang.Runnable getConnectionKiller(DatabaseIdentifier databaseIdentifier,
                                              java.sql.Connection conn)
Returns a Runnable which can be used to kill the connection. This Runnable instance will be used to terminate a running statement. This is necessary because jdbc.sql.Statement.cancel() and jdbc.sql.Connection.close() wonĄŻt always be able to do the job.

Parameters:
databaseIdentifier - uniquely identifies a database
conn - the connection object
Returns:
a Runnable which can be used to kill the connection.

getConnectionId

public int getConnectionId(DatabaseIdentifier databaseIdentifier,
                           java.sql.Connection conn)
Returns an identifier for the connection. This id should be unique across all clients.

Parameters:
databaseIdentifier - uniquely identifies a database
conn - the connection object
Returns:
an identifier for the connection

createControlConnection

public IControlConnection createControlConnection(DatabaseIdentifier databaseIdentifier)
                                           throws java.sql.SQLException
Returns an IControlConnection object which is used for all shared usage to that particular database.

Parameters:
databaseIdentifier - uniquely identifies a database
Returns:
an IControlConnection object which is used for all shared usage to that particular database.
Throws:
java.sql.SQLException

getConnectionInitializer

public IConnectionInitializer getConnectionInitializer()
Returns a IConnectionInitializer object which is used to initialize connection to proper state. Clients may want to let end user customize the connection status by providing preference pages. The extension point preferenceSections is interesting to data server vendors if they want to contribute preference controls to an existing DTP preference page.

Returns:
a IConnectionInitializer object which is used to initialize connection to proper state.
See Also:
org.eclipse.datatools.common.ui.preferences.AbstractDBPreferenceFieldPage

createConnection

public java.sql.Connection createConnection(java.lang.String profileName,
                                            java.lang.String dbName)
Creates a jdbc connection from the given connection profile name and database name. By default, the connection is retrieved from connetivity layer, but vendors may override this method to use different approaches.

Parameters:
profileName -
dbName -
Returns:

createConnection

public java.sql.Connection createConnection(DatabaseIdentifier databaseIdentifier,
                                            boolean usePool)
                                     throws java.sql.SQLException,
                                            NoSuchProfileException
Returns a connection for caller to use. By default there's no connection pool associated with a connection profile and this method just ignore the usePool parameter and delegates to createConnection(String, String). Vendors who has the requirement to use connection pool may override this method.

Parameters:
databaseIdentifier - the database identifier
usePool - whether to retrieve the connection from connection pool.
Returns:
a Connection instance
Throws:
java.sql.SQLException - if database error occurs
NoSuchProfileException

getDefaultConnectionProperties

public java.util.Properties getDefaultConnectionProperties(java.lang.String profileName)
                                                    throws NoSuchProfileException
Returns the default properties of the given profile for creating a connection to that profile

Parameters:
profileName - the profile name
Returns:
properties of this profile
Throws:
NoSuchProfileException - if this profile does not exist

closeConnection

public void closeConnection(java.sql.Connection connection,
                            int connId,
                            DatabaseIdentifier databaseIdentifier)
                     throws java.sql.SQLException
Closes the connection object. Subclasses may need to do further log or cleanup jobs.

Parameters:
connection -
connId -
databaseIdentifier -
Throws:
java.sql.SQLException

getConnectionProcessor

public ConnectionService.ConnectionProcessor getConnectionProcessor(DatabaseIdentifier databaseIdentifier)
Get an ConnectionProcessor

Returns:


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