• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Using preparedStatement containing Oracle's to_date

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following query runs fine within sql navigator but when the METHOD containing this query is executed, an empty result set is always returned....any ideas as to why the ResultSet is always empty when this executes?
st = con.prepareStatement("SELECT id " +
"FROM partpohdr " +
"WHERE tradepartnerid = ? " +
"AND dealerid = ? " +
"AND dateentered = TO_DATE(?,'DD-MON-YYYY') " +
"AND ponumber = ? " +
"AND delete_flag = 0");
st.setInt(1, tradePartnerID);
st.setInt(2,dealerID);
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
st.setString(3, dateFormat.format(dateEntered));
st.setString(4,poNumber);
rs = st.executeQuery();
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sara,
Personally, with my environment -- SUN [sparc] Solaris 7, Oracle 8i (8.1.7.4), J2SE 1.4.2_02 and Oracle's JDBC (thin) driver -- I use the "setTimestamp()" method.
Although it was not clear to me from your post, I assume that "dateEntered"
(from the following line of your posted code)




is an instance of class "java.util.Date". If that is correct, then I would use the following code:

Good Luck,
Avi.
 
Sara Watson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Avi, thanks for the advice....
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic