开发中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&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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值