-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Per user connections
PostPosted: Fri Jun 02, 2006 7:00 am 
Newbie

Joined: Fri Jun 02, 2006 6:51 am
Posts: 3
For reasons unbeknownst to me, in an application we are building for a client instead of the usual app wide connection pool, they are passing our application a user/pass, and they want us to connect to the DB with that information for that person only. So each HttpSession would have its own unique DB connection for it to use only. Is there an easy way to do this? Can someone point me in the right direction?

Thanks
-Andy


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 02, 2006 7:09 am 
Regular
Regular

Joined: Mon May 08, 2006 6:00 am
Posts: 53
Location: India
Hi

I am assuming you are making a normal JDBC connection to DB and not using any Datasource configured.

By reading your problem description, what you want is to get a Database connection by passed username and passwrod. For this you need to associate this user name and password with Hibernate configuration (which we normally specify in hibernate.cfg.xml).

You can do that at runtime , by using addproperty method of Configuration objecy of Hibernate.

But belive me this looks to me a costly affair of passing different id and passwrod for connectivity each time, think about redesigning your application

If I have gone wrong somehwhere in u/s your problem, let me know

Sudhir H


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 02, 2006 7:25 am 
Newbie

Joined: Fri Jun 02, 2006 6:51 am
Posts: 3
Normally, we just add a global username/password in the hibernate conf file, and use a connection pool for connections, but this client wants each logged in user to connect to the database with their own user information for security reasons. So unfortunetly I have no power to redesign how they want things to work.

My problem is, now once I use any username and password to connect to the DB all logged in users use that connection. Is it possible or a good idea to re-impliment my HibernateSessionFactory in a way to store the HibernateSession in the HttpSession, so that each logged in user has their own HibernateSession? It sounds like it might work, is there a major downside I am missing?

Thanks
-Andy


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 02, 2006 10:27 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Look at providing a custom ConnectionProvider implementation that knows how to retrieve this contextual username/password info as it is required to make connections...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 02, 2006 1:48 pm 
Newbie

Joined: Fri Jun 02, 2006 6:51 am
Posts: 3
steve wrote:
Look at providing a custom ConnectionProvider implementation that knows how to retrieve this contextual username/password info as it is required to make connections...


Is there a way to pass information into the connection provider, I'm having issues getting the user/password to the provider, does Hibernate facilitate this or does my provider need to go out and grab the HttpSession and get the information from there.

-Andy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.