-->
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: change database type
PostPosted: Fri Jul 02, 2004 11:50 am 
Newbie

Joined: Mon Jun 07, 2004 3:07 pm
Posts: 3
hi
i create a jar file and deliver to the customer. But he uses the another DB type. How can i save the DB information in a .properties file or .xml file but not in the .jar ?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 04, 2004 9:54 am 
Newbie

Joined: Sun Jul 04, 2004 8:58 am
Posts: 1
Hello! I suppose the most direct way that comes to mind to decouple this in a standalone application is to read a file or use the environment to figure out the properties and put them into a Properties object. Then when you are configuring, use Configuration::setProperties to dynamically configure the required items prior to buildSessionFactory().

Code:
Properties p = new Properties();
  // set stuff here, e.g. 
  // hibernate.dialect = net.sf.hibernate.dialect.Oracle9Dialect
  // hibernate.connection.isolation = 3
  // hibernate.connection.datasource = jndi:comp/env/jdbc/ORCL

Configuration cfg = new Configuration().setProperties( p );
SessionFactory s_SessFac = cfg.buildSessionFactory();
  // etc



I suppose what you'd have to mainly change is the SQL Dialect, as there are other ways (JNDI for instance) for the database connection or pool itself.

Doesn't hibernate look in the classpath for the config file(s)? It just isn't clear to me what the exact priorities are.

Hope this helps!


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.