dimanche 22 mars 2015

how to check if an entry exists in java sqlite column

please i am trying to check if an entry exists in an sqlite database column. and i am using java. here is what my code looks like



String name =JTextField.getText();
String sql0 = "select * from Objects where Description like " + name;
pStmt = conn.prepareStatement(sql0);
rs = pStmt.executeQuery();

if (rs.next()) {//if there is such entry...
System.out.println("there is an entry");
} else {//no such entry add the asset normally...
System.out.println("there is no such entry");

}


the code is just a test code for testing my sqlite query... name is the the entry to search for in the Description Column. whenever i run this i get an error saying no such column as the value i have stored as name. please i really need help on this thanks.


Aucun commentaire:

Enregistrer un commentaire