iv创建了一个与MySQL非常协调的程序。然而,当我将它转换为SQLlite时,一切工作,如创建表,getConnection()到数据库和这样的EXCEPT值插入表? 我无法使用Java(Netbeans)向SQLite数据库插入值。我只能插入一行而不是多行?在MySQL中,我可以一次插入多行,但是,我不能在SQLite中?Java - MySQL - > SQLite - 无法使用java插入SQLite数据库
的代码是(这适用于只有一行):
Connection con;
Statement s= con.CreateStatement();
String st = "Insert into table1 (10,'abc')";
s.executeUpdate(st);
s.close();
如果我做这样的事情(不超过一排工作 - 不知道为什么 - SQLite的):
Connection con;
Statement s= con.CreateStatement();
String st = "Insert into table1 (10,'abc'), (5,'vfvdv')"; //now it doesnt work since Im inserting more than one row. I can't figure out what Im doing wrong -
//Iv also tried Insert into table1(ID, Name) values (10,'abc'), (5,'afb'); but it dont work.
s.executeUpdate(st);
s.close();
任何java专家或任何人都可以帮助我解决这个问题。我无法弄清楚我在做什么错或什么,因为当我在'SQLite'命令行输入我的命令时,它可以正常工作。但是,在使用SQLite的JAVA中,出于某种原因,我只能更新一行? 但是,与MySQL的Java工作正常,但不是SQLlite。
任何人都可以澄清我做错了什么是明智的。 非常感谢您阅读本文和您的时间。
非常感谢快速回复:)。 – Aaqib