baomidou / mybatis-plus

An powerful enhanced toolkit of MyBatis for simplify development
https://baomidou.com
Apache License 2.0
16.41k stars 4.31k forks source link

在mybatis-puls 3.5.3.1版本中使用IllegalSQLInnerInterceptor插件出现异常 #6190

Closed haoyi01 closed 5 months ago

haoyi01 commented 5 months ago

java 8 + mysql 8.0+ mybatis-puls 3.5.3.1 使用druid 1.1.7数据源 出现异常: debug 后 发现是 IllegalSQLInnerInterceptor#getIndexInfos 方法中:conn.getSchema() 报错:

getIndexInfo fault, with key:null, dbName:null, tableName:member_reservation_store java.sql.SQLFeatureNotSupportedException at com.alibaba.druid.pool.DruidPooledConnection.getSchema(DruidPooledConnection.java:1191) 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 org.apache.ibatis.logging.jdbc.ConnectionLogger.invoke(ConnectionLogger.java:63) at com.sun.proxy.$Proxy107.getSchema(Unknown Source) at com.baomidou.mybatisplus.extension.plugins.inner.IllegalSQLInnerInterceptor.getIndexInfos(IllegalSQLInnerInterceptor.java:325) at com.baomidou.mybatisplus.extension.plugins.inner.IllegalSQLInnerInterceptor.getIndexInfos(IllegalSQLInnerInterceptor.java:303) at com.baomidou.mybatisplus.extension.plugins.inner.IllegalSQLInnerInterceptor.validUseIndex(IllegalSQLInnerInterceptor.java:229) at com.baomidou.mybatisplus.extension.plugins.inner.IllegalSQLInnerInterceptor.validWhere(IllegalSQLInnerInterceptor.java:280) at com.baomidou.mybatisplus.extension.plugins.inner.IllegalSQLInnerInterceptor.validWhere(IllegalSQLInnerInterceptor.java:285) at com.baomidou.mybatisplus.extension.plugins.inner.IllegalSQLInnerInterceptor.validWhere(IllegalSQLInnerInterceptor.java:285) at com.baomidou.mybatisplus.extension.plugins.inner.IllegalSQLInnerInterceptor.validWhere(IllegalSQLInnerInterceptor.java:249) at com.baomidou.mybatisplus.extension.plugins.inner.IllegalSQLInnerInterceptor.processSelect(IllegalSQLInnerInterceptor.java:125) at com.baomidou.mybatisplus.extension.parser.JsqlParserSupport.processParser(JsqlParserSupport.java:91) at com.baomidou.mybatisplus.extension.parser.JsqlParserSupport.parserSingle(JsqlParserSupport.java:50) at com.baomidou.mybatisplus.extension.plugins.inner.IllegalSQLInnerInterceptor.beforePrepare(IllegalSQLInnerInterceptor.java:111) at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:102) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62) at com.sun.proxy.$Proxy106.prepare(Unknown Source) 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 org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49) at com.d1m.plugin.mybatis.sensitive.interceptor.SensitiveAndEncryptWriteInterceptor.intercept(SensitiveAndEncryptWriteInterceptor.java:162)

haoyi01 commented 5 months ago

后续发现druid 连接池 无实现getSchema方法 getCatalog就已经返回了 schema 这块是不是需要根据不同的数据源做下兼容?

miemieYaho commented 5 months ago

什么年代了还用druid

nieqiurong commented 5 months ago

mybatis-plus最低要求都1.8了,而getSchema是属于jdk1.7开始的,对应的jdbc规范是4.1,Java高版本能使用低版本驱动,请检查驱动和连接池支持情况,有可能是连接池不支持驱动支持。

nieqiurong commented 5 months ago

https://github.com/alibaba/druid/releases/tag/1.2.1