GithubHelp home page GithubHelp logo

dnault / couchbase-jdbc-driver Goto Github PK

View Code? Open in Web Editor NEW

This project forked from datagrip/couchbase-jdbc-driver

1.0 0.0 0.0 16.63 MB

Minimal implementation of JDBC Driver for Couchbase

License: Apache License 2.0

Java 100.00%

couchbase-jdbc-driver's Introduction

Couchbase N1QL JDBC Driver

This driver supports the Couchbase N1QL query language with some extensions for basic bucket management.

How to build jar

# Linux, MacOs
./gradlew jar

# Windows
gradlew.bat jar

You'll find it in build/libs.

JDBC connection string

jdbc:couchbase:<host1[:port1],host2[:port2],...>[/defaultBucket][?<property1>=<value>&<property2>=<value>&...]

The driver supports a custom Couchbase port mapping, and the specified port should be a key-value service port [11210 by default].

If you are connecting to a pre Couchbase 6.5 cluster, a defaultBucket must be specified in order to properly initialize the connection.

Recognized properties are the following:

  • Recognized by the driver itself
    • user=<username> [required parameter]
    • password=<password> [required parameter]
    • sslenabled=true/false
    • meta.sampling.size=<integer> specifies a number of documents fetched in order to infer a database schema
    • query.scan.consistency=not_bounded/request_plus specifies a query scan consistency (RYW consistency) [default value is not_bounded]
    • loggingLevel [default value is severe]
  • Propagated to a Couchbase cluster
    • The full list of recognized parameters is documented in the Couchbase Client-Settings Documentation. Any client setting with a system property name may also be specified as a connection string parameter (without the com.couchbase.env. prefix).

Extended N1QL statements

This driver supports some extra statements for the N1QL query language. These are for a bucket (keyspace) management (create and drop). Important note: create bucket statement is valid for Couchbase Enterprise edition only.

Create bucket statement

create-bucket ::= CREATE ( BUCKET | TABLE ) [ WITH PRIMARY INDEX ] keyspace-ref [ bucket-with ] 
keyspace-ref ::= [ namespace ':' ] keyspace
bucket-with ::= WITH expr

Where expr is a json object with optional bucket settings:

  • flushEnabled true/false [default is false]
  • ramQuotaMB number [default is 100]
  • replicaNumber number [default is 1]
  • replicaIndexes true/false [default is false]
  • maxTTL number of seconds [default is 0]
  • compressionMode string, one of "off"/"passive"/"active" [default is passive]
  • bucketType string, one of "membase"/"memcached"/"ephemeral" [default is membase]
  • conflictResolutionType string, one of "lww"/"seqno" [default is seqno]
  • evictionPolicy string, one of "fullEviction"/"valueOnly"/"nruEviction"/"noEviction" [default is based on a bucket type]

If WITH PRIMARY INDEX clause is present, a default primary index will be built for the newly created bucket.

Example:

create bucket with primary index bucket_name 
    with { ramQuotaMB: 128, bucketType: "ephemeral" }

Drop bucket statement

drop-bucket ::= DROP ( BUCKET | TABLE ) keyspace-ref
keyspace-ref ::= [ namespace ':' ] keyspace

Example:

drop bucket bucket_name

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.