Java 连接 Sqlserver2005

Java 连接 Sqlserver2005

 

1.包 : sqljdbc.jar

 

2. ddl : sqljdbc_auth.dll

 

3. 设置 TCP/IP启动 :

 

        (1)打开SQL   Server   Configuration   Manager  
        (2)转到SQL   Server   2005   Network   Configuration->Protocols   for   SQLEXPRESS  
        (3)将TCP/IP设置为Enabled(启用)  
        (4)双击TCP/IP项,转到IP   Addresses页  
        (5)IP   All中设置TCP   Port为1433  
        (6)重新启动服务  

4. hibernate 配置(整合Spring)

 

 

<bean id="MyDataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource"
  destroy-method="close">
  <property name="driver">
   <value>com.microsoft.sqlserver.jdbc.SQLServerDriver</value>
  </property>
  <property name="driverUrl">
   <!--
    <value>jdbc:oracle:thin:qefoa/[email protected]:1521:qefoa</value>
   --> 
    <value>jdbc:sqlserver://localhost:1433;DatabaseName=resource;user=sa;password=resource</value>
  </property>
  <property name="user">
   <value>sa</value>
  </property>
  <property name="password">
   <value>resource</value>
  </property>
  <property name="alias">
   <value>resource</value>
  </property>
  <property name="houseKeepingSleepTime">
   <value>90000</value>
  </property>
  <property name="prototypeCount">
   <value>5</value>
  </property>
  <property name="maximumConnectionCount">
   <value>100</value>
  </property>
  <property name="minimumConnectionCount">
   <value>10</value>
  </property>
  <property name="trace">
   <value>true</value>
  </property>
  <property name="verbose">
   <value>true</value>
  </property>
 </bean>
 
 <!-- session factory, 指定了lobHandler -->
 <bean id="MyHibernateSessionFactory"
  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource">
   <ref bean="MyDataSource" />
  </property>
  <property name="lobHandler">
   <ref bean="oracleLobHandler" />
  </property>
  <property name="hibernateProperties">
   <props>
    <!--
    <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
    -->
    <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
   </props>
  </property>

  <property name="mappingResources">
   <list>
   
    <!-- 管理 -->
    
    <value>org/css/resource/businesssoft/hibernate/model/DeptPO.hbm.xml</value>
      <value>org/css/resource/businesssoft/hibernate/model/UserPO.hbm.xml</value>
      <value>org/css/resource/businesssoft/hibernate/model/UserDeptPO.hbm.xml</value>
      
      <!-- 字典 -->
      <value>org/css/resource/skeletonsoft/util/dicttools/DictType.hbm.xml</value>
      <!-- 缓存-->
      <value>org/css/resource/skeletonsoft/util/dicttools/GCachedTime.hbm.xml</value>
      <!-- 日志 -->
      <value>org/css/resource/skeletonsoft/log/model/ResoureLog.hbm.xml</value>
    <!-- 资源库 -->
    <value>org/css/resource/businesssoft/searchengine/bussiness/po/DirctoryPopedom.hbm.xml</value>
    <value>org/css/resource/businesssoft/searchengine/bussiness/po/ResourceDirectory.hbm.xml</value>
    <value>org/css/resource/businesssoft/searchengine/bussiness/po/ResourceFile.hbm.xml</value>
    <value>org/css/resource/businesssoft/searchengine/bussiness/po/ResourceMenu.hbm.xml</value>
    <value>org/css/resource/businesssoft/searchengine/bussiness/po/ResourcePopedom.hbm.xml</value>
    
   </list>
  </property>
 </bean>

你可能感兴趣的:(java,spring,sql,Hibernate,bean,server,sqlserver)