views:

182

answers:

2

I have a standalone application that needs to connect to a Sybase database via a datasource, I'm trying to connect using getConnection() and get the connection from this Sybase datasource which is hosted in WAS 6.1, sadly I'm getting an error JZ004 -> Sybase(R) jConnect for JDBC(TM) Programmer's Reference: SQL Exception and Warning Messages

JZ004 error message is:
User name property missing in DriverManager.getConnection(..., Properties) Action: Provide the required user property.

As you can see, this is not a connectivity (so we can discard JNDI or lookup problems), but rather a configuration problem. For my Sybase datasource in WAS 6.1 I have set up the proper authentication alias (Component-managed Authentication Alias), and I know the credentials are alright, "Test Connection" is successful for this datasource. Somebody had a similar problem and was because of the authentication alias-> http://forum.springsource.org/showthread.php?t=39915

Next, I tried calling getConnection() but now I provided the credentials like getConnection(user, password)... and this time it worked!!! So I suspect that somehow WAS 6.1 is not picking or taking the authentication info I set in the datasource as mentioned before.

If you think that maybe getConnection(user, password) should be OK for my case, well, that's not the case since I have a requirement to keep the credentials in the server, the standalone application only needs to know the JNDI information to lookup the datasource.

Please let me know if have faced a similar problem, or what would you suggest me to do.

Thanks.

A: 

In order to use the configured resource, you need to look it up rather than using DriverManager directly:

new InitialContext().lookup("myDS");
bkail
That's what I'm doing, but i get the problem mentioned before. The DriverManager exception appears in the actual stack trace.I added a new question for this case:http://stackoverflow.com/questions/2677079/call-to-datasource-getconnection-not-returning-the-expected-connection
Abel Morelos
A: 

In another thread -> Call to DataSource.getConnection not returning the expected connection, I got an answer that also solved this issue, basically the answer is that an authentication alias won't work for external clients according to the J2C documentation. The workaround is to provide the user and password as custom properties instead of being provided as an authentication alias.

Abel Morelos