我有3个表,第一个表是restaurant owner,它的主键是restaurant\u name,第二个表是fines,它的主键是fine\u name,第三个表是它们之间的关系,称为restaurant\u mine,它将上面的两个主键作为外键。每当一个餐馆老板进了一顿新的饭,我都想去;餐厅名称和用餐名称将存储在彼此相邻的table上,如餐厅所有者x(其拥有餐厅y)输入了sanwdwich餐,则table上应包含y |三明治
代码:
try {
Connection conn = DriverManager.getConnection(dbURL, "hr", "hr");
String query = "INSERT INTO RESTURANT_MEAL (PRODUCT_NAME, RESTURANT_NAME)" + "values(?,?)";
Statement statement = conn.createStatement();
PreparedStatement insert = conn.prepareStatement(query);
insert = conn.prepareStatement(query);
for (int i = 0; i < products.size(); i++) {
insert.setString(1, products.get(i).getProductName());
insert.setString(2, businessName);
insert.execute();
}
insert.execute();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
输出:将饭菜保存在餐桌上,出现错误:
java.sql.sqlexception:索引::1处缺少in或out参数
关系表中没有保存任何内容
暂无答案!
目前还没有任何答案,快来回答吧!