Skip to content
JDBC Driver for Yugabyte SQL (YSQL)
Java Other
  1. Java 98.8%
  2. Other 1.2%
Branch: master
Clone or download
Latest commit 7be91ec Dec 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
.travis Import pgjdbc code as of the following commit: Sep 23, 2019
certdir Import pgjdbc code as of the following commit: Sep 23, 2019
docs Import pgjdbc code as of the following commit: Sep 23, 2019
examples Update Readme.adoc Dec 5, 2019
jdbc-yugabytedb [maven-release-plugin] prepare for next development iteration Oct 28, 2019
packaging Import pgjdbc code as of the following commit: Sep 23, 2019
test-anorm-sbt Import pgjdbc code as of the following commit: Sep 23, 2019
.editorconfig Import pgjdbc code as of the following commit: Sep 23, 2019
.gitattributes Import pgjdbc code as of the following commit: Sep 23, 2019
.gitignore Import pgjdbc code as of the following commit: Sep 23, 2019
.travis.yml Import pgjdbc code as of the following commit: Sep 23, 2019
CHANGELOG.md Import pgjdbc code as of the following commit: Sep 23, 2019
CONTRIBUTING.md Import pgjdbc code as of the following commit: Sep 23, 2019
LICENSE Import pgjdbc code as of the following commit: Sep 23, 2019
README.md Update README.md Dec 4, 2019
TESTING.md Import pgjdbc code as of the following commit: Sep 23, 2019
appveyor.yml Import pgjdbc code as of the following commit: Sep 23, 2019
backend_protocol_v4_wanted_features.md Import pgjdbc code as of the following commit: Sep 23, 2019
build.properties Import pgjdbc code as of the following commit: Sep 23, 2019
codecov.yml Import pgjdbc code as of the following commit: Sep 23, 2019
contributors.json Import pgjdbc code as of the following commit: Sep 23, 2019
pom.xml [maven-release-plugin] prepare for next development iteration Oct 28, 2019
release_notes.sh Import pgjdbc code as of the following commit: Sep 23, 2019
release_notes_filter.pl Import pgjdbc code as of the following commit: Sep 23, 2019
release_stage.sh Import pgjdbc code as of the following commit: Sep 23, 2019
settings.xml Import pgjdbc code as of the following commit: Sep 23, 2019
ssltest.properties Import pgjdbc code as of the following commit: Sep 23, 2019
toolchains.xml Import pgjdbc code as of the following commit: Sep 23, 2019

README.md

YugabyteDB JDBC Driver

JDBC driver for YugaByte YSQL. Based on the PostgreSQL JDBC Driver. This driver adds a YBClusterAwareDataSource that requires only an initial contact point for the YugabyteDB cluster. Then it discovers the rest of the nodes and automatically responds to nodes being started/added or stopped/removed. Internally it maintains a connection pool for each node and it will choose a live node to get a connection. Then, whenever the connection is closed it will be returned to the respective pool.

Get the Driver

From Maven

Add the following lines to your maven project.

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

Build locally

  1. Clone this repository.

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

     mvn clean install -DskipTests
    
  3. 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-3-SNAPSHOT</version>
    </dependency> 

Use the Driver

  • Create the DataSource by passing an initial contact point

    String jdbcUrl = "jdbc:postgresql://127.0.0.1:5433/yugabyte";
    YBClusterAwareDataSource ds = new YBClusterAwareDataSource(jdbcUrl);
    
  • Use like a regular (pooling) DataSource

    // Using try-with-resources to auto-close the connection when done.
    try (Connection connection = ds.getConnection()) {
        // Use the connection as usual.
    } catch (java.sql.SQLException e) {
        // Handle/Report error.
    }
    
You can’t perform that action at this time.