Skip to content

Commit d01c70c

Browse files
Merge remote-tracking branch 'origin/develop' into develop
2 parents d33c675 + f8253da commit d01c70c

File tree

75 files changed

+7396
-1731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+7396
-1731
lines changed

.github/workflows/build.yaml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,31 @@ on:
1010
type: [opened, reopened, edited, synchronize]
1111

1212
jobs:
13+
prepare:
14+
name: Prepare Maven cache
15+
runs-on: ubuntu-latest
16+
17+
env:
18+
MAVEN_ARGS: --batch-mode -Dstyle.color=always
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Set up JDK
25+
uses: actions/setup-java@v4
26+
with:
27+
java-version: '8'
28+
distribution: 'temurin'
29+
cache: 'maven'
30+
31+
- name: Download dependencies for JDBC
32+
run: mvn $MAVEN_ARGS dependency:resolve-plugins dependency:go-offline
33+
1334
build:
1435
name: Build JDBC Driver
1536
runs-on: ubuntu-latest
37+
needs: prepare
1638

1739
strategy:
1840
matrix:
@@ -75,9 +97,6 @@ jobs:
7597
if: env.NEED_SDK == 'true'
7698
run: rm -rf yc
7799

78-
- name: Download dependencies
79-
run: mvn $MAVEN_ARGS dependency:resolve-plugins dependency:go-offline
80-
81100
- name: Build with Maven
82101
run: mvn $MAVEN_ARGS package
83102

@@ -144,9 +163,6 @@ jobs:
144163
if: env.NEED_SDK == 'true'
145164
run: rm -rf yc
146165

147-
- name: Download dependencies
148-
run: mvn $MAVEN_ARGS dependency:resolve-plugins dependency:go-offline
149-
150166
- name: Build with Maven
151167
run: mvn $MAVEN_ARGS test
152168

.github/workflows/ci.yaml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: YDB JDBC Driver CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- release*
8+
pull_request:
9+
type: [opened, reopened, edited, synchronize]
10+
11+
jobs:
12+
prepare:
13+
name: Prepare Maven cache
14+
runs-on: ubuntu-latest
15+
16+
env:
17+
MAVEN_ARGS: --batch-mode -Dstyle.color=always
18+
19+
steps:
20+
- name: Checkout YDB JDBC Driver
21+
uses: actions/checkout@v4
22+
with:
23+
path: jdbc
24+
25+
- name: Checkout YDB Java Examples
26+
uses: actions/checkout@v4
27+
with:
28+
repository: ydb-platform/ydb-java-examples
29+
path: examples
30+
31+
- name: Set up Java
32+
uses: actions/setup-java@v4
33+
with:
34+
java-version: 17
35+
distribution: 'temurin'
36+
cache: 'maven'
37+
cache-dependency-path: |
38+
jdbc/pom.xml
39+
40+
- name: Download YDB JDBC Driver dependencies
41+
working-directory: ./jdbc
42+
run: mvn $MAVEN_ARGS dependency:go-offline
43+
44+
- name: Download YDB Java Examples dependencies
45+
working-directory: ./examples
46+
run: mvn $MAVEN_ARGS dependency:go-offline
47+
48+
build:
49+
name: YDB JDBC Driver CI on JDK
50+
runs-on: ubuntu-latest
51+
needs: prepare
52+
53+
strategy:
54+
matrix:
55+
java: [ '8', '11', '17']
56+
57+
env:
58+
MAVEN_ARGS: --batch-mode -Dstyle.color=always -DYDB_DOCKER_ISOLATION=true
59+
60+
steps:
61+
- name: Checkout YDB JDBC Driver
62+
uses: actions/checkout@v4
63+
with:
64+
path: jdbc
65+
66+
- name: Set up Java
67+
uses: actions/setup-java@v4
68+
with:
69+
java-version: ${{ matrix.java }}
70+
distribution: 'temurin'
71+
cache: 'maven'
72+
cache-dependency-path: |
73+
jdbc/pom.xml
74+
75+
- name: Extract YDB JDBC Driver version
76+
working-directory: ./jdbc
77+
run: |
78+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
79+
echo "JDBC_VERSION=$VERSION" >> "$GITHUB_ENV"
80+
81+
- name: Build YDB JDBC Driver
82+
working-directory: ./jdbc
83+
run: mvn $MAVEN_ARGS install
84+
85+
- name: Checkout YDB Java Examples
86+
uses: actions/checkout@v4
87+
with:
88+
repository: ydb-platform/ydb-java-examples
89+
path: examples
90+
91+
- name: Test examples with Maven
92+
working-directory: ./examples
93+
run: mvn $MAVEN_ARGS -Dydb.jdbc.version=$JDBC_VERSION test

