lundi 10 août 2015

how to count rows contains specific values

i wrote the below code to retriev some records from sqlite database, but what i am trying to do is count all rosw in the table that contains specific (lat, lng)

sqliteFactory.getXMLPath("53.074415", "8.788047");

code:

public void getNodeID(String lat, String lng) throws ClassNotFoundException, SQLException {
    Connection conn = getConnection();
    PreparedStatement ps = conn.prepareStatement("select "+this.NODE_ID_COL+" from "+this.TABLE_NAME+" where "+this.LAT_COL+" = ? And "+this.LNG_COL+" = ?");

    ps.setString(1, lat);
    ps.setString(2, lng);
    ResultSet resSet = ps.executeQuery();

    while (resSet.next()) {
        Log.v(TAG, "getNodeID", "NodeID(lat="+lat+", lng="+lng+"): "+resSet.getString(this.NODE_ID_COL));
    }

    resSet.close();
    ps.close();
    conn.close();
}

Aucun commentaire:

Enregistrer un commentaire