Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Mike London
Ranch Hand
Posts: 1185
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic