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.
Getting started with JDBCX is a breeze. Just download it from GitHub Releases or Maven Central, add it to your classpath, and modify your JDBC connection string by replacing jdbc:
with jdbcx:
. For PRQL over SQL, simply switch to jdbcx:prql:
to activate the extension.
# SQL
docker run --rm -it -e VERBOSE=true jdbcx/jdbcx \
'jdbcx:derby:memory:x;create=true' 'select * from SYS.SYSTABLES'
# Scripting
docker run --rm -it -e VERBOSE=true jdbcx/jdbcx \
'jdbcx:script:derby:memory:x;create=true' \
'helper.format("SELECT * FROM %s.%s", "SYS", "SYSTABLES")'
# PRQL
docker run --rm -it -e VERBOSE=true jdbcx/jdbcx \
'jdbcx:prql:derby:memory:x;create=true' 'from `SYS.SYSTABLES`'
# Shell
docker run --rm -it -e VERBOSE=true jdbcx/jdbcx \
'jdbcx:shell:derby:memory:x;create=true' 'echo "select * from SYS.SYSTABLES"'
# Download latest JDBCX from https://github.com/jdbcx/jdbcx/releases
# or use nightly build at https://s01.oss.sonatype.org/content/repositories/snapshots/io/github/jdbcx/jdbcx-driver/
wget -O jdbcx.jar $(curl -sL https://api.github.com/repos/jdbcx/jdbcx/releases/latest \
| grep "browser_download_url.*jdbcx-driver.*.jar" | tail -1 \
| cut -d : -f 2,3 | tr -d \")
# Download Apache Derby embedded database and its JDBC driver
wget https://repo1.maven.org/maven2/org/apache/derby/derby/10.16.1.1/derby-10.16.1.1.jar \
https://repo1.maven.org/maven2/org/apache/derby/derbyshared/10.16.1.1/derbyshared-10.16.1.1.jar
# Download JavaScript engine
wget https://repo1.maven.org/maven2/org/mozilla/rhino/1.7.14/rhino-1.7.14.jar \
https://repo1.maven.org/maven2/org/mozilla/rhino-engine/1.7.14/rhino-engine-1.7.14.jar
# SQL
java -Dverbose=true -jar jdbcx.jar 'jdbcx:derby:memory:x;create=True' 'select * from SYS.SYSTABLES'
# Scripting
java -Dverbose=true -jar jdbcx.jar 'jdbcx:script:derby:memory:x;create=True' \
'helper.format("SELECT * FROM %s.%s", "SYS", "SYSTABLES")'
# PRQL
cargo install prqlc
java -Djdbcx.prql.cli.path=~/.cargo/bin/prqlc -Dverbose=true -jar jdbcx.jar \
'jdbcx:prql:derby:memory:x;create=True' 'from `SYS.SYSTABLES`'
# Together on a database in cloud
wget https://repo1.maven.org/maven2/com/clickhouse/clickhouse-jdbc/0.4.6/clickhouse-jdbc-0.4.6-http.jar
cat << 'EOF' > my.js
helper.format(
"select '%s' conn, arrayJoin(splitByChar('\\n', '%s')) result",
conn, // current java.sql.Connection instance
helper.escapeSingleQuote(helper.cli("~/.cargo/bin/prqlc", "-h"))
)
EOF
java -Djdbcx.custom.classpath=`pwd` -Dverbose=true -jar jdbcx.jar \
'jdbcx:script:ch://explorer@play.clickhouse.com:443?ssl=true' @my.js
Due to dbeaver/dbeaver#19165, you have to edit existing driver settings by adding jdbcx-driver
jar file. Alternatively, you may follow instructions below to setup a new database driver.