I am having this problem using JDBC. I can create a table called food.db with text fields breakfast, lunch, dinner. When I call the following....
statement.executeUpdate("create table food (breakfast string, lunch string, dinner string)");
breakfast = JOptionPane.showInputDialog("What was your breakfast?");
lunch = JOptionPane.showInputDialog("What was your lunch?");
dinner = JOptionPane.showInputDialog("What was your dinner?");
statement.executeUpdate("insert into food values(\'"+breakfast+"\', \'"+lunch+"\' ,\'"+dinner+"\')");
That last statement, however, results in an error. For whatever reason, it says that whatever I type in for "breakfast" (for example, oatmeal) is not a column, even though I know that I can use SQLite's syntax in this way to update columns.
Also I have checked the argument to executeUpdate(), and the syntax with single quotes and everything matches up...I have tried text and string column fields, get the same error for both.
PreparedStatementwith a parameterized query instead of concatenating user input into a query. You are currently open to SQL injection.