• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Parameter Index out of range !

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All
Consider the following code:

The above method is in from the Bean class and is being called from servlet. This is actually to fetch data from database and display on the browser. Am using JSP and JSTL to display on the browser. Now my problem is am getting "Parameter index out of range(2) number of parameters which is (1)" error on the tomcat console. Am not able to trace out the problem in this code. Can anyone tell me the origin of the error and how to handle it?

And one more issue is, I have given 2 queries(query1, query2) to execute. I actually wanted to combine those 2 queries to a single query but din't knew how. I mean how to combine 2 select statements? Can I write 2 separate queries to fetch data? Is my code correct?
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Swapna ,

I did not see code completely but give you some tips

look at your code below



For each query you should have either a separate variable of prepared statement or use then one by for each queries.


you should have something like




now when you are setting the value for place holder ? then for each prepared statement it should start from 1





I mean how to combine 2 select statements?




You should check relationship between tables, It there is any relationship available, you can use joins.


Shailesh
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic