Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

SimpleJdbcDaoSupport

 
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
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • 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
 
this is supposed to be a surprise, but it smells like a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic