JdbcTemplate details part1

May 5, 2008 at 7:41 pm | Posted in Uncategorized | Leave a comment
Tags: ,

JdbcTemplate methods

Data Retrieval

queryForInt(), queryForLong()
expects unique value.

queryForMap()
expects one row. each column is a map key.

queryForList()
expects multiple rows. each entry of list is a map, and the map uses columns as keys.

queryForObject()
expects one row as an instance

query()
expects multiple rows. returns multiple objects. each row becomes one instance.

classes

* PreparedStatementCreator
create prepared statement and bind values

* PreparedStatementSetter
bind values to prepared statement when you want to separate creation of prepared statement binding of values.

* ResultSetExtractor
process entire resultset and return one object. recommended to access resultset stateless

* RowCallbackHandler
process entire resultset statefull. Object which implement this interface will usually used after jdbctemplate call.

* RowMapper
process each result row and construct an object.

Data Manipulation

update()
for insert,update, and delete statement

etc.

execute()
for DDL

JdbcTemplate extensions

* NamedParameterJdbcTemplate
Support named parameter (‘:id’,’:name’), use SqlParameterSource or Map to bind values to named parameters.

* SqlParameterSource
interface that represents keys, values, and sqlTypes for named parameters.

* SimpleJdbcTemplate
use Java5 functions such as vargs and generic.

Advertisements

Leave a Comment »

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.
Entries and comments feeds.

%d bloggers like this: