Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SimpleJdbcDaoSupport

 
Mark Hughes
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

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

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??

best
Mark
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mark Hughes
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok Thanks for your help.

Best
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic