You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/connect/jdbc/connecting-to-an-azure-sql-database.md
+18-6Lines changed: 18 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: "Connecting to an Azure SQL database"
3
3
description: "This article discusses issues when using the Microsoft JDBC Driver for SQL Server to connect to an Azure SQL Database."
4
4
ms.custom: ""
5
-
ms.date: "08/12/2019"
5
+
ms.date: "12/18/2020"
6
6
ms.prod: sql
7
7
ms.prod_service: connectivity
8
8
ms.reviewer: ""
@@ -27,7 +27,7 @@ This article discusses issues when using the [!INCLUDE[jdbcNoVersion](../../incl
27
27
## Details
28
28
29
29
When connecting to an [!INCLUDE[ssAzure](../../includes/ssazure_md.md)], you should connect to the master database to call **SQLServerDatabaseMetaData.getCatalogs**.
30
-
[!INCLUDE[ssAzure](../../includes/ssazure_md.md)] doesn't support returning the entire set of catalogs from a user database. **SQLServerDatabaseMetaData.getCatalogs** use the sys.databases view to get the catalogs. Please refer to the discussion of permissions in [sys.databases (Transact-SQL)](../../relational-databases/system-catalog-views/sys-databases-transact-sql.md) to understand **SQLServerDatabaseMetaData.getCatalogs** behavior on an [!INCLUDE[ssAzure](../../includes/ssazure_md.md)].
30
+
[!INCLUDE[ssAzure](../../includes/ssazure_md.md)] doesn't support returning the entire set of catalogs from a user database. **SQLServerDatabaseMetaData.getCatalogs** use the sys.databases view to get the catalogs. Refer to the discussion of permissions in [sys.databases (Transact-SQL)](../../relational-databases/system-catalog-views/sys-databases-transact-sql.md) to understand **SQLServerDatabaseMetaData.getCatalogs** behavior on an [!INCLUDE[ssAzure](../../includes/ssazure_md.md)].
31
31
32
32
## Connections dropped
33
33
@@ -37,7 +37,13 @@ When connecting to an [!INCLUDE[ssAzure](../../includes/ssazure_md.md)], idle co
37
37
38
38
- Idle by the Azure SQL Gateway, where TCP **keepalive** messages might be occurring (making the connection not idle from a TCP perspective), but not had an active query in 30 minutes. In this scenario, the Gateway will determine that the TDS connection is idle at 30 minutes and terminate the connection.
39
39
40
-
To avoid dropping idle connections by a network component, the following registry settings (or their non-Windows equivalents) should be set on the operating system where the driver is loaded:
40
+
To address the second point and avoid the Gateway terminating idle connections, you can:
41
+
42
+
* Use the **Redirect**[connection policy](/azure/azure-sql/database/connectivity-architecture#connection-policy) when configuring your Azure SQL data source.
43
+
44
+
* Keep connections active via lightweight activity. This method is not recommended and should only be used if there are no other possible options.
45
+
46
+
To address the first point and avoid dropping idle connections by a network component, the following registry settings (or their non-Windows equivalents) should be set on the operating system where the driver is loaded:
41
47
42
48
|Registry Setting|Recommended Value|
43
49
|----------------------|-----------------------|
@@ -47,7 +53,13 @@ To avoid dropping idle connections by a network component, the following registr
47
53
48
54
Restart the computer for the registry settings to take effect.
49
55
50
-
To accomplish this when running in Azure create a startup task to add the registry keys. For example, add the following Startup task to the service definition file:
56
+
The KeepAliveTime and KeepAliveInterval values are in milliseconds. These settings will have the effect of disconnecting an unresponsive connection within 10 to 40 seconds. After a keep alive packet is sent, if no response is received, it will be retried every second up to 10 times. If no response is received during that time, the client-side socket is disconnected. Depending on your environment, you may want to increase the KeepAliveInterval to accommodate known disruptions (like virtual machine migrations) that might cause a server to be unresponsive for longer than 10 seconds.
57
+
58
+
> [!NOTE]
59
+
> TcpMaxDataRetransmissions is not controllable on Windows Vista or Windows 2008 and higher.
60
+
61
+
To perform this configuration when running in Azure, create a startup task to add the registry keys. For example, add the following Startup task to the service definition file:
62
+
51
63
52
64
```xml
53
65
<Startup>
@@ -56,7 +68,7 @@ To accomplish this when running in Azure create a startup task to add the regist
56
68
</Startup>
57
69
```
58
70
59
-
Then add a AddKeepAlive.cmd file to your project. Set the "Copy to Output Directory" setting to Copy always. The following is a sample AddKeepAlive.cmd file:
71
+
Then add a AddKeepAlive.cmd file to your project. Set the "Copy to Output Directory" setting to Copy always. The following script is a sample AddKeepAlive.cmd file:
0 commit comments