Skip to content

Instantly share code, notes, and snippets.

@SergioDiniz
Created November 18, 2016 21:58
Show Gist options
  • Save SergioDiniz/6ccd279db7cacac021ab01624fdf8278 to your computer and use it in GitHub Desktop.
Save SergioDiniz/6ccd279db7cacac021ab01624fdf8278 to your computer and use it in GitHub Desktop.
hibernate.cfg.xml for PostgreSQL
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:postgresql://localhost/myDBName</property> <!-- BD Mane -->
<property name="connection.driver_class">org.postgresql.Driver</property> <!-- DB Driver -->
<property name="connection.username">postgres</property> <!-- DB User -->
<property name="connection.password">12345</property> <!-- DB Password -->
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property> <!-- DB Dialect -->
<property name="hbm2ddl.auto">update</property> <!-- create / create-drop / update -->
<property name="show_sql">true</property> <!-- Show SQL in console -->
<property name="format_sql">true</property> <!-- Show SQL formatted -->
<mapping class="beans.Task"/>
</session-factory>
</hibernate-configuration>
@Elvintest
Copy link

Hello, could you happen to know how to configure 2 or more databases in one cfg.xml file and and respectively in one session?

@farzadafi
Copy link

Thanks for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment