Question about ResultSet.getString(String columnName)

Hi, experts,
I have a sql select sentence:
    select to_char(sysdate, 'FMMonth DD, YYYY') today_month_dd_yyyy from dual
The result is
    'September 28, 2004'

But when I use java.sql.ResultSet (in a server application in Weblogic812) to get the today_month_dd_yyyy value, the java code:
always return
    9? 28, 2004

Why? Can someone help me to fix this.

Thanks in advance.
Who is Participating?
Venci75Connect With a Mentor Commented:
What happens if you first change the language of your session:
why you not use Calendar.getInstance() instead?
zzynxSoftware engineerCommented:
What's the column type in your database? Is the date stored as a string or a date?
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

zzynxSoftware engineerCommented:
Do you really simply want the current day?
What about:
System.out.println( (new SimpleDateFormat("MMMM DD, yyyy")).format(new Date()) );
Just leave the DB column as date and format it on the java side.
  select SYSDATE "txnDate" from dual

  SimpleDateFormat format=new SimpleDateFormat("MMMMM dd, yyyy");
  Date dt=rs.getTimestamp("txnDate");
  String dateStr=format.format(dt);
One question, are you using the native drivers provided by oracle or the ones supplied by Weblogic. the reason is that since you are doing a to_char, it should not matter to driver to display text as date. Try using this query and see thats the result:

select to_char(sysdate, '/YYYY\DD/FMMonth\') today_month_dd_yyyy from dual

and if in the java code, you get a result like:


then there might be a problem with the driver you are using, as it might be trying to be intelligent to display the date in numericals instead of plain text.

If this works, then I suggest using the latest oracle db drivers, and verify if the issues gets resolved or no

acanuvaAuthor Commented:
Thanks very much for all answers.

Actually, I simplified my problem to get a quick answer. Let me describe it with more details.

I use jdbc to call a stored procedure which returns a ResultSet (in stored procedure, a cursor), one of the columns of the ResultSet is named 'today_month_dd_yyyy'. The definition of this column is something like:
    OPEN xx_cursor FOR
        SELECT DISTINCT to_char(sysdate, 'MM/DD/YYYY  HH:MI:SS A.M.') print_time,
               to_char(sysdate, 'FMMonth DD, YYYY') today_month_dd_yyyy,
               to_char(sysdate, 'MM/DD/YYYY') today_mm_dd_yyyy
        FROM    ......
        WHERE    ........
After getting the ResultSet, I use rset.getString(columnName) to get the value of 'today_month_dd_yyyy' column. I cann't change the sql because this stored procedure is also used by other programs.

Then, comes the problem. When I test
    select to_char(sysdate, 'FMMonth DD, YYYY') today_month_dd_yyyy from dual
The result is
    'September 28, 2004'

But in java:
I got
    9? 28, 2004

You close the question, so I believe you solved your problem. Isn't it?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.