I am running the same select query on the same database using the same code but using 2 different app servers.
Query: Find a certian day’s entries in a journal.
1) Existing legacy app server (BroadVision running on unix):
Select title, content from journal where entry_date = TO_DATE(?, ‘DD/MM/YY HH24:MI:SS’);
DEBUG:core.StatementCreatorUtils:Setting SQL statement parameter value: column index 1, parameter value [Thu Sep 29 14:32:58 IST 2011], value class [java.util.Date], SQL type unknown
This works fine
2) JBoss app server (Running on windows):
Select title, content from journal where entry_date = TO_DATE(?, ‘DD/MM/YY HH24:MI:SS’);
DEBUG:core.StatementCreatorUtils:Setting SQL statement parameter value: column index 1, parameter value [Thu Sep 29 14:41:26 IST 2011], value class [java.util.Date], SQL type unknown
ORA-01858: a non-numeric character was found where a numeric was expected
Any ideas how to get this running on the JBoss app?
Thanks,
Kenny
The code seems incorrect to me. The
TO_DATEfunction’s goal is to transform a string in a given format into a date. And you’re not passing a string as argument to this function, but ajava.util.Dateobject.You should remove the use of the
TO_DATEfunction, transform yourjava.util.Dateinto ajava.sql.Timestampobject, and usesetTimestampto pass the argument to your prepared statement.The fact that it worked as is on your unix box looks like an accident to me.