Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit 28f40fc

Browse files
Merge pull request #24237 from David-Engel/encrypt2
Make Encrypt option explicit in connection string samples
2 parents f2667aa + 8a2d48c commit 28f40fc

10 files changed

Lines changed: 21 additions & 21 deletions

docs/connect/jdbc/building-the-connection-url.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,44 +42,44 @@ For a detailed list of properties that can be set in the connection string, see
4242

4343
Connect to the default database on the local computer by using a user name and password:
4444

45-
`jdbc:sqlserver://localhost;user=MyUserName;password=*****;`
45+
`jdbc:sqlserver://localhost;encrypt=true;user=MyUserName;password=*****;`
4646

4747
> [!NOTE]
4848
> Although the previous example uses a username and password in the connection string, you should use integrated security as it is more secure. For more information, see the [Connecting with Integrated Authentication](#Connectingintegrated) section later in this topic.
4949
5050
The following connection string shows an example of how to connect to a [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] database using integrated authentication and Kerberos from an application running on any operating system supported by the [!INCLUDE[jdbcNoVersion](../../includes/jdbcnoversion_md.md)]:
5151

5252
```java
53-
jdbc:sqlserver://;servername=server_name;integratedSecurity=true;authenticationScheme=JavaKerberos
53+
jdbc:sqlserver://;servername=server_name;encrypt=true;integratedSecurity=true;authenticationScheme=JavaKerberos
5454
```
5555

5656
Connect to the default database on the local computer by using integrated authentication:
5757

58-
`jdbc:sqlserver://localhost;integratedSecurity=true;`
58+
`jdbc:sqlserver://localhost;encrypt=true;integratedSecurity=true;`
5959

6060
Connect to a named database on a remote server:
6161

62-
`jdbc:sqlserver://localhost;databaseName=AdventureWorks;integratedSecurity=true;`
62+
`jdbc:sqlserver://localhost;encrypt=true;databaseName=AdventureWorks;integratedSecurity=true;`
6363

6464
Connect on the default port to the remote server:
6565

66-
`jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks;integratedSecurity=true;`
66+
`jdbc:sqlserver://localhost:1433;encrypt=true;databaseName=AdventureWorks;integratedSecurity=true;`
6767

6868
Connect by specifying a customized application name:
6969

70-
`jdbc:sqlserver://localhost;databaseName=AdventureWorks;integratedSecurity=true;applicationName=MyApp;`
70+
`jdbc:sqlserver://localhost;encrypt=true;databaseName=AdventureWorks;integratedSecurity=true;applicationName=MyApp;`
7171

7272
## Named and multiple SQL Server instances
7373

7474
[!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] allows for the installation of multiple database instances per server. Each instance is identified by a specific name. To connect to a named instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)], you can either specify the port number of the named instance (preferred), or you can specify the instance name as a JDBC URL property or a **datasource** property. If no instance name or port number property is specified, a connection to the default instance is created. See the following examples:
7575

7676
To specify a port number, use the following format:
7777

78-
`jdbc:sqlserver://localhost:1433;integratedSecurity=true;<more properties as required>;`
78+
`jdbc:sqlserver://localhost:1433;encrypt=true;integratedSecurity=true;<more properties as required>;`
7979

8080
To use a JDBC URL property, use the following format:
8181

82-
`jdbc:sqlserver://localhost;instanceName=instance1;integratedSecurity=true;<more properties as required>;`
82+
`jdbc:sqlserver://localhost;encrypt=true;instanceName=instance1;integratedSecurity=true;<more properties as required>;`
8383

8484
## Escaping values in the connection URL
8585

