[英]Can't connect to SQL Server using JDBC
I'm having issues connecting to a Database server with the JDBC driver in Netbeans. 我在使用Netbeans中的JDBC驱动程序连接数据库服务器时遇到问题。 I've tried everything, enabling TCP/IP, opening the ports, I've followed tutorials online.
我已经尝试了所有方法,启用TCP / IP,打开端口,并在网上关注了教程。 It just won't work.
只是行不通。
This is the error message I get in the console: 这是我在控制台中收到的错误消息:
Information: Error: The TCP / IP connection could not be made to the MANUEL-PC host, port 1433. Error: "Connection refused: connect Verify the connection properties, check that there is an instance of SQL Server running on the host and accepting TCP / IP connections on the port and verify that there is no firewall blocking TCP connections on the port. "
Start of the class we're using... 我们正在使用的课程开始...
public class DBPosteo
{
private final String URL ="jdbc:sqlserver://MANUEL-PC\\SQLEXPRESS:1433;databaseName=DLC_MotorDeBusqueda;integratedSecurity=true";
private Connection con;
String query = "";
PreparedStatement pstmt;
ResultSet rs;
public void init()
throws ClassNotFoundException, SQLException
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(URL);
}
DB Server name in SQL Management Studio SQL Management Studio中的数据库服务器名称
Thanks in advance for the help... I've never struggled so much with Databases in my life :) 在此先感谢您的帮助...我一生中从没有像数据库那样苦苦挣扎:)
Remove the port number . 删除端口号 。
Only specify either instance name ( SQLEXPRESS
) or port number ( 1433
), never both. 仅指定实例名称(
SQLEXPRESS
) 或端口号( 1433
),不要同时指定两者。
Since port 1433
is reserved for the unnamed instance, the SQLEXPRESS
named instance would be on a different port, and unless you specifically configured it (unlikely), that port is dynamic and can change on reboots, so you need the named lookup. 由于端口
1433
是为未命名实例保留的,因此SQLEXPRESS
命名实例将位于其他端口上,除非您进行了特殊配置(不太可能),否则该端口是动态的,并且可以在重新启动时更改,因此您需要命名查找。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.