yugabyte / jdbc-yugabytedb

JDBC Driver for Yugabyte SQL (YSQL)
BSD 2-Clause "Simplified" License
17 stars 7 forks source link

YugabyteDB JDBC Driver [Deprecated] - Please consider using the new YugabyteDB JDBC Driver from https://github.com/yugabyte/pgjdbc

This is a distributed JDBC driver for YugabyteDB SQL. This driver is based on the PostgreSQL JDBC Driver.

Features

This JDBC driver has the following features:

Cluster Awareness to eliminate need for a load balancer

This driver adds a YBClusterAwareDataSource that requires only an initial contact point for the YugabyteDB cluster, using which it discovers the rest of the nodes. Additionally, it automatically learns about the nodes being started/added or stopped/removed. Internally the driver keeps track of number of connections it has created to each server endpoint and every new connection request is connected to the least loaded server as per the driver's view.

Topology Awareness to enable geo-distributed apps

This is similar to 'Cluster Awareness' but uses those servers which are part of a given set of geo-locations specified by topology-keys.

Shard awareness for high performance

NOTE: This feature is still in the design phase.

Connection Properties added for load balancing

Please refer to the [Use the Driver](#Use the Driver) section for examples.

Get the Driver

From Maven

Either add the following lines to your maven project in pom.xml file.

<dependency>
  <groupId>com.yugabyte</groupId>
  <artifactId>jdbc-yugabytedb</artifactId>
  <version>42.2.7-yb-5-beta.5</version>
</dependency>

or you can visit to this link for the latest version of dependency: https://search.maven.org/artifact/com.yugabyte/jdbc-yugabytedb

Build locally

  1. Build environment

    gpgsuite needs to be present on the machine where build is performed.

    https://gpgtools.org/

    Please install gpg and create a key.

  2. Clone this repository.

    git clone https://github.com/yugabyte/jdbc-yugabytedb.git && cd jdbc-yugabytedb
  3. Build and install into your local maven folder.

     mvn clean install -DskipTests
  4. Finally, use it by adding the lines below to your project.

    <dependency>
        <groupId>com.yugabyte</groupId>
        <artifactId>jdbc-yugabytedb</artifactId>
        <version>42.2.7-yb-6-SNAPSHOT</version>
    </dependency> 

    Note: You need to have installed 2.7.2.0-b0 or above version of YugabyteDB on your system for load balancing to work.

Use the Driver