Solved

How to insert a Timestamp in Oracle from Java?

Posted on 2006-06-15
10
3,348 Views
Last Modified: 2008-01-09
Hi,
I have a Oracle table column as Timestamp(6).
I also have another column that is just Date.

Now my question is: How do I insert a record in this table using the Timestamp(6)...

What are optlions...of ..converting a date to Timestamp???

Do I convert my date to a Timestamp?
Can I just create a new Timestamp(6) --- How?

Let me know...

Thax....
_Esam.
0
Comment
Question by:_Esam
  • 5
  • 4
10 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 100 total points
ID: 16911925
Timestamp ts = new Timestamp(new java.util.Date().getTime());
prepStatement.setTimestamp(1, ts);
0
 
LVL 49

Assisted Solution

by:Ryan Chong
Ryan Chong earned 25 total points
ID: 16912052
Alternatively try directly include the SYSDATE in your insert statement, like:

...
SQLStr = "Insert into mytable (fld1, fld2, myTimeStamp) values (?, ?, SYSDATE) ";
...
0
 

Author Comment

by:_Esam
ID: 16912091
>Timestamp(6)

What does this imply? size 6?
What does size 6 for Timestamp mean? I am not clear about this... It's in oracle table..

Let me know..

Thax.
_Esam

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16912141
>>What does size 6 for Timestamp mean?

Where have you seen that? The code i posted will work
0
 

Author Comment

by:_Esam
ID: 16912227
Yes, I tried both examples that are given above, and they worked just fine.

Well, when I do a desc TABLE1;

The timestamp rows I get as:

ROW_UPDT_TMS        TIMESTAMPT(6) ???

What does this mean?

Thanks.
_Esam.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 86

Expert Comment

by:CEHJ
ID: 16912286
Probably the size of the datatype - 6 bytes long
0
 

Author Comment

by:_Esam
ID: 16912381
That would make sense?

But that byte thing is  related to java - I didn't think it was somehow related to oracle Timestamp!!!!


Thanks.
_Esam
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16912444
bytes are related to everything ;-)
0
 

Author Comment

by:_Esam
ID: 16912595
That's absolutely right but in terms of declaring the Oracle Timestamp!!
I didn't know that...

Thanks.
_Esam...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16912619
:-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now