Get Timestamp from Sqlserver

Asked

Viewed 29 times

0

I really wanted to get the TimeStamp from the Sqlserver database, but I’m not getting it, follow my example:

Connection connUpdate = DriverManager.getConnection(ConnectionURL);
PreparedStatement atualizaDevice = connUpdate.prepareStatement("select current_timestamp");
atualizaDevice.execute();
ResultSet r = atualizaDevice.getResultSet();
Timestamp t = r.getTimestamp(1);
String time = String.valueOf(t);
txtTime.setText(time);
Log.e("TIME", time);
connUpdate.close();

Using this code returns the following error:

java.sql.Sqlexception: No Current Row in the Resultset.

Any idea what to do?

1 answer

0

  • executing the query in sqlserver it returns the result normally, place tbm select current_timestamp as TIME and enter "TIME" as method parameter, but even so it returns the same error

Browser other questions tagged

You are not signed in. Login or sign up in order to post.