无法在Mac中打开Azure SQL数据库的端口1433

丹尼尔·约翰·戈麦斯

我正在尝试在Java应用程序上访问Azure托管的SQL数据库。我使用nmap检查了端口1433,它显示它已关闭:

Starting Nmap 7.12 ( https://nmap.org ) at 2016-09-02 09:44 PHT
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00014s latency).
Other addresses for localhost (not scanned): ::1
PORT     STATE  SERVICE
1433/tcp closed ms-sql-s

我已经编辑了/etc/pf.conf并重新启动了Mac,但是该端口仍然关闭。这是我的pf.conf:

scrub-anchor "com.apple/*"
nat-anchor "com.apple/*"
rdr-anchor "com.apple/*"
dummynet-anchor "com.apple/*"
anchor "com.apple/*"
load anchor "com.apple" from "/etc/pf.anchors/com.apple"
pass in proto tcp from any to any port 1433

另外,我的防火墙设置为关闭。

我的Java应用抛出此错误:

Error starting database: The TCP/IP connection to the host flowengine7.database.windows.net, port 1433 has failed. Error: "Connection timed out: no further information. 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.".

Java代码:

 String connectionString =
                "jdbc:sqlserver://dbName.database.windows.net:1433;database=dbName;user=user@@user;password=passwordhere;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;";

        Connection connection = null;

        try {
            connection = DriverManager.getConnection(connectionString);
            println 'connected';
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            if (connection != null) try {
                connection.close();
            } catch (Exception e) {
            }
        }
邪恶的

您正在忽略Azure SQL服务器级防火墙https :
//azure.microsoft.com/zh-cn/documentation/articles/sql-database-configure-firewall-settings/

防火墙入口

您需要在其中列出Mac的公共IP地址,以便能够从本地连接。默认情况下,只有Azure服务可以在您的Azure SQL实例上达到1433 / TCP(由Azure SQL防火墙中的“允许访问Azure服务”设置允许)。

如果每次重新启动DSL / Cable / Fiber调制解调器时都获得一个新的公共IP地址,则需要定义整个地址范围,而不仅仅是一个地址范围(即174.73.0.0-174.73.255.255与列表174.73相对)。 16.180)。希望您将始终获得相同范围内的IP地址。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章