SonicBase. In-memory embedded, standalone or distributed sql database

JDBC Driver

The SonicBase jdbc jar is available from the Maven Central repository. If you are using maven, add the jdbc jar to your project pom.xml file. In the dependencies section add the following:


<dependency>
    <groupId>com.sonicbase</groupId>
    <artifactId>sonicbase-jdbc</artifactId>
    <version>[version]</version>
</dependency>
        
The jdbc version should match your SonicBase server version.

Prerequisites

JDK Requirements

The jvm running the jdbc driver needs to be at least version 8.

Connecting

Include the following line before creating a connection:
    Class.forName("com.sonicbase.jdbcdriver.Driver");

Connect to the database with the following code:
    Connection conn = DriverManager.getConnection("jdbc:sonicbase:<address-0>:<port-0>,<address-1>:<port-1><address-n>:<port-n>/<database name>");

"address-0" thru "address-n" should be the ip addresses of all the replicas of shard 0. Enter all the replicas of the first shard configured in the config file for this cluster. Note that each address/port combination is separated by a comma.

Connection Pool

C3P0 is a good connection pool to use. Below is an example of how to use it:


ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDriverClass("com.sonicbase.jdbcdriver.Driver");
cpds.setJdbcUrl("jdbc:sonicbase:localhost:9010/db");

cpds.setMinPoolSize(5); cpds.setAcquireIncrement(1); cpds.setMaxPoolSize(20);
//aquire connection Connection conn = cpds.getConnection();
//release connection conn.close();