Solved

insert date to database

Posted on 2007-04-09
6
210 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 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
Industry Leaders: 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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
ejb example issues 3 56
Bot application - advice 3 64
How to drop system generated virtual column in a table in12c 15 123
update using pipeline function 3 34
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
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 tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

697 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