Spring JDBC Template

queryForObject() should return null instead of throwing an Exception

License

License

GroupId

GroupId

cn.danielw
ArtifactId

ArtifactId

spring-jdbc-template
Last Version

Last Version

0.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

Spring JDBC Template
queryForObject() should return null instead of throwing an Exception
Project URL

Project URL

https://github.com/DanielYWoo/spring-jdbc-template
Source Code Management

Source Code Management

https://github.com/DanielYWoo/spring-jdbc-template

Download spring-jdbc-template

How to add to project

<!-- https://jarcasting.com/artifacts/cn.danielw/spring-jdbc-template/ -->
<dependency>
    <groupId>cn.danielw</groupId>
    <artifactId>spring-jdbc-template</artifactId>
    <version>0.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/cn.danielw/spring-jdbc-template/
implementation 'cn.danielw:spring-jdbc-template:0.2.1'
// https://jarcasting.com/artifacts/cn.danielw/spring-jdbc-template/
implementation ("cn.danielw:spring-jdbc-template:0.2.1")
'cn.danielw:spring-jdbc-template:jar:0.2.1'
<dependency org="cn.danielw" name="spring-jdbc-template" rev="0.2.1">
  <artifact name="spring-jdbc-template" type="jar" />
</dependency>
@Grapes(
@Grab(group='cn.danielw', module='spring-jdbc-template', version='0.2.1')
)
libraryDependencies += "cn.danielw" % "spring-jdbc-template" % "0.2.1"
[cn.danielw/spring-jdbc-template "0.2.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.springframework : spring-jdbc jar 4.3.6.RELEASE

test (3)

Group / Artifact Type Version
junit : junit jar 4.11
org.mockito : mockito-core jar 2.7.10
com.h2database : h2 jar 1.4.193

Project Modules

There are no modules declared in this project.

Build Status

spring-jdbc-template

Spring jdbc template throws EmptyResultDataAccessException when no result is found, but 99.99% of developers expect NULL, right? This is a very simple wrapper for JdbcTemplate and NamedParameterJdbcTemplate, but returns null for queryForObject() methods.

usage

Exactly like Spring JdbcTemplate, actually it's a subclass of it.

e.g.

 int value = new JdbcTemplate(dataSource).queryForInt("select age from user where id=?", id);
 User u = new NamedParameterJdbcTemplate(dataSource).queryForObject(
    "select * from user where id=:id", params, rowMapper);

Versions

Version
0.2.1