Skip to content
Advertisement

having trouble inserting values into table with syntax error

Everytime at around “composedLine = String.format(“%s, %s, %s, %s, %s”, composedLine, values[0], values[1], values[2], values[3]);” it produces “INSERT INTO airport VALUES (, ABR, Aberdeen Regional Airport, Aberdeen”

instead of “INSERT INTO airport VALUES (ABR, Aberdeen Regional Airport, Aberdeen”

which causes a syntax error when I use executeupdate due to the “,” before the ABR.

JavaScript

Advertisement

Answer

This code is a security vulnerability. Specifically, SQL injection. This is not how you do it.

The correct way also solves your problem in passing. Thus, solution: Do it the correct way, solves all your problems.

Correct way:

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