-->
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.  [ 3 posts ] 
Author Message
 Post subject: Change properties dynamiclly
PostPosted: Tue Nov 25, 2008 5:32 am 
Newbie

Joined: Tue Nov 25, 2008 5:18 am
Posts: 2
Hello,

i try to change username and password dynamically within code.
But it don't work and i'm tired of trying.

Can someone please explain me, what i'm doing wrong?

Hibernate version: 3.2.6.ga

Code:
Configuration cfg = new AnnotationConfiguration().configure(  );
cfg.setProperty( "connection.username", pUsername );
cfg.setProperty( "connection.password", pPassword );
cfg.buildSessionFactory().openSession();


That should work, or? But when opening teh connection i get an exception:

Quote:
Access denied for user ''@'localhost' (using password: NO)


Thanks in regard.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2008 6:27 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
I think you need to prefix the properties with "hibernate.". Eg.

Code:
cfg.setProperty("hibernate.connection.username", pUsername );
cfg.setProperty("hibernate.connection.password", pPassword );


We are doing this in our project and it works fine. The only other difference I see is that we are doing Configuration cfg = new Configuration();. I don't know if that makes any difference.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2008 7:14 am 
Newbie

Joined: Tue Nov 25, 2008 5:18 am
Posts: 2
hi,

thank you so much. you were right. it just was the fsck prefix.
I thought since hibernate 3 it isn't necessary to prefix the config strings with hibernate.

anyway thank you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.