@@ -89,7 +89,7 @@ Before version 8.4, escaped values can contain special characters (especially '=
8989

9090
In version 8.4 and above, escaped values can contain special characters, including braces. However, closing braces must be escaped. For example, with a password of `pass";{}word`, a connection string would need to escape the password as follows:
9191

92-
`jdbc:sqlserver://localhost;username=MyUsername;password={pass";{}}word};`
92+
`jdbc:sqlserver://localhost;encrypt=true;username=MyUsername;password={pass";{}}word};`
9393

9494
> [!NOTE]
9595
> White space inside the braces is literal and not trimmed.
@@ -117,15 +117,15 @@ The JDBC driver supports the use of IPv6 addresses with the connection propertie
117117

118118
**To use the serverName property:**
119119

120-
`jdbc:sqlserver://;serverName=3ffe:8311:eeee:f70f:0:5eae:10.203.31.9\\instance1;integratedSecurity=true;`
120+
`jdbc:sqlserver://;serverName=3ffe:8311:eeee:f70f:0:5eae:10.203.31.9\\instance1;encrypt=true;integratedSecurity=true;`
121121

122122
**To use the properties collection:**
123123

124124
`Properties pro = new Properties();`
125125

126126
`pro.setProperty("serverName", "serverName=3ffe:8311:eeee:f70f:0:5eae:10.203.31.9\\instance1");`
127127

128-
`Connection con = DriverManager.getConnection("jdbc:sqlserver://;integratedSecurity=true;", pro);`
128+
`Connection con = DriverManager.getConnection("jdbc:sqlserver://;encrypt=true;integratedSecurity=true;", pro);`
129129

130130
## See also
131131

docs/connect/jdbc/caching-result-set-data-sample.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class CacheResultSet {
6060
public static void main(String[] args) {
6161

6262
// Create a variable for the connection string.
63-
String connectionUrl = "jdbc:sqlserver://<server>:<port>;databaseName=AdventureWorks;user=<user>;password=<password>";
63+
String connectionUrl = "jdbc:sqlserver://<server>:<port>;encrypt=true;databaseName=AdventureWorks;user=<user>;password=<password>";
6464

6565
try (Connection con = DriverManager.getConnection(connectionUrl);
6666
Statement stmt = con.createStatement(SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY, SQLServerResultSet.CONCUR_READ_ONLY);) {

docs/connect/jdbc/connection-url-sample.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class ConnectURL {
4747
public static void main(String[] args) {
4848

4949
// Create a variable for the connection string.
50-
String connectionUrl = "jdbc:sqlserver://<server>:<port>;databaseName=AdventureWorks;user=<user>;password=<password>";
50+
String connectionUrl = "jdbc:sqlserver://<server>:<port>;encrypt=true;databaseName=AdventureWorks;user=<user>;password=<password>";
5151

5252
try (Connection con = DriverManager.getConnection(connectionUrl); Statement stmt = con.createStatement();) {
5353
String SQL = "SELECT TOP 10 * FROM Person.Contact";

docs/connect/jdbc/data-discovery-classification-sample.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class DataDiscoveryAndClassification {
4545
String tableName = "JDBC_SQL_DATA_DISCOVERY_CLASSIFICATION";
4646

4747
// Create a variable for the connection string.
48-
String connectionUrl = "jdbc:sqlserver://<server>:<port>;databaseName=<database>;username=<user>;password=<password>;";
48+
String connectionUrl = "jdbc:sqlserver://<server>:<port>;encrypt=true;databaseName=<database>;username=<user>;password=<password>;";
4949

5050
// Establish the connection.
5151
try (Connection con = DriverManager.getConnection(connectionUrl); Statement stmt = con.createStatement()) {

docs/connect/jdbc/modifying-result-set-data-sample.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class UpdateResultSet {
5050
public static void main(String[] args) {
5151

5252
// Create a variable for the connection string.
53-
String connectionUrl = "jdbc:sqlserver://<server>:<port>;databaseName=AdventureWorks;user=<user>;password=<password>";
53+
String connectionUrl = "jdbc:sqlserver://<server>:<port>;encrypt=true;databaseName=AdventureWorks;user=<user>;password=<password>";
5454

5555
try (Connection con = DriverManager.getConnection(connectionUrl);
5656
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);) {

docs/connect/jdbc/reference/getcolumns-method-sqlserverdatabasemetadata.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public java.sql.ResultSet getColumns(java.lang.String catalog,
166166
import java.sql.*;
167167
public class c1 {
168168
public static void main(String[] args) {
169-
String connectionUrl = "jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks;integratedsecurity=true";
169+
String connectionUrl = "jdbc:sqlserver://localhost:1433;encrypt=true;databaseName=AdventureWorks;integratedsecurity=true";
170170
171171
Connection con = null;
172172
Statement stmt = null;

docs/connect/jdbc/release-notes-for-the-jdbc-driver.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ Microsoft JDBC Driver 6.0 for SQL Server is fully compliant with JDBC specificat
780780
To ensure that you have the right sqljdbc42.jar or sqljdbc41.jar file, run the following lines of code. If the output is "Driver version: 6.0.7507.100", you have the JDBC Driver 6.0 package.
781781

782782
```java
783-
Connection conn = DriverManager.getConnection("jdbc:sqlserver://<server>;user=<user>;password=<password>;");
783+
Connection conn = DriverManager.getConnection("jdbc:sqlserver://<server>;encrypt=true;user=<user>;password=<password>;");
784784
System.out.println("Driver version: " + conn.getMetaData().getDriverVersion());
785785
```
786786

@@ -827,7 +827,7 @@ Microsoft JDBC Driver 4.2 for SQL Server is fully compliant with JDBC specificat
827827
To ensure you have the right sqljdbc42.jar or sqljdbc41.jar file, run the following lines of code. If the output is "Driver version: 4.2.6420.100", you have the JDBC Driver 4.2 package.
828828

829829
```java
830-
Connection conn = DriverManager.getConnection("jdbc:sqlserver://<server>;user=<user>;password=<password>;");
830+
Connection conn = DriverManager.getConnection("jdbc:sqlserver://<server>;encrypt=true;user=<user>;password=<password>;");
831831
System.out.println("Driver version: " + conn.getMetaData().getDriverVersion());
832832
```
833833

docs/connect/jdbc/retrieving-result-set-data-sample.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class RetrieveResultSet {
4646
public static void main(String[] args) {
4747

4848
// Create a variable for the connection string.
49-
String connectionUrl = "jdbc:sqlserver://<server>:<port>;databaseName=AdventureWorks;user=<user>;password=<password>";
49+
String connectionUrl = "jdbc:sqlserver://<server>:<port>;encrypt=true;databaseName=AdventureWorks;user=<user>;password=<password>";
5050

5151
try (Connection con = DriverManager.getConnection(connectionUrl); Statement stmt = con.createStatement();) {
5252
createTable(stmt);

docs/connect/jdbc/sparse-columns.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class SparseColumns {
5858
public static void main(String args[]) {
5959

6060
// Create a variable for the connection string.
61-
String connectionUrl = "jdbc:sqlserver://<server>:<port>;databaseName=AdventureWorks;user=<user>;password=<password>";
61+
String connectionUrl = "jdbc:sqlserver://<server>:<port>;encrypt=true;databaseName=AdventureWorks;user=<user>;password=<password>";
6262

6363
try (Connection con = DriverManager.getConnection(connectionUrl); Statement stmt = con.createStatement()) {
6464

docs/connect/jdbc/spatial-data-types-sample.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class SpatialDataTypes {
5252
public static void main(String[] args) {
5353

5454
// Create a variable for the connection string.
55-
String connectionUrl = "jdbc:sqlserver://<server>:<port>;databaseName=<database>;user=<user>;password=<password>";
55+
String connectionUrl = "jdbc:sqlserver://<server>:<port>;encrypt=true;databaseName=<database>;user=<user>;password=<password>";
5656
// Establish the connection.
5757
try (Connection con = DriverManager.getConnection(connectionUrl); Statement stmt = con.createStatement();) {
5858
dropAndCreateTable(stmt);

0 commit comments

Comments
 (0)