Get SQLServer TimeStamp

0

I'd like to get the TimeStamp from the SQLServer database, but I'm not getting it, here's 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?

    
asked by anonymous 09.08.2017 / 14:52

1 answer

0

You have to select the database row, the way you are doing is not selecting. Read on in this article: link a Excption returned is coming directly from the missing line selection

    
09.08.2017 / 14:57