I'm having an issue connecting to a DB2 database on a Websphere 6.0 app server.
Here is my connection code :
-----------------------------------
(dbBean)
public boolean connect()
{
try
{
dbCon = abc.DB.DB_ConnectionBean.getConnection();
}
catch(Exception e)
{
System.out.print("Failed to connect to DB " + e);
}
return true;
}
(dbConnectionBean)
public static Connection getConnection()throws Exception
{
// Obtain our environment naming context
ctx = new InitialContext();
Context envCtx = (Context) ctx.lookup("java:comp/env");
// Look up our data source
DataSource ds = (DataSource)envCtx.lookup("jdbc/ABCDEFG");
// Allocate and use a connection from the pool
dbCon = ds.getConnection();
return(dbCon);
}
here is the web.xml piece :
<resource-ref id="somethingABC">
<description>abc stuff</description>
<res-ref-name>jdbc/ABCDEFG</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
but when I deploy the webapp and try to run the
jsp page, it comes back with this error on the jsp page :
-----------
Error 500: [IBM/DB2][T2zos/2.9.32]T2zosPreparedStatement.readPrepareDescribeOutput_:nativePrepareInto:1377
B2 engine SQL error, SQLCODE = -904, SQLSTATE = 57011, error tokens = 00D31024;00001004;NULL.CIM202.?RRSAF
---------------
I looked up the SQLCODE = -904 but it seems maybe I'm setting up the JNDI wrong. I'm not sure..
When I was
testing on
tomcat, we were using
jdbc and we connected successfully and ran reports.
After migrating to webpshere 6.0, the server admins set up the jndi and according to their test page, our database connection pool works.. However I can't seem to access it. I've got the right names according to the server admin so I don't know.
I even tried using JSTL SQL tags to see if I could connect, but either I got an error or instead of results from the DB, i got the varialbles like $ColName as my results and not any real data.
I'm a little confused at this point. Any help on why my jndi isn't working would be appreciated.