import java.net.URL
import xtdb.api.XtdbClient
XtdbClient.openClient(URL("http://localhost:3000"))
.use { client ->
// ...
}
Getting started (Kotlin)
In Kotlin, you can access XTDB via a remote HTTP client, or in-process (e.g. for testing purposes).
Connecting through HTTP
-
Firstly, to run the XTDB server, check out the general getting started guide.
-
Then, add the thin client Maven coordinates to your dependency manager of choice.
-
You can then open up an XTDB client by running:
From here, check out the IXtdb
API docs to submit data and run queries.
In process
If you’re running a JVM, you can also use XTDB directly, in-process. In-process XTDB is particularly useful for testing and interactive development - you can start an in-memory node quickly and with little hassle, which makes it a great tool for unit tests and REPL experimentation.
-
First, ensure you are running JDK 17+ and then add the
xtdb-core
Maven coordinates to your dependency manager. -
You’ll also need to add the following JVM arguments to run Apache Arrow:
-
--add-opens=java.base/java.nio=ALL-UNNAMED
-
-Dio.netty.tryReflectionSetAccessible=true
-
-
Open up an in-process node using
Xtdb
:import xtdb.api.Xtdb Xtdb.openNode() .use { xtdb -> // ... }
This node uses exactly the same API as the thin client - so, again, from here, check out the IXtdb
API docs to submit data and run queries.