Giter VIP home page Giter VIP logo

JDBCX

GitHub release (latest SemVer including pre-releases) GitHub release (by tag) Docker Pulls Coverage Sonatype Nexus (Snapshots)

JDBCX enhances the JDBC driver by supporting additional data formats, compression algorithms, object mapping, type conversion, and query languages beyond SQL. It simplifies complex federated queries with dynamic query embedding and remote bridge server connectivity for multiple data sources.

image

Quick Start

Getting started with JDBCX is easy. You can use JDBCX driver, bridge server, or both.

Features

Feature Examples
Chained query
-- ask a question(check out ~/.jdbcx/web/baidu-*.properties for details)
{{ web.baidu-llm(pre.query=web.baidu-auth): who are you? }}

-- get messages of a chat(see ~/.jdbcx/web/m365-*.properties for details)
{{ web.m365-graph(
	pre.query=web.m365-auth,
	result.json.path=value,
	m365.api="chats/<URL encoded chat ID>/messages?$top=50")
}}
Dynamic query
-- https://clickhouse.com/docs/en/sql-reference/aggregate-functions/parametric-functions#retention
{% var(delimiter=;): dates=['2020-01-01','2020-01-02','2020-01-03'] %}
SELECT
    uid,
    retention({{ script: "date='" + ${dates}.join("',date='") + "'" }}) AS r
FROM retention_test
WHERE date IN ({{ script: "'" + ${dates}.join("','") + "'" }})
GROUP BY uid
ORDER BY uid ASC
Multi-language query
{% var: num=3 %}
select {{ script: ${num} - 2 }} one,
    {{ shell: echo 2 }} two,
    {{ db.ch-play: select ${num} }} three
Query substitution
{% var: func=toYear, sdate='2023-01-01' %}
SELECT ${func}(create_date) AS d, count(1) AS c
FROM my_table
WHERE create_date >= ${sdate}
GROUP BY d
Scripting
-- benchmark on ClickHouse
select a[1] `CPU%`, a[2] `MEM(KB)`, a[3] `Elapsed Time(s)`,
	a[4] `CPU Time(s)`, a[5] `User Time(s)`, a[6] `Switches`,
	a[7] `Waits`, a[8] `File Inputs`, a[9] `File Outputs`, a[10] `Swaps`
from (
select splitByChar(',', '{{ shell.myserver(cli.stderr.redirect=true): 
/bin/time -f '%P,%M,%e,%S,%U,%c,%w,%I,%O,%W' du -sh . > /dev/null
}}') a
)

-- runtime inspection
{{ script: helper.table(
  // fields
  ['connection_class_loader', 'current_class_loader', 'context_class_loader'],
  // rows
  [
    [
      Packages.io.github.jdbcx.WrappedDriver.__javaObject__.getClassLoader(),
      helper.getClass().getClassLoader(),
      java.lang.Thread.currentThread().getContextClassLoader()
    ]
  ]
)
}}

Known Issues

# Issue Workaround
1 Query cancellation is not fully supported avoid query like {{ shell: top }}
2 Scripting does not work on DBeaver use JDK instead of JRE
3 Connection pooling is not supported -
4 Multi-ResultSet is not fully supported -
5 Nested query is not supported -

Performance

Test Environment

  • JDK: openjdk version "17.0.7" 2023-04-18
  • Tool: Apache JMeter 5.6.2
  • Database: ClickHouse 22.8
  • JDBC Driver: clickhouse-jdbc v0.4.6

Test Configuration

  • Concurrent Users: 20
  • Loop Count: 1000
  • Connection Pool:
    • Size: 30
    • Init SQL and Validation Query are identical

Test Results

Connection Init SQL Test Query Avg Response Time (ms) Max Response Time (ms) Throughput (qps)
jdbc:ch select * from system.numbers limit 1 select * from system.numbers limit 50000 69 815 279.87
jdbcx:ch select * from system.numbers limit 1 select * from system.numbers limit 50000 71 891 272.99
jdbcx:script:ch 'select * from system.numbers limit 1' 'select * from system.numbers limit ' + 50000 72 1251 270.65
jdbcx:shell:ch echo 'select * from system.numbers limit 1' echo 'select * from system.numbers limit 50000' 91 650 214.45
jdbcx:prql:ch from `system.numbers` | take 1 from `system.numbers` | take 50000 106 1103 184.27

JDBCX's Projects

jdbcx icon jdbcx

JDBCX: Extended JDBC driver for dynamic multi-language queries with optional bridge server for federated datasource connectivity.

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.