cancel
Showing results for 
Search instead for 
Did you mean: 

Creating DataSource dynamically in WAS

Former Member
0 Kudos

Hi,

I want to create a datasource in WAS from my own web application at runtime depending upon which database the user has chosen from the dropdown list on the JSP page.

Can any one help me and tell me how to go about it.

i want to know which APIs and which classes to use.

Its a very urgent requirement.

Regards

Saurabh

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

For information, on how to create a datasource

http://java.sun.com/j2se/1.4.2/docs/guide/jdbc/bridge.html

I have used the following snippet of code inorder to achieve connection for a datasource defined in WAS.

So you may try creating a datasource based on the above link,and see if it can create a datasource in WAS.


java.sql.DataSource datasource;
initialContext = new InitialContext();
					dataSource = (java.sql.DataSource) initialContext.lookup("jdbc/xyz123");
					conn = dataSource.getConnection();

Regards,

Harish

(Please award points ,if this answer has been helpfull)

Former Member
0 Kudos

Hi,

As i understand DataSources are static entities in any application. we should be creating the DataSources initially and assign Alias to the Datasources,.. at runtime we can decide the alias and use the corresponding alias.

Regards,

S.Divakar

Former Member
0 Kudos

Hi Divakar,

The requirement is such that the user can choose the type of RDBMS from the list on the jsp page and provide all the info like username.password,etc and when he submits the page a datasource should be created on WAS which can be used later by the application.

Can you help on how to create a data source.

Regards

saurabh