| Author |
[Solved] Preparedstatement not returning any results
|
Hans ter Wal
Greenhorn
Joined: Oct 01, 2003
Posts: 12
|
|
[Update] Seemed that the data type of one of fields was CHAR and wasn't all the way up with appended with spaces, somehow a statement does this automatically. Hans Hi everyone, I'm having some problems with one of my preparedStatements, which used to work fine some time ago, but now seem to be giving me a no result. The strange thing is that when I use a normal statement I get a result back, or if I use a another preparedStatement it works fine. The database is Oracle and the appserver is websphere 5, I'm not getting any exceptions just an empty resultset. I've there is anyone who can give me some insight I would be much appreciated!! Regards, Hans ter Wal PS The are 10 spaces included in the T$ITEM But the browser only shows one ======= Statement 1 - the problem giving one ============= .... ps = c.prepareStatement( "SELECT T$AMNT, T$PERC FROM TTDSLS911100 WHERE T$BDNO = ? AND ( T$ITEM = ? OR T$CPRG = ? ) AND T$STDT <= sysdate AND sysdate <= T$EDDT", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); ps.setString(1, "testbid"); ps.setString(2, " C1806A"); //10 spaces included in the T$ITEM ps.setString(3, "237113"); rs = ps.executeQuery(); if (rs.first()) { out.println("yeaha<br>"); } else { out.println("grrrrrE<br>"); } .... Result: grrrrrrE ======= Statement 2 - No problem statemen ============= ... stmt = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = stmt.executeQuery("SELECT T$AMNT, T$PERC FROM TTDSLS911100 WHERE T$BDNO = "testbid" AND ( T$ITEM = " C1806A" OR T$CPRG = "237113" ) AND T$STDT <= sysdate AND sysdate <= T$EDDT");//10 spaces included in the T$ITEM if (rs.first()) { out.println("yeaha<br>"); } else { out.println("grrrrrE<br>"); } ... Result: Yeaha =================== Statement 3 no prob statement ======== ... ps = c.prepareStatement( "SELECT TTIITM001100.T$VOOR FROM TTIITM001100 WHERE TTIITM001100.T$ITEM = ?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); ps.setString(1, " C1806A");//10 spaces included in the T$ITEM rs = ps.executeQuery(); if (rs.first()) { out.println("yeaha<br>"); } else { out.println("grrrrrE<br>"); } ... Result: Yeaha [ October 23, 2003: Message edited by: Hans ter Wal ] [ October 24, 2003: Message edited by: Hans ter Wal ]
|
SCJP & SCWCD
|
 |
 |
|
|
subject: [Solved] Preparedstatement not returning any results
|
|
|