java - Sqlite 数据库未使用 java 更新

标签 java sqlite

我正在尝试更新我的新数据库,但由于某种原因,在执行我的准备语句后,数据保持不变。它不返回任何错误或任何异常。请看一下我的代码,看看是否可以帮助我。提前致谢。

    try {
connect();
PreparedStatement update = con.prepareStatement("UPDATE generalInfo SET "
+ "site" + " = '"
+ siteTt + "' , "
+ "area" + " = '"
+ areaTt + "' , "
+ "unit" + " = '"
+ unitTt + "' , "
+ "unitName" + " = '"
+ unitNameTt + "' , "
+ "drawing" + " = '"
+ drawingTt + "' , "
+ "system" + " = '"
+ systemTt + "' , "
+ "stream" + " = '"
+ streamTt + "' , "
+ "product" + " = '"
+ productTt + "' , "
+ "equipmentLoc" + " = '"
+ equipLocTt + "' , "
+ "specificLoc" + " = '"
+ specificLocTt + "' , "
+ "camOperator" + " = '"
+ camTechTt + "' , "
+ "camSerial" + " = '"
+ camSerialTt + "' , "
+ "gasSurveyOperator" + " = '"
+ surveyTechTt + "' , "
+ "gasSurveySerial" + " = '"
+ surveySerialTt + "' , "
+ "equipmentDesc" + " = '"
+ equipDescTt + "' , "
+ "equipmentType" + " = '"
+ equipTypeTt + "' , "
+ "equipmentSize" + " = '"
+ equipSizeTt + "' , "
+ "equipmentID" + " = '"
+ equipIDTt + "' , "
+ "[Maintenance type]" + " = '"
+ repairTt + "' , "
+ "measurementPosition" + " = '"
+ sourceTt + "'"                  
+ " WHERE leakerID = " + Integer.parseInt(leakerIDCombo.getSelectedItem().toString())+";");
update.closeOnCompletion();
update.executeUpdate();
con.close();
System.out.println("saved");
    } catch (SQLException ex) {
        Logger.getLogger(RefineryData.class.getName()).log(Level.SEVERE, null, ex);
    }

最佳答案

永远不要忘记提交您的更改:

con.setAutoCommit(true);
update.closeOnCompletion();
update.executeUpdate();
con.close();

update.closeOnCompletion();
update.executeUpdate();
con.commit();
con.close();

关于java - Sqlite 数据库未使用 java 更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34266237/

相关文章:

sql - 如何返回 SQLite 表中所有列标题的列表?

r - 从sqlite导入具有大int值的列

sql - SQLite 中的累积求和值

java - 无法在 Spring Boot 2.1.1.RELEASE 中访问消息源

java - JPA:分离后保留(用于创建实体副本)会混淆 EntityManager 缓存

java - 如何找到 hadoop 数据集中的所有键组合?

sqlite 在左连接时返回相同的值

java - 如何处理 MVC 2D 游戏中对象的图形表示?

Java:如何在类内部引用另一个元素的类?

python - 在virtualenv中下载sqlite3