aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes jndi issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "jndi issue" Watch "jndi issue" New topic
Author

jndi issue

william gates
Ranch Hand

Joined: Feb 21, 2007
Posts: 112
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.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10059
    
163

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


[My Blog] [JavaRanch Journal]
william gates
Ranch Hand

Joined: Feb 21, 2007
Posts: 112
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.
 
jQuery in Action, 2nd edition
 
subject: jndi issue