CHANGELOG.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,69 @@
1+
## 2.3.2 ##
2+
3+
* Fixed typo in YdbTracer
4+
5+
## 2.3.1 ##
6+
7+
* Updated transaction tracer implementation
8+
* Fixed table description cache
9+
10+
## 2.3.0 ##
11+
12+
* QueryService is enabled by default
13+
14+
## 2.2.14 ##
15+
16+
* Fixed saKeyFile option
17+
18+
## 2.2.13 ##
19+
20+
* Fixed usePrefixPath for preparing of YQL statements
21+
22+
## 2.2.12 ##
23+
24+
* Added option usePrefixPath
25+
* Added options saKeyFile and tokenFile
26+
* Upgraded to YDB Java SDK 2.3.3
27+
28+
## 2.2.11 ##
29+
30+
* Added transaction tracer
31+
* Added option useStreamResultSets to switch on streamable result sets
32+
* Updated options to control query special modes
33+
34+
## 2.2.10 ##
35+
36+
* Added auto batch mode for simple UPDATE/DELETE/REPLACE
37+
38+
## 2.2.9 ##
39+
40+
* Removed cleaning of unclosed result set
41+
* Added checks of invalid values of Decimal
42+
43+
## 2.2.8 ##
44+
45+
* Added support of stream cancelling
46+
47+
## 2.2.7 ##
48+
49+
* Fixed concurrency issues in QueryServiceExecutor
50+
* Fixed QueryClient pool autoresize
51+
52+
## 2.2.6 ##
53+
54+
* Added logs for QueryClient executor
55+
56+
## 2.2.5 ##
57+
58+
* Added lazy result set implementation
59+
* Added flag to forced usage of BulkUpsert and ScanQuery
60+
* Fixed error of LIMIT & OFFSET keywords parsing
61+
62+
## 2.2.4 ##
63+
64+
* Added support of BulkUpsert
65+
* Upgraded to YDB Java SDK v2.3.0
66+
167
## 2.2.3 ##
268

369
* Added custom sql types for usage of native YDB types

