Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Empty ResultSet when query should produce one result

843859Jan 25 2007 — edited Jan 26 2007
Hi, hopefully there is a really smart person here who can shed some light on an issue that has been bothering my team. .

We connect to an Oracle 10g database using prepared statements and for some reason the result when using java differ from when you put the query in the database client (Oracle SQL Developer).

when we run this query in the client it results in one row. But the result in the code will turn the if ( rs.next() ) statement false.

executeQuery(SELECT <snip> FROM BOOKABLE_UNIT bu, BOOKABLE_UNIT_PUBLISH bup, MUS_WC_CC_ASSIGNMENT wccc WHERE bu.BOOKABLE_UNIT_ID=bup.BOOKABLE_UNIT_ID(+) AND bu.COST_CENTER = wccc.COST_CENTER (+) and SYSDATE >= wccc.START_DATE (+) and bu.START_DATE < wccc.END_DATE (+) AND bu.BOOKABLE_UNIT_ID = 470550 AND (bu.START_DATE<= '2007-01-25' AND (bu.END_DATE>='2007-01-30' OR bu.END_DATE IS NULL)) ORDER BY bu.START_DATE DESC )

this is a part of the code:

ps = con.prepareStatement(SQL_FIND_VERSION_BY_ID_AND_DATE);
ps.setLong(1, buId);
ps.setDate(2, querySDate);
ps.setDate(3, queryEDate);
rs = ps.executeQuery();
if (rs.next()) {
result = this.createDTO(rs);
}

That's regrettably all info I can give. Anyone recognize this situation and can give me a clue about what's wrong? The query gives perfect result when used in other contexts and all variables are nullified in the beginning of the method so no crap should be staying... It's just in one instance it refuses to produce the logical result.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 23 2007
Added on Jan 25 2007
9 comments
2,719 views