aspose file tools*
The moose likes Other Application Frameworks and the fly likes passing parameters to sql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "passing parameters to sql" Watch "passing parameters to sql" New topic
Author

passing parameters to sql

Ruchee Goyal
Greenhorn

Joined: Sep 12, 2006
Posts: 12
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);
Herman Schelti
Ranch Hand

Joined: Jul 17, 2006
Posts: 387
hi Rachee,

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



and


Herman
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

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.
 
 
subject: passing parameters to sql