com.yandex.ydb.examples.simple.SimpleExample Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ydb-sdk-examples Show documentation
Show all versions of ydb-sdk-examples Show documentation
Examples of usage Java SDK for Yandex Database (YDB)
package com.yandex.ydb.examples.simple;
import java.util.concurrent.Executors;
import com.yandex.ydb.core.grpc.GrpcTransport;
import com.yandex.ydb.core.rpc.RpcTransport;
/**
* @author Sergey Polovko
*/
public abstract class SimpleExample {
protected void doMain() {
String host = System.getProperty("HOST", "some.host.name.com");
int port = Integer.parseInt(System.getProperty("PORT", "2135"));
String path = System.getProperty("PATH", "/Root/");
if (!path.endsWith("/")) {
path += "/";
}
System.err.println("Run with -DHOST= and -DPORT= to override connection settings");
System.err.println();
System.err.println("HOST=" + host);
System.err.println("PORT=" + port);
System.err.println("PATH=" + path);
System.err.println();
try (RpcTransport transport = GrpcTransport.forHost(host, port)
.withCallExecutor(Executors.newFixedThreadPool(3))
.build())
{
run(transport, path);
} catch (Throwable t) {
t.printStackTrace();
}
}
abstract void run(RpcTransport transport, String pathPrefix);
}