Reputation: 13
First, thank you for reading, and I'm sorry about my English.
I have developed a Java Web Service with Eclipse, with a JDBC connection to Oracle Database, which contains some methods that gets information from this database (that I created in my local machine for tests), like getEmployee(int id), getAllEmployees(), etc.
I can generate the .wsdl and the .war, but I don't know how to request database credentials when the administrator deploys my WebService in the server (IBM WebSphere Application Server v7.0).
The problem: in my tests, I connect to Oracle Database with my host, user and pass, which are hardcoded in a Java file as constants, but I need that server's administrator can change this values for connect to its database, or something like this. (He said me that WebService WAR had to request for database configuration, like user-pass-host.., but I don't know if it's posible or there are other ways)
Again, thanks for reading until here, and all answers will be welcome.
Regards.
PD: If you need some extra info, tell me.
Upvotes: 1
Views: 96
Reputation: 18040
You need to switch to Datasource configuration, and use that in your application. In this way
1) you will not hardcode any database details in your application,
2) administrator will be able to provide authentication alias with user/pass for that application.
Manually creating database connections and embedding drivers in application is not recommended for Java EE applications.
This page describes how to configure Datasource in WebSphere.
In the code e.g. in your web service class, you use datasource like this (pseudo code):
@Resource
DataSource myDatasource;
.....
myDatasource.getConnection();
Upvotes: 1