Solved

insert date to database

Posted on 2007-04-09
6
208 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
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 …

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