简体   繁体   中英

Sqlite Database not updating using java

I am trying to update my new database but for some reason after executing my Prepared Statement the data remains the same. It returns no errors or any exceptions. Please have a look at my code and see if you can help me. Thanks in advance.

    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);
    }

never forgett to commit your changes:

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

or

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM