[英]Using JDBC to connect to SQL database that has a firewall
我目前正在做一些测试,我想自动化数据库的一些查询。 目前,我要连接的服务器上有防火墙将其阻止,因此我对如何设置JDBC和MYSQL Workbench感到有些困惑。 我想知道有人可以给我一些有关成功连接到远程数据库的建议。
JDBC与防火墙或其他与网络相关的结构无关。 为了正确连接到数据库服务器,当前尝试连接的计算机应具有对数据库服务器的访问权限和足够的特权。 与系统管理员或其他负责解决此网络问题的人员联系。
首先,您是否尝试连接到SQL数据库? 如果是这样,您会收到类似的错误消息吗
SQLServerException: The TCP/IP connection to the host localhost, port (number) 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.
您控制服务器,还是与控制服务器的人联系? 我遇到了与您相同的问题,并通过转到服务器防火墙设置并允许<port-number>
通过防火墙来解决此问题,然后将JDBC连接字符串设置为
Server=myServerAddress;Port=<port-number>;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
我使用的是SQL Server,而不是MySQL,但我认为这是端口问题,而不是数据库管理系统。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.