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/en/developer/00-drivers/03-jdbc.md
+31-2Lines changed: 31 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ To download the Databend JDBC driver:
17
17
To verify the version of Databend JDBC driver, for example, _databend-jdbc-0.1.1.jar_, run the following command in the terminal:
18
18
19
19
```bash
20
-
java -jar databend-jdbc-0.2.1.jar --version
20
+
java -jar databend-jdbc-0.3.7.jar --version
21
21
```
22
22
23
23
The Databend JDBC driver is provided as a JAR file and can be integrated directly into your Java-based projects. Alternatively, you can declare a Maven dependency in your project's pom.xml file, like so:
@@ -26,7 +26,7 @@ The Databend JDBC driver is provided as a JAR file and can be integrated directl
You can update multiple rows in a single batch binding parameters in an REPLACE INTO statement and calling addBatch() and executeBatch().
188
+
189
+
As an example, the following code update the rows which have conflict values in field `a`. The example binds values to the parameters in the REPLACE INTO statement and calls addBatch() and executeBatch() to perform a batch update according to the key field.
190
+
```java
191
+
Connection c =Utils.createConnection();
192
+
c.setAutoCommit(false);
193
+
PreparedStatement ps1 = c.prepareStatement("insert into test_prepare_statement values");
194
+
ps1.setInt(1, 1);
195
+
ps1.setInt(2, 2);
196
+
ps1.addBatch();
197
+
ps1.executeBatch();
198
+
199
+
PreparedStatement ps = c.prepareStatement("replace into test_prepare_statement on(a) values");
200
+
ps.setInt(1, 1);
201
+
ps.setString(2, "a");
202
+
ps.addBatch();
203
+
ps.setInt(1, 3);
204
+
ps.setString(2, "b");
205
+
ps.addBatch();
206
+
System.out.println("execute batch replace into");
207
+
int[] ans = ps.executeBatch();
208
+
...
209
+
```
210
+
211
+
:::tip
212
+
Databend does not support `executeBatch()` in UPDATE statement. If you want to do batch update, please use REPLACE INTO.
0 commit comments