Skip to content
Advertisement

Using Java, update an exisitng SQL table row from Excel Sheet

I am using apache Poi to pull data from an excel sheet that’s uploaded to the server. The object is to pull the excel data, which has four columns (clientId, clientName, monthlyMinimum, setUpFee), and update an existing row’s monthly minimum & set up fee, based off the clientId, in an existing database table named client. I have this code in a different section of my project to Insert a new client and it works, but am struggling to get it to update an existing one. Can anyone tell me what I am doing wrong with the clientId, where it is not updating these two fields?

Update: I updated the code to include the wisdom from one of the comments, but it’s still not quite working. I am getting stuck inside the if statement for count modulus batchsize. This is the Database error it is throwing: java.sql.BatchUpdateException: Incorrect syntax near ‘(‘.

Advertisement

Answer

The answer above solved half of my issues. The other half of the issue was the update statement. Should be String sql = "UPDATE client SET monthlyMinimum = ? , oliSetUpFee= ? WHERE clientId = ?";

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement