0

I have created a DataSource in MobileFirst server.xml:

<dataSource jndiName="jdbc/QAIWDB2">
        <jdbcDriver libraryRef="DB2Lib"/>
         <properties databaseName="QAIWPRD" password="pass" portNumber="99999" serverName="xyz.com" user="user"/>
    </dataSource>

When I am trying to access it from a Java Adpater I am getting an error while deploying the adapter

Adapter deployment failed: An object could not be obtained for name jdbc/QAIWDB2.

The code in Java Adapter is

static DataSource ds = null;
    static Context ctx = null;

    public static void init() throws NamingException {
        ctx = new InitialContext();
        ds = (DataSource)ctx.lookup("jdbc/QAIWDB2");
    }
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
Saptak Niyogi
  • 240
  • 2
  • 10

1 Answers1

0

Try the DB2 JNDI definition proposal mentioned in this answer: https://stackoverflow.com/a/17851124/1530814.

Of course, change the values to yours...

<dataSource jndiName="jdbc/db2" type="javax.sql.DataSource">
    <jdbcDriver>
        <library>
            <fileset dir="/usr/lib/java/ibm-db2-universal-driver" includes="db2jcc4.jar, db2jcc_license_cisuz.jar, db2jcc_license_cu.jar"/>
        </library>
    </jdbcDriver>

    <properties databaseName="DB2T" portNumber="21020" serverName="db2t.lvm.de password=" ... " user=" ... "/>
</dataSource>
Community
  • 1
  • 1
Idan Adar
  • 44,156
  • 13
  • 50
  • 89