English 中文(简体)
Getting a connection from a Sybase datasource in WAS 6.1 fails with message "User name property missing in DriverManager.getConnection"
原标题:

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.

最佳回答

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.

问题回答

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

new InitialContext().lookup("myDS");




相关问题
MaxPooledStatements setting in JDBC oracle

I can t figure out how to set MaxPooledStatements in Oracle using the Oracle thin JDBC driver. Could someone point me in the right direction?

pass ResultSet from servlet to JSP

I am doing the following in my SampleServlet.java //Fill resultset from db .... try { ArrayList Rows = new ArrayList(); while (resultSet.next()){ ArrayList row = new ArrayList(); ...

How to correctly use ResultSet with h:dataTable

The problem is, that after displaying the ResultSet with <h:dataTable>, the connection is left open. If I close it, it closes the ResultSet too. I m thinking about copying the ResultSet data ...

Mysql session variable in JDBC string

am using this connection string to connect to mysql from java: jdbc:mysql://localhost:3306/db?noDatetimeStringSync=true&useUnicode=yes&characterEncoding=UTF-8 is it possible to set the ...

热门标签