IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
  • 1.  Creating connection to databse using java service

    Posted 06/02/09 01:55 PM

    Hello,

    I want to create a connection to a database from a Java service rather than an adapter service and i am doing this for my practice purpose (creating a “how to connect to databse using Java service” document). Any pointers or references to a java code is appreciated.

    I am connecting to MSSQL server 2005 from IS 7.1.2. The inputs that i will be providing are database URL, Driver class and username/password.

    Note:

    This is not regarding using an existing connection, it has to create a new connection in the code.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 2.  RE: Creating connection to databse using java service

    Posted 06/02/09 10:36 PM

    Akki,

    What you got to do it simply embed the java connectivity code in a java service.
    Here is the sample code:

    import java.sql.*;
    try
    {
    Class.forName( “com.microsoft.jdbc.sqlserver.SQLServerDriver”);

                        Connection conn = DriverManager.getConnection(          "jdbc:microsoft:sqlserver://server:port;User='';Password=");                          
    
    System.out.println("connected");
    
    }
    catch (Exception e)
    {
    e.printStackTrace();
    return null;
    }
    

    just make sure you have the jars at the right place.

    • HS

    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 3.  RE: Creating connection to databse using java service

    Posted 06/03/09 05:10 PM

    I would strongly encourage not doing this and instead use the facilities provided by the JDBC adapter. If you must access a DB while running a Java service, use the IS Java API to invoke a proper JDBC service.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 4.  RE: Creating connection to databse using java service

    Posted 06/04/09 08:15 PM

    Rob,

    I understand the concern and it was just a curious how to thing.

    Harsh,

    Thanks for the pointer.

    Cheers,
    Akshith


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods