I am producing a small website for educational purposes, and very new to JSP and the JDBC. I have been stuck all day, on a small piece of code (which have fundamental issues), and hopefully someone can help .
As its the holiday season, i have emailed my tutor for some help but they will not return until early january
Basically, i am trying to run two SQL Queries within the same code, one which inserts data to a table and the other to update another table.
I have attached the area of the code below and the error description.
Hopefully someone can point me in the right direction. I have also tried using a batch execute, but that didnt work either.
Well, first of all you should be using PreparedStatement to do your insertions and updates. Especially when the data is coming from the user of a web application, you're just asking for an SQL injection attack.
But back to the basic problem. If you want to execute two updates, just execute one and then execute the other. There isn't anything in JDBC which lets you combine two random updates and execute them in one statement.
Oh, and don't use "LIKE" in your where-clause if you really mean "equal". At best you're just making the database do extra work and at worst you'll accidentally update records which shouldn't be updated. There's nothing like updating every record in a table to have the same data to spoil your day. Especially if you didn't have a backup.