SET @a=CONCAT('SELECT a.accout_,a.name,a.birthday_,b.name_j FROM users a,role b,users_role c WHERE a.`id`=c.`user_id` AND b.`id_j`=c.`role` LIMIT ',(#{page}-1)*#{rows},",",#{rows},'') PREPARE texts FROM @a EXECUTE texts
#{page}#{rows}为什么没有识别不出来 这是异常信息 求大佬指点一下 万分感谢
org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause: 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 'PREPARE texts FROM @a
EXECUTE texts' at line 2
### The error may exist in file [D:\mybatisSimple\out\artifacts\mybatisSimple_war_exploded\WEB-INF\classes\com\bypx\mapping\userXM.xml]
### The error may involve com.bypx.dao.UserXMDao.userquery-Inline
### The error occurred while setting parameters
### SQL: SET @a=CONCAT('SELECT a.accout_,a.name,a.birthday_,b.name_j FROM users a,role b,users_role c WHERE a.`id`=c.`user_id` AND b.`id_j`=c.`role` LIMIT ',(?-1)*?,",",?,'') PREPARE texts FROM @a EXECUTE texts
### Cause: 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 'PREPARE texts FROM @a
EXECUTE texts' at line 2
; bad SQL grammar []; nested exception is 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 'PREPARE texts FROM @a
EXECUTE texts' at line 2
你这个做法有点古怪,为什么传递一个字符串给MySQL?然后它是 PREPARE 可执行的SQL?
你用 Mybatis 直接 处理 page 和 rows 参数就可以了啊:
何必还搞个复杂难懂的东西呢?
项目里面很多翻页的语句?试试#PageHelper#!
从此只需要:
要想使用去看看文档吧。
不过,框架只是为你提高工作效率的而已,原理还是懂的最好。
参数是识别出来 可问题还是没有得到解决
org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause: 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 'PREPARE texts FROM @a
EXECUTE texts' at line 2
### The error may exist in file [D:\mybatisSimple\out\artifacts\mybatisSimple_war_exploded\WEB-INF\classes\com\bypx\mapping\userXM.xml]
### The error may involve com.bypx.dao.UserXMDao.userquery-Inline
### The error occurred while setting parameters
### SQL: SET @a=CONCAT('SELECT a.accout_,a.name,a.birthday_,b.name_j FROM users a,role b,users_role c WHERE a.`id`=c.`user_id` AND b.`id_j`=c.`role` LIMIT ',(1-1)*3,",",3,'') PREPARE texts FROM @a EXECUTE texts
### Cause: 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 'PREPARE texts FROM @a
EXECUTE texts' at line 2
; bad SQL grammar []; nested exception is 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 'PREPARE texts FROM @a
EXECUTE texts' at line 2
新的异常 说我
有问题难道是没有加分号的问题(O_O)?
有人吗