org.itsallcode.jdbc.dialect.H2Dialect Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simple-jdbc Show documentation
Show all versions of simple-jdbc Show documentation
Library to simplify using JDBC
package org.itsallcode.jdbc.dialect;
import java.time.LocalDate;
import java.time.LocalTime;
import org.itsallcode.jdbc.resultset.generic.ColumnMetaData;
/**
* DB dialect for the H2 database.
*/
public class H2Dialect extends BaseDbDialect {
/**
* Create a new instance.
*/
public H2Dialect() {
super("jdbc:h2:");
}
@Override
public ColumnValueExtractor createExtractor(final ColumnMetaData column) {
return switch (column.type().jdbcType()) {
case TIMESTAMP -> Extractors.timestampToUTCInstant();
case TIMESTAMP_WITH_TIMEZONE -> Extractors.timestampToInstant();
case CLOB -> Extractors.clobToString();
case BLOB -> Extractors.blobToBytes();
case TIME -> Extractors.forType(LocalTime.class);
case DATE -> Extractors.forType(LocalDate.class);
default -> Extractors.generic();
};
}
}