Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
274 views
Welcome To Ask or Share your Answers For Others

1 Answer

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...