SQL Exception: Too few parameters.....

Discussion in 'Java' started by Aaron B., Nov 23, 2004.

  1. Aaron B.

    Aaron B. Guest

    I am experienceing a problem that was already brought up on this group
    five years ago, see http://groups.google.com/groups?hl=...l=en&lr=&q=author:pranubha%40comp.nus.edu.sg+
    To repeat, the problem is as follows. As I'm trying to execute a
    perfect SQL query thru my java program, I get an SQLException, saying:
    "Too few parameters. Expected 2", or sometimes "Expected 1". Someone
    back then suggests to use PreparedStatements instead of normal
    queries. What is that? I need someone to explain it to me. Thanks a
    lot!

    Aaron B.
    Aaron B., Nov 23, 2004
    #1
    1. Advertising

  2. Aaron B.

    thirdrock Guest

    Aaron B. wrote:
    > As I'm trying to execute a
    > perfect SQL query thru my java program, I get an SQLException, saying:
    > "Too few parameters. Expected 2", or sometimes "Expected 1".

    What is happening is that the SQL server is expecting some parameters
    for your query, and you are not providing them.

    > Someone
    > back then suggests to use PreparedStatements instead of normal
    > queries. What is that? I need someone to explain it to me. Thanks a
    > lot!


    You don't have a help file?

    If you were using the mySQL odbc driver, you would find some sample code
    in the documentation that would answer your question, but as you haven't
    even provided information on which sql server you are using, you might
    find help not forthcoming.

    Ian
    thirdrock, Nov 23, 2004
    #2
    1. Advertising

  3. Aaron,

    It happened to me when the query has mispelled column names. When that
    happens, SQL Server tries to use those mispelled names as parameters, and
    it expects that you previously define those parametes.

    Erich

    Aaron B. <> wrote:
    > I am experienceing a problem that was already brought up on this group
    > five years ago, see http://groups.google.com/groups?hl=...l=en&lr=&q=author:pranubha%40comp.nus.edu.sg+
    > To repeat, the problem is as follows. As I'm trying to execute a
    > perfect SQL query thru my java program, I get an SQLException, saying:
    > "Too few parameters. Expected 2", or sometimes "Expected 1". Someone
    > back then suggests to use PreparedStatements instead of normal
    > queries. What is that? I need someone to explain it to me. Thanks a
    > lot!


    > Aaron B.
    Erich Reimberg N., Nov 23, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. geletine

    Too few parameters. Expected 2

    geletine, May 21, 2006, in forum: Java
    Replies:
    3
    Views:
    7,789
    geletine
    May 22, 2006
  2. Trey Guy
    Replies:
    5
    Views:
    128
    Mark Schupp
    Jul 7, 2003
  3. Robert Mark Bram

    Too few parameters to RecordSet.Open?

    Robert Mark Bram, Oct 18, 2003, in forum: ASP General
    Replies:
    2
    Views:
    153
    Robert Mark Bram
    Oct 18, 2003
  4. Miranda
    Replies:
    6
    Views:
    302
    Bob Barrows
    Nov 29, 2003
  5. kbrad
    Replies:
    8
    Views:
    173
    Aaron [SQL Server MVP]
    Sep 29, 2004
Loading...

Share This Page