Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6375535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:37:41+00:00 2026-05-25T01:37:41+00:00

I have a table column of data type DATE. I am inserting through Java

  • 0

I have a table column of data type DATE. I am inserting through Java PreparedStatement , how can I store timestamp also when inserting? Is it possible to store time stamp in DATE column?

I tried

ps.setTimestamp(index, new java.sql.Timestamp(date.getTime()));

But did not work.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:37:41+00:00Added an answer on May 25, 2026 at 1:37 am

    The mapping between SQL types and JDBC types in Oracle is a bit complicated, especially for the DATE and TIMESTAMP SQL types.

    The Oracle database allows you to store timestamp information in DATE columns, which is quite contrary to the definition of the DATE in the SQL standard. Prior to 9.2 when the TIMESTAMP column support was introduced, Statement.setTimestamp would work for DATE columns. Since 9.2, and until 11.1, the JDBC driver mapped the SQL DATE type to the JDBC Date and the SQL TIMESTAMP type to the JDBC Timestamp. The possible solutions to storing timestamps using the 10.2 JDBC drivers are listed in the Oracle JDBC FAQ, and are reproduced here:

    There are several ways to address this problem in the 9.2 through 10.2
    drivers:

    • Alter your tables to use TIMESTAMP instead of DATE. This is probably
      rarely possible, but it is the best solution when it is.

    • Alter your application to use defineColumnType to define the columns
      as TIMESTAMP rather than DATE. There are problems with this because
      you really don’t want to use defineColumnType unless you have to (see
      What is defineColumnType and when should I use it? ).

    • Alter you application to use getTimestamp rather than getObject. This
      is a good solution when possible, however many applications contain
      generic code that relies on getObject, so it isn’t always possible.

    • Set the V8Compatible connection property. This tells the JDBC drivers
      to use the old mapping rather than the new one. You can set this flag
      either as a connection property or a system property. You set the
      connection property by adding it to the java.util.Properties object
      passed to DriverManager.getConnection or to
      OracleDataSource.setConnectionProperties. You set the system property
      by including a -D option in your java command line.

      java -Doracle.jdbc.V8Compatible=”true” MyApp

    You could also use the JDBC 11.1 drivers (they will work against a 10g instance), and the FAQ has this to state:

    Oracle JDBC 11.1 fixes this problem. Beginning with this release the
    driver maps SQL DATE columns to java.sql.Timestamp by default. There
    is no need to set V8Compatible to get the correct mapping.
    V8Compatible is strongly deprecated. You should not use it at all. If
    you do set it to true it won’t hurt anything, but you should stop
    using it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with a column date (type mysql date : yyyy-mm-dd) I
I have a last_notified column on my MySQL table, data type DATETIME I want
I have a table with a Date column. Each Date may appear multiple times.
I have a table with a Date column, and I would like to do
I have the holiday table whose description are Name Null? Type HOLIDAYDATE DATE DESCRIPTION
i have a table with data title and date of the data inserted. and
I have a column called DayShift in a table which is of Yes/No data
I have several tables whose only unique data is a uniqueidentifier (a Guid) column.
I have a table column that needs to be limited to a certain width
I have a table where one column has duplicate records but other columns are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.