SQL Server连接中出现错误

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL Server连接中出现错误相关的知识,希望对你有一定的参考价值。

每次电脑开机时,都会出现一个窗口,上面显示"Your SQL Server installation is either corrupt or had been tampered with (unknown package id) Please rerun setup".
网上答案是:
要解决此错误并再次启动 SQL Server,请执行以下任一操作:

从原始产品 CD 中运行 SQL Server 7.0 安装程序。这样做不会重新安装 SQL Server 或任何组件;但是,这会在内部更新 SQL Server 7.0,以反映新的 Windows 计算机名。还需要通过运行以下两个存储过程来更新 SQL Server 的内部服务器名:

sp_dropserver <old_name>
go
sp_addserver <newname>, local
go

如果将 SQL Server 配置为侦听多协议或 NWLink IPX/SPX 网络库,则需要将这些库删除,然后再使用 SQL Server 网络实用工具重新添加它们。
请将 Windows 计算机名重新更改为最初安装 SQL Server 7.0 时的原始名称。

可我不记得原来给计算机起的什么名字了,也看不懂第一个方法,请问具体该怎么做呢?哪位大侠帮帮忙。

你应该把原本的SQL Server卸载并重新启动电脑,再插入安装CD 重新安装SQL SEVER,运行 autorun.exe,然后选择第一个“安装SQL Server2000 简体中文个人版”,即可开始SQL2000个人版的安装,开始一路按默认情况设置点击“下一步”……直到“服务帐户”窗

这里我们需要选择“使用本地系统帐户”,然后选择下一步,到“身份验证模式”窗口,(不能显示图片)
“选定对每个服务使用同一账户”在服务设置点“本地系统账户”然后选择下一步,到“身份验证模式”窗口这里,我们需要选择“混和模式……”,下面可以选择“空密码”即可点击“下一步”。以后的其它各项都可以按默认情况设置点下一步……直到完成。
参考技术A 请确认您登陆的服务器是否存在
其次请确认您与服务器间的网络连接
并且请检查SQL的账户,密码以及权限设置
再者请您在使用账户密码登陆SQL服务器时,确认您SQL服务器的验证方式
还有最后一点,确认服务器是否在运行
参考技术B 你里面存了什么重要的东西没有,如果没有那就按第一个方法 把CD放进去重装一次就可以了 后面的转存可以不用做

SQL Server 数据库连接错误

【中文标题】SQL Server 数据库连接错误【英文标题】:SQL Server Database Connection Errors 【发布时间】:2014-01-11 17:14:10 【问题描述】:

本质上,我们正在尝试将数据库连接到使用 Java 定制的大厅/工人管理程序。这是一个多模块项目,我们的数据库团队决定使用 SQL Server 作为管理基础。

不幸的是,这被证明是有问题的,导致我们完全不确定如何修复大量错误。在通过 Stack 搜索后,出现了类似的问题,但要么没有解决,而是简单地自行“开始工作”,或者通过离开 SQL Server 来“修复”,这也是我们无法做到的。

事不宜迟,这就是问题本身。该程序正确地对所有数据进行操作,因为它是在“测试模式”中进行调试的,其中值被直接馈送到代码中,而无需使用外部数据库。真正的问题出现在试图将两者放在一起时。

首先,localhost 的连接端口被证明是有问题的。使用端口 1433 我们甚至无法建立连接,甚至解锁端口也没有改变。移动到 1434 后,我们设法建立了某种联系。

如果有必要,这里是关于端口 1433 的错误块:

The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:241)
at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2243)
at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:491)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1309)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.j256.ormlite.jdbc.JdbcConnectionSource.makeConnection(JdbcConnectionSource.java:252)
at com.j256.ormlite.jdbc.JdbcConnectionSource.getReadWriteConnection(JdbcConnectionSource.java:184)
at com.j256.ormlite.jdbc.JdbcConnectionSource.getReadOnlyConnection(JdbcConnectionSource.java:170)
at com.j256.ormlite.stmt.StatementExecutor.buildIterator(StatementExecutor.java:243)
at com.j256.ormlite.stmt.StatementExecutor.query(StatementExecutor.java:197)
at com.j256.ormlite.stmt.StatementExecutor.queryForAll(StatementExecutor.java:118)
at com.j256.ormlite.dao.BaseDaoImpl.queryForAll(BaseDaoImpl.java:239)
at controler.AdminRoomControler.getListRoomEquipmentData(AdminRoomControler.java:51)
at gui.panel.ReservationRoomPanel.reloadData(ReservationRoomPanel.java:57)
at gui.panel.ReservationRoomPanel.initialize(ReservationRoomPanel.java:82)
at gui.panel.ReservationRoomPanel.<init>(ReservationRoomPanel.java:40)
at gui.frame.ApplicationFrame.initialize(ApplicationFrame.java:58)
at gui.frame.ApplicationFrame.<init>(ApplicationFrame.java:37)
at main.Program$1.run(Program.java:22)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

