随笔-126  评论-247  文章-5  trackbacks-0

之前 , 不使用 maven 管理 jar 包的时候 , 链接 SQL Server 数据库的时候用的都是 sqljdbc4.jar 驱动包 , 刚用 maven 做测试的时候 , 到中央仓库找不到 sqljdbc4.jar 的坐标 ,

到网上搜了一下 , 说是可以用 jtds 通过 jdbc 来链接 SQL Server , 实验了一下 , 果真行 !

pom.xml :

     ... ... ... ... ...
    <!-- sql server driver -->
    
<dependency>
      
<groupId>net.sourceforge.jtds</groupId>
      
<artifactId>jtds</artifactId>
      
<version>1.2.4</version>
    
</dependency>
    ... ... ... ... ...


hibernate.cfg.xml :


<hibernate-configuration>

    
<session-factory>

        
<!-- Database connection settings -->
        
<property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
        
<property name="connection.url">jdbc:jtds:sqlserver://localhost:1433/TEST</property>
        
<property name="connection.username">USERNAME</property>
        
<property name="connection.password">PASSWORD</property>

        
<!-- JDBC connection pool (use the built-in) 
        <property name="connection.pool_size">1</property>
        
-->
        
        
<!-- SQL dialect -->
        
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>

        
<!-- Enable Hibernate's automatic session context management 
        <property name="current_session_context_class">thread</property>
        
-->
        
        
<!-- Disable the second-level cache  
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
        
-->

        
<!-- Echo all executed SQL to stdout -->
        
<property name="show_sql">true</property>
        
        
<!--  
        <property name="format_sql">true</property>
        
-->
        
        
<!-- Drop and re-create the database schema on startup 
        <property name="hbm2ddl.auto">update</property>
        
-->

        
<!--  
        <mapping resource="com/fancy/po/person.hbm.xml"/>
        
-->
        
    
</session-factory>

</hibernate-configuration>



  
posted on 2012-10-03 21:53 fancydeepin 阅读(9943) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: