Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
It returns a java.sql.Timestamp, not java.sql.Date instance.
select current_timestamp from dule
It returns a oracle.sql.TIMESTAMPTZ, not java.sql.Timestamp instance.
How to make them return values of JDBC java.sql.* standard types?
In Oracle, a DATE
data type has year, month, day, hour, minute and second components.
In Java:
a java.sql.Date
class has year, month and day components.
a java.sql.Timestamp
class has year, month, day, hour, minute and second components.
The correct Java data type for an Oracle DATE
is java.sql.Timestamp
and not java.sql.Date
(you can use java.sql.Date
as the return value from stored procedures, etc. but it will truncate the time components).
In Oracle, CURRENT_TIMESTAMP
has the data type TIMESTAMP WITH TIME ZONE
. In Java, this is the equivalent of oracle.sql.TIMESTAMPTZ
class.
Oracle SQL returns Oracle data types. You can use trunc(current_date) to get rid of the time part (not that it will affect the return type, though!). However, to get the right data type with JDBC, simply use the proper get method in https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSet.html. The getDate
method returns a java.sql.Date
, the getTimestamp
method returns a java.sql.Timestamp
.
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.