Win a copy of Microservices in Action this week in the Web Services 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

counting a subset of records  RSS feed

 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table with a particular column named ID

The records in the table have an integer in the field and there may be several records with the same integer value

I am using the following code where Search_ID has just been calculated...........

The program falters on this line and I am unclear why ?

Bob M
 
Bob Matthews
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry..........missed  quote marks
 
Sheriff
Posts: 23885
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to guess that Search_ID is not a column in that database table, and "faltering" means the program crashes because of that error. More information on your problem would be extremely useful.

I see that you are using a PreparedStatement, which is a good first step. But guessing (again) that Search_ID is a variable in your code, or something like that, then the PreparedStatement would look something like this:



Then you would use ps.setInt() to fill in the question mark before executing the SQL.

Hope that helps -- if I'm on the wrong track then by all means help us by providing a full description of the problem.
 
Bob Matthews
Ranch Hand
Posts: 168
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul..that did it

Bob M
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!