1
爲什麼此語句在工作臺中工作正常,但在Java中不起作用。SQL在Java中無效,但在Workbench中不存在語法
SET @sqlstmt := IF(@exist <= 0, 'select ''INFO: Key does not exist.''', 'ALTER TABLE `SOMETABLE` DROP FOREIGN KEY `SOMEKEY`');
在Java中,我得到
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 'SET @sqlstmt := IF(@exist <= 0, 'select ''INFO: Key does not exist.''', 'ALTER ' at line 1
這些引號看起來很奇怪。不是'''而不是兩個單引號嗎? – 11684
你試過簡化查詢來隔離導致錯誤的部分嗎? – djechlin
你知道JDBC用作分隔符麼? – 11684