Java
Supported projects
The following projects can be used to implement Java applications using the YugabyteDB YSQL and YCQL APIs.
Driver | Documentation and Guides | Latest Driver Version | Supported YugabyteDB Version |
---|---|---|---|
YugabyteDB JDBC Driver [Recommended] | Documentation Blog Reference |
42.3.5-yb-1 | 2.8 and above |
PostgreSQL JDBC Driver | Documentation Reference |
42.3.4 | 2.4 and above |
Vert.x Pg Client | Documentation | 4.3.2 | |
YugabyteDB YCQL (3.10) Driver | Documentation Reference |
3.10.3-yb-2 | |
YugabyteDB YCQL (4.6) Driver | Documentation Reference |
4.6.0-yb-11 |
Projects | Documentation and Guides | Example Apps |
---|---|---|
Hibernate ORM | Documentation Hello World Blog |
Hibernate ORM App |
Spring Data JPA | Documentation Hello World Blog |
Spring Data JPA App |
Ebean ORM | Documentation Hello World Blog |
Ebean ORM App |
MyBatis ORM | Documentation Hello World |
MyBatis ORM App |
Spring Data YugabyteDB | Documentation Blog |
Spring Data YugabyteDB Sample App |
Learn how to establish a connection to a YugabyteDB database and begin basic CRUD operations by referring to Connect an app or Use an ORM.
For reference documentation, including using projects with SSL, refer to the drivers and ORMs reference pages.
Prerequisites
To develop Java driver applications for YugabyteDB, you need the following:
-
Java Development Kit (JDK)
Install JDK 8 or later. JDK installers for Linux and macOS can be downloaded from Oracle, Adoptium (OpenJDK), or Azul Systems (OpenJDK). Homebrew users on macOS can install using
brew install openjdk
. -
Create a Java project
You can create Java projects using Maven or Gradle software project management tools. For ease-of-use, use an integrated development environment (IDE) such as IntelliJ IDEA or Eclipse IDE to configure Maven or Gradle to build and run your project.
If you are not using an IDE, see Building Maven or Creating New Gradle Projects for more information on how to set up a Java project.
-
Create a project called "DriverDemo".
$ mvn archetype:generate \ -DgroupId=com.yugabyte \ -DartifactId=DriverDemo \ -DarchetypeArtifactId=maven-archetype-quickstart \ -DinteractiveMode=false $ cd DriverDemo
-
Open the pom.xml file in a text editor and add the following below the
<url>
element.<properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties>
If you're using Java 11, it should be:
<properties> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> </properties>
-
-
YugabyteDB cluster
- Create a free cluster on YugabyteDB Managed. Refer to Use a cloud cluster. Note that YugabyteDB Managed requires SSL.
- Alternatively, set up a standalone YugabyteDB cluster by following the steps in Install YugabyteDB.