I have a large legacy application which calls resultSet.getString(column) and the column it is calling on is the DATE format in Oracle. This code worked just fine with Oracle 10g client. It would return the following:
‘2008-05-19 10:03:56.0’
However, when I use the Oracle 11g client (the server has not changed) it gives the following:
‘2008-05-19 10:03:56’
Now, I know the right way to fix this is by changing the code to NOT use getString for a date function, but it’s a ton of code and we are trying to do this without having to do code changes.
Is there any configuration parameter(s) I can use to fix this on the Oracle client side?
I’ve tried the following and it doesn’t even change the format:
Statement stmt = conn.createStatement();
stmt.execute("alter session set nls_date_format = 'YYYY-MM-DD HH24:MI'");
This one took off the seconds, but when running a query it is still using the one with seconds. So I don’t think the NSL_DATE_FORMAT update will work.
The thread below seems to indicate that the date format is hard coded in the jdbc drivers:
Java: ResultSet getString() differs between environments
If that is true then the only solutions seem to be:
Change all the code to use getDate()
Change all the queries to use to_char(date, ‘YYYY-MM-DD HH24:MI:SS.F’)
Does anyone see any other solution?