lundi 13 juillet 2015

SQL error or missing database (no such column: RollNo)

I was writing a java code using eclipse ide and sqlite(as my database) and on executing the sql query using the statements:
String query="select Name,Surname,Fees,RollNo,AdNo from student where class='"+1+"'";
PreparedStatement pst=c.prepareStatement(query);
ResultSet rs=pst.executeQuery();
I got the error:SQL error or missing database (no such column: RollNo)
where Name,Surname,Fees,RollNo,AdNo are the valid and exact names of the coulumns in the table student

But when I am passing this query(given below) using this same set of statements it is displaying the whole table correctly
String query="select * from student where class='"+1+"'";
PreparedStatement pst=c.prepareStatement(query);
ResultSet rs=pst.executeQuery();
What is the problem with the code do I need to rename my columns although I have tried names like Roll_No and Ad_No but it is showing the same error.

Aucun commentaire:

Enregistrer un commentaire