Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Oracle JDBC Timestamp error - ORA-01841
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
![]() |
![]() |