将端口更改为 1434 后,我们遇到了另一个问题。出于某种原因,SQL Server 以我们完全不知道如何解决的 Prelogin Handshake 问题来响应我们的连接。错误如下:

sty 11, 2014 5:32:02 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: 0a8f83b1-ce25-48c1-8796-c2c5c7d080b7 Prelogin error: host localhost port 1434 Error reading prelogin response: Software caused connection abort: recv failed ClientConnectionId:0a8f83b1-ce25-48c1-8796-c2c5c7d080b7
sty 11, 2014 5:32:02 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: 982a07f7-0cbd-417f-8bcb-47eebe6b4524 Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:982a07f7-0cbd-417f-8bcb-47eebe6b4524
sty 11, 2014 5:32:02 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: 9c136851-d172-4b98-8722-16941642d14a Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:9c136851-d172-4b98-8722-16941642d14a
sty 11, 2014 5:32:03 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: bc3db9f2-6d56-43bd-9145-051dc418d8b9 Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:bc3db9f2-6d56-43bd-9145-051dc418d8b9
sty 11, 2014 5:32:04 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: 93c0fd9c-925d-40d9-af4e-35be3f3ec0d4 Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:93c0fd9c-925d-40d9-af4e-35be3f3ec0d4
sty 11, 2014 5:32:05 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: cb32d339-0c63-4549-8821-61b2818c9548 Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:cb32d339-0c63-4549-8821-61b2818c9548
sty 11, 2014 5:32:06 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: 5c63f908-8019-48ac-9b4e-0b9a4c29e6e6 Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:5c63f908-8019-48ac-9b4e-0b9a4c29e6e6
sty 11, 2014 5:32:07 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: ce8945a8-1fe7-40b8-a7c9-331f263be084 Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:ce8945a8-1fe7-40b8-a7c9-331f263be084
sty 11, 2014 5:32:08 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: a0ed799f-471e-4496-8fb5-6f2599faa45f Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:a0ed799f-471e-4496-8fb5-6f2599faa45f
sty 11, 2014 5:32:09 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: f35803a2-7e46-4163-a9db-08977c78fd63 Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:f35803a2-7e46-4163-a9db-08977c78fd63
sty 11, 2014 5:32:10 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: 182e2bf0-9ad6-40e6-b767-ab6bf7173929 Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:182e2bf0-9ad6-40e6-b767-ab6bf7173929
sty 11, 2014 5:32:11 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: 7d71a9ec-c22b-4247-8bd2-540e75470e80 Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:7d71a9ec-c22b-4247-8bd2-540e75470e80
sty 11, 2014 5:32:12 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: 9a739139-241f-47c4-bfe8-bb3a1cbe3c18 Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:9a739139-241f-47c4-bfe8-bb3a1cbe3c18
sty 11, 2014 5:32:13 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: d53915f6-5419-4bd0-883f-5c25a12d5678 Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:d53915f6-5419-4bd0-883f-5c25a12d5678
sty 11, 2014 5:32:14 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: 8eaec619-d01a-4138-bb06-44cdc8a08fe9 Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:8eaec619-d01a-4138-bb06-44cdc8a08fe9
sty 11, 2014 5:32:15 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: 4c176172-9ff5-479a-b39a-40e026da9e16 Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:4c176172-9ff5-479a-b39a-40e026da9e16
sty 11, 2014 5:32:16 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: 6b9ab775-5845-4b11-ad25-9cef7b56f041 Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:6b9ab775-5845-4b11-ad25-9cef7b56f041
sty 11, 2014 5:32:17 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: 04ef0517-4410-4d63-947c-d349ed4684ad Prelogin error: host localhost port 1434 Error reading prelogin response: Connection reset ClientConnectionId:04ef0517-4410-4d63-947c-d349ed4684ad
com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset ClientConnectionId:04ef0517-4410-4d63-947c-d349ed4684ad
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1654)
    at com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:1789)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.Prelogin(SQLServerConnection.java:1424)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1319)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at com.j256.ormlite.jdbc.JdbcConnectionSource.makeConnection(JdbcConnectionSource.java:252)
    at com.j256.ormlite.jdbc.JdbcConnectionSource.getReadWriteConnection(JdbcConnectionSource.java:184)
    at com.j256.ormlite.jdbc.JdbcConnectionSource.getReadOnlyConnection(JdbcConnectionSource.java:170)
    at com.j256.ormlite.stmt.StatementExecutor.buildIterator(StatementExecutor.java:243)
    at com.j256.ormlite.stmt.StatementExecutor.query(StatementExecutor.java:197)
    at com.j256.ormlite.stmt.StatementExecutor.queryForAll(StatementExecutor.java:118)
    at com.j256.ormlite.dao.BaseDaoImpl.queryForAll(BaseDaoImpl.java:239)
    at controler.AdminRoomControler.getListRoomEquipmentData(AdminRoomControler.java:51)
    at gui.panel.ReservationRoomPanel.reloadData(ReservationRoomPanel.java:57)
    at gui.panel.ReservationRoomPanel.initialize(ReservationRoomPanel.java:82)
    at gui.panel.ReservationRoomPanel.<init>(ReservationRoomPanel.java:40)
    at gui.frame.ApplicationFrame.initialize(ApplicationFrame.java:58)
    at gui.frame.ApplicationFrame.<init>(ApplicationFrame.java:37)
    at main.Program$1.run(Program.java:22)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

