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.  [ 2 posts ] 
Author Message
 Post subject: JDBC Username and Password
PostPosted: Tue Feb 16, 2010 8:04 pm 
Beginner
Beginner

Joined: Wed Jun 01, 2005 6:51 pm
Posts: 27
Location: Philippines
I have a situation where the JDBC connection isn't a static set of username and password, but that the actual user making the request is used to make the connection.

Is it possible to pass the JDBC Connection Username and Password to Hibernate at runtime in the context or some other way?

_________________
Mike "Ollie" Oliver


Top
 Profile  
 
 Post subject: Re: JDBC Username and Password
PostPosted: Wed Feb 17, 2010 3:08 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
This is set at configuration time, so once you have started your application and built the session factory it can't be changed. You can set this programmatically on the configuration. We are doing something like this:

Code:
Configuration cfg = new Conficguration();
cfg.setProperty("hibernate.connection.url", dbUrl);
cfg.setProperty("hibernate.connection.username", username);
cfg.setProperty("hibernate.connection.password", password);
// .. and a lot of other things....
cfg.configure();
SessionFactory sf = cfg.buildSessionFactory();


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.