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

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: Logo

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

Facebook photo

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

Connecting to %s