0

how to get timestamp from oracle DB using JDBC? on sql i can use select sysdate from dual.

i was trying something like

ResultSet rs = <>.createPreparedStatement("select sysdate from dual");
rs.executeQuery();

while(rs.next())
  rs.get<What to write here?>
2

3 Answers 3

2

rs.get(1) will solve the problem. otherwise give the alias name to the column and use that.

Sign up to request clarification or add additional context in comments.

Comments

1
SELECT SYSTIMESTAMP FROM DUAL;

SYSTIMESTAMP returns the system date, including fractional seconds and time zone, of the system on which the database resides. The return type is TIMESTAMP WITH TIME ZONE.

1 Comment

What it does? try to explain.
-1

If the value of sysdate is an int you can use this:

  while(rs.next()){
   int sysdate= rs.getInt("sysdate");  

But if the value of sysdate is a String you can use this:

   while(rs.next()){
   String sysdate= rs.getString("sysdate");  

For more info go to link

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.