We have a PreparedStatment that fails to return result sets on rare random occasions. We are run at batch process 15 times a month. Once every 6-7 months one of these Prepared Statement will not return results. When we query the database the data is defiantly there. If we rerun the process then it finds the data and everything is fine, sometimes we need to rerun a couple of times before it works. It is always the same prepared statement that fails to return results, but it never throws an exception.
Recently in our test environment this has been happening once every 10 times that we run our process. The only difference between the two environments is that in production we are using the 1.4.2 Sun JVM. In test we are using Java 1.5.0_07. Both are running Oracle 10g.
After studying the results the only thing I have spotted that is out of the ordinary is a timestamp that has nanos where it shouldn't. We are querying using a DATE field; the value we are looking for is a constant that is derived from:
Calendar cal1 = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
Calendar cal2 = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
cal1.set(1970,1,1);
cal2.set(1800,1,1);
long millis = cal2.getTimeInMillis() - cal1.getTimeInMillis() + 21600000;
java.sql.Timestamp ts = new java.sql.Timestamp(millis);
Then we do ps.setTimestamp(ts);
When we crash we print out ts, and it always looks something like: 1800-01-01 00:00:00.008. The value in nanos is always different, but shouldn't it be zero? What could cause it to get a value from the above code?
I haven’t been able to find anything else that looks consistent from one crash to the next. Could this be our problem, or does oracle ignore this value in nanos? Is there anything else that I should be looking for that would cause a PreparedStatment to just not find the data one time and work perfectly the next? Again it works most of the time, and I don't see anything else that looks consistent from one to the next.
Any Advice is appreciated. Thanks,
Jason
Recently in our test environment this has been happening once every 10 times that we run our process. The only difference between the two environments is that in production we are using the 1.4.2 Sun JVM. In test we are using Java 1.5.0_07. Both are running Oracle 10g.
After studying the results the only thing I have spotted that is out of the ordinary is a timestamp that has nanos where it shouldn't. We are querying using a DATE field; the value we are looking for is a constant that is derived from:
Calendar cal1 = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
Calendar cal2 = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
cal1.set(1970,1,1);
cal2.set(1800,1,1);
long millis = cal2.getTimeInMillis() - cal1.getTimeInMillis() + 21600000;
java.sql.Timestamp ts = new java.sql.Timestamp(millis);
Then we do ps.setTimestamp(ts);
When we crash we print out ts, and it always looks something like: 1800-01-01 00:00:00.008. The value in nanos is always different, but shouldn't it be zero? What could cause it to get a value from the above code?
I haven’t been able to find anything else that looks consistent from one crash to the next. Could this be our problem, or does oracle ignore this value in nanos? Is there anything else that I should be looking for that would cause a PreparedStatment to just not find the data one time and work perfectly the next? Again it works most of the time, and I don't see anything else that looks consistent from one to the next.
Any Advice is appreciated. Thanks,
Jason