IBM DB2 Information Integrator
Java API Reference
for Developing Wrappers

com.ibm.db2.wrapper
Class RemoteConnection

java.lang.Object
  extended bycom.ibm.db2.wrapper.SqlqgBaseClass
      extended bycom.ibm.db2.wrapper.RemoteConnection

public class RemoteConnection
extends com.ibm.db2.wrapper.SqlqgBaseClass

The RemoteConnection class represents a connection (session) with a data source server. The operations on the data source server (database) are processed through a connection. Connections can be created only for untrusted and fenced data source servers. The RemoteConnection base class implementation maintains the following information:



Usage:
You can create an instance of your RemoteConnection subclass by invoking the FencedServer.createRemoteConnection method on an instance of the appropriate fenced server subclass. The federated server calls this method before processing the first remote operation at the relevant data source server. The federated server destroys the RemoteConnection instance after a predefined number of transactions are processed by the application without using the data source server.

Since:
IBM DB2 Information Integrator Version 8.2

Field Summary
static int NO_PHASE_KIND
          Constant to indicate that no transactions are supported.
static int ONE_PHASE_KIND
          Constant to indicate that one-phase commit transactions are supported.
 
Constructor Summary
protected RemoteConnection(FencedServer remoteServer, FencedRemoteUser remoteUser, int connectionKind, long id)
          Construct a connection for the specified server with the user authorization and transaction type as specified.
 
Method Summary
protected  void commit()
          Indicate the successful completion of a transaction and that the remote data source then commits the transaction.
protected  void connect()
          Invoke the code to connect to the data source server.
protected  RemotePassthru createRemotePassthru(long id)
          Create a RemotePassthru object to run pass-through statements.
protected  RemoteQuery createRemoteQuery(long id)
          Create a RemoteQuery object to run SQL statements.
protected  void disconnect()
          Invoke the code to disconnect from the data source server.
 short getCodepage()
          Retrieve the code page for the connection.
 int getKind()
          Retrieve the connection type.
 FencedServer getServer()
          Retrieve the data source server object that contains this connection.
 FencedRemoteUser getUser()
          Retrieve the user mapping to authenticate this connection.
 Wrapper getWrapper()
          Retrieve the wrapper object.
 boolean isConnected()
          Verify whether the connection with the data source server exists.
 void markDisconnected()
          Set the flag to indicate that the connection with the data source server finished.
protected  void rollback()
          Indicate the unsuccessful completion of a transaction and that the remote data source then rolls back the transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_PHASE_KIND

public static final int NO_PHASE_KIND
Constant to indicate that no transactions are supported.

Since:
IBM DB2 Information Integrator Version 8.2
See Also:
Constant Field Values

ONE_PHASE_KIND

public static final int ONE_PHASE_KIND
Constant to indicate that one-phase commit transactions are supported.

Since:
IBM DB2 Information Integrator Version 8.2
See Also:
Constant Field Values
Constructor Detail

RemoteConnection

protected RemoteConnection(FencedServer remoteServer,
                           FencedRemoteUser remoteUser,
                           int connectionKind,
                           long id)
Construct a connection for the specified server with the user authorization and transaction type as specified.

Parameters:
remoteServer - The data source server that contains the connection.
remoteUser - The user mapping object that is used for authentication.
connectionKind - The type of connection, specifies the supported transaction types. A connection that can support one-phase commit transactions is indicated by the ONE_PHASE_KIND constant. A connection that does not have transaction support is indicated by the NO_PHASE_KIND constant.
id - An integer value that represents the RemoteConnection object.
Since:
IBM DB2 Information Integrator Version 8.2
See Also:
FencedServer, FencedRemoteUser
Method Detail

commit

protected void commit()
               throws java.lang.Exception
Indicate the successful completion of a transaction and that the remote data source then commits the transaction. A default implementation does nothing. The wrapper can override this method to implement necessary commit logic for the remote data source.

Throws:
java.lang.Exception - if the method fails.
Since:
IBM DB2 Information Integrator Version 8.2

connect

protected void connect()
                throws java.lang.Exception
