租了一个百度云服务器,搭建好数据库环境后,成功在自己电脑上通过ssms远程连接上了云服务器上的数据库,但接着我在Androidstudio中用Java进行连接时却一直报错,下面是报错:
E/SqlConnect: 数据库连接失败
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host .....(此处省略为ip), port 1433 has failed. Error: "socket failed: EPERM (Operation not permitted). 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.".
at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2574)
at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:715)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:3427)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:3077)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2919)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1787)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1229)
at java.sql.DriverManager.getConnection(DriverManager.java:580)
at java.sql.DriverManager.getConnection(DriverManager.java:236)
at com.example.jianxing.SqlConnect$1.run(SqlConnect.java:44)
at java.lang.Thread.run(Thread.java:919)