If I have a hibernate apps that need to open multiple connection, how to
do this?
I think should be :
hibernate.cfg.xml
Code:
<?xml version='1.0' encoding='utf-8'?>
<!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.url">jdbc:sqlserver://PC1:XXXX;database=DB1</property>
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="connection.username">sa</property>
<property name="connection.password">P@ssw0rd</property>
<!-- Set AutoCommit to true -->
<property name="connection.autocommit">true</property>
<!-- SQL Dialect to use. Dialects are database specific -->
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<!-- Mapping files -->
</session-factory>
<session-factory>
<property name="connection.url">jdbc:sqlserver://PC2:3751;database=DB2</property>
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="connection.username">sa</property>
<property name="connection.password">P@ssw0rd</property>
<!-- Set AutoCommit to true -->
<property name="connection.autocommit">true</property>
<!-- SQL Dialect to use. Dialects are database specific -->
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<!-- Mapping files -->
</session-factory>
</hibernate-configuration>
But what about java/POJO ?
this is for single connection:
Code:
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session = sessionFactory.openSession();
what about multiple?