cancel
Showing results for 
Search instead for 
Did you mean: 

MSSQL DB, bigint, preparedStatement

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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.