如果這是重復的,我很抱歉,但我還沒有找到答案。我正在開發一個在 JavaFX 中運行基本庫存管理系統的項目。我目前正在嘗試允許用戶將新項目添加到 SQLite 數據庫中,雖然 ID 和項目名稱被添加到數據庫中就好了,但輸入到文本字段中的初始值似乎被忽略了。程序將值 0.0 放在可用單位字段中。這是我當前的代碼:Main.javapackage sample; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage primaryStage){ try { Parent root = FXMLLoader.load(getClass().getResource("DatabaseView.fxml")); Scene scene = new Scene(root); primaryStage.setTitle("Brewer's Guide Inventory Management"); primaryStage.setScene(scene); primaryStage.show(); } catch (Exception e){ e.printStackTrace(); } } public static void main(String[] args) { launch(args); } }beerDatabaseData.java package sample; import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; public class beerDatabaseData { private final StringProperty ID; private final StringProperty name; private DoubleProperty units; public beerDatabaseData (String ID, String Name, Double Units) { this.ID = new SimpleStringProperty(ID); this.name = new SimpleStringProperty(Name); this.units = new SimpleDoubleProperty(Units); } public StringProperty IDProperty() { return this.ID; } public String getID() { return this.IDProperty().get(); }我想有一個明顯的問題導致了這種情況,但我沒有看到它。我需要更改或包含哪些內容才能使這項工作有效?提前謝謝你。
1 回答

陪伴而非守候
TA貢獻1757條經驗 獲得超8個贊
看起來Malt_Units
您的表中的列是數字,但您嘗試將其作為字符串插入。您應該解析輸入中的值,然后將其設置為Double
:
Prs.setDouble(3, Double.parseDouble(this.unitsInput1.getText()));
添加回答
舉報
0/150
提交
取消