SQL on JSON


License

License

Categories

Categories

JSON Data
GroupId

GroupId

com.github.terma
ArtifactId

ArtifactId

sql-on-json
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

SQL on JSON
SQL on JSON
Project URL

Project URL

https://github.com/terma/sql-on-json
Source Code Management

Source Code Management

https://github.com/terma/sql-on-json

Download sql-on-json

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.terma/sql-on-json/ -->
<dependency>
    <groupId>com.github.terma</groupId>
    <artifactId>sql-on-json</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.terma/sql-on-json/
implementation 'com.github.terma:sql-on-json:2.0.0'
// https://jarcasting.com/artifacts/com.github.terma/sql-on-json/
implementation ("com.github.terma:sql-on-json:2.0.0")
'com.github.terma:sql-on-json:jar:2.0.0'
<dependency org="com.github.terma" name="sql-on-json" rev="2.0.0">
  <artifact name="sql-on-json" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.terma', module='sql-on-json', version='2.0.0')
)
libraryDependencies += "com.github.terma" % "sql-on-json" % "2.0.0"
[com.github.terma/sql-on-json "2.0.0"]

Dependencies

compile (3)

Group / Artifact Type Version
com.google.code.gson : gson jar 2.3.1
org.apache.commons : commons-lang3 jar 3.5
org.hsqldb : hsqldb jar 2.3.5

test (2)

Group / Artifact Type Version
com.h2database : h2 jar 1.4.195
junit : junit jar 4.10

Project Modules

There are no modules declared in this project.

sql-on-json

Build Status Maven Central

How to use

try (Connection c = new SqlOnJson().convertPlain("{a:[{id:12000,name:\"super\"},{id:90,name:\"remta\"}]}")) {
    ResultSet rs = c.prepareStatement("select * from a").executeQuery();
    while (rs.next()) {
        // my business logic
    }
}

Use non default DB

By default sql-on-json uses HSQLDB

final SqlOnJson sqlOnJson = new SqlOnJson("driver-class", "url", "user", "password");
try (Connection c = sqlOnJson.convertPlain("{a:[{id:12000,name:\"super\"},{id:90,name:\"remta\"}]}")) {
    ...
}

For example you can use H2

final SqlOnJson sqlOnJson = new SqlOnJson("org.h2.Driver", "jdbc:h2:mem:", "", "");
try (...)

To make DB URL unique per new SqlOnJson(...) you can use placeholder <INSTANCE_ID> in second parameter of constructor url, for HSQLDB it will be jdbc:hsqldb:mem:sql_on_json_<INSTANCE_ID>;shutdown=true

Versions

Version
2.0.0
1.0.1
1.0.0
0.0.4
0.0.3
0.0.2