无法从azure app连接ms sql server

时间:2018-04-04 10:46:20

标签: azure azure-sql-database

我有Azure应用程序和SQL Database.SQL URL,如jdbc:sqlserver://xxxxx.database.windows.net:1433;databaseName=xxxxx,尝试连接我的本地tomcat,它已成功连接。但是当尝试从Azure应用程序连接时,我得到异常

 [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (JCA PoolFiller) IJ000610: Unable to fill pool: java:jboss/DB/DS: javax.resource.ResourceException: IJ031084: Unable to create connection
    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:345)
    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:352)
    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:287)
    at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.createConnectionEventListener(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1320)
    at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.fillTo(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1136)
    at org.jboss.jca.core.connectionmanager.pool.mcp.PoolFiller.run(PoolFiller.java:97)
    at java.lang.Thread.run(Thread.java:748)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot open server "App-server" requested by the login.  The login failed.

2 个答案:

答案 0 :(得分:1)

  

但我无法从sql数据库

中使用azure app server(VM)

您的意思是您在Azure VM上托管应用程序吗?

如果我理解正确,您应该将Azure VM的公共IP地址添加到sql server防火墙。

通过Azure门户添加VM的IP地址:

enter image description here

此外,您应该将端口 1433 添加到VM的 NSG入站规则操作系统防火墙设置

答案 1 :(得分:-1)

请确保您已设置On"允许访问Azure服务"在Azure门户上为Azure SQL数据库或其逻辑服务器设置。请参见下图。

您还需要在连接字符串上指定user @ database。有关如何构建连接字符串的更多详细信息,请阅读here

enter image description here