Getting DataSource Object of JDBC Connection

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.


Have you find the solution ?


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 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.



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.

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() {

	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.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


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


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.


In flow, you can call
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.