-->
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.  [ 7 posts ] 
Author Message
 Post subject: Dynamic Database Connection
PostPosted: Tue Aug 07, 2007 7:23 pm 
Newbie

Joined: Wed Aug 01, 2007 10:36 am
Posts: 7
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0

Hi, i need to obtain the parameters of jdbc connection from the database to generate the hibernate.cfg.xml, in the books nothing appear to help me. If anyone can help me.

Thanx a lot

Jorge


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 09, 2007 12:56 am 
Beginner
Beginner

Joined: Thu May 17, 2007 2:41 pm
Posts: 48
what do you mean by
parameters of jdbc connection

like jdbc:mysql://localhost/"+projname? or what?

be more explicit.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 09, 2007 3:20 am 
Newbie

Joined: Sun May 06, 2007 5:57 am
Posts: 10
Please tell us, which database you are using.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 09, 2007 10:50 am 
Newbie

Joined: Wed Aug 01, 2007 10:36 am
Posts: 7
hi, i use Oracle 10g Database


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 8:28 pm 
Beginner
Beginner

Joined: Thu May 17, 2007 2:41 pm
Posts: 48
try this

jdbc:oracle:thin:@//localhost:1521/<oracle_sid>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 16, 2007 10:55 am 
Newbie

Joined: Wed Aug 01, 2007 10:36 am
Posts: 7
in the hibernate.cfg.xml file:

<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-
3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.username">THE UID</property>
<property name="connection.password">THE PWD</property>
<property name="connection.url">
THE URL
</property>
<property name="connection.driver_class">
THE DRIVER
</property>
<property name="dialect">
THE DIALECT
</property>
<mapping resource="xxx.hbm.xmll"/>
</session-factory>
</hibernate-configuration>

in this file i need to obtain the parameters uid, pwd, url, driver, and dialect from a properties file, this is that i call dynamic. I donĀ“t know how do this. If any can help me.

thanxs a lot


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 16, 2007 11:27 am 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
You could bind these parameters from a properties file during your build process. Or, use a combination of file based and java based configuration.
e.g. When building your session factory:
Code:
Configuration config = new Configuration()
   .configure()    // load properties from hibernate.cfg.xml
   // override or define additional properties
   .setProperty("hibernate.dialect", properties.getDialect())
   .setProperty("hibernate.connection.driver_class", properties.getDriverClass())
...etc


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