The Java binding is distrubuted via maven central:
implementation 'com.gel:driver:0.4.0'
<dependency>
<groupId>com.gel</groupId>
<artifactId>driver</artifactId>
<version>0.4.0</version>
</dependency>
libraryDependencies ++= Seq(
"com.gel" % "driver" % "0.4.0"
)
The GelClientPool
class contains all the methods necessary to interact with the Gel database.
import com.gel.driver.GelClientPool;
void main() {
var clientPool = new GelClientPool();
clientPool.query(String.class, "SELECT 'Hello, Java!'")
.thenAccept(System.out::println);
}
The GelClientPool
uses CompletionStage
for asynchronous operations, allowing you
to integrate it with your favorite asynchronous frameworks
import com.gel.driver.GelClientPool;
import reactor.core.publisher.Mono;
void main() {
var clientPool = new GelClientPool();
Mono.fromFuture(clientPool.querySingle(String.class, "SELECT 'Hello, Java!'"))
.doOnNext(System.out::println)
.block();
}
This also means it plays nicely with other JVM language that support asynchronous programming via CompletionStage
import com.gel.driver.GelClientPool
import kotlinx.coroutines.future.await
import kotlinx.coroutines.runBlocking
fun main() {
val clientPool = GelClientPool()
runBlocking {
clientPool.querySingle(String::class.java, "SELECT 'Hello, Kotlin!'")
.thenAccept { println(it) }
.await()
}
}
import com.gel.driver.GelClientPool
import scala.jdk.FutureConverters.*
object Main extends App {
val clientPool = new GelClientPool()
clientPool.querySingle(classOf[String], "SELECT 'Hello, Scala!'")
.asScala
.map(println)
}
Some examples of using the Java clientPool api can be found in the examples directory.
This project uses gradle. To build the project run the following command:
./gradlew build