I have a problem transferring listview items from a listview to a SQL database on netbeans using javaFX.
Here is a method that is called when you click the button to add to the listView items to the database (Add Order). I need all the items in the listview to be written to a column.
private static void insertColl(){
try{
stmt = conn1.createStatement();
String description = listView.getText();
String query = " insert into ORDERS(DESCRIPTION)"
+ " values (?)";
PreparedStatement preparedStmt = conn1.prepareStatement(query);
preparedStmt.execute();
stmt.close();
}
catch (SQLException sqlExcept){
sqlExcept.printStackTrace();
}
Here is what our javafx project looks like, the listview in question has an arrow pointing next to it.
Apologies if I am not using the correct terminology, as I am new to this. Thank you for your help.
I think you misunderstood how PreparedStatement work, you should to set your paremetres to your statement ;
PreparedStatement preparedStmt = conn1.prepareStatement(query);
preparedStmt.setString(1, description );//<-------------------