Data Replication 2
Results 1 to 1 of 1

Thread: HOW TO: Connect to Attunity Server using Connection URL in JDBC

  1. #1
    Adeeb Mass'ad is offline Support Manager
    Join Date
    Aug 2006
    Location
    Jaffa of Nazareth
    Posts
    169
    Rep Power
    14

    HOW TO: Connect to Attunity Server using Connection URL in JDBC

    DESCRIPTION

    Attunity provides a full JDBC 2.0 driver. The user can use the ThinClient kit to work against any Attunity DataSource, from simple FLAT files on the PC, to VSAM CICS and IMS/DB DataSources on the Mainframe.

    Attached a simple JDBC program which works with the DriverManager interface and a URL to connect to the Attunity Server.

    SAMPLE CODE

    Here's an explanation about some highlights in the sample code:

    STEP 1 - Loading the JDBC Classes

    When working with the DriverManager interface, the first step is to load the JDBC driver classes. For Attunity its done as follows:-
    Class.forName("com.attunity.jdbc.NvDriver");
    STEP 2 - Understanding the Connection URL

    Here is a sample URL:-
    String sURL = "jdbc:attconnect://10.0.0.15:2551;DefTdpName=VSAMCICS_DS;";
    • Connect to the Attunity Server Daemon located at IP - 10.0.0.15, and Port Number - 2551.
    • Set the Default DataSource to VSAM CICS DataSource (called VSAMCICS_DS). This DataSource should be located on the specified server.
    STEP 3 - Connect to the Server

    Get a connection from the JDBC DriverManager using your URL:-
    con = DriverManager.getConnection(sURL, null, null);
    See the attached sample for the full code.

    NOTES
    • The sample targets the daemon on the "localhost", this can be easily modified.
    • The JAVA CLASSPATH should contain a full reference to the NVJDBC2.JAR. When debugging your code using the "Log" properties, the CLASSPATH should also include the NVLOG2.JAR and the NVAPISPY2.JAR files.
    Here is a sample output:-
    T:\JDBC>java SimpleJDBC
    Connect using the following URL:

    URL = jdbc:attconnect://localhost:2551;DefTdpName=NavDemo;OneTdpMode=1;

    Execute the Query...
    Get Rows:

    Col1 = 1, Col2 = John Friedman
    Col1 = 2, Col2 = Jack Jones
    Col1 = 3, Col2 = Ron Murphy
    Col1 = 4, Col2 = Richard Smith
    ...
    Col1 = 29, Col2 = Daniel Black
    Col1 = 30, Col2 = Rick Stanley
    Last edited by Adeeb Mass'ad; 09-20-2006 at 12:50 PM.
    To Find Out more About Attunity Technology:
    Attunity
    or:
    Contact Us

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •