Solved

How to insert a Timestamp in Oracle from Java?

Posted on 2006-06-15
10
3,439 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 52

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

738 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