JdbcTemplate details part3

May 12, 2008 at 7:52 pm | Posted in Uncategorized | Leave a comment
Tags: ,

Error translation

Translate java.sql.SqlException to Spring’s data access exception hierarchy.

DataAccessException
Root cause for all dao access exceptions. unchecked exception.
direct parent class is NestedRuntimeException

Native jdbc resource

When you need to work on native jdbc connections instead of spring wrapped connections, providing NativeJdbcExtractor to jdbcTemplate allows you to retrieve native connections. Then, you can cast the connection to the vendor specific connection object.

SingleConnectionDataSource, DriverManagerDataSource

Datasource for testing.

DriverManagerDataSource
Create new connection every time.
useful for test outside of container, based on what API says.

SingleConnectionDataSource
Sub class of DriverManagerDataSource.
Always use the same connection, and not for multi threaded environement.

Transaction Management in JDBC

DatasourceUtils
Utility class to retrieve a connection from spring transaction managers(thread bounded connection).

TransactionAwareDataSourceProxy
Let your datasource participate spring transaction management. reference my other post.

DataSourceTransactionManager
Implementation of PlatformTransactionManager. So, use this as a transaction manager if application solely use datasource. Bind connection to current thread.

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

Blog at WordPress.com.
Entries and comments feeds.

%d bloggers like this: