Win a copy of Functional Design and Architecture this week in the Functional programming 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

SimpleJdbcDaoSupport

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok Thanks for your help.

Best
Mark
 
rubbery bacon. rubbery tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic