My program executes INSERT query. When I run it, I get an 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 'INSERT INTO words(lang1, lang2, category, lang2_code, user) SELECT 'ahoj', 'hell' at line 1
I tried to print the actual statement to the stdout:
SET @lang:='Angličtina', @categ:='Nová';
INSERT INTO words(lang1, lang2, category, lang2_code, user)
SELECT 'ahoj', 'hello', c.id, l.id, 1 FROM categories c, languages l
WHERE c.name = @categ AND l.name = @lang;
As you can see, the statement is altered in the log. 'hell'
instead of 'hello'
. When I copy that into the mysql command line and execute, it works just fine so I assume the problem is in the JDBC somewhere.