https://github.com/datagrip/couchbase-jdbc-driver
Minimal implementation of JDBC Driver for Couchbase
https://github.com/datagrip/couchbase-jdbc-driver
couchbase jdbc
Last synced: 6 months ago
JSON representation
Minimal implementation of JDBC Driver for Couchbase
- Host: GitHub
- URL: https://github.com/datagrip/couchbase-jdbc-driver
- Owner: DataGrip
- License: apache-2.0
- Created: 2020-07-02T11:20:12.000Z (over 5 years ago)
- Default Branch: dev
- Last Pushed: 2023-10-11T12:55:29.000Z (over 2 years ago)
- Last Synced: 2025-04-06T09:24:49.579Z (9 months ago)
- Topics: couchbase, jdbc
- Language: Java
- Homepage:
- Size: 16.3 MB
- Stars: 14
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
README
# 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:[/defaultBucket][?=&=&...]
```
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=` [required parameter]
* `password=` [required parameter]
* `sslenabled=true/false`
* `meta.sampling.size=` 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](https://docs.couchbase.com/java-sdk/current/ref/client-settings.html).
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
```