Wrapper to simplify working with JDBC.
This project is at an early development stage and the API will change without backwards compatibility.
This project requires Java 17 or later.
Add dependency to your gradle project:
dependencies {
implementation 'org.itsallcode:simple-jdbc:0.7.0'
}
record Name(int id, String name) {
Object[] toRow() {
return new Object[] { id, name };
}
}
ConnectionFactory connectionFactory = ConnectionFactory.create();
try (SimpleConnection connection = connectionFactory.create("jdbc:h2:mem:", "user", "password")) {
connection.executeScript(readResource("/schema.sql"));
connection.insert("NAMES", List.of("ID", "NAME"), Name::toRow,
Stream.of(new Name(1, "a"), new Name(2, "b"), new Name(3, "c")));
try (SimpleResultSet<Row> rs = connection.query("select * from names order by id")) {
List<Row> result = rs.stream().toList();
assertEquals(3, result.size());
assertEquals(1, result.get(0).get(0).value());
}
}
./gradlew dependencyUpdates
Install to local maven repository:
./gradlew clean publishToMavenLocal
To calculate and view test coverage:
./gradlew check jacocoTestReport
open build/reports/jacoco/test/html/index.html
-
Add the following to your
~/.gradle/gradle.properties
:ossrhUsername=<your maven central username> ossrhPassword=<your maven central passwort> signing.keyId=<gpg key id (last 8 chars)> signing.password=<gpg key password> signing.secretKeyRingFile=<path to secret keyring file>
-
Increment version number in
build.gradle
andREADME.md
, update CHANGELOG.md, commit and push. -
Optional: run the following command to do a dry-run:
./gradlew clean check build publishToSonatype closeSonatypeStagingRepository --info
-
Run the following command to publish to Maven Central:
./gradlew clean check build publishToSonatype closeAndReleaseSonatypeStagingRepository --info
-
Create a new release on GitHub.
-
After some time the release will be available at Maven Central.