I have to query a MS SQL DB using java <p>I have to query a MS SQL DB using java. I am querying DB using following code</p> <pre><code> Class.forName("net.sourceforge.jtds.jdbc.Driver"); Connection conn = DriverManager.getConnection( "jdbc:jtds:sqlserver://XXX.XX.XX&gt;XX:1433/DBNAME", "USERNAME", "Password"); querystr="select DATEDIFF(second,Finish_Time,ReqTime) As FinishDifference from DB.SCHEMA.TABLE where ID='123'"; Statement stmt=conn.createStatement(); ResultSet res=stmt.executeQuery(querystr); System.out.print(res.getRow()); </code></pre> <p>When I query DB manually using query string, I am able to successfully gets results but res.getRow() shows 0.</p>