README.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/ydb-platform/ydb-jdbc-driver/blob/master/LICENSE)
22
[![Maven metadata URL](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2Ftech%2Fydb%2Fjdbc%2Fydb-jdbc-driver%2Fmaven-metadata.xml)](https://mvnrepository.com/artifact/tech.ydb.jdbc/ydb-jdbc-driver)
33
[![Build](https://img.shields.io/github/actions/workflow/status/ydb-platform/ydb-jdbc-driver/build.yaml)](https://github.com/ydb-platform/ydb-jdbc-driver/actions/workflows/build.yaml)
4+
[![CI](https://img.shields.io/github/actions/workflow/status/ydb-platform/ydb-jdbc-driver/ci.yaml?label=CI)](https://github.com/ydb-platform/ydb-jdbc-driver/actions/workflows/ci.yaml)
45
[![Codecov](https://img.shields.io/codecov/c/github/ydb-platform/ydb-jdbc-driver)](https://app.codecov.io/gh/ydb-platform/ydb-jdbc-driver)
56

67
## JDBC Driver for YDB
@@ -10,9 +11,9 @@
1011
1) Drop in [JDBC driver](https://github.com/ydb-platform/ydb-jdbc-driver/releases) to classpath or pick this file in IDE
1112
2) Connect to YDB
1213
* Local or remote Docker (anonymous authentication):<br>`jdbc:ydb:grpc://localhost:2136/local`
13-
* Self-hosted cluster:<br>`jdbc:ydb:grpcs://<host>:2135/Root/testdb?secureConnectionCertificate=file:~/myca.cer`
14-
* Connect with token to the cloud instance:<br>`jdbc:ydb:grpcs://<host>:2135/path/to/database?token=file:~/my_token`
15-
* Connect with service account to the cloud instance:<br>`jdbc:ydb:grpcs://<host>:2135/path/to/database?saFile=file:~/sa_key.json`
14+
* Self-hosted cluster:<br>`jdbc:ydb:grpcs://<host>:2135/Root/testdb?secureConnectionCertificate=~/myca.cer`
15+
* Connect with token to the cloud instance:<br>`jdbc:ydb:grpcs://<host>:2135/path/to/database?tokenFile=~/my_token`
16+
* Connect with service account to the cloud instance:<br>`jdbc:ydb:grpcs://<host>:2135/path/to/database?saKeyFile=~/sa_key.json`
1617
3) Execute queries, see example in [YdbDriverExampleTest.java](jdbc/src/test/java/tech/ydb/jdbc/YdbDriverExampleTest.java)
1718

1819
### Usage with Maven
@@ -25,21 +26,17 @@ Specify the YDB JDBC driver in the dependencies:
2526
<dependency>
2627
<groupId>tech.ydb.jdbc</groupId>
2728
<artifactId>ydb-jdbc-driver</artifactId>
28-
<version>2.2.3</version>
29+
<version>2.3.2</version>
2930
</dependency>
3031

3132
<!-- Shaded version with included dependencies -->
3233
<dependency>
3334
<groupId>tech.ydb.jdbc</groupId>
3435
<artifactId>ydb-jdbc-driver-shaded</artifactId>
35-
<version>2.2.3</version>
36+
<version>2.3.2</version>
3637
</dependency>
3738
</dependencies>
3839
```
39-
### Using QueryService mode
40-
By default JDBC driver executes all queries via TableService, so it brings corresponding [limitations](https://ydb.tech/docs/en/concepts/limits-ydb#query).
41-
To eliminate these limitations you can try a new experimentail [QueryService](https://ydb.tech/docs/en/conceptrs/query_service) mode by passing property `useQueryService=true` to the JDBC URL
42-
4340
### Authentication modes
4441

4542
YDB JDBC Driver supports the following [authentication modes](https://ydb.tech/en/docs/reference/ydb-sdk/auth):
@@ -52,19 +49,18 @@ YDB JDBC Driver supports the following [authentication modes](https://ydb.tech/e
5249
### Driver properties reference
5350

5451
Driver supports the following configuration properties, which can be specified in the URL or passed via extra properties:
55-
* `saFile` - service account key for authentication, can be passed either as literal JSON value or as a file reference;
52+
* `saKeyFile` - file location of service account key for authentication;
53+
* `tokenFile` - file location with token value for token based authentication;
5654
* `iamEndpoint` - custom IAM endpoint for authentication via service account key;
57-
* `token` - token value for authentication, can be passed either as literal value or as a file reference;
5855
* `useMetadata` - boolean value, true if metadata authentication should be used, false otherwise (and default);
5956
* `metadataURL` - custom metadata endpoint;
6057
* `localDatacenter` - name of the datacenter local to the application being connected;
6158
* `secureConnection` - boolean value, true if TLS should be enforced (normally configured via `grpc://` or `grpcs://` scheme in the JDBC URL);
6259
* `secureConnectionCertificate` - custom CA certificate for TLS connections, can be passed either as literal value or as a file reference.
6360

64-
File references for `saFile`, `token` or `secureConnectionCertificate` must be prefixed with the `file:` URL scheme, for example:
65-
* `saFile=file:~/mysaley1.json`
66-
* `token=file:/opt/secret/token-file`
67-
* `secureConnectionCertificate=file:/etc/ssl/cacert.cer`
61+
### Using TableService mode
62+
By default JDBC driver executes all queries via QueryService, which uses grpc streams for the results recieving.
63+
If your database instance doesn't support this service, you can use old TableService mode by passing property `useQueryService=false` to the JDBC URL.
6864

6965
### Building
7066
By default all tests are run using a local YDB instance in Docker (if host has Docker or Docker Machine installed)

jdbc-shaded/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>tech.ydb.jdbc</groupId>
88
<artifactId>ydb-jdbc-driver-parent</artifactId>
9-
<version>2.2.4-SNAPSHOT</version>
9+
<version>2.3.3-SNAPSHOT</version>
1010
</parent>
1111

1212
<artifactId>ydb-jdbc-driver-shaded</artifactId>

jdbc/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>tech.ydb.jdbc</groupId>
88
<artifactId>ydb-jdbc-driver-parent</artifactId>
9-
<version>2.2.4-SNAPSHOT</version>
9+
<version>2.3.3-SNAPSHOT</version>
1010
</parent>
1111

1212
<artifactId>ydb-jdbc-driver</artifactId>
@@ -76,7 +76,7 @@
7676
<argLine>@{argLine} -Duser.timezone=GMT-04</argLine>
7777
<environmentVariables>
7878
<TESTCONTAINERS_REUSE_ENABLE>true</TESTCONTAINERS_REUSE_ENABLE>
79-
<YDB_DOCKER_IMAGE>cr.yandex/yc/yandex-docker-local-ydb:trunk</YDB_DOCKER_IMAGE>
79+
<YDB_DOCKER_IMAGE>ydbplatform/local-ydb:trunk</YDB_DOCKER_IMAGE>
8080
</environmentVariables>
8181
<systemPropertyVariables>
8282
<java.util.logging.config.file>src/test/resources/logging.properties</java.util.logging.config.file>

jdbc/src/main/java/tech/ydb/jdbc/YdbConnection.java

Lines changed: 3 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,76 +2,19 @@
22

33
import java.sql.Connection;
44
import java.sql.SQLException;
5-
import java.util.List;
65

76
import javax.annotation.Nullable;
87

98
import tech.ydb.jdbc.context.YdbContext;
10-
import tech.ydb.jdbc.context.YdbValidator;
11-
import tech.ydb.jdbc.query.ExplainedQuery;
12-
import tech.ydb.jdbc.query.YdbQuery;
13-
import tech.ydb.table.query.Params;
14-
import tech.ydb.table.result.ResultSetReader;
9+
import tech.ydb.jdbc.context.YdbExecutor;
1510

1611
public interface YdbConnection extends Connection {
17-
/**
18-
* Return current YDB transaction, if exists
19-
*
20-
* @return YDB transaction ID or null, if no transaction started
21-
*/
2212
@Nullable
23-
String getYdbTxId();
24-
13+
String getYdbTxId() throws SQLException;
2514

2615
YdbContext getCtx();
2716

28-
/**
29-
* Explicitly execute query as a schema query
30-
*
31-
* @param yql query (DDL) to execute
32-
* @param validator handler for logging and warnings
33-
* @throws SQLException if query cannot be executed
34-
*/
35-
void executeSchemeQuery(String yql, YdbValidator validator) throws SQLException;
36-
37-
/**
38-
* Explicitly execute query as a data query
39-
*
40-
* @param query query to execute
41-
* @param yql YQL text to execute
42-
* @param params parameters for query
43-
* @param timeout timeout of operation
44-
* @param keepInCache flag to store query in server-side cache
45-
* @param validator handler for logging and warnings
46-
* @return list of result set
47-
* @throws SQLException if query cannot be executed
48-
*/
49-
List<ResultSetReader> executeDataQuery(YdbQuery query, String yql, YdbValidator validator,
50-
int timeout, boolean keepInCache, Params params) throws SQLException;
51-
52-
/**
53-
* Explicitly execute query as a scan query
54-
*
55-
* @param query query to execute
56-
* @param yql YQL text to execute
57-
* @param params parameters for query
58-
* @param validator handler for logging and warnings
59-
* @return single result set with rows
60-
* @throws SQLException if query cannot be executed
61-
*/
62-
ResultSetReader executeScanQuery(YdbQuery query, String yql, YdbValidator validator, Params params)
63-
throws SQLException;
64-
65-
/**
66-
* Explicitly explain this query
67-
*
68-
* @param yql query to explain
69-
* @param validator handler for logging and warnings
70-
* @return list of result set of two string columns: {@link YdbConst#EXPLAIN_COLUMN_AST}
71-
* and {@link YdbConst#EXPLAIN_COLUMN_PLAN}
72-
* @throws SQLException if query cannot be explained
73-
*/
74-
ExplainedQuery executeExplainQuery(String yql, YdbValidator validator) throws SQLException;
17+
YdbExecutor getExecutor();
7518

7619
@Override
7720
YdbDatabaseMetaData getMetaData() throws SQLException;

0 commit comments

Comments
 (0)