您的位置:首页 > 博客中心 > 数据库 >

com.microsoft.sqlserver.jdbc.SQLServerException: 用户 'sa' 登录失败。

时间:2022-03-14 07:46

com.microsoft.sqlserver.jdbc.SQLServerException: 用户 ‘sa‘ 登录失败。
 at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:196)
 at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:246)
 at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:83)
 at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2532)
 at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:1929)
 at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)
 at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:1917)
 at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4026)
 at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1416)
 at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1061)
 at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:833)
 at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:716)
 at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841)
 at java.sql.DriverManager.getConnection(DriverManager.java:582)
 at java.sql.DriverManager.getConnection(DriverManager.java:185)
 at com.lzw.dao.Dao.<clinit>(Dao.java:40)
 at com.lzw.login.Login$2.actionPerformed(Login.java:54)
 at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
 at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
 at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
 at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
 at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
 at java.awt.Component.processMouseEvent(Component.java:6216)
 at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
 at java.awt.Component.processEvent(Component.java:5981)
 at java.awt.Container.processEvent(Container.java:2041)
 at java.awt.Component.dispatchEventImpl(Component.java:4583)
 at java.awt.Container.dispatchEventImpl(Container.java:2099)
 at java.awt.Component.dispatchEvent(Component.java:4413)
 at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4556)
 at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4220)
 at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4150)
 at java.awt.Container.dispatchEventImpl(Container.java:2085)
 at java.awt.Window.dispatchEventImpl(Window.java:2475)
 at java.awt.Component.dispatchEvent(Component.java:4413)
 at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
 at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
 at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
 at com.lzw.dao.Dao.getUser(Dao.java:119)
 at com.lzw.login.Login$2.actionPerformed(Login.java:54)
 at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
 at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
 at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
 at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
 at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
 at java.awt.Component.processMouseEvent(Component.java:6216)
 at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
 at java.awt.Component.processEvent(Component.java:5981)
 at java.awt.Container.processEvent(Container.java:2041)
 at java.awt.Component.dispatchEventImpl(Component.java:4583)
 at java.awt.Container.dispatchEventImpl(Container.java:2099)
 at java.awt.Component.dispatchEvent(Component.java:4413)
 at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4556)
 at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4220)
 at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4150)
 at java.awt.Container.dispatchEventImpl(Container.java:2085)
 at java.awt.Window.dispatchEventImpl(Window.java:2475)
 at java.awt.Component.dispatchEvent(Component.java:4413)
 at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
 at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
 at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

突然心血来潮,想做个小程序来用下,但是却被这个报错拦了下来。自己也做了以下检查:

1、确认链接字符没错;

2、sa用户在资源管理器可登录;

3、已经设置 SQL server 及windows 身份验证模式;

4、外围配置已配置好。

但还是解决“sa”登录不了的问题。后面百度了下,看到有讨论端口的问题,突然想到,有可能1433端口被其他程序占用了。马上改成1435(如下图),果然解决了这个问题。现在分享下,希望对大家有帮助!

技术分享

本类排行

今日推荐

热门手游