ALBERLAU blog

Blog about my personal experience in software development.

Thursday, January 10, 2008

 

Oracle JDBC oracle.sql.TIMESTAMP issue

Because of this magics it's possible to spend whole day while finding solution. The problem was java.lang.ClassCastException: oracle.sql.TIMESTAMP cannot be cast to java.sql.Timestamp on Tomcat, while on OC4J application was running fine. As I supposed ResultSet was returning oracle.sql.TIMESTAMP instead of java.sql.Timestamp. If oracle.sql.TIMESTAMP were extending java.sql.Timestamp there would be no problem. But it extends oracle.sql.Datum. I tried different Oracle JDBC versions, starting from classes12.jar ending ojdbc6.jar . The problem remains unsolved. After deeper research i found that Oracle JDBC uses oracle.jdbc.J2EE13Compliant property to determine what to return : oracle.sql.TIMESTAMP or java.sql.Timestamp. In case when this property is false, Oracle JDBC becomes not JDBC compatible, because oracle.jdbc.driver.TimestampAccessor returns oracle.sql.TIMESTAMP. There is some abstract info about oracle.jdbc.J2EE13Compliant in Oracle JDBC FAQ . There is more issues related to this property. In case of oracle.jdbc.J2EE13Compliant==true and precission not equals zero and scale is minus 127 oracle.jdbc.driver.NumberCommonAccessor returns Double in other cases it will return BigDecimal . The fastest and easest way to solve this problem is to add -Doracle.jdbc.J2EE13Compliant=true to your Tomcat or any other "not J2EE13Compliant" application server startup properties. It's a strange ways to get compatibilities :)

Labels: , , , , ,


Comments:
Thanks to your post I've spent only 3 hours with this problem. Thanks for solution :)
 
Great, worked for me as well. Thanks for the post!
 
Thanks!
 
Hi

What do you thing about below diet supplement? I'm going to buy something good for muscle growth. Please give me a piece of advice.

[url=http://www.suplementy-olimp.pl/olimp-pure-whey-80.php]Olimp Nutrition Pure Whey[/url]
 
Thanks this worked.
 
Post a Comment

Subscribe to Post Comments [Atom]





<< Home

Archives

January 2008   February 2008   March 2009  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]