UCAExc ::: 3.0.7用户缺少未找到的权限或对象:SLIPSET

时间:2016-11-30 18:08:08

标签: java sql ms-access jdbc ucanaccess

我查看了此网站上的类似主题,但似乎没有任何建议的答案可行。我正在编写一个使用SQL与Access数据库交互的java程序。我已成功连接到数据库并从中提取信息。但是,我需要更新数据库,并且我一直遇到此错误

  

UCAExc ::: 3.0.7用户缺少未找到的权限或对象:SLIPSET

为什么我无法成功更新Access数据库?

以下是与更新相关的代码

String sqlSlip ="UPDATE Slip" +
                "SET slipOpen = 0 AND boatID =?" +
                "WHERE slipNumber = ?";

PreparedStatement slipUpdate = connection.prepareStatement(sqlSlip);
slipUpdate.setDouble(1, boatIDdub);
slipUpdate.setDouble(2, rs.getInt("slipNumber"));

ResultSet updateSlip = slipUpdate.executeQuery();

String sqlCustomer = " INSERT INTO Customer(customerLName, customerFName, slipNumber, boatID, customerNumber)" +
                     "VALUES (?, ?, ?, ?, ?)";

PreparedStatement custUpdate = connection.prepareStatement(sqlCustomer);
custUpdate.setString(1,custLName);
custUpdate.setString(2, custFName);
custUpdate.setDouble(3, rs.getInt("slipNumber"));
custUpdate.setDouble(4, boatIDdub);
custUpdate.setDouble(5, customerNumber);

ResultSet updateCust = custUpdate.executeQuery();
connection.close()

1 个答案:

答案 0 :(得分:2)

如果您要检查sqlSlip字符串的内容,您会看到它包含

UPDATE SlipSET slipOpen = 0 AND boatID =?WHERE slipNumber = ?

您需要在每个字符串片段的末尾添加一个空格,并使用逗号而不是AND ...

String sqlSlip ="UPDATE Slip " +
                "SET slipOpen = 0, boatID = ? " +
                "WHERE slipNumber = ?";

...以便字符串包含

UPDATE Slip SET slipOpen = 0, boatID = ? WHERE slipNumber = ?

另请注意,要执行INSERT查询,您需要使用.executeUpdate(),而不是.executeQuery()