Solved

insert date to database

Posted on 2007-04-09
6
206 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
  • 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 500 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

708 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

19 Experts available now in Live!

Get 1:1 Help Now