Skip to content
JDBC Driver for Yugabyte SQL (YSQL)
Java Other
  1. Java 98.8%
  2. Other 1.2%
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Import pgjdbc code as of the following commit: Sep 23, 2019
.travis Import pgjdbc code as of the following commit: Sep 23, 2019
certdir
docs Import pgjdbc code as of the following commit: Sep 23, 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
ybjdbc [maven-release-plugin] prepare for next development iteration Oct 4, 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 Sep 27, 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 4, 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

README.md

YSQL 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 YugaByte 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>ysql</artifactId>
    <version>42.2.7-yb-1</version>
</dependency>

Build locally

  1. Clone this repository.

    git clone https://github.com/yugabyte/ybjdbc.git && cd ybjdbc
    
  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>ysql</artifactId>
        <version>42.2.7-yb-2-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.