Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import tech.ydb.query.tools.SessionRetryContext;
import tech.ydb.table.result.ResultSetReader;

import java.time.Duration;

/*
* @author Kirill Kurdyukov
*/
Expand All @@ -17,7 +19,10 @@ public class Application {

public static void main(String[] args) {
// Создаем драйвер для подключения к YDB через gRPC
try (GrpcTransport grpcTransport = GrpcTransport.forConnectionString(CONNECTION_STRING).build()) {
try (GrpcTransport grpcTransport = GrpcTransport
.forConnectionString(CONNECTION_STRING)
.withConnectTimeout(Duration.ofSeconds(10)
).build()) {
// Создаем клиент для выполнения SQL-запросов
try (QueryClient queryClient = QueryClient.newClient(grpcTransport).build()) {
// Создаем контекст для автоматических повторных попыток выполнения запросов
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import tech.ydb.query.QueryClient;
import tech.ydb.query.tools.SessionRetryContext;

import java.time.Duration;

/*
* @author Kirill Kurdyukov
*/
Expand All @@ -12,7 +14,10 @@ public class Application {
private static final String CONNECTION_STRING = "grpc://localhost:2136/local";

public static void main(String[] args) {
try (GrpcTransport grpcTransport = GrpcTransport.forConnectionString(CONNECTION_STRING).build()) {
try (GrpcTransport grpcTransport = GrpcTransport
.forConnectionString(CONNECTION_STRING)
.withConnectTimeout(Duration.ofSeconds(10)
).build()) {
try (QueryClient queryClient = QueryClient.newClient(grpcTransport).build()) {
var retryCtx = SessionRetryContext.create(queryClient).build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import tech.ydb.query.QueryClient;
import tech.ydb.query.tools.SessionRetryContext;

import java.time.Duration;

/*
* Пример работы с транзакциями в YDB, урок - 4.1 Распределенные транзакции
* @author Kirill Kurdyukov
Expand All @@ -14,7 +16,10 @@ public class Application {
private static final String CONNECTION_STRING = "grpc://localhost:2136/local";

public static void main(String[] args) {
try (GrpcTransport grpcTransport = GrpcTransport.forConnectionString(CONNECTION_STRING).build()) {
try (GrpcTransport grpcTransport = GrpcTransport
.forConnectionString(CONNECTION_STRING)
.withConnectTimeout(Duration.ofSeconds(10)
).build()) {
try (QueryClient queryClient = QueryClient.newClient(grpcTransport).build()) {
var retryCtx = SessionRetryContext.create(queryClient).build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import tech.ydb.query.QueryClient;
import tech.ydb.query.tools.SessionRetryContext;

import java.time.Duration;

/*
* Пример работы с индексами в YDB: создание и использование вторичных индексов
* @author Kirill Kurdyukov
Expand All @@ -14,7 +16,10 @@ public class Application {
private static final String CONNECTION_STRING = "grpc://localhost:2136/local";

public static void main(String[] args) {
try (GrpcTransport grpcTransport = GrpcTransport.forConnectionString(CONNECTION_STRING).build()) {
try (GrpcTransport grpcTransport = GrpcTransport
.forConnectionString(CONNECTION_STRING)
.withConnectTimeout(Duration.ofSeconds(10)
).build()) {
try (QueryClient queryClient = QueryClient.newClient(grpcTransport).build()) {
var retryCtx = SessionRetryContext.create(queryClient).build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import tech.ydb.query.tools.SessionRetryContext;
import tech.ydb.topic.TopicClient;

import java.time.Duration;

/*
* Пример работы с топиками в YDB
* @author Kirill Kurdyukov
Expand All @@ -14,7 +16,10 @@ public class Application {
private static final String CONNECTION_STRING = "grpc://localhost:2136/local";

public static void main(String[] args) throws InterruptedException {
try (GrpcTransport grpcTransport = GrpcTransport.forConnectionString(CONNECTION_STRING).build();
try (GrpcTransport grpcTransport = GrpcTransport
.forConnectionString(CONNECTION_STRING)
.withConnectTimeout(Duration.ofSeconds(10)
).build();
QueryClient queryClient = QueryClient.newClient(grpcTransport).build();
TopicClient topicClient = TopicClient.newClient(grpcTransport).build()) {
var retryCtx = SessionRetryContext.create(queryClient).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -35,7 +36,10 @@ public class Application {
private static final String CONNECTION_STRING = "grpc://localhost:2136/local";

public static void main(String[] args) throws IOException, InterruptedException {
try (GrpcTransport grpcTransport = GrpcTransport.forConnectionString(CONNECTION_STRING).build();
try (GrpcTransport grpcTransport = GrpcTransport
.forConnectionString(CONNECTION_STRING)
.withConnectTimeout(Duration.ofSeconds(10)
).build();
QueryClient queryClient = QueryClient.newClient(grpcTransport).build();
TopicClient topicClient = TopicClient.newClient(grpcTransport).build()) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -39,7 +40,10 @@ public class Application {
private static final String CONNECTION_STRING = "grpc://localhost:2136/local";

public static void main(String[] args) throws IOException, InterruptedException {
try (GrpcTransport grpcTransport = GrpcTransport.forConnectionString(CONNECTION_STRING).build();
try (GrpcTransport grpcTransport = GrpcTransport
.forConnectionString(CONNECTION_STRING)
.withConnectTimeout(Duration.ofSeconds(10)
).build();
QueryClient queryClient = QueryClient.newClient(grpcTransport).build();
TopicClient topicClient = TopicClient.newClient(grpcTransport).build()) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tech.ydb.app;

import java.time.Duration;
import java.util.UUID;
import tech.ydb.core.grpc.GrpcTransport;
import tech.ydb.query.QueryClient;
Expand All @@ -15,7 +16,10 @@ public class Application {
private static final String CONNECTION_STRING = "grpc://localhost:2136/local";

public static void main(String[] args) throws InterruptedException {
try (GrpcTransport grpcTransport = GrpcTransport.forConnectionString(CONNECTION_STRING).build();
try (GrpcTransport grpcTransport = GrpcTransport
.forConnectionString(CONNECTION_STRING)
.withConnectTimeout(Duration.ofSeconds(10)
).build();
QueryClient queryClient = QueryClient.newClient(grpcTransport).build();
TopicClient topicClient = TopicClient.newClient(grpcTransport).build()) {
var retryCtx = SessionRetryContext.create(queryClient).build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tech.ydb.app;

import java.time.Duration;
import java.util.List;
import tech.ydb.core.grpc.GrpcTransport;
import tech.ydb.query.QueryClient;
Expand All @@ -13,7 +14,10 @@ public class Application {
private static final String CONNECTION_STRING = "grpc://localhost:2136/local";

public static void main(String[] args) {
try (GrpcTransport grpcTransport = GrpcTransport.forConnectionString(CONNECTION_STRING).build();
try (GrpcTransport grpcTransport = GrpcTransport
.forConnectionString(CONNECTION_STRING)
.withConnectTimeout(Duration.ofSeconds(10)
).build();
QueryClient queryClient = QueryClient.newClient(grpcTransport).build()) {
var retryCtx = SessionRetryContext.create(queryClient).build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import tech.ydb.core.grpc.GrpcTransport;
Expand All @@ -21,7 +22,10 @@ public class Application {
private static final String CONNECTION_STRING = "grpc://localhost:2136/local";

public static void main(String[] args) {
try (GrpcTransport grpcTransport = GrpcTransport.forConnectionString(CONNECTION_STRING).build();
try (GrpcTransport grpcTransport = GrpcTransport
.forConnectionString(CONNECTION_STRING)
.withConnectTimeout(Duration.ofSeconds(10)
).build();
TableClient tableClient = TableClient.newClient(grpcTransport).build();
QueryClient queryClient = QueryClient.newClient(grpcTransport).build()) {
var retryCtx = SessionRetryContext.create(queryClient).build();
Expand Down