Invoke the code to connect to the data source server. This method does nothing by default. The connect method can be implemented by the wrapper writer if the wrapper-specific connection class needs to perform any operation to establish a connection with the remote data source.

Throws:
java.lang.Exception - if the method fails.
Since:
IBM DB2 Information Integrator Version 8.2

createRemotePassthru

protected RemotePassthru createRemotePassthru(long id)
                                       throws java.lang.Exception
Create a RemotePassthru object to run pass-through statements. This method returns null by default. However, if the wrapper supports the ability to run pass-through statements, it must implement the method in the wrapper-specific connection class. When the createRemotePassthru method is used in this situation, it must return a value that is not null.

Parameters:
id - An integer value that represents the RemotePassthru object.
Returns:
A RemotePassthru instance or null if the operation is not supported by the wrapper.
Throws:
java.lang.Exception - if the object creation fails.
Since:
IBM DB2 Information Integrator Version 8.2
See Also:
RemotePassthru

createRemoteQuery

protected RemoteQuery createRemoteQuery(long id)
                                 throws java.lang.Exception
Create a RemoteQuery object to run SQL statements. This method returns null by default. However, if the wrapper supports the ability to run SQL statements, it must implement the method in the wrapper-specific connection class. When the createRemoteQuery is used in this situation, it must return a value that is not null.

Parameters:
id - An integer value that represents the RemoteQuery object.
Returns:
A RemoteQuery instance or null if the operation is not supported by the wrapper.
Throws:
java.lang.Exception - if the object creation fails.
Since:
IBM DB2 Information Integrator Version 8.2
See Also:
RemoteQuery

disconnect

protected void disconnect()
                   throws java.lang.Exception
Invoke the code to disconnect from the data source server. This method does nothing by default. The disconnect method can be implemented by the wrapper writer if the wrapper-specific connection class needs to perform any operation to terminate a connection with the remote data source.

Throws:
java.lang.Exception - if the method fails.
Since:
IBM DB2 Information Integrator Version 8.2

getCodepage

public final short getCodepage()
Retrieve the code page for the connection.

Returns:
The code page.
Since:
IBM DB2 Information Integrator Version 8.2

getKind

public final int getKind()
Retrieve the connection type. A connection can either support one-phase commit transactions (indicated by the ONE_PHASE_KIND constant) or cannot support transactions (indicated by the NO_PHASE_KIND constant).

Returns:
The connection type.
Since:
IBM DB2 Information Integrator Version 8.2

getServer

public final FencedServer getServer()
Retrieve the data source server object that contains this connection.

Returns:
The data source server for this connection.
Since:
IBM DB2 Information Integrator Version 8.2
See Also:
FencedServer

getUser

public final FencedRemoteUser getUser()
Retrieve the user mapping to authenticate this connection.

Returns:
The user mapping for this connection.
Since:
IBM DB2 Information Integrator Version 8.2
See Also:
FencedRemoteUser

getWrapper

public final Wrapper getWrapper()
Retrieve the wrapper object.

Returns:
The wrapper object.
Since:
IBM DB2 Information Integrator Version 8.2
See Also:
Wrapper

isConnected

public final boolean isConnected()
Verify whether the connection with the data source server exists.

Returns:
true if a connection with the server exists, false otherwise.
Since:
IBM DB2 Information Integrator Version 8.2

markDisconnected

public final void markDisconnected()
Set the flag to indicate that the connection with the data source server finished.

Since:
IBM DB2 Information Integrator Version 8.2

rollback

protected void rollback()
                 throws java.lang.Exception
Indicate the unsuccessful completion of a transaction and that the remote data source then rolls back the transaction. A default implementation does nothing. The wrapper can override this method to implement necessary rollback logic for the remote data source.

Throws:
java.lang.Exception - if the method fails.
Since:
IBM DB2 Information Integrator Version 8.2

IBM DB2 Information Integrator
Java API Reference
for Developing Wrappers

(C)Copyright IBM Corp. 2002. All rights reserved.

Links on this page are made available for your convenience and may take you to non-IBM sites. IBM does not warrant any sample code provided on these sites.