Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/surrealdb/surrealdb.java
SurrealDB SDK for Java
https://github.com/surrealdb/surrealdb.java
database database-connector iot-database java java-library realtime-database surreal surrealdb
Last synced: 3 months ago
JSON representation
SurrealDB SDK for Java
- Host: GitHub
- URL: https://github.com/surrealdb/surrealdb.java
- Owner: surrealdb
- License: apache-2.0
- Created: 2022-09-24T08:06:16.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-26T16:42:02.000Z (4 months ago)
- Last Synced: 2024-07-27T23:32:33.344Z (3 months ago)
- Topics: database, database-connector, iot-database, java, java-library, realtime-database, surreal, surrealdb
- Language: Java
- Homepage: https://surrealdb.com
- Size: 850 KB
- Stars: 63
- Watchers: 19
- Forks: 23
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-surreal - surrealdb.java - <a href="https://surrealdb.com#gh-dark-mode-only" target="_blank"><img src="/img/white/text.svg" height="12" alt="SurrealDB"></a> <a href="https://surrealdb.com#gh-light-mode-only" target="_blank"><img src="/img/black/text.svg" height="12" alt="SurrealDB"></a> official driver for Java. (Client libraries)
README
# surrealdb.java
The official SurrealDB library for Java.
[![](https://img.shields.io/badge/status-beta-ff00bb.svg?style=flat-square)](https://github.com/surrealdb/surrealdb.java) [![](https://img.shields.io/badge/docs-view-44cc11.svg?style=flat-square)](https://surrealdb.com/docs/integration/libraries/java) [![](https://img.shields.io/badge/license-Apache_License_2.0-00bfff.svg?style=flat-square)](https://github.com/surrealdb/surrealdb.java)
### Features
- Sync & Async driver implementations available.
- Complex JSON serialization & deserialization to Java classes.
- Simple API (very similar to the Javascript driver, [see docs](https://surrealdb.com/docs/integration/libraries/java)).### Installation
Gradle:
```groovy
ext {
surrealdbVersion = "0.1.0"
}dependencies {
implementation "com.surrealdb:surrealdb-driver:${surrealdbVersion}"
}
```Maven:
```xmlcom.surrealdb
surrealdb-driver
0.1.0```
### Quick Start
```java
package org.example;import com.surrealdb.connection.SurrealConnection;
import com.surrealdb.connection.SurrealWebSocketConnection;
import com.surrealdb.driver.SyncSurrealDriver;import java.util.List;
public class Main {
public static void main(String[] args) {
SurrealConnection connection = new SurrealWebSocketConnection("127.0.0.1", 8000);
connection.connect(30); // timeout after 30 secondsSyncSurrealDriver driver = new SyncSurrealDriver(connection);
driver.signIn("root", "root"); // username & password
driver.use("test", "test"); // namespace & databasePerson tobie = driver.create("person", new Person("Founder & CEO", "Tobie", "Morgan Hitchcock", true));
List people = driver.select("person", Person.class);
System.out.println();
System.out.println("Tobie = "+tobie);
System.out.println();
System.out.println("people = "+people);
System.out.println();connection.disconnect();
// for more docs, see https://surrealdb.com/docs/integration/libraries/java
}
}class Person {
String id;
String title;
String firstName;
String lastName;
boolean marketing;public Person(String title, String firstName, String lastName, boolean marketing) {
this.title = title;
this.firstName = firstName;
this.lastName = lastName;
this.marketing = marketing;
}@Override
public String toString() {
return "Person{" +
"id='" + id + '\'' +
", title='" + title + '\'' +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", marketing=" + marketing +
'}';
}
}
```### Developing
You can build the project with `./gradlew build`.
Unit tests are run with `./gradlew test`.
Integration tests are run with `./gradlew integrationTest`.
Integration tests depend on having docker installed.The following environment variables can be used to avoid relying on docker.
| ENV | Description |
|--|--|
| SURREALDB_JAVA_HOST | The host address of SurrealDB |
| SURREALDB_JAVA_PORT | The port address of SurrealDB |### Planned Features
- A complete SDK With Repository pattern.
- JDBC interface (work in progress can be found in `src/main/java/com/surrealdb/jdbc`)
- Open an issue for feature requests### Minimum Requirements
- Java 17