Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

How to implement retries in JDBC template?

$
0
0
I have an app using NamedParameterJdbcTemplate to run some queries. It's been working reasonably well.

Today I discovered that one of my datasources is failing with an obscure problem when it tries to retrieve data. It doesn't fail all of the time. When the query runs again in a few minutes, it usually succeeds. The DBA is telling me that they're going to fix this soon in the database, but I'd like to see if I can do my own mitigation if this happens again. The SQLException has a specific error code for this, so I should be able to check for it, if I had infrastructure that can do this.

I noticed the JdbcRetryPolicy in Spring Data. This seems like it should be close to what I need, but I can't find any information that describes how I can use this with a vanilla Spring JDBC template. I haven't used Spring Data before. I browsed through the Spring Data ref manual, but I didn't anything obvious that helps me.

Viewing all articles
Browse latest Browse all 297

Trending Articles