Value cannot be converted to requested type

hi.

can anyone tell me why i get the following error:

[sunm][Oracle JDBC Driver]Value can not be converted to requested type

I get this error when i try to execute a SQL query like the one below:

SELECT * FROM orders WHERE orders.date BETWEEN '20-SEP-05' AND '22-SEP-05'

this is not the exact query i am trying to excute, but serves the purpose of this forum post.

ideally, i'd like to use the "?" parameter instead of the dates written above. the application's user selects a StartDate and EndDate for his search. this should display a list of orders within that date range.

i have tried using several date formats, as well as the TO_DATE() function. i always get this error when using the "?" parameter but it displays the correct records when i use an actual date.

i also only get this error when working with dates. i can use the "?" parameter with no problems for any other table column.

someone please help!!

[982 byte] By [InfoSysExperts] at [2007-11-26 11:03:11]
# 1

How is the user selecting a start and end date? By using the calendar? You might need to convert the calendar's date into an SQL friendly date. For instance, try this:

somethingRowSet.setObject(1, (new java.sql.Timestamp(((java.util.Date)StartDate.getValue()).getTime()).toString()))

You might also want to try turning on printStatements in the row set's properties. This will cause the row set to print out the parameters to the log file so you can then analyze what exactly the row set is doing.

Hope this helps.

-Jeff

jsr at 2007-7-7 3:17:03 > top of Java-index,Development Tools,Java Tools...