File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Application Frameworks and the fly likes SimpleJdbcDaoSupport Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "SimpleJdbcDaoSupport" Watch "SimpleJdbcDaoSupport" New topic


Mark Hughes
Ranch Hand

Joined: Jul 14, 2006
Posts: 146
Hey Guys,

Im a newbie to SimpleJdbcDaoSupport, and am trying to do a simple select statement from my database table to get one field and return a string as follows.

<pre name="code" class="core">
String query = "SELECT id FROM table WHERE name = 'test'";
ps = getConnection().prepareStatement(query);
rs = ps.executeQuery();
if (
strResult = rs.getString("id");

Now i want to convert the above to use SimpleJdbcDaoSupport and i see SimpleJdbcDaoSupport has getSimpleJdbcTemplate() and getJdbcTemplate() which gives methods such as query but each query method seems to take 2 or more arguemts such as sql and mapping object and returns an object or list, Is there the ability to just give an sql statement and get the returned result as a string?? or equivelent??

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

No, the purpose of these helper classes is to allow you to map the result set back to a java Object. So they will all expect some sort of RowMapper implementation to do this.

GenRocket - Experts at Building Test Data
Mark Hughes
Ranch Hand

Joined: Jul 14, 2006
Posts: 146
ok Thanks for your help.

I agree. Here's the link:
subject: SimpleJdbcDaoSupport
It's not a secret anymore!