This repository contains the FaunaDB drivers for the JVM languages. Currently, Java and Scala clients are implemented.
- All drivers fully support the current version of the FaunaDB API.
- Java and Scala clients share the same underlying library faunadb-common.
- Supports Dropwizard Metrics hooks for stats reporting.
Javadocs and Scaladocs are hosted on GitHub:
Details Documentation for each language:
- Jackson for JSON parsing.
- Async HTTP client and Netty for the HTTP transport.
- Joda Time for date and time manipulation.
- Java 8
- Scala 2.11.x
- Scala 2.12.x
Download from the Maven central repository:
<dependencies>
...
<dependency>
<groupId>com.faunadb</groupId>
<artifactId>faunadb-java</artifactId>
<version>2.9.0</version>
<scope>compile</scope>
</dependency>
...
</dependencies>
import com.faunadb.client.FaunaClient;
import static com.faunadb.client.query.Language.*;
/**
* This example connects to FaunaDB Cloud using the secret provided
* and creates a new database named "my-first-database"
*/
public class Main {
public static void main(String[] args) throws Exception {
//Create an admin connection to FaunaDB.
FaunaClient adminClient =
FaunaClient.builder()
.withSecret("put-your-key-secret-here")
.build();
adminClient.query(
CreateDatabase(
Obj("name", Value("my-first-database"))
)
).get();
client.close();
}
}
Detailed Java Documentation can be found here
libraryDependencies += ("com.faunadb" %% "faunadb-scala" % "2.9.0")
import faunadb._
import faunadb.query._
import scala.concurrent._
import scala.concurrent.duration._
/**
* This example connects to FaunaDB Cloud using the secret provided
* and creates a new database named "my-first-database"
*/
object Main extends App {
import ExecutionContext.Implicits._
val client = FaunaClient(
secret = "put-your-secret-here"
)
val result = client.query(
CreateDatabase(
Obj("name" -> "my-first-database")
)
)
Await.result(result, Duration.Inf)
client.close()
}
The faunadb-jvm project is built using sbt:
To build and run tests against cloud, set the env variable
FAUNA_ROOT_KEY
to your admin key secret and run sbt test
from the
project directory.
Alternatively, tests can be run via a Docker container with
FAUNA_ROOT_KEY="your-cloud-secret" make docker-test
(an alternate
Debian-based JDK image can be provided via RUNTIME_IMAGE
).
To run tests against an enterprise cluster or developer instance, you
will also need to set FAUNA_SCHEME
(http or https), FAUNA_DOMAIN
and FAUNA_PORT
.
All projects in this repository are licensed under the Mozilla Public License