Siebel Object Interfaces Reference > Interfaces Reference > Application Methods >

Attach Method

The Attach method allows an external application to reconnect to an existing Siebel session.





A string containing the Siebel Session Id. The sessionString is typically the output of the Detach method.


Boolean indicating whether or not the method was successfully executed

Used With

COM Data Control, Java Data Bean


Each of these examples instantiates the first COM Data Control instance, logs in to a Siebel Server, detaches this instance, and then gains the session string. It then instantiates the second COM Data Control instance. It does not need to log in again, as it attaches to the existing session by using the session string. This reuses the connection created by the first instance.

The following example is for COM Data Control and is written in native Visual Basic:

Dim SiebelApplication_first As SiebelDataControl
Dim SiebelApplication_second As SiebelDataControl
Dim errCode As Integer
Dim sessionString As String
Dim attachResult As Boolean
Dim errText As String

' Instantiate the first instance
Set SiebelApplication_first = CreateObject("SiebelDataControl.SiebelDataControl.1")

' Login to Siebel
SiebelApplication_first.Login "host=""Siebel.tcpip.none.none://<virtual ip>:<port>/<enterprise>/<object manager>""", "<user id>", "<password>"

errCode = SiebelApplication_first.GetLastErrCode
If errCode <> 0 Then
   errText = SiebelApplication_first.GetLastErrText
   MsgBox errText
   Exit Sub
End If

' Detach this instance from Siebel and get session id
sessionString = SiebelApplication_first.Detach
MsgBox "The session string is: " & sessionString

' Instantiate the second instance
Set SiebelApplication_second = CreateObject("SiebelDataControl.SiebelDataControl.1")

' Attach the existing session to this instance
attachResult = SiebelApplication_second.Attach(sessionString)
If (attachResult = True) Then
   MsgBox "Session attached!"
   MsgBox "Session attach failed"
End If

Set SiebelApplication_second = Nothing
Set SiebelApplication_first = Nothing

The following example is for Java Data Bean:


public class JDBAttachDetachDemo
   private SiebelDataBean m_dataBean_first = null;
   private SiebelDataBean m_dataBean_second = null;

   public static void main(String[] args)
      JDBAttachDetachDemo demo = new JDBAttachDetachDemo();

   public JDBAttachDetachDemo()
         // Instantiate the Siebel Data Bean
         m_dataBean_first = new SiebelDataBean();

         // Login to the servers
          <enterprise>/<object manager name>","<user id>","<password>");

         System.out.println("Logged in to the Siebel server ");

         //Get the Detach Handle
         String detachHandle = m_dataBean_first.detach();
         System.out.println("The session id is: " + detachHandle);

         // Instantiate another Java Data Bean
         SiebelDataBean m_dataBean_second = new SiebelDataBean();

         // Do Attach
         System.out.println("Attaching in to the Siebel server ");
         System.out.println("Attach Done ");

         // Logoff

      catch (SiebelException e)

Siebel Object Interfaces Reference Copyright © 2008, Oracle. All rights reserved.