db2 - Cannot find datasource in Java Adapter in IBM MobileFirst -


i have created 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 trying access java adpater getting error while deploying adapter

adapter deployment failed: object not obtained 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");     } 

try db2 jndi definition proposal mentioned in answer: https://stackoverflow.com/a/17851124/1530814.

of course, change values 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> 

Comments