Skip to content

Commit

Permalink
Merge pull request #39 from ydb-platform/release_v2.0.5
Browse files Browse the repository at this point in the history
Release v2.0.5
  • Loading branch information
alex268 committed Dec 8, 2023
2 parents a5389c8 + 06d0aaf commit b492829
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 9 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 2.0.5 ##

* Extended usage of standard JDBC exception classes
* Fixed too small default timeout

## 2.0.4 ##

* Fixed problem with prepareDataQuery for YQL-specific queries
* Added prepared queries cache
* Updated implementation of getUpdateCount() and getMoreResults()
* Added usage of standard JDBC exception classes SQLRecoverableException and SQLTransientException

## 2.0.3 ##

* Added SqlState info to YDB exceptions
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

### Quickstart

1) Drop in [JDBC driver](https://github.com/ydb-platform/ydb-jdbc-driver/releases) to classpath or pick this file in IDEA
1) Drop in [JDBC driver](https://github.com/ydb-platform/ydb-jdbc-driver/releases) to classpath or pick this file in IDE
2) Connect to YDB
* Local or remote Docker (anonymous authentication):<br>`jdbc:ydb:grpc://localhost:2136/local`
* Self-hosted cluster:<br>`jdbc:ydb:grpcs://<host>:2135/Root/testdb?secureConnectionCertificate=file:~/myca.cer`
Expand All @@ -25,14 +25,14 @@ Specify the YDB JDBC driver in the dependencies:
<dependency>
<groupId>tech.ydb.jdbc</groupId>
<artifactId>ydb-jdbc-driver</artifactId>
<version>2.0.3</version>
<version>2.0.5</version>
</dependency>

<!-- Shaded version with included dependencies -->
<dependency>
<groupId>tech.ydb.jdbc</groupId>
<artifactId>ydb-jdbc-driver-shaded</artifactId>
<version>2.0.3</version>
<version>2.0.5</version>
</dependency>
</dependencies>
```
Expand Down
2 changes: 1 addition & 1 deletion jdbc-shaded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>tech.ydb.jdbc</groupId>
<artifactId>ydb-jdbc-driver-parent</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
</parent>

<artifactId>ydb-jdbc-driver-shaded</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>tech.ydb.jdbc</groupId>
<artifactId>ydb-jdbc-driver-parent</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
</parent>

<artifactId>ydb-jdbc-driver</artifactId>
Expand Down
15 changes: 15 additions & 0 deletions jdbc/src/main/java/tech/ydb/jdbc/exception/ExceptionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,24 @@ public static SQLException createException(String message, UnexpectedResultExcep
String sqlState = getSQLState(code);
int vendorCode = getVendorCode(code);

// base retryable statuses are translated to SQLRecoverableException
if (code.isRetryable(false)) {
return new YdbRetryableException(message, sqlState, vendorCode, cause);
}

// transport problems are translated to SQLTransientConnectionException
if (code == StatusCode.TRANSPORT_UNAVAILABLE || code == StatusCode.UNAVAILABLE) {
return new YdbUnavailbaleException(message, sqlState, vendorCode, cause);
}

// timeouts are translated to SQLTimeoutException
if (code == StatusCode.TIMEOUT ||
code == StatusCode.CLIENT_DEADLINE_EXPIRED ||
code == StatusCode.CLIENT_DEADLINE_EXCEEDED) {
return new YdbTimeoutException(message, sqlState, vendorCode, cause);
}

// all others transient problems are translated to base SQLTransientException
if (code.isRetryable(true)) {
return new YdbConditionallyRetryableException(message, sqlState, vendorCode, cause);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package tech.ydb.jdbc.exception;

import java.sql.SQLTimeoutException;

import tech.ydb.core.Status;
import tech.ydb.core.UnexpectedResultException;

/**
*
* @author Aleksandr Gorshenin
*/
public class YdbTimeoutException extends SQLTimeoutException {
private static final long serialVersionUID = -6309565506198809222L;

private final Status status;

YdbTimeoutException(String message, String sqlState, int code, UnexpectedResultException cause) {
super(message, sqlState, code, cause);
this.status = cause.getStatus();
}

public Status getStatus() {
return status;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package tech.ydb.jdbc.exception;

import java.sql.SQLTransientConnectionException;

import tech.ydb.core.Status;
import tech.ydb.core.UnexpectedResultException;

/**
*
* @author Aleksandr Gorshenin
*/
public class YdbUnavailbaleException extends SQLTransientConnectionException {
private static final long serialVersionUID = 7162301155514557562L;

private final Status status;

YdbUnavailbaleException(String message, String sqlState, int code, UnexpectedResultException cause) {
super(message, sqlState, code, cause);
this.status = cause.getStatus();
}

public Status getStatus() {
return status;
}

}
11 changes: 8 additions & 3 deletions jdbc/src/main/java/tech/ydb/jdbc/impl/BaseYdbStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,15 @@ protected List<YdbResult> executeScanQuery(YdbQuery query, Params params) throws
}

protected List<YdbResult> executeDataQuery(YdbQuery query, Params params) throws SQLException {
ExecuteDataQuerySettings settings = new ExecuteDataQuerySettings();

int timeout = getQueryTimeout();
ExecuteDataQuerySettings settings = new ExecuteDataQuerySettings()
.setOperationTimeout(Duration.ofSeconds(timeout))
.setTimeout(Duration.ofSeconds(timeout + 1));
if (timeout > 0) {
settings = settings
.setOperationTimeout(Duration.ofSeconds(timeout))
.setTimeout(Duration.ofSeconds(timeout + 1));
}

if (!isPoolable()) {
settings = settings.disableQueryCache();
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>tech.ydb.jdbc</groupId>

<artifactId>ydb-jdbc-driver-parent</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>

<name>YDB JDBC Module</name>
<description>JDBC Driver over YDB Java SDK</description>
Expand Down

0 comments on commit b492829

Please sign in to comment.