how to config when use hibernate+sqlserver2005

1. there is sql server 2005 express edition which is free, user can download from: http://msdn.microsoft.com/zh-cn/express/bb410792.aspx 2. download jdbc driver from micorsoft, choose the proper driver version from the following website: http://www.microsoft.com/downloads/results.aspx?pocId=&freetext=JDBC&DisplayLang=en 3. download hibernate3 from http://hibernate.org 4. add the jdbc driver and all the hibernate related jar files (not only hibernate3.jar) to the build path 5. configue the for sql server port, by defualt, the connection by TCP/IP to database server is forbidden, In database configuration Manager, you should first enable it and also, for the connection, config the port, for IPAll connection, set the port to 1433; If not set the port, when connection, there will be exception like: connection refuesed, TCP/IP connection failed. the step: SQL Server Configuration Manager--> SQL Server 2005 Network configuration --> Network Protocol --> TCP/IP, 6. In the hibernate configuration file, configure like the following code:

<?xml version="1.0" encoding="UTF-8"?>



<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">



<hibernate-configuration>

    

    <session-factory>

        

        <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>

        <property name="hibernate.connection.url">jdbc:sqlserver://localhost:1433;DatabaseName=hibernate</property>

        <property name="hibernate.connection.username">sa</property>

        <property name="hibernate.connection.password">sa</property>

        <property name="hibernate.connection.pool.size">20</property>

        <property name="hibernate.connection.show_sql">true</property>

        <property name="jdbc.fetch_size">50</property>

        <property name="jdbc.batch_size">25</property>

        <property name="jdbc.use_scrollable_resultset">false</property>

        <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>

        

        <mapping resource="home/stronger/hibernate/CoreCitizen.hbm.xml"/>

    </session-factory>

    

</hibernate-configuration>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值