Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 598283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:22:19+00:00 2026-05-13T16:22:19+00:00

I’m working on getting our system’s java beans to be able to use the

  • 0

I’m working on getting our system’s java beans to be able to use the SQL IN clause when running queries down through the database, but am running into a perplexing problem.

I am build the SQL query for the PreparedStatement in the following generic pattern:

select [column names] 
from [table name]
where [a column name] IN (?, ? , ?, ..., ?)

The …, represents any number of ?’s depending on the number of values the user is deciding to build into the IN clause. I run a loop to get these into the query string.

From here, I use the PreparedStatement’s setString( idx, String ) method, and iterate through the list of values and run from index 1 – # of values.

The PreparedStatement runs the query via the executeQuery() method and the returned ResultSet seems to be incorrect.

In a specific instance using 4 values, when I take the query in the PreparedStatement to SQL and replace each ? with the exact values in ‘ ‘, I get 3 results (as one of the values is purposely not in the DB).

The ResultSet, on the other hand only has 1 row in its set, and that row always corresponds to the first ? parameter in the IN clause.

I even tried faking the IN clause with ([column name] = ? OR [column name] = ? … OR column name] = ?) but the same issue occurs here too.

Any ideas what is going on here? Connecting to an Oracle database, by the way.

Logs:

2010-02-10 11:16:28,505 DEBUG  basic.BasicCursor - Preparing statement SELECT MERCHANT_ID, M_NAME, M_AUTHEN, M_ADMIN_AUTHEN, M_CONTACT_ADDR, M_PAYMENT_ADDR, M_HAS_MPROXY, M_DISABLED, M_FREETEXT, TXN_ID, M_TAX_NAME, M_TAX_RATE, MERCHANT_PARENT_ID, MERCHANT_ROOT_ID, RESERVED_1, RESERVED_2, RESERVED_3, RESERVED_4, EMAIL, LOGICAL_TYPE, CHANNEL_MASK FROM MERCHANT0 WHERE MERCHANT_ID IN (?, ?, ?, ?)  ORDER BY MERCHANT_ID
2010-02-10 11:16:28,505 DEBUG  basic.BasicCursor - Adding string  to slot 1: 6172222222
2010-02-10 11:16:28,505 DEBUG  basic.BasicCursor - Adding string  to slot 2:  6177740603
2010-02-10 11:16:28,505 DEBUG  basic.BasicCursor - Adding string  to slot 3:  6177740602
2010-02-10 11:16:28,505 DEBUG  basic.BasicCursor - Adding string  to slot 4:  6172441111
2010-02-10 11:16:28,512 DEBUG  basic.BasicCursor - scanCursor() calling... checking for next row. Current row is : 0
2010-02-10 11:16:28,512 DEBUG  basic.BasicCursor - scanCursor() called, hit
2010-02-10 11:16:28,512 DEBUG  basic.BasicCursor - scanCursor() got object 6172222222
2010-02-10 11:16:28,512 DEBUG  basic.BasicCursor - scanCursor() calling... checking for next row. Current row is : 1
2010-02-10 11:16:28,512 DEBUG  basic.BasicCursor - scanCursor() called, not hit
2010-02-10 11:16:28,505 DEBUG  basic.BasicCursor - The size of variables list = 4

EDIT: Found the issues with the PreparedStatement. I’ll leave it as an exercise to those curious to figure it out. It’s visible in the log statements above. Unfortunately, now my problem has cascaded to some annoying proprietary code we have that limits the rows from the now expected ResultSet to displaying only 1 record anyway. sigh

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:22:19+00:00Added an answer on May 13, 2026 at 4:22 pm
    • double-check the complete constructed query and compare that it is actually what you expect
    • double-check that you actually call setString() with different values for the index and the String and that you’re not using the same value over and over again
    • double-check that you’re not calling next() on your ResultSet more than once per loop iteration.
    • edit: System.out.println() and check (and possibly post) the following:
      • The complete SQL query string
      • toString() of the newly created PreparedStatement
      • both parameters of each setString() call and toString() of the PreparedStatement each time you call setString()
      • the return value of next() each time you call it
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 434k
  • Answers 434k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think this is a rendering issue and completely depends… May 15, 2026 at 3:08 pm
  • Editorial Team
    Editorial Team added an answer Because you want your css to be applied to tinymces… May 15, 2026 at 3:08 pm
  • Editorial Team
    Editorial Team added an answer Tiny bug is that you are using incorrect quotes in… May 15, 2026 at 3:08 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.