webMethods

webMethods

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.

 View Only
  • 1.  Getting DataSource Object of JDBC Connection

    Posted Thu May 15, 2003 12:03 PM

    I want to get a DataSource Object inside my Java Code that is representing the Data Source configured in the Integration Server Administration Console.

    We�ve been written some code that looks like the following, but does not work:

    Context ctx = new InitialContext();
    DataSource ds = (DataSource) ctx.lookup(“jdbc/xeed”);
    con = ds.getConnection(user, password);

    Is there a way to get the WM-Datasource via JNDI lookup?

    Thanks for helping me.

    Steven.


    #webMethods-General
    #webMethods
    #Integration-Server-and-ESB


  • 2.  RE: Getting DataSource Object of JDBC Connection

    Posted Mon June 28, 2004 09:56 AM

    Have you find the solution ?

    Yannick


    #webMethods-General
    #webMethods
    #Integration-Server-and-ESB


  • 3.  RE: Getting DataSource Object of JDBC Connection

    Posted Mon June 28, 2004 02:23 PM

    Hi Steve,

    I haven’t tried this myself, but looking at the Java API (under Developer/docs/API/Java/index.html), there are several DB-related classes under com.wm.app.b2b.server which may help you achieve what you’re after - for example DBConnectionManager, DBConnection and JDBCConnection.

    The problem with these classes in meeting your stated requirements is that they are not sub-classes of Java “DataSource” (or more correctly, they do not implement the DataSource interface). You may be able to write a “wrapper” class yourself that implements DataSource and wraps a DBConnectionManager, if you must work with DataSources.

    These classes will let you execute SQL etc. - so perhaps that’s all you need.

    Hope this helps.

    Cheers,

    Steve


    #Integration-Server-and-ESB
    #webMethods
    #webMethods-General


  • 4.  RE: Getting DataSource Object of JDBC Connection

    Posted Tue June 29, 2004 07:31 PM

    What is your job really do ?

    I’ve hacked WmJDBCAdapter for getting Connection object.

    It worked by Adapter Service creation that return specific Connection.

    Code snippet

    1. Write FetchConnection class.
    package com.wm.adapter.wmjdbc.services;
    
    import java.sql.Connection;
    import java.util.Locale;
    
    import javax.resource.ResourceException;
    
    import com.wm.adapter.wmjdbc.connection.ConnectionInfo;
    import com.wm.adapter.wmjdbc.connection.JDBCConnection;
    import com.wm.adk.cci.interaction.WmAdapterService;
    import com.wm.adk.cci.record.WmRecord;
    import com.wm.adk.cci.record.WmRecordFactory;
    import com.wm.adk.connection.WmManagedConnection;
    import com.wm.adk.error.AdapterException;
    import com.wm.adk.metadata.WmTemplateDescriptor;
    
    /**
    * @author Kyun Sang Song
    *
    * Created on 2004. 5. 19.
    * 
    */
    public class FetchConnection extends WmAdapterService {
    
    public FetchConnection() {
    super();
    }
    
    public WmRecord execute(WmManagedConnection conn, WmRecord arg1)
    throws ResourceException {
    WmRecord out = WmRecordFactory.getFactory().createWmRecord("Output");
    ConnectionInfo cInfo = ((JDBCConnection) conn).getConnectionInfo();
    Connection dbCon = cInfo.getConnection();
    out.put(_connectionName, dbCon);
    return out;
    }
    
    public void fillWmTemplateDescriptor(WmTemplateDescriptor d, Locale l)
    throws AdapterException {
    
    d.createGroup("FetchConnection", new String[] {"connectionName"} );
    
    d.setRequired("connectionName");
    
    d.setResourceDomain("connectionName", "outputFieldNames",
    new String[0]);
    
    }
    
    private String _connectionName = "dbConnection";
    
    public String getConnectionName() {
    return _connectionName;
    }
    
    public void setConnectionName(String connectionName) {
    _connectionName = connectionName;
    }
    
    }
    
    
    1. add line to JDBCConnectionFactory class
        public void fillResourceAdapterMetadataInfo(ResourceAdapterMetadataInfo info, 
    Locale locale)
    throws AdapterException
    {
    ...
    info.addServiceTemplate((com.wm.adapter.wmjdbc.services.FetchConnection.class).getName());
    }
    

    #webMethods-General
    #webMethods
    #Integration-Server-and-ESB


  • 5.  RE: Getting DataSource Object of JDBC Connection

    Posted Fri July 08, 2005 04:42 AM

    Hi,

    Do you know where I can find classes from the com.wm.adk package. I should use them in a custom java service.

    Regards


    #Integration-Server-and-ESB
    #webMethods
    #webMethods-General


  • 6.  RE: Getting DataSource Object of JDBC Connection

    Posted Mon July 11, 2005 02:37 AM

    Hi Toon,

    are you licensed for the Adapter Development Kit?

    Otherwise you wont be able to use these classes.

    The classes can be found in WmART/code/jars/wmart.jar

    Remember that the Pools in the IS Admin Console are only available for wM internal purposes. They are using a specialized driver.

    Regards,
    Holger


    #webMethods-General
    #Integration-Server-and-ESB
    #webMethods


  • 7.  RE: Getting DataSource Object of JDBC Connection

    Posted Tue July 12, 2005 09:45 AM

    In flow, you can call wm.art.admin.connection:getResourceConfiguration.
    This brings back a list of values that you specify in the connectionAlias input.
    I’ve created a service that takes connectionAlias, type, and systemName as inputs and gives me the output value. It’s easy enough for you to do the same to get a value. The password is returned encryped.


    #webMethods
    #Integration-Server-and-ESB
    #webMethods-General