Skip to content

Latest commit

 

History

History
101 lines (74 loc) · 3.89 KB

README.md

File metadata and controls

101 lines (74 loc) · 3.89 KB

simple-jdbc

Wrapper to simplify working with JDBC.

This project is at an early development stage and the API will change without backwards compatibility.

Java CI CodeQL Quality Gate Status Coverage Reliability Rating Security Rating Vulnerabilities Maven Central

Usage

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());
    }
}

Development

Check if dependencies are up-to-date

./gradlew dependencyUpdates

Building

Install to local maven repository:

./gradlew clean publishToMavenLocal

Test Coverage

To calculate and view test coverage:

./gradlew check jacocoTestReport
open build/reports/jacoco/test/html/index.html

Publish to Maven Central

  1. 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>
  2. Increment version number in build.gradle and README.md, update CHANGELOG.md, commit and push.

  3. Optional: run the following command to do a dry-run:

    ./gradlew clean check build publishToSonatype closeSonatypeStagingRepository --info
  4. Run the following command to publish to Maven Central:

    ./gradlew clean check build publishToSonatype closeAndReleaseSonatypeStagingRepository --info
  5. Create a new release on GitHub.

  6. After some time the release will be available at Maven Central.