• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jndi issue

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by william gates:
[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



Going by this error message, it does not appear to be a jndi issue. Looks like you have successfully looked up the datasource but while getting the connection from that datasource the exception is being thrown (the error is from the DB server). You might have to check the connection properties that you have set for the datasource
 
william gates
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply. I didn't set the datasource.. I only set up my connection bean, the web.xml and so on.

The server Admin handles the websphere 6.0 server and the connection pooling and so on. For security reasons I have no access to any of that information. I only know whatever the server admin reveals is the datasource name. And from there I thought the way I did things it should work. But it hasn't.

thanks for your reply though.
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic