`

开发中sql server一些问题的解决办法

 
阅读更多
Java开发中连接sql server中的问题

1. 在Java中使用jtds链接sqlserver
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
  <persistence-unit name="example" transaction-type="RESOURCE_LOCAL">
      <properties>
         <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
         <property name="hibernate.connection.driver_class" value="net.sourceforge.jtds.jdbc.Driver"/>
         <property name="hibernate.connection.username" value="sa"/>
         <property name="hibernate.connection.password" value="**"/>
         <property name="hibernate.connection.url" value="jdbc:jtds:sqlserver://localhost:1433/collectiondb;instance=CollectionDB "/>
         <property name="hibernate.max_fetch_depth" value="3"/>
         <property name="hibernate.hbm2ddl.auto" value="validate"/><!-- validate -->
      </properties>
    
      
      <!-- 
      <properties>
         <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
         <property name="hibernate.connection.driver_class" value="org.gjt.mm.mysql.Driver"/>
         <property name="hibernate.connection.username" value="root"/>
         <property name="hibernate.connection.password" value="admin"/>
         <property name="hibernate.connection.url" value="jdbc:mysql://szOIBnchmrkAP1:3306/test?useUnicode=true&amp;characterEncoding=UTF-8"/>
         <property name="hibernate.max_fetch_depth" value="3"/>
         <property name="hibernate.hbm2ddl.auto" value="validate"/>
      </properties>
       -->
      
  </persistence-unit>
</persistence>

jtds URL语法:
http://ldison.iteye.com/blog/1007579


2.启动TOMCAT时Hibernate报错:
[ERROR][org.hibernate.tool.hbm2ddl.SchemaValidator]HHH000319: Could not get database metadata
java.sql.SQLException: Network error IOException: Connection refused: connect
at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:436)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
[ERROR][org.hibernate.tool.hbm2ddl.SchemaValidator]HHH000300: Could not complete schema validation
解决方法:
http://blog.csdn.net/anialy/article/details/8575428


3.Tomcat在没有启动服务“sql server browser”时会报如下错误:
Unable to get information from SQL Server: localhost.


4. SQL Server 禁止修改表结构的解决办法
Management studio 中打开 Tools - Operations 在对话框中选择Designers,将其中的Prevent saving changes that require re-creation前的对勾去掉,然后就可以修改表结构并完成保存操作了。
http://www.cnblogs.com/jaxu/archive/2009/10/21/1587488.html
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics