How can I pass text or strings using SQLite JDBC? -


i having problem using jdbc. can create table called food.db text fields breakfast, lunch, dinner. when call following....

          statement.executeupdate("create table food (breakfast string, lunch string, dinner string)");           breakfast = joptionpane.showinputdialog("what breakfast?");             lunch = joptionpane.showinputdialog("what lunch?");             dinner = joptionpane.showinputdialog("what dinner?");          statement.executeupdate("insert food values(\'"+breakfast+"\', \'"+lunch+"\' ,\'"+dinner+"\')"); 

that last statement, however, results in error. whatever reason, says whatever type in "breakfast" (for example, oatmeal) not column, though know can use sqlite's syntax in way update columns.

also have checked argument executeupdate(), , syntax single quotes , matches up...i have tried text , string column fields, same error both.

try this

change string varchar(size) or text

 statement.executeupdate("create table food (breakfast varchar(25), lunch varchar(25), dinner varchar(25))");  string breakfast = joptionpane.showinputdialog("what breakfast?");  string lunch = joptionpane.showinputdialog("what lunch?");  string dinner = joptionpane.showinputdialog("what dinner?");  statement.executeupdate("insert food (breakfast, lunch , dinner) values ('"+breakfast+"', '"+lunch+"' ,'"+dinner+"')"); 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -