?
Solved

insert date to database

Posted on 2007-04-09
6
Medium Priority
?
212 Views
Last Modified: 2013-12-18
how to write a gava code that insert a system date into oracle daatbase
this is my database table:
CREATE DIMENSION times_dim
   LEVEL day         IS TIMES.TIME_ID
   LEVEL month       IS TIMES.CALENDAR_MONTH_DESC
   LEVEL quarter     IS TIMES.CALENDAR_QUARTER_DESC
   LEVEL year        IS TIMES.CALENDAR_YEAR
   LEVEL fis_week    IS TIMES.WEEK_ENDING_DAY
   LEVEL fis_month   IS TIMES.FISCAL_MONTH_DESC
   LEVEL fis_quarter IS TIMES.FISCAL_QUARTER_DESC
   LEVEL fis_year    IS TIMES.FISCAL_YEAR
   HIERARCHY cal_rollup    (
             day     CHILD OF
             month   CHILD OF
             quarter CHILD OF
             year
   )
   HIERARCHY fis_rollup    (
             day         CHILD OF
             fis_week    CHILD OF
             fis_month   CHILD OF
             fis_quarter CHILD OF
             fis_year
   );
0
Comment
Question by:fm134
[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
  • 3
  • 3
6 Comments
 
LVL 16

Expert Comment

by:Peter Kwan
ID: 18874987
If you are using a prepared statement, you may do this:

For Oracle8i or below:
java.sql.Date d = new java.sql.Date();
d.setTime((new java.util.Date()).getTime());
stmt.setDate(x, d);

For Oracle9i or above:
java.sql.Timestamp t = new java.sql.Timestamp((new java.util.Date()).getTime());
stmt.setTimestamp(x, t);
0
 
LVL 16

Accepted Solution

by:
Peter Kwan earned 2000 total points
ID: 18874999
For Oracle8i one, should be:
java.sql.Date d = new java.sql.Date((new java.util.Date()).getTime());
stmt.setDate(x, d);
0
 

Author Comment

by:fm134
ID: 18875015
I am using oracle 10g
0
Independent Software Vendors: 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 16

Expert Comment

by:Peter Kwan
ID: 18875027
So you can use the Timestamp one
0
 

Author Comment

by:fm134
ID: 18897193
hi pkwan
thanks alot for helping me but can u please showme excactly who ti insert it to the database in java. becuase this  isthe first time I deal withe dimentions
0
 

Author Comment

by:fm134
ID: 18897202
hi pkwan
thanks alot for helping me but can u please showme excactly who ti insert it to the database in java. becuase this  isthe first time I deal withe dimentions
0

Featured Post

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!

Question has a verified solution.

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

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
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 …
Suggested Courses
Course of the Month7 days, 19 hours left to enroll

765 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