我不知道爲什麼我的程序不是在創建表格,但是我也需要關於如何在創建代碼時使用代碼填充表格的一些想法?我還需要再向這個數據庫添加兩個表。從代碼創建JAVA數據庫。陳述不會執行並創建表?
這是我得到的錯誤:
java.sql.SQLSyntaxErrorException: Table/View 'PIZZASIZE' does not exist.
Caused by: ERROR 42X05: Table/View 'PIZZASIZE' does not exist.
Caused by: java.lang.RuntimeException: Exception in Application start method
Caused by: javafx.fxml.LoadException: file:/C:/Users/Allie/Documents/NetBeansProjects/Pizzeria_AllieBeckman/dist/run1674141987/Pizzeria_AllieBeckman.jar!/pizzeria_alliebeckman/FXMLDocument.fxml
這是一個本應創建表的代碼:
// connect to the derby URL using the given username and password
connect = DriverManager.getConnection("jdbc:derby://localhost:1527/pizzeria;create=true", connectProps);
// current url for pre created database "jdbc:derby://localhost:1527/pizza"
// if connection is successful print that it succeeded.
System.out.println("database created");
stmt = connect.createStatement();
String sqlCreate = "CREATE TABLE PIZZASIZE "
+ "(id int NOT NULL, "
+ "size char(20) NOT NULL, "
+ "PRIMARY KEY (id))";
stmt.execute(sqlCreate);
嘗試'stmt.executeUpdate(sqlCreate)與stmt.executeUpdate(sqlCreate)' –
同樣的錯誤:( –
'的System.out.println( 「數據庫中創建」);?'這是執行 –