• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Configuration of 2 Databases using spring

 
Sahil Saxena
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have 2 databases db1 and db2 both installed on same postgres server.

How should i configure both of them in applicationContext.xml?

I am using hibernate and spring combination.

- db1 is already confiured in applicationContext as below

<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName">
<value>org.postgresql.Driver</value>
</property>

<property name="url">
<value>jdbc ostgresql://1.1.1.1:5432/db1</value>;
</property>

<property name="username">
<value>postgres</value>
</property>

<property name="password">
<value>postgres</value>
</property>
</bean>

Should i create one more datasource in applicationContext.xml???

Thanks
[ February 07, 2006: Message edited by: Sahil Saxena ]
 
Michael Duffy
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sahil Saxena:
Hi,
I have 2 databases db1 and db2 both installed on same postgres server.

How should i configure both of them in applicationContext.xml?

I am using hibernate and spring combination.

- db1 is already confiured in applicationContext as below

<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName">
<value>org.postgresql.Driver</value>
</property>

<property name="url">
<value>jdbc ostgresql://1.1.1.1:5432/db1</value>;
</property>

<property name="username">
<value>postgres</value>
</property>

<property name="password">
<value>postgres</value>
</property>
</bean>

Should i create one more datasource in applicationContext.xml???

Thanks

[ February 07, 2006: Message edited by: Sahil Saxena ]


Yes. Give them different ids, and then inject them into the objects that need them.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic