-->
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: Hide db password
PostPosted: Mon Jul 02, 2007 4:37 pm 
Newbie

Joined: Tue Aug 16, 2005 9:21 am
Posts: 12
Hi,

I think this question is simple, but I did not find how to do it.
I'd like to hide the password from hibernate.cfg.xml.

I'll store this password into a crypted file.

Tryied like this, but does not work.

Code:
   AnnotationConfiguration cfg = new AnnotationConfiguration();

    cfg.configure("/hibernate.cfg.xml")
        .setProperty("connection.username", DB_USERNAME)
        .setProperty("connection.password", DB_PASSWORD);

    session = sessionFactory.openSession();


PS: With the password in the hibernate.cfg.xml works normal. :-)

Any help is welcome

Rodrigo G. Tavares de Souza
Campinas - Brazil


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 03, 2007 3:04 am 
Senior
Senior

Joined: Thu May 17, 2007 2:31 am
Posts: 194
Location: Sri Lanka
Hi

Change it to

confg.setProperty("hibernate.connection.username",DB_USERNAME);
confg.setProperty("hibernate.connection.password",DB_PASSWORD );


Amila
(Don't forget to rate if helps)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 03, 2007 11:59 am 
Newbie

Joined: Tue Aug 16, 2005 9:21 am
Posts: 12
I've tried this one too, but does not work.
Code:
// Together
    cfg.configure(CONFIG_FILE_LOCATION)
        .setProperty("hibernate.connection.username", DB_USERNAME)
        .setProperty("hibernate.connection.password", DB_PASSWORD);

// Separated
    cfg.configure(CONFIG_FILE_LOCATION);
    cfg.setProperty("hibernate.connection.username", DB_USERNAME);
    cfg.setProperty("hibernate.connection.password", DB_PASSWORD);

// Changing order
    cfg.setProperty("hibernate.connection.username", DB_USERNAME)
        .setProperty("hibernate.connection.password", DB_PASSWORD)
        .configure(CONFIG_FILE_LOCATION);

// No one worked...
// PS: I've made  all these tests with "connection.username"
// and "connection.password" too...
 


I know it should works, setting the whole configuration by this way, but I really like to work together with configuration file.

Is there someone else to give me a light?

Thx,

Rodrigo G. Tavares de Souza
Campinas - Brazil


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.