I have an application on android that connects to a database through JDBC, and when making a query with top 1, I get the following error:
java.sql, SQLEXCEPTION: use of the execute query (String) method is not supported on this type of stament
and this is the query in question
select top 1 * from reporte where nombre_ruta = 'nombre_ruta' order by fecha desc;
the query in the database works perfectly, I hope you can guide me:)
the code is as follows:
try {
String query = "select top 1 nombre_ruta,descripcion from reporte where nombre_ruta = '"+marker.getTitle()+"';";
con = connectionclass (un, passwords, db, ip);
if (con == null) {
isConnected(getApplicationContext());
} else {
stmt = con.prepareStatement(query);
stmt.setQueryTimeout(1);
rs=stmt.executeQuery(query);
while (rs.next()) {
reporte = rs.getString("nombre_ruta");
descripcion=rs.getString("descripcion");
}