最后,我们遇到了排版问题,文件和数据库中的列名不匹配。不幸的是,更正这一点导致出现更多错误。雪上加霜,有时它甚至没有检测到不匹配错误,所以我们在这里完全不知所措。

这是我们用来连接数据库的代码:

package database;

import java.sql.SQLException;

import POJO.Administrator;
import POJO.Equipment;
import POJO.Event;
import POJO.Guest;
import POJO.Personnel;
import POJO.Room;

import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.dao.DaoManager;
import com.j256.ormlite.jdbc.JdbcConnectionSource;
import com.j256.ormlite.support.ConnectionSource;


public class DbManager  

    // Proper db address should be placed here.
    private final String DATABASE_URL = "jdbc:sqlserver://localhost:1434;databaseName=IO;integratedSecurity=true;";

    private ConnectionSource connectionSource;

    public Dao<Administrator,Integer> administratorDao;
    public Dao<Equipment,Integer> equipmentDao;
    public Dao<Event,Integer> eventDao;
    public Dao<Guest,Integer> guestDao;
    public Dao<Personnel,Integer> personnelDao;
    public Dao<Room,Integer> roomDao;

    public DbManager() throws SQLException
    
        connectionSource = new JdbcConnectionSource(DATABASE_URL);
        administratorDao = DaoManager.createDao(connectionSource, Administrator.class);
        equipmentDao = DaoManager.createDao(connectionSource, Equipment.class);
        eventDao = DaoManager.createDao(connectionSource, Event.class);
        guestDao = DaoManager.createDao(connectionSource, Guest.class);
        personnelDao = DaoManager.createDao(connectionSource, Personnel.class);
        roomDao = DaoManager.createDao(connectionSource, Room.class);
    

    @Override
    protected void finalize() throws Throwable
    
        connectionSource.close();       
        super.finalize();

    

我们完全没有想法,实际上,任何与将数据库从 SQL Server 完全重写为其他东西无关的事情都会有所帮助。提前谢谢!

【问题讨论】:

请告诉我们您尝试使用的实际 Microsoft SQL Server 版本(2012、2008、2005...)和版本(Express Edition、Standard Edition...)。跨度> 当然!我们正在使用带有 Service Pack 1 的 Microsoft SQL Server 2012 Developer。 要验证 SQL Server 正在侦听的端口,请参阅说明 here。该文档也可能会有所帮助:How to configure SQL Server to listen on a specific port. 【参考方案1】:

SQL Server Browser 使用端口 1434。确认在 SQL Server 上启用了 TCP/IP,然后再次尝试使用默认端口 (1433)。

见this post。

【讨论】:

这是 TCP/IP。非常感谢您,现在可以使用了!啊,最简单的事情总是逃避你。 不客气!四只眼睛总比两只眼睛好。

以上是关于SQL Server连接中出现错误的主要内容,如果未能解决你的问题,请参考以下文章

在 SQL Server 上使用不同的排序规则跨两个数据库进行连接并出现错误

sql server登录时出现错误233

我用SQL sever2008的时候出现连接服务器的错误,请大家帮助

网站部署到 IIS 并连接到 SQL Server 2012 时出现问题,出现找不到网络错误

Unity3d连接SQL Server数据库出现SocketException: 使用了与请求的协议不兼容的地址错误

连接sql server2005时提示:内部连接致命错误。