Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to Config "hibernate.cfg.xml" in dynamic mannner ?

843859Aug 11 2009 — edited Nov 20 2014
Hi,

I'm developing an application with Hibernate for object relational mapping & c3p0 for connection pool.
it works fine for a particular DB user & Password. But how can i access the Database with different DB users who have different access
privileges.

Can i create Dynamic "hibernate.cfg.xml" file which create connection pool for relevant user ?

My hibernate.cfg.xml which is using now :

<!DOCTYPE hibernate-configuration SYSTEM
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">
org.postgresql.Driver
</property>
<property name="hibernate.connection.url">
jdbc:postgresql://localhost:5444/fvx-hrm
</property>
<property name="hibernate.connection.username">
enterprisedb
</property>
<property name="hibernate.connection.password">
myroot
</property>
<property name="hibernate.dialect">
org.hibernate.dialect.PostgreSQLDialect
</property>
<property name="hibernate.jdbc.use_get_generated_keys">
false
</property>
<property name="hibernate.default_entity_mode">
pojo
</property>
<!-- Use the C3P0 connection pool provider -->
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<!-- Show and print nice SQL on stdout -->
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- List of XML mapping files -->
<mapping package="initial_customize"/>
<mapping class="initial_customize.CompanyUnit"/>
<mapping class="initial_customize.CompanyHoliday"/>
<mapping class="initial_customize.Currency"/>
<mapping class="initial_customize.Duty"/>
<mapping class="initial_customize.EmployeeGroupType"/>
<mapping class="initial_customize.Experience"/>
</session-factory>
</hibernate-configuration>


Is there any way i can create Connection pools depending on the Accessing user ?
please Help.

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 10 2009
Added on Aug 11 2009
3 comments
792 views