Skip to Content
author's profile photo Former Member
Former Member

MSSQL DB, bigint, preparedStatement

I'm trying to execute the following prepared statement:

-


pStmnt = connection.prepareStatement("select col1 from table1 where col2 = ?");

pStmnt.setLong(1, 45L);

//col 2 is a 'bigint' on the MSSQL 2000 database, hence setLong.

Resultset rs = pStmnt.executeQuery();

-


I do not get any exceptions, but just an empty resultset. I've verified that the query does return some rows if run from another tool.

If I were to go against an 'int' column or a 'varchar' column as part of the 'where' clause, the query runs just fine!!!

Could there be anything wrong with the 'bigint' type?!

I'm trying to run this on an EP6 SP2 iView.

thanks and your help is always appreciated,

Biju.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Feb 21, 2005 at 11:10 AM

    Hi Biju,

    simply put

    pStmnt.setLong(1, 45);

    because:

    PreparedStatement.setLong(1, 45) will assign the value 45 to the first parameter as a Java long. The driver will convert 45 to a JDBC BIGINT in order to send it to the database. Which JDBC type the driver sends to the database is determined by the standard mapping from Java types to JDBC types.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.