I keep getting the error "error in setting data!", please could you see if there is any obvious problem. I am running the database through sqlite. Please could you help to see what the problem is, thanks.
The sql database strusture:
package parts_system;
import java.io.IOException;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextArea;
/**
*
* @author bened_000
*/
public class FXMLDocumentController implements Initializable {
@FXML
private Label label;
@FXML
private TextArea AddPartCostStock;
@FXML
private TextArea AddPartDescriptionStock;
@FXML
private TableView<?> StockTable;
@FXML
private Button AddToStock;
@FXML
private Button RemoveFromStock;
@FXML
private Button EditVehicle;
@FXML
private TextArea VPAddVehicleReg;
@FXML
private Button AddToVehicle;
@FXML
private TextArea AddPartAmountStock;
@FXML
private TextArea SearchStock;
@FXML
private TextArea VPAddCustomerName;
@FXML
private TableView<?> VehiclePartTable;
@FXML
private TextArea VPAddPartName;
@FXML
private TextArea VPAddPartID;
@FXML
private TextArea SearchVehicle;
@FXML
private ChoiceBox<?> SearchOptionsVehicle;
@FXML
private TextArea VPAddDateInstall;
@FXML
private Button Exit;
private ObservableList<stock> stocklist=FXCollections.observableArrayList();
private ObservableList<part> list2=FXCollections.observableArrayList();
private final ObservableList comboOption =FXCollections.observableArrayList();
@FXML
private TextArea AddPartNameStock;
@FXML
private TableColumn<?, ?> sName;
@FXML
private TableColumn<?, ?> sAmount;
@FXML
private TableColumn<?, ?> sCost;
@FXML
private TableColumn<?, ?> sDescription;
@FXML
private TableColumn<?, ?> vPartID;
@FXML
private TableColumn<?, ?> vName;
@FXML
private TableColumn<?, ?> vCost;
@FXML
private TableColumn<?, ?> vDescription;
@FXML
private TableColumn<?, ?> vVehicleReg;
@FXML
private TableColumn<?, ?> vCustomerName;
@FXML
private TableColumn<?, ?> vInstallationDate;
@FXML
private TableColumn<?, ?> vWarrantyExpires;
@FXML
private TableColumn<?, ?> vRepairID;
@FXML
private TextArea VPAddRepairID;
@FXML void addStock(ActionEvent event) throws IOException{
try{
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\bened_000\\Documents\\NetBeansProjects\\garage\\SE35-master\\scratch\\Benedict\\parts_System\\src\\parts_system\\new.sqlite");
String sql= "INSERT INTO stock(name,numberofparts,cost,description)VALUES(?,?,?,?)";
PreparedStatement stmt1 =conn.prepareStatement(sql);
stmt1.setString(2, AddPartNameStock.getText());
stmt1.setDouble(3, Double.parseDouble(AddPartAmountStock.getText()));
stmt1.setDouble(4, Double.parseDouble(AddPartCostStock.getText()));
stmt1.setString(5, AddPartDescriptionStock.getText());
stmt1.execute();
stmt1.close();
conn.close();
} catch (Exception e) {
System.out.println("error in setting data!");
}
}