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