Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assertion botch: negative time oracle 11

my java application is trying to run an insert query to an oracle DB. the table i am inserting to has a DATE field called last_modified my query uses Timestamp, while counting on the oracle to convert to date field. every day at 23:00 i get the following error

java.lang.RuntimeException: **Assertion botch: negative time**
at
oracle.jdbc.driver.DateCommonBinder.setOracleHMS(OraclePreparedStatement.java:18740)
    at
oracle.jdbc.driver.TimestampBinder.bind(OraclePreparedStatement.java:19245)
    at
oracle.jdbc.driver.OraclePreparedStatement.setupBindBuffers(OraclePreparedStatement.java:3014)
    at
oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:9973)
    at
oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:213)

i have checked the time zones using:

SELECT SYSTIMESTAMP, CURRENT_TIMESTAMP, DBTIMEZONE, SESSIONTIMEZONE FROM DUAL;

i got: 05-JUN-13 08.09.29.244232 AM +02:00, 05-JUN-13 08.09.29.244236 AM +02:00, +00:00,+02:00

the client mochine( the one on which i have the java application) and the DB machine are the same one. but still i get the java.lang.RuntimeException: Assertion botch: negative time

my questions are:

  1. how can i add to my code a catch block that will avoid the need to restart my application every day at 23:00 ? it seems to me that the exception is an java.lang.RuntimeException and i cant add catch(java.lang.RuntimeException e) or can i ?

  2. is the Assertion botch: negative time an assertion ? can i catch it using catch (java.lang.AssertionError e) ?

  3. i read, that after changing the linux time zone i should run a restart on the machine. till then the oracle will not use the new time zone. is there a way for me to know what is configured and what timezone the oracle is using ? thanks.
like image 491
Oded Avatar asked Jun 10 '26 17:06

Oded


1 Answers

Had the same problem. We fixed it by using vm parametr to explicitly set Java timezone.

-Duser.timezone=<yourTZ>

This is a strange bug, when Date objects are correct on the other end, but still bug when time falls into TZ gap.

like image 186
Imaskar Avatar answered Jun 12 '26 08:06

Imaskar