Solved

How to insert a Timestamp in Oracle from Java?

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

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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to convert from xls to xlsx using java 7 56
How  can  i  resolve  HTTP Status 404 -? 8 45
Java: The Public Class Main 4 32
swing controls 2 16
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 functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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 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…

828 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