Win a copy of Svelte and Sapper in Action this week in the 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

passing parameters to sql

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm using JdbcTemplate to fetch results from database,
The query is
String envHost = "SELECT * FROM AC_FBCAPP_V WHERE classification IN (?) and hostname IN (select hostname from AC_APPLICATIONS_V where hmaapplicationsid = ?)";

now i've to pass multiple parameters for classification column and a single parameter for hostname column.
How do i do that?
for other queries who need a single parameter only i was using something like:

list = jdbcTemplate.query(envHost, new Object[] {appName}, rowMapper);
 
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Rachee,

If you know that the number of classification columns will be 3, you can try
something like:



and


Herman
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, there is no facility in JDBC for passing multiple parameters they way you want.
You will have to build your sql dynamically with the required number of parameters.
 
it's a teeny, tiny, wafer thin ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic