geeky · java

Spring JdbcTemplate to get db function output

e.g. SQL

select myFunction(param1, param2) from dual

returns a String value.

Do this using Spring JdbcTemplate via:

String result = getJdbcTemplate().queryForObject(sql, 
	new Object[] {
		param1, param2
	},
	String.class
);

See any big issue doing it this way? I personally don’t. I assume Spring will throw a SQL exception if for any reason the function errs out?

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s