Syntax error in Java, MySQL

0

I have a syntax error in the following String and I do not know what is due. Nparte is of type int .

String editSQL="UPDATE PARTESDETRABAJO SET DESCRIPCIONTAREA=?,"+"FECHAENTRADA=?,"+"FECHAENTREGA=?,"+"TIEMPOEMPLEADO=?"+"WHERE NPARTE="+sesion.getAttribute("ENparte");

I get the following error and I can not solve it, I have passed sesion.getAttribute("ENparte") to int and I am peta, but as is the error is this:

  

Error: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You   have an error in your SQL syntax; check the manual that corresponds to   your MySQL server version for the right syntax to use near 'NPARTE = 1'   at line 1

    
asked by gulez 06.06.2018 в 10:53
source

1 answer

3

Where you have written

"TIEMPOEMPLEADO=?"+"WHERE NPARTE="

you must put

"TIEMPOEMPLEADO=?"+" WHERE NPARTE="

You have not left space before the WHERE and that is why the query is failing you.

Although if we are strict, I do not know why the query in that concatenation. You could directly write

String editSQL="UPDATE PARTESDETRABAJO SET DESCRIPCIONTAREA=?, FECHAENTRADA=?, FECHAENTREGA=?, TIEMPOEMPLEADO=? WHERE NPARTE="+sesion.getAttribute("ENparte");
    
answered by 06.06.2018 / 11:00
source