SQL ошибка или отсутствует база данных (рядом с «[]»: синтаксическая ошибка) ошибка говорит, что проблема где-то здесь
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database
(near "[]": syntax error)
at org.sqlite.core.DB.newSQLException(DB.java:909)
at org.sqlite.core.DB.newSQLException(DB.java:921)
at org.sqlite.core.DB.throwex(DB.java:886)
at org.sqlite.core.NativeDB._exec_utf8(Native Method)
at org.sqlite.core.NativeDB._exec(NativeDB.java:87)
at org.sqlite.jdbc3.JDBC3Statement.executeUpdate(JDBC3Statement.java:116)
at
kino.FXMLKinoUserController.dodajRezerwacje(FXMLKinoUserController.java:732)
int rs = conn.createStatement().executeUpdate("INSERT INTO rezerwacja(id_rezerwacji,nazwisko,nr_kontaktowy,ilosc_biletow,id_seansu,miejsca) Values "
+ "(NULL," + "'" + textfieldNazwisko.getText() + "','" + textfieldNrtel.getText() + "','" + textfieldIloscBiletow.getText() + "'," + rsIdSeansu.getInt("id_seansu") + checkboxList.toString()+ ")");
вот код этого метода
private void dodajRezerwacje(ActionEvent event) {
Connection conn = dc.Connect();
if (validateFieldsRezerwacje()){
try {
a1 =new CheckBox("A1");
a1.setOnAction(e ->{
checkboxList.add(a1.getText());
});
a2 =new CheckBox("A2");
a2.setOnAction(e ->{
checkboxList.add(a2.getText());
});
a3 =new CheckBox("A3");
a3.setOnAction(e ->{
checkboxList.add(a3.getText());
});
a4 =new CheckBox("A4");
a4.setOnAction(e ->{
checkboxList.add(a4.getText());
});
a5 =new CheckBox("A5");
a5.setOnAction(e ->{
checkboxList.add(a5.getText());
});
a6 =new CheckBox("A6");
a6.setOnAction(e ->{
checkboxList.add(a6.getText());
});
a7 =new CheckBox("A7");
a7.setOnAction(e ->{
checkboxList.add(a7.getText());
});
a8 =new CheckBox("A8");
a8.setOnAction(e ->{
checkboxList.add(a8.getText());
});
a9 =new CheckBox("A9");
a9.setOnAction(e ->{
checkboxList.add(a9.getText());
});
a10 =new CheckBox("A10");
a10.setOnAction(e ->{
checkboxList.add(a10.getText());
});
b1 =new CheckBox("B1");
b1.setOnAction(e ->{
checkboxList.add(b1.getText());
});
b2 =new CheckBox("B2");
b2.setOnAction(e ->{
checkboxList.add(b2.getText());
});
b3 =new CheckBox("B3");
b3.setOnAction(e ->{
checkboxList.add(b3.getText());
});
b4 =new CheckBox("B4");
b4.setOnAction(e ->{
checkboxList.add(b4.getText());
});
b5 =new CheckBox("B5");
b5.setOnAction(e ->{
checkboxList.add(b5.getText());
});
b6 =new CheckBox("B6");
b6.setOnAction(e ->{
checkboxList.add(b6.getText());
});
b7 =new CheckBox("B7");
b7.setOnAction(e ->{
checkboxList.add(b7.getText());
});
b8 =new CheckBox("B8");
b8.setOnAction(e ->{
checkboxList.add(b8.getText());
});
b9 =new CheckBox("B9");
b9.setOnAction(e ->{
checkboxList.add(b9.getText());
});
b10 =new CheckBox("B10");
b10.setOnAction(e ->{
checkboxList.add(b10.getText());
});
c1 =new CheckBox("C1");
c1.setOnAction(e ->{
checkboxList.add(c1.getText());
});
c2 =new CheckBox("C2");
c2.setOnAction(e ->{
checkboxList.add(c2.getText());
});
c3 =new CheckBox("C3");
c3.setOnAction(e ->{
checkboxList.add(c3.getText());
});
c4 =new CheckBox("C4");
c4.setOnAction(e ->{
checkboxList.add(c4.getText());
});
c5 =new CheckBox("C5");
c5.setOnAction(e ->{
checkboxList.add(c5.getText());
});
c6 =new CheckBox("C6");
c6.setOnAction(e ->{
checkboxList.add(c6.getText());
});
c7 =new CheckBox("C7");
c7.setOnAction(e ->{
checkboxList.add(c7.getText());
});
c8 =new CheckBox("C8");
c8.setOnAction(e ->{
checkboxList.add(c8.getText());
});
c9 =new CheckBox("C9");
c9.setOnAction(e ->{
checkboxList.add(c9.getText());
});
c10 =new CheckBox("C10");
c10.setOnAction(e ->{
checkboxList.add(c10.getText());
});
String film = comboboxFilm.getSelectionModel().getSelectedItem().toString();
ResultSet rsIdFilmu = conn.createStatement().executeQuery("SELECT id_filmu FROM film WHERE tytul='" + film + "'");
String dzien = comboboxDzien.getSelectionModel().getSelectedItem().toString();
String godzina = comboboxGodzina.getSelectionModel().getSelectedItem().toString();
ResultSet rsIdSeansu = conn.createStatement().executeQuery("SELECT id_seansu FROM Seans WHERE id_filmu='" + rsIdFilmu.getInt("id_filmu") + "' AND dzien='" + dzien + "' AND godzina='" + godzina + "'");
ResultSet rsWM = conn.createStatement().executeQuery("SELECT ilosc_wolnych_miejsc FROM Seans WHERE Seans.id_seansu='"+rsIdSeansu.getInt("id_seansu")+"'");
Integer wolne = rsWM.getInt("ilosc_wolnych_miejsc");
Integer bilety = Integer.parseInt(textfieldIloscBiletow.getText());
if (bilety>0 && bilety<=wolne){
Integer wolneMiejsca = wolne - bilety;
int rs = conn.createStatement().executeUpdate("INSERT INTO rezerwacja(id_rezerwacji,nazwisko,nr_kontaktowy,ilosc_biletow,id_seansu,miejsca) Values "
+ "(NULL," + "'" + textfieldNazwisko.getText() + "','" + textfieldNrtel.getText() + "','" + textfieldIloscBiletow.getText() + "'," + rsIdSeansu.getInt("id_seansu") + checkboxList.toString()+ ")");
int rs2 = conn.createStatement().executeUpdate("UPDATE Seans SET ilosc_wolnych_miejsc='"+wolneMiejsca+"' WHERE id_seansu='"+rsIdSeansu.getInt("id_seansu")+"'");
} else brakZaznaczenia("Wystąpił błąd", "Przepraszamy, brak wolnych miejsc", "Spróbuj ponownie.");
conn.close();
rsIdFilmu.close();
rsIdSeansu.close();
rsWM.close();
} catch (SQLException ex) {
Logger.getLogger(FXMLKinoUserController.class.getName()).log(Level.SEVERE, null, ex);
}
czyscWybrane("rezerwacja");
loadDataFromDatabase(event);
}
}
извините, не все в коде на английском sh