源代码是: import java.sql.*; public class ConnectionDemo { static String driver = com.microsoft.sqlserver.jdbc.SQLServerDriver; private static final String url = jdbc:sqlserver://localhost:1433;DatabaseName=MyDB; public static void main(S
源代码是:
import java.sql.*;
public class ConnectionDemo {
static String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
private static final String url = "jdbc:sqlserver://localhost:1433;DatabaseName=MyDB";
public static void main(String[] args) {
Connection con = null;
try {
Class.forName(driver); // 加载驱动
con = DriverManager.getConnection(url, "sa", "sa");
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(con);
try {
con.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
运行之后报错:
模板采用响应式设计,自动适应手机,电脑及平板显示;满足单一店铺外卖需求。功能:1.菜单分类管理2.菜品管理:菜品增加,删除,修改3.订单管理4.友情链接管理5.数据库备份6.文章模块:如:促销活动,帮助中心7.单页模块:如:企业信息,关于我们更强大的功能在开发中……安装方法:上传到网站根目录,运行http://www.***.com/install 自动
0
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: Connection refused: connect. Please verify the connection properties and check that a SQL Server instance is running on the host and
accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:130)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1195)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(SQLServerConnection.java:1054)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:758)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at ch6.practise.ConnectionDemo.main(ConnectionDemo.java:14)
java.lang.NullPointerException
at ch6.practise.ConnectionDemo.main(ConnectionDemo.java:22)
null
请各位高手帮忙看一下是咋回事呢,连了一晚上加一早上了,还是连不上,唉……
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号