-->
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.  [ 14 posts ] 
Author Message
 Post subject: SETTING HIBERNATE PROPERTIES...
PostPosted: Wed Aug 11, 2004 4:15 am 
Newbie

Joined: Fri Aug 06, 2004 9:44 am
Posts: 11
It is possible to set these 3 hibernate properties:

hibernate.connection.url jdbc:sapdb://myserver/mydb

hibernate.connection.username user

hibernate.connection.password pswd


using an external Java method like

setHibernateProperties(url, user, password) ?

Regards,

Massimo


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 4:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
why would you like to do that?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 4:27 am 
Newbie

Joined: Fri Aug 06, 2004 9:44 am
Posts: 11
i have to do that in my project :)
you think is impossible ?

Massimo


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 4:27 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
probably you should consider explaining me what you want to do, so I can tell you how?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 4:36 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
A good way for all initializations is using an Init servlet who load all properties files for any framework...
You can do that for Hibernate.
But if you need more help give us more details.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 4:43 am 
Newbie

Joined: Fri Aug 06, 2004 9:44 am
Posts: 11
I'm doing a simple Java Application, and i don't know how to use an Init servlet, i'm sorry...

I'm just looking for a simple method which can let me set these hibernate properties.

Imagine that i have a Java class like this

class hibernateProperties....

{

...

public void setURL()

public String getURL()

public String getUser()

public String getPswd()

}

i need to create a method like:

hb = new HibernateProperties();

void setHibernateProperties(hb.getURL(), hb.getUser(), hb.getPswd());
{
in which i can configure hibernate
}

Massimo


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 4:47 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
Do you need to change properties when you re using this application?
Or when initialization is done, you never need to change it?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 4:49 am 
Newbie

Joined: Fri Aug 06, 2004 9:44 am
Posts: 11
I have to initialize properties when i start the application


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 4:55 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
So you can use your HibernateProperties object and initialize your configuration like this.
Use Javadoc you could find more informations about it.
Then you can use your cfg to open session....


Configuration cfg = new Configuration().addClass(Panel.class).addClass(map_Obj1.class).addClass(map_Obj2.class);
cfg.setProperty("hibernate.dialect", "net.sf.hibernate.dialect.Oracle9Dialect");
cfg.setProperty("hibernate.connection.driver_class", "oracle.jdbc.driver.OracleDriver");
cfg.setProperty("hibernate.connection.username", "admin");
cfg.setProperty("hibernate.connection.password", "pwd");
cfg.setProperty("hibernate.connection.url", "jdbc:oracle:thin:@ip:1522:DEV");


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 5:12 am 
Newbie

Joined: Fri Aug 06, 2004 9:44 am
Posts: 11
Thank you very much!
I'll try that

Massimo


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 9:38 am 
Newbie

Joined: Fri Aug 06, 2004 9:44 am
Posts: 11
ops i think i'm not able to do that

i made

Configuration cfg = new Configuration();
sessions = cfg.configure().buildSessionFactory();
cfg.setProperty("hibernate.connection.username", "user");
cfg.setProperty("hibernate.connection.password", "pswd");
cfg.setProperty("hibernate.connection.url", "jdbc:sapdb://server/db");

ok?

i've got also my hibernate.cfg.xml configuration file

<property name="hibernate.connection.url">
jdbc:sapdb://server/db
</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.password">pswd</property>

if i remove these properties from the configuration file, hibernate does not start !

how can i do ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 10:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You must of course set the properties before building the session factory. Please read the docs and think.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 12, 2004 3:22 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
As Michael has said, read more carefully hibernate reference, and try this tutorial.
http://www.gloegl.de/8.html
kind regards and good reading :+)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 12, 2004 3:40 am 
Newbie

Joined: Fri Aug 06, 2004 9:44 am
Posts: 11
I've already red that tutorial but thank you.
Now my application is working good.


Thanks to all


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