SQLite JavaFX INSERT В синтаксическую ошибку около x - PullRequest
0 голосов
/ 29 января 2019

У меня есть строка кода для вставки многих переменных в базу данных под названием GoodDB.по какой-то причине я не могу заставить его работать и получить синтаксическую ошибку.

Я прочитал несколько потоков, где мой код 1: 1, но по какой-то причине он все еще не работает для меня

public void submitButton (ActionEvent event) throws IOException{

    try {
        Connection conn = DriverManager.getConnection("jdbc:sqlite:--Location--");
        Statement statement = conn.createStatement();
        statement.executeUpdate("INSERT INTO GooDB (Date, UID, prodCode, TableNr, TableTwo, Line, Var, Comment, CommentTwo, Person, Dept, Qty) VALUES '" + dDate.getValue() + "', '" + tfuID.getText() + "', '" +
                tfprodCode.getText() + "', '" + tfTableNr.getText() + "', '" + tfLine.getText() + "', '" + tfcommentTwo.getText() + "', '" + taComm.getText() + "', '" + cbPerson.getValue() + "', '" + cbTableTwo.getValue() + "', '" +
                cbDept.getValue() + "', '" + cbQty.getValue() + "'");

        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setTitle("u good");
        alert.setHeaderText("u good");
        alert.setContentText(null);
        alert.showAndWait();

    } catch (SQLException e){
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setTitle("DB Error");
        alert.setHeaderText("DB Connection Failed");
        alert.setContentText(e.getMessage());
        alert.showAndWait();
    }
}

При вводе данных я получаю сообщение об ошибке, описанное в «catch», показывающее

[SQLITE_ERROR] SQL error or missing database (near "'null'": syntax error)
...