Solved

How to insert a Timestamp in Oracle from Java?

Posted on 2006-06-15
10
3,372 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 50

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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 86
eclipse package explorer vs project explorer view 2 134
tomcat not starting 6 45
configure dependency in POM for new database 3 26
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

810 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