Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2003
    Posts
    6

    Unanswered: 9i JDBC driver returns java.sql.Date instead of java.sql.Timestamp.

    In Oracle 9.2.0.4, it seems Oracle has yet again altered the way the JDBC drivers return Oracle DATE columns. These columns now only refer to date information; the Oracle type TIMESTAMP now is used to contain date and time information. Since my application does not support java.sql.Date, it is reporting that some columns cannot be populated, because the type is unsupported.

    Is there anyway that I can get my Oracle DATE columns to return java.sql.Timestamp objects ?

    This seems like a bug on Oracle's part--we have a column that stores date and time data (an Oracle DATE column), and the Oracle JDBC driver tells us that the column only stores a date (it reports it as java.sql.Date). I could change my database schema to change my column type from DATE to TIMESTAMP but for obvious reasons, Im not too keen on changing the schema.

    I am using oracle.jdbc.OracleDriver.

    Thanks

  2. #2
    Join Date
    Apr 2003
    Location
    Los Alamos/Santa Fe, NM
    Posts
    69

    oh man

    Darn it...Then we are going to have that problem too. If you find the answer post it for me. I will research too. If I find an answer, I will post.
    Michellea Southern-David

  3. #3
    Join Date
    Apr 2003
    Location
    Los Alamos/Santa Fe, NM
    Posts
    69
    Covert the date into a string. I asked my java programmer what he did in the code. He said he never uses the Oracle java classes. He uses the java classes. I hope I am saying this right, because I am not a programmer. I am not sure the answer above would help.
    Michellea Southern-David

  4. #4
    Join Date
    Oct 2003
    Posts
    6
    Originally posted by msouthern
    Covert the date into a string. I asked my java programmer what he did in the code. He said he never uses the Oracle java classes. He uses the java classes. I hope I am saying this right, because I am not a programmer. I am not sure the answer above would help.
    te

    Not sure I understand what you mean. I'm getting a Date without Time info from the database. So no matter what I do with it, I can never get the Time info. Any help would really be appreciated.

    Thanks

  5. #5
    Join Date
    Sep 2003
    Location
    Canada
    Posts
    1
    I would recommend first take java.sql.Timestamp value
    of DATE column from ResultSet
    and further convert it to java.util.Date, for instance

    . . .

    ResultSet rs = stmt.executeQuery("SELECT sysdate FROM dual");
    rs.next();

    java.sql.Timestamp ts = rs.getTimestamp(1);
    java.util.Date dt = ts==null ? null:new java.util.Date( ts.getTime() );

    . . .

    Unfortunately java.sql.Date can not hold time,
    but java.util.Date can. You may use it.

    Regards

  6. #6
    Join Date
    Oct 2003
    Posts
    6
    Originally posted by ankostyuk
    I would recommend first take java.sql.Timestamp value
    of DATE column from ResultSet
    and further convert it to java.util.Date, for instance

    . . .

    ResultSet rs = stmt.executeQuery("SELECT sysdate FROM dual");
    rs.next();

    java.sql.Timestamp ts = rs.getTimestamp(1);
    java.util.Date dt = ts==null ? null:new java.util.Date( ts.getTime() );

    . . .

    Unfortunately java.sql.Date can not hold time,
    but java.util.Date can. You may use it.

    Regards
    My problem is that I cannot do a
    java.sql.Timestamp ts = rs.getTimestamp(1);
    as this throws an exception. coz the jdbc driver returns a java.sql.Date and not a java.sql.Timestamp.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •