Azure Synapse 中 SQL 池的连接字符串Connection strings for SQL pools in Azure Synapse

可以使用几种不同的应用程序协议(例如,ADO.NETODBCPHPJDBC)连接到 Azure Synapse 中的 SQL 池。You can connect to a SQL pool in Azure Synapse with several different application protocols such as, ADO.NET, ODBC, PHP, and JDBC. 下面是每个协议的连接字符串的一些示例。Below are some examples of connections strings for each protocol. 可以使用 Azure 门户来生成连接字符串。You can also use the Azure portal to build your connection string.

若要使用 Azure 门户生成连接字符串,请导航到“SQL 池”边栏选项卡,在“概要”下单击“显示数据库连接字符串” 。To build your connection string using the Azure portal, navigate to your SQL pool blade, under Essentials click on Show database connection strings.

示例 ADO.NET 连接字符串Sample ADO.NET connection string

Server=tcp:{your_server},1433;Database={your_database};User ID={your_user_name};Password={your_password_here};Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;

示例 ODBC 连接字符串Sample ODBC connection string

Driver={SQL Server Native Client 11.0};Server=tcp:{your_server},1433;Database={your_database};Uid={your_user_name};Pwd={your_password_here};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;

示例 PHP 连接字符串Sample PHP connection string

Server: {your_server},1433 \r\nSQL Database: {your_database}\r\nUser Name: {your_user_name}\r\n\r\nPHP Data Objects(PDO) Sample Code:\r\n\r\ntry {\r\n   $conn = new PDO ( \"sqlsrv:server = tcp:{your_server},1433; Database = {your_database}\", \"{your_user_name}\", \"{your_password_here}\");\r\n    $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );\r\n}\r\ncatch ( PDOException $e ) {\r\n   print( \"Error connecting to SQL Server.\" );\r\n   die(print_r($e));\r\n}\r\n\rSQL Server Extension Sample Code:\r\n\r\n$connectionInfo = array(\"UID\" => \"{your_user_name}\", \"pwd\" => \"{your_password_here}\", \"Database\" => \"{your_database}\", \"LoginTimeout\" => 30, \"Encrypt\" => 1, \"TrustServerCertificate\" => 0);\r\n$serverName = \"tcp:{your_server},1433\";\r\n$conn = sqlsrv_connect($serverName, $connectionInfo);

示例 JDBC 连接字符串Sample JDBC connection string



请考虑将连接超时值设置为 300 秒,以便连接可以经受住短时间内不可用。Consider setting the connection timeout to 300 seconds in order to allow the connection to survive short periods of unavailability.

后续步骤Next steps

若要开始使用 Visual Studio 和其他应用程序来查询 SQL 池,请参阅使用 Visual Studio 进行查询To start querying your SQL pool with Visual Studio and other applications, see Query with Visual Studio.