-2

I have looked through similar threads on this site and none of the suggested answers seem to work. I am writing a java program that interacts with an Access database using SQL. I have successfully connected to the database and pulled information from it. However, I need to update the database and I keep running into this error

UCAExc:::3.0.7 user lacks privilege or object not found: SLIPSET

Why am I not able to successfully update the Access database?

Here is the code relevant to the updates

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()
Gord Thompson
  • 98,607
  • 26
  • 164
  • 342
ace7
  • 71
  • 1
  • 2
  • 6

1 Answers1

2

If you were to inspect the contents of your sqlSlip string you would see that it contains

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

You need to add a space to the end of each string fragment and use a comma instead of AND ...

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

... so that the string contains

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

Also note that to perform an INSERT query you need to use .executeUpdate(), not .executeQuery().

Gord Thompson
  • 98,607
  • 26
  • 164
  • 342