sqlex-mapper

Map java.sql.SQLException to more a meaningful exceptions hierarchy

License

License

Categories

Categories

Net
GroupId

GroupId

net.bzdyl
ArtifactId

ArtifactId

sqlex-mapper
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

sqlex-mapper
Map java.sql.SQLException to more a meaningful exceptions hierarchy
Project URL

Project URL

https://github.com/pbzdyl/sqlex-mapper
Source Code Management

Source Code Management

https://github.com/pbzdyl/sqlex-mapper

Download sqlex-mapper

How to add to project

<!-- https://jarcasting.com/artifacts/net.bzdyl/sqlex-mapper/ -->
<dependency>
    <groupId>net.bzdyl</groupId>
    <artifactId>sqlex-mapper</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/net.bzdyl/sqlex-mapper/
implementation 'net.bzdyl:sqlex-mapper:0.1.1'
// https://jarcasting.com/artifacts/net.bzdyl/sqlex-mapper/
implementation ("net.bzdyl:sqlex-mapper:0.1.1")
'net.bzdyl:sqlex-mapper:jar:0.1.1'
<dependency org="net.bzdyl" name="sqlex-mapper" rev="0.1.1">
  <artifact name="sqlex-mapper" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.bzdyl', module='sqlex-mapper', version='0.1.1')
)
libraryDependencies += "net.bzdyl" % "sqlex-mapper" % "0.1.1"
[net.bzdyl/sqlex-mapper "0.1.1"]

Dependencies

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.assertj : assertj-core jar 3.3.0

Project Modules

There are no modules declared in this project.

sqlex-mapper

Map java.sql.SQLException to a more meaningful exceptions hierarchy

Exception handling in JDBC is not easy. It provides base java.sql.SQLException with getSQLState and getErrorCode information but it's vendor specific and cumbersome to use. Yes, JDBC 4 (since Java 6) provides some improvements (additional exception hierarchy including classes like java.sql.SQLIntegrityConstraintViolationException etc.). Unfortunately not all SQL vendors catched up with those improvements (e.g. PostgreSQL still uses a single class for all kinds of errors).

This projects borrows the idea and code from Spring Framework. It provides simplified version of SQLExceptionTranslator - SqlExceptionMapper.

The default implementation of SqlExceptionMapper provides translation similar to SQLErrorCodeSQLExceptionTranslator and uses the same error codes mapping.

This is a very early version and API can still change.

Credits

Big 'thank you' goes to Spring Framework team for their implementation.

License

This project is released under version 2.0 of the [Apache License][].

Versions

Version
0.1.1
0.1.0