Reputation: 467
Hi I am new to java I am trying to do hibernate in eclipse this is my configuration file Hibernate.cfg.xml I edited it in note pad and copied it my app
<!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="hbm2ddl.auto">update</property>
<property name="dialect">org.hibernate.dialect.SqlServerDialect</property>
<property name="connection.url" value="jdbc:sqlserver://localhost;databaseName=empDb;instanceName=MSHassan"/>
<property name="connection.username">hmohamed</property>
<property name="connection.password">Kocroc1234</property>
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SqlServerDriver</property>
<mapping resource="employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>
I am getting error Cannot parse configuration file Hibernate.cfg.xml
Upvotes: 1
Views: 457
Reputation: 154200
You need to change:
<property name="connection.url" value="jdbc:sqlserver://localhost;databaseName=empDb;instanceName=MSHassan"/>
to:
<property name="connection.url">jdbc:sqlserver://localhost;databaseName=empDb;instanceName=MSHassan</property>
The former variant is valid for JPA (in persistence.xml), while the latter is Hibernate cfg specific.
Upvotes: 1