Wednesday, 20 April 2016

Scenario : DB connection using CFG file and properties file


Scenario

An Hibernate core application has following files in the classpath directory with following entries :

In hibernate.properties
hibernate.connection.url = jdbc:mysql://localhost/myAppDB1

hibernate.cfg.xml file
<property name="hibernate.connection.url">
   jdbc:mysql://localhost/myAppDB2
</property>

Given the files have the above statements in correct places in the file, when hibernate gets initialized, to which DB the Hibernate will be connected ?


Answer

myAppDB2
Any properties defined in hibernate.properties will be overridden by the hibernate.cfg.xml file defined properties.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.