我不知道为什么我的程序不是在创建表格,但是我也需要关于如何在创建代码时使用代码填充表格的一些想法?我还需要再向这个数据库添加两个表。从代码创建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( “数据库中创建”);?'这是执行 –