Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI DATASOURCE PROBLEM WITH WSAD

 
thomas davis
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing a problem of getting connection.
I have done changes in ibm-web-bnd.xml(<resRefBindings xmi:id="ResourceRefBinding_1125512347889" jndiName="jdbc/session_borg">
<bindingResourceRef href="WEB-INF/web.xml#ResourceRef_1125512347889"/>
</resRefBindings>)

I have added JNDI NAME IN datasource in server perspective.
I have added piece of code in web.xml
<resource-ref id="ResourceRef_1125512347889">
<res-ref-name>jdbc/session_borg</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</web-app>

My code for accessing the connection is as follows:
boolean ret =false;
InitialContext ic=new InitialContext();
DataSource ds =(DataSource) ic.lookup("java:comp/env/jdbc/sample");
Connection con = (Connection) ds.getConnection();
Statement stmt = null;
ResultSet rs = null;
try {
stmt = con.createStatement();
rs= stmt.executeQuery(GET_SQL);
while(rs.next()){
System.out.println("Login Detaile "+rs.getString(1)+" "+rs.getString(2));
if(rs.getString(1).equals(loginId)&& rs.getString(2).equals(password))
{ret =true;
return ret;}
}
}



I am getting an exception as follows :
Exception

An exception occurred while invoking method setDataSourceProperties on com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl used by resource Data source 1 : java.lang.reflect.InvocationTargetException
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic