@JFinal 波总 用sql查一张表是否存在时报错,之前的项目可以用的啊?报错-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

@JFinal 波总 用sql查一张表是否存在时报错,之前的项目可以用的啊?报错

爱吃鱼的程序员 2020-06-06 09:19:56 109

sql:select * from information_schema.TABLES where TABLE_SCHEMA=(select database()) and `table_name` ='your table'

报错:

com.jfinal.plugin.activerecord.ActiveRecordException: java.lang.UnsupportedOperationException: Cannot support SQL for `schema.table`
    at com.jfinal.plugin.activerecord.DbPro.find(DbPro.java:329)
    at com.jfinal.plugin.activerecord.DbPro.findFirst(DbPro.java:355)
    at com.jfinal.plugin.activerecord.DbPro.findFirst(DbPro.java:364)
    at com.jfinal.plugin.activerecord.Db.findFirst(Db.java:301)
    at com.ymm.project.model.examine.Examine.getTableNames(Examine.java:94)
    at com.ymm.project.model.examine.Examine.adopt(Examine.java:64)
    at com.ymm.project.controller.examine.ExamineController.adopt(ExamineController.java:50)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.jfinal.aop.Invocation.invoke(Invocation.java:75)
    at com.jfinal.core.ActionHandler.handle(ActionHandler.java:81)
    at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:89)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.UnsupportedOperationException: Cannot support SQL for `schema.table`
    at io.shardingjdbc.core.parsing.parser.clause.TableReferencesClauseParser.parseTableFactor(TableReferencesClauseParser.java:67)
    at io.shardingjdbc.core.parsing.parser.dialect.mysql.clause.MySQLTableReferencesClauseParser.parseTableReference(MySQLTableReferencesClauseParser.java:24)
    at io.shardingjdbc.core.parsing.parser.clause.TableReferencesClauseParser.parse(TableReferencesClauseParser.java:54)
    at io.shardingjdbc.core.parsing.parser.sql.dql.select.AbstractSelectParser.parseTable(AbstractSelectParser.java:109)
    at io.shardingjdbc.core.parsing.parser.sql.dql.select.AbstractSelectParser.parseFrom(AbstractSelectParser.java:98)
    at io.shardingjdbc.core.parsing.parser.dialect.mysql.sql.MySQLSelectParser.parseInternal(MySQLSelectParser.java:50)
    at io.shardingjdbc.core.parsing.parser.sql.dql.select.AbstractSelectParser.parseInternal(AbstractSelectParser.java:81)
    at io.shardingjdbc.core.parsing.parser.sql.dql.select.AbstractSelectParser.parse(AbstractSelectParser.java:68)
    at io.shardingjdbc.core.parsing.parser.sql.dql.select.AbstractSelectParser.parse(AbstractSelectParser.java:46)
    at io.shardingjdbc.core.parsing.SQLParsingEngine.parse(SQLParsingEngine.java:50)
    at io.shardingjdbc.core.routing.router.ParsingSQLRouter.parse(ParsingSQLRouter.java:74)
    at io.shardingjdbc.core.routing.PreparedStatementRoutingEngine.route(PreparedStatementRoutingEngine.java:55)
    at io.shardingjdbc.core.jdbc.core.statement.ShardingPreparedStatement.route(ShardingPreparedStatement.java:150)
    at io.shardingjdbc.core.jdbc.core.statement.ShardingPreparedStatement.executeQuery(ShardingPreparedStatement.java:115)
    at com.jfinal.plugin.activerecord.DbPro.find(DbPro.java:314)
    at com.jfinal.plugin.activerecord.DbPro.find(DbPro.java:327)
    ... 32 more

SQL
分享到
取消 提交回答
全部回答(1)
  • 爱吃鱼的程序员
    2020-06-06 09:20:14
                        <p>注意观察最终的 sql,将里头的 :</p> 
    

    `schema.table`

    改成 :

    `schema`.`table`

     

    纯 sql 错误问题,与 jfinal 无关

     

                            谢谢波总,原因是shardingjdbc这的问题
                        
    
                            之前不是maven的项目可以用的,现在项目是maven jfinal3.6版本就报错了
    
                        
    
                            SELECT COUNT(TABLE_NAME) AS counts  FROM INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'ymm_lk_log_2'
    

    这是我打印出的sql,在数据库里可以运行的

    0 0
数据库
使用钉钉扫一扫加入圈子
+ 订阅

分享数据库前沿,解构实战干货,推动数据库技术变革

推荐文章
相似问题