Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Oracle JDBC Timestamp error - ORA-01841

Oracle JDBC Timestamp error - ORA-01841

From: Luch <optimaljedi_at_hotmail.com>
Date: 13 May 2004 13:42:15 -0700
Message-ID: <3d047c59.0405131242.460250e2@posting.google.com>


I'm using the JDBC driver that came with Oracle 9 release 2. I've tried both the classes12 and classes 11, and using the parameter: -Doracle.jdbc.V8Compatibility="true"

I get this error when trying to insert a Java timestamp into an oracle date field: java.sql.SQLException: ORA-01841: (full) year must be between -4713 and +9999, and not be 0

The thing is, I'm trying a JDO implementation which requires this to work. Does anyone know of this issue? Here is the program code:

import java.sql.PreparedStatement;
import java.sql.*;
import java.util.*;
import java.sql.Timestamp;


public class JDBCTime2
{
  public static void main(String[] args) throws Exception {     String driverName = "oracle.jdbc.driver.OracleDriver";     String url = "jdbc:oracle:thin:@duke:1521:trax";     String user = "odb";
    String pass = "odb";

    Class driverClass = Class.forName (driverName);     Driver driver = DriverManager.getDriver (url);     Properties props = new Properties ();     props.setProperty ("user", user);
    props.setProperty ("password", pass);     Connection c = driver.connect (url, props);

    try {
      // drop the test table, in case it exists

//-- new stuff below -------

      PreparedStatement ps = c.prepareStatement("INSERT INTO ODB.AC_ACTUAL_FLIGHTS(AC, CREATED_BY, CREATED_DATE, FLIGHT_LEG, FLIGHT_LOG) VALUES (?, ?, ?, ?, ?)");

      ps.setString(1, "J-TRAX");
      ps.setString(2, "INTERFACE");
      Timestamp t = new
java.sql.Timestamp(System.currentTimeMillis());
      System.out.println(t);
      ps.setTimestamp(3, t, null);
      ps.setInt(4, 2);
      ps.setString(5, "383282");
      int rows = ps.executeUpdate();

      System.out.println("UPDATE:" + rows);
      ps.close();

//!--- end new stuff --

}

    catch (Exception e) {
      e.printStackTrace();
}

    c.commit();

  }
} Received on Thu May 13 2004 - 15:42:15 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US