I want to connect to MS SQl server 2005 using hibernate in java. i am unable to find the jars and the hibernate.cfg.xml file for the same. can someone help me with the same
All you need is the driver class and proper dialect. See http://msdn.microsoft.com/en-us/library/ms378749.aspx
If you have the driver, then (at a minimum) you need to specify the connection properties: http://www.roseindia.net/hibernate/firstexample.shtml
The proper dialect appears to be: org.hibernate.dialect.SQLServerDialect
I am unable to find the jars.
Get a JDBC driver for SQL Server 2005 from Microsoft or use the open source alternative jTDS.
and the hibernate.cfg.xml file for the same
The dialect for SQL Server 2005 is org.hibernate.dialect.SQLServerDialect
.
The other params (like the driver class name, the jdbc URL) will depend on the driver you choose. Refer to the respective documentation.
As mentioned by Pascal Thivent, use any one driver. In case of JTDS, use the following configuration.
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:jtds:sqlserver://XX.XX.XXX.XX:YYYY/DB-NAME</property>
<property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property name="connection.username">username</property>
<property name="connection.password">password</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
.
.
.
</session-factory>
</hibernate-configuration>
And in case of Microsoft SQL JDBC Driver,
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:microsoft:sqlserver://XX.XX.XXX.XX:YYYY/DB-NAME</property>
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="connection.username">username</property>
<property name="connection.password">password</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
.
.
.
</session-factory>
</hibernate-configuration>