Answer the question
In order to leave comments, you need to log in
Record in the database is not updated (JavaFX + JDBC + SQLite) - JavaFX, how to fix it?
Good day, dear forum users.
A couple of weeks since I started learning Java and faced such a problem... I
created a small application using java9 + javafx + jdbc (sqlite) + scenebuilder + maven (intellij idea).
It is necessary that the changed record from the tableView table be updated in the database too. Adding and deleting an entry works, but for some reason changing it doesn't. In this case, no error is displayed.
Database structure id, site, sitName, siteLogin, etc. (total 26 columns). First id primary auto increment
What am I doing wrong or missing?
Codes:
public void sqlupdate(String site, String siteLogin, String sitePass /* bla-bla */) {
String updatesql = "UPDATE data SET site=? , " + " siteLogin = ? ," + " sitePass = ? ," + " ftp = ?," + " ftpLogin = ?," + " ftpPass = ?," + "port = ?," + "person = ?," + "personEmail = ?," + "personPass = ?," + "personPhone = ?," + "dbName = ?," + "dbUser = ?," + "dbPass = ?," + "dbHost = ?," + "hostingUrl = ?," + "hostingLogin = ?," + "hostingPass = ?," + "providerUrl = ?," + "providerLogin = ?," + "providerPass = ?," + "otherUrl = ?," + "otherLogin = ?," + "otherPass = ?," + "notes = ? "
+ "WHERE id = ?";
try {
SQLiteConfig config = new SQLiteConfig();
Connection c = db.getInstance().getConnection();
PreparedStatement pstmt = c.prepareStatement(updatesql);
pstmt.setString(1, site);
pstmt.setString(2, siteLogin);
pstmt.setString(3, sitePass);
/* и т.д.и т.п. Пробовал также использовать геттеры pstmt.setString(1, website.getSite); но как-то безрезультатно*/
// update
pstmt.executeUpdate();
} catch (SQLException ex) {
ex.printStackTrace();
System.out.println("Возникла ошибка при добавлении записи");
}
@Override
public void AddButtonChange(ActionEvent actionEvent) {
sqlupdate("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question