Nebula Java is a Java client for developers to connect their projects to Nebula Graph.
NOTE: Nebula Java is not thread-safe.
In this repository, you can find two branches for the source code of Nebula Java of different versions.
The master branch is for Nebula Java v2.0, which works with Nebula Graph v2.0 only.
This README file provides Java developers with instructions on how to connect to Nebula Graph v2.0.
In the v1.0 branch, you can find source code of these:
- Nebula Java v1.0, which works with Nebula Graph v1.1.0 and earlier versions only.
- Nebula Graph Exchange, Nebula Spark Connector, Nebula Flink Connector, and nebula-algorithm.
For more information, see README of v1.0.
To use this Java client, do a check of these:
- Java 8 or a later version is installed.
- Nebula Graph v2.0 is deployed. For more information, see Deployment and installation of Nebula Graph.
If you use Maven to manage your project, add the following dependency to your pom.xml
file. Replace 2.0.0-rc1
with an appropriate Nebula Java v2.x version. For more versions, visit releases.
<dependency>
<groupId>com.vesoft</groupId>
<artifactId>client</artifactId>
<version>2.0.0-rc1</version>
</dependency>
To connect to the nebula-graphd
process of Nebula Graph v2.0:
NebulaPoolConfig nebulaPoolConfig = new NebulaPoolConfig();
nebulaPoolConfig.setMaxConnSize(10);
List<HostAddress> addresses = Arrays.asList(new HostAddress("127.0.0.1", 3699),
new HostAddress("127.0.0.1", 3700));
NebulaPool pool = new NebulaPool();
pool.init(addresses, nebulaPoolConfig);
Session session = pool.getSession("root", "nebula", false);
session.execute("SHOW HOSTS;");
session.release();
pool.close();