File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Can you use jdbcTemplate QueryForList with SQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Can you use jdbcTemplate QueryForList with SQL "in" Expression?" Watch "Can you use jdbcTemplate QueryForList with SQL "in" Expression?" New topic
Author

Can you use jdbcTemplate QueryForList with SQL "in" Expression?

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1034
Does the queryForList work when you have an "in" expression in your SQL like this:

Select * from CUSTOMER where CUST_ID in (1,5,7,9)

My question is whether the "in" is supported in queryForList?

We seem to be having problems with it and all the examples I've seen don't use it.

Is there a better JDBCTemplate method to use for multiple "in" values?

Thanks,

mike
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 597

JDBC prepared statements does not supported "in" clause for multiple values due to SQL injection attack security issue

Any code based on prepared statements (JDBC templates) does not support 'IN' clauses in queries.

Here is a good resource that provide alternate approaches
http://www.javaranch.com/journal/200510/Journal200510.jsp#a2


Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can you use jdbcTemplate QueryForList with SQL "in" Expression?
 
Similar Threads
Anyone know where I can find a short explanation of how to use getJdbcTemplate?
spring jdbc and action class
Which framework would be the best ?
Displaying Sql query string results in jsp by using Spring Framework
JDBCTemplate QueryForList returns wrong value