请帮助我找出如何允许mysql连接器j定义用户变量并使此代码有效:
Statement s = conn.createStatement();
s.executeQuery ("set @categoryId := (Select CategoryId from categories order by CategoryId desc LIMIT 1);\n" +
"set @categoryId := IF(@categoryId is Null, 1, @categoryId);");
现在它引发了一个异常:
MysqLSyntaxErrorException occured : 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 @categoryId := IF(@categoryId is Null, 1, @categoryId)' at line 2
我知道在.net中你可以在连接字符串中定义“允许用户变量=真”选项.如何在java中做到这一点?
解决方法:
我发现了如何使它工作.只需设置datasource属性allowMultiQueries = true
jdbc:MysqL://localhost:3306/DBS?allowMultiQueries=true
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。