This content has been marked as final. Show 3 replies
I am using ojdbc6 and the code is as below:
OracleDataSource ods = null;
ods = new OracleDataSource();
Properties props = new Properties();
Now, when I do ods.getConnectionProperties().getProperty("password") it returns me null. This means that the connection properties overrides the password and make it non readable.
Though this used to work perfectly fine with ojdbc14.
Correct - the password property is filtered out when you call the 'getProperty' method of the Oracle datasource. If you use the 'setPassword' method to set the password you can retrieve the password by using the 'getPassword' method.
That filtering began with the OJDBC5.jar file.
dataSource.setPassword("tiger"); dataSource.setUser("SCOTT"); . . . System.out.println(dataSource.getPassword()); tiger
Please suggest, if there is a way to read password property. I want to create an instance of hibernate session factory from the oracleDataSource provided by client.
What is stopping you from doing that? Oracle still has the password available to use when creating connections. You haven't indicated that you have gotten any error or exception.
The OracleDataSource API doesn't provide any implementation like getPassword(). There is no exception, my need is to only get the password. But I am not sure how can I do it.
I want to create an instance of hibernate session factory from the oracleDataSource provided by client.
Did you try that? You don't need the password to do that? Sounds like you are just trying to hack the password.
As mentioned the latest Oracle jar filters the password out when you use getProperties and has made the getPassword method protected. You need to extend the class to get access to the getPassword method now.
But that won't give you the password unless setPassword was called to set it. You said that setProperties is being used. Those properties can only be accessed directly if you extend the class.