This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Connection pool with multiple users Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Connection pool with multiple users" Watch "Connection pool with multiple users" New topic

Connection pool with multiple users

Swathi Sri

Joined: Jan 18, 2007
Posts: 22
Hi all,

Our application is deployed in websphere server and works with Teradata. Connection pooling is used through server settings for datasource. Java code for getting connection is as follows:

Context ctx = new InitialContext();
Datasource ds = (DataSource) ctx.lookup("java:comp/env/test");
Connection conn = ds.getConnection(username, password);

username and password could be different sometimes. My doubt is "Does connection get established each time ds.getConnection(username,password) is called"?
If connection need not be established every time and it uses connection pooling properly how does authentication works?

Can anybody please clarify my doubt?

Thanks & Regards,
Swathi Sri

Joined: Jan 18, 2007
Posts: 22
Hi All,

Can anybody please clarify my doubt?

Thanks in advance..
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

Any reason not to create a different datasource for the users if there is a small number of users? If there is a lot of users, you could create another id to access the database on their behalf.

I don't know what happens in your scenario as I've never had cause to do this. You could see if your datasource documentation says anything on this.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Connection pool with multiple users
It's not a secret anymore!