• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

counting a subset of records  RSS feed

 
Ranch Hand
Posts: 191
  • 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: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry..........missed  quote marks
 
Sheriff
Posts: 24366
55
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: 191
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul..that did it

Bob M
 
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!