qq_35142030 2016-11-12 01:08 采纳率: 66.7%
浏览 1508
已采纳

想用java连一下sql server数据库出现SQLException,求助

import java.sql.*;

public class SMS {
public static void main(String args[]){
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection ct=null;
ct=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=StudentManager", "ss","123");
System.out.println("connected");
} catch (ClassNotFoundException e) {
e.printStackTrace();
System.out.println("unconnected1");
} catch (SQLException e) {
e.printStackTrace();
System.out.println("unconnected2");
}

}

}

com.microsoft.sqlserver.jdbc.SQLServerException: 用户 'ss' 登录失败。
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at SMS.main(SMS.java:9)
unconnected2

  • 写回答

7条回答 默认 最新

  • Royal_lr 2016-11-12 04:26
    关注

    估计是远程连接没有打开吧

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(6条)

报告相同问题?

悬赏问题

  • ¥15 stm32c8t6工程,使用hal库
  • ¥100 有偿求易语言word文档取doc和docx页数方法或模块
  • ¥15 找能接spark如图片的,可议价
  • ¥15 关于#单片机#的问题,请各位专家解答!
  • ¥15 博通raid 的写入速度很高也很低
  • ¥15 目标计数模型训练过程中的问题
  • ¥100 Acess连接SQL 数据库后 不能用中文筛选
  • ¥15 用友U9Cloud的webapi
  • ¥20 电脑拓展屏桌面被莫名遮挡
  • ¥20 ensp,用局域网解决