i wrote the below code to retrieve all the records from the table, but as i created a new table, i want to check if the ResultSet is empty or not to display a message if it is empty.
how can i do that
code:
public void selectAll() throws SQLException, ClassNotFoundException {
if (this.isTableExists(this.TABLE_NAME)) {
Connection conn = this.getConnection();
Statement stmt = conn.createStatement();
ResultSet resSet = stmt.executeQuery("select * from "+this.TABLE_NAME+";");//i want to check if it is empty or not.
while (resSet.next()) {
Log.d(TAG, "selectAll", "ID: "+resSet.getString(ID_COL));
Log.d(TAG, "selectAll", "Node: "+resSet.getString(NODE_ID_COL));
Log.d(TAG, "selectAll", "Lat: "+resSet.getString(LAT_COL));
Log.d(TAG, "selectAll", "Lng: "+resSet.getString(LNG_COL));
Log.d(TAG, "selectAll", "xmlPath: "+resSet.getString(XML_PATH_COL));
}
resSet.close();
stmt.close();
conn.close();
}
else{
Log.e(TAG, "selectAll", "table: ["+this.TABLE_NAME+"] does not exist");
}
}
Aucun commentaire:
Enregistrer un commentaire