Skip to content

Commit 94ae140

Browse files
committed
improve JDBC docs
1 parent 045f367 commit 94ae140

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

docs/guide_db.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ First complete the [installation instructions](index.md).
2121
=== "Java"
2222
```java
2323
import java.sql.*;
24+
import org.sqlite.SQLiteConfig;
2425
import net.mlin.genomicsqlite.GenomicSQLite;
2526
```
2627

@@ -102,14 +103,14 @@ First complete the [installation instructions](index.md).
102103

103104
=== "Java"
104105
```java
105-
java.util.Properties config = new java.util.Properties();
106-
config.setProperty("genomicsqlite.config_json", "{}");
107-
// Properties may originate from org.sqlite.SQLiteConfig.toProperties()
108-
// with genomicsqlite.config_json added in.
106+
SQLiteConfig config = new SQLiteConfig();
107+
// config.setReadOnly(true)
108+
// (or other sqlite-jdbc settings as needed)
109+
java.util.Properties props = config.toProperties();
110+
props.setProperty("genomicsqlite.config_json", "{}");
109111

110112
Connection dbconn = DriverManager.getConnection(
111-
"jdbc:genomicsqlite:" + dbfileName,
112-
config
113+
"jdbc:genomicsqlite:" + dbfileName, props
113114
);
114115
```
115116

docs/index.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,23 @@ It's usually easiest to obtain the extension as a pre-compiled shared library (L
6565
</dependency>
6666
</dependencies>
6767
```
68-
Or, download the JAR from [GitHub Releases](https://github.com/mlin/GenomicSQLite/releases) and place it in your classpath, along with [sqlite-jdbc](https://github.com/xerial/sqlite-jdbc)'s JAR which is also required. The package loads a bundled shared library by default. To override the bundled file, set environment variable `LIBGENOMICSQLITE` to a filename.
68+
69+
Or to your `build.gradle`:
70+
```groovy
71+
repositories {
72+
maven {
73+
url 'https://raw.githubusercontent.com/wiki/mlin/GenomicSQLite/mvn-repo/'
74+
}
75+
}
76+
77+
dependencies {
78+
compile group: 'net.mlin', name: 'genomicsqlite-jdbc', version: 'vX.Y.Z'
79+
}
80+
```
81+
82+
Alternatively, download the JAR from [GitHub Releases](https://github.com/mlin/GenomicSQLite/releases) and place it in your classpath, along with [sqlite-jdbc](https://github.com/xerial/sqlite-jdbc)'s JAR which is also required. The package loads a bundled shared library by default. To override the bundled file, set environment variable `LIBGENOMICSQLITE` to a filename.
83+
84+
To bundle GenomicSQLite and sqlite-jdbc inside an "Uber JAR" for your application, you may need to enable the [ServicesResourceTransformer for Maven Shade](https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#ServicesResourceTransformer) or [mergeServiceFiles() for Gradle Shadow](https://stackoverflow.com/questions/32887966/shadow-plugin-gradle-what-does-mergeservicefiles-do), to ensure the JDBC drivers will be registered automatically when the "Uber JAR" loads.
6985

7086
Recommendation: *also* install the Python package, which includes a useful command-line shell and smoke-test script.
7187

0 commit comments

Comments
 (0)