Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Timestamp truncates the trailing Zeros in nanoseconds

lijJun 25 2005 — edited Jun 29 2005
I have a Database Timestamp(6) field as part of the Primary key. When the value is read from database(resultset.getTimestamp(colA)) and set to a java.sql.timestamp variable, it looses the trailing zero's of the nanosecond part.
Timestamp Column value(in DB)=20-Jun-05 10:30:22.695000 AM
TimeStamp tm= rs.getTimestamp(colA) returns only 20-Jun-05 10:30:22.695

So when i try to insert a detail record using the same value in the foreign key part, error occurs saying FK not found. eg: preparedstatment.setTimestamp(tm)
Im using PreparedStatement,binding parameters to insert into detail table. However if i convert to string and insert using the timestamp casting {ts ?} it works.
Currently im using JDK1.3 and ojdbc14.jar.
Why doesnt oracle take the value, what effect does the trailing zeros have.
Pleae Help

Lijith Chandy
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 27 2005
Added on Jun 25 2005
3 comments
1,569 views