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: README.md
+75-78
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
-
# Salesforce DataCloud JDBC Driver
1
+
# Salesforce Data Cloud JDBC Driver
2
2
3
-
With the Salesforce Data Cloud JDBC driver you can efficiently query millions of rows of data with low latency, and perform bulk data extractions.
4
-
This driver is read-only, forward-only, and requires Java 8 or greater. It uses the new [Data Cloud Query API SQL syntax](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/data-cloud-sql-context.html).
3
+
This driver allows you to efficiently query large datasets in Salesforce Data Cloud with low latency and perform bulk data extractions. It's read-only, forward-only, and requires Java 8 or later. The driver uses the Data Cloud Query API SQL syntax (see [Data Cloud Query API SQL syntax](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/data-cloud-sql-context.html) for details).
5
4
5
+
## Getting Started
6
6
7
-
##Getting started
7
+
### Maven Dependency
8
8
9
-
To add the driver to your project, add the following Maven dependency:
9
+
To use the driver in your Maven project, add the following to your `pom.xml`:
10
10
11
11
```xml
12
12
<dependency>
@@ -16,52 +16,53 @@ To add the driver to your project, add the following Maven dependency:
16
16
</dependency>
17
17
```
18
18
19
-
The class name for this driver is:
19
+
Replace `${jdbc.version}` with the actual version of the driver. It's good practice to manage this version in a properties section of your pom.xml.
20
20
21
-
```
22
-
com.salesforce.datacloud.jdbc.DataCloudJDBCDriver
23
-
```
21
+
### Driver Class
24
22
25
-
## Building the driver:
23
+
The driver class name is: `com.salesforce.datacloud.jdbc.DataCloudJDBCDriver`
26
24
27
-
Use the following command to build and test the driver:
We support three of the [OAuth authorization flows][oauth authorization flows] provided by Salesforce.
46
-
All of these flows require a connected app be configured for the driver to authenticate as, see the documentation here: [connected app overview][connected app overview].
47
-
Set the following properties appropriately to establish a connection with your chosen OAuth authorization flow:
| clientId | The consumer key of the connected app. |
54
-
| clientSecret | The consumer secret of the connected app. |
55
-
| privateKey | The private key of the connected app. |
56
-
| coreToken | OAuth token that a connected app uses to request access to a protected resource on behalf of the client application. |
57
-
| refreshToken | Token obtained from the web server, user-agent, or hybrid app token flow. |
49
+
The driver supports several OAuth authorization flows provided by Salesforce (see [OAuth authorization flows](https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_flows.htm&type=5)). You'll need to configure a connected app (see [Connected App Overview](https://help.salesforce.com/s/articleView?id=sf.connected_app_overview.htm&type=5)).
58
50
51
+
The following table outlines the properties for each flow:
The documentation for username and password authentication can be found [here][username flow].
63
+
#### Username/Password Authentication
63
64
64
-
To configure username and password, set properties like so:
65
+
See [Username/Password Flow](https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_username_password_flow.htm&type=5) for more information. Example:
The documentation for jwt authentication can be found [here][jwt flow].
75
+
#### JWT Authentication
77
76
78
-
Instructions to generate a private key can be found [here](#generating-a-private-key-for-jwt-authentication)
77
+
See [JWT Flow](https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_jwt_flow.htm&type=5). For generating a private key, see [Generating a Private Key](#generating-a-private-key-for-jwt-authentication). Example:
See this page on available [connection settings][connection settings].
102
-
These settings can be configured in properties by using the prefix `querySetting.`
103
-
104
-
For example, to control locale set the following property:
100
+
Additional connection settings are available (see [Connection Settings](https://tableau.github.io/hyper-db/docs/hyper-api/connection#connection-settings)). Prefix properties with `querySetting.`. For example, to set the locale:
105
101
106
102
```java
107
103
properties.put("querySetting.lc_time", "en_US");
108
104
```
109
105
110
-
---
111
-
112
-
### Generating a private key for jwt authentication
106
+
## Generating a Private Key for JWT Authentication <aname="generating-a-private-key-for-jwt-authentication"></a>
113
107
114
-
To authenticate using key-pair authentication you'll need to generate a certificate and register it with your connected app.
108
+
For JWT authentication, you need a certificate registered with your connected app.
115
109
116
-
```shell
117
-
#create a key pair:
110
+
```bash
111
+
#Create a key pair:
118
112
openssl genrsa -out keypair.key 2048
119
-
# create a digital certificate, follow the prompts:
-`dataspace`: The data space to query, defaults to "default"
128
-
-`User-Agent`: The User-Agent string identifies the JDBC driver and, optionally, the client application making the database connection. <br />
129
-
By default, the User-Agent string will end with "salesforce-datacloud-jdbc/{version}" and we will prepend any User-Agent provided by the client application. <br />
130
-
For example: "User-Agent: ClientApp/1.2.3 salesforce-datacloud-jdbc/1.0"
123
+
-`dataspace`: The data space to query (defaults to "default").
124
+
-`User-Agent`: Identifies the JDBC driver and client application. Defaults to `salesforce-datacloud-jdbc/{version}`. You can prepend your application's User-Agent string. Example: `User-Agent: ClientApp/1.2.3 salesforce-datacloud-jdbc/1.0`
System.out.println(resultSet.getString(1)); // Assuming a string in the first column
150
+
}
151
151
}
152
152
}
153
153
}
154
154
```
155
155
156
-
## Generated assertions
157
-
158
-
Some of our classes are tested using assertions generated with [the assertj assertions generator][assertion generator].
159
-
Due to some transient test-compile issues we experienced, we checked in generated assertions for some of our classes.
160
-
If you make changes to any of these classes, you will need to re-run the assertion generator to have the appropriate assertions available for that class.
156
+
Remember to replace placeholders like `${userName}` and `${query}` with your actual values. Consider using parameterized queries to prevent SQL injection vulnerabilities.
161
157
162
-
To find examples of these generated assertions, look for files with the path `**/test/**/*Assert.java`.
158
+
## Generated Assertions
163
159
164
-
To re-generate these assertions execute the following command:
160
+
Some classes use generated assertions (from [AssertJ Assertions Generator](https://joel-costigliola.github.io/assertj/assertj-assertions-generator-maven-plugin.html#configuration)). If you modify these classes, regenerate the assertions:
0 commit comments