get the value of a query count SQL in a resultset of andorid studio

1

I hope you can help me, I'm making an android application that connects to sql server. I have a class that only helps me count the values of a column

public void consulta( ){
ResultSet rs;
PreparedStatement ps=conexion().prepareStatement("select count(*) from 
Articulo");
rs = ps.executeQuery();
}

the query should give 35, the problem is that when trying to get the result, I do not know if it's okay

 String dat=rs.getString("articulo");

throws me invalid column

    
asked by Yeltssin Mendoza 16.04.2018 в 23:47
source

1 answer

0

When you use Select count(*) in your query, the result is an integer,

  

count () : Returns the number of items in a group.

In this case you can not get a field by the name:

rs.getString("articulo");

To obtain the article field you must change the query to:

PreparedStatement ps=conexion().prepareStatement("select * from Articulo");

In this way you can truly get the fields from the Articulo table.

    
answered by 17.04.2018 / 00:37
source