You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "sl2026 (via GitHub)" <gi...@apache.org> on 2023/07/25 06:42:06 UTC

[GitHub] [shardingsphere] sl2026 opened a new issue, #27439: An error occurs after use shadingsphere-jdbc

sl2026 opened a new issue, #27439:
URL: https://github.com/apache/shardingsphere/issues/27439

   shardingsphere-jdbc version 5.2.1
   maven 
   `
          <dependency>
   			<groupId>org.apache.shardingsphere</groupId>
   			<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
   			<version>5.2.1</version>
   		</dependency>
   `
   error message :
   `
   Caused by: org.apache.ibatis.executor.ExecutorException: Error preparing statement.  Cause: org.apache.shardingsphere.dialect.exception.syntax.database.UnknownDatabaseException
   	at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:97)
   	at org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:59)
   	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.baomidou.mybatisplus.extension.plugins.PaginationInterceptor.intercept(PaginationInterceptor.java:193)
   	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
   	at com.sun.proxy.$Proxy1524.prepare(Unknown Source)
   	at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.prepareStatement(MybatisSimpleExecutor.java:94)
   	at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doQuery(MybatisSimpleExecutor.java:68)
   	at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
   	at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
   	at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:165)
   	at org.apache.ibatis.executor.loader.ResultLoader.selectList(ResultLoader.java:81)
   	at org.apache.ibatis.executor.loader.ResultLoader.loadResult(ResultLoader.java:70)
   	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getNestedQueryMappingValue(DefaultResultSetHandler.java:799)
   	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getPropertyMappingValue(DefaultResultSetHandler.java:504)
   	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyPropertyMappings(DefaultResultSetHandler.java:480)
   	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:404)
   	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:354)
   	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:328)
   	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:301)
   	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:194)
   	at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:65)
   	at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
   	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.Plugin.invoke(Plugin.java:63)
   	at com.sun.proxy.$Proxy1524.query(Unknown Source)
   	at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doQuery(MybatisSimpleExecutor.java:69)
   	at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
   	at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
   	at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:165)
   	at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:92)
   	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.Plugin.invoke(Plugin.java:63)
   	at com.sun.proxy.$Proxy1523.query(Unknown Source)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
   	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.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
   	... 126 common frames omitted
   Caused by: org.apache.shardingsphere.dialect.exception.syntax.database.UnknownDatabaseException: null
   	at org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.lambda$getSchemas$0(SelectStatementContext.java:138)
   	at org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions.checkNotNull(ShardingSpherePreconditions.java:55)
   	at org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.getSchemas(SelectStatementContext.java:138)
   	at org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.<init>(SelectStatementContext.java:116)
   	at org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.createSubqueryContexts(SelectStatementContext.java:125)
   	at org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.<init>(SelectStatementContext.java:111)
   	at org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.createSubqueryContexts(SelectStatementContext.java:125)
   	at org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.<init>(SelectStatementContext.java:111)
   	at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.getDMLStatementContext(SQLStatementContextFactory.java:163)
   	at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.newInstance(SQLStatementContextFactory.java:146)
   	at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.newInstance(SQLStatementContextFactory.java:131)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(ShardingSpherePreparedStatement.java:196)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(ShardingSpherePreparedStatement.java:160)
   	at org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection.prepareStatement(ShardingSphereConnection.java:91)
   	at org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:86)
   	at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:88)
   	... 176 common frames omitted
   `
   in mybatis plus  use "select "
   also ok,but use shardingsphere-jdbc alert select error
   
   
   
   Specific query is :
   <resultMap id="q2" type="e1">
           <id column="id" property="id"/>
           <result column="c1" property="c1"/>
           <result column="c2" property="c2"/>
           <collection property="c3" ofType="e2" select="q3" column="{c3=c3,c4=c4,c5=c5}" >
   
           </collection>
   
       </resultMap>
   <select id = 'q1' resultMap="q2">
   </select>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] sl2026 commented on issue #27439: An error occurs after use shadingsphere-jdbc

Posted by "sl2026 (via GitHub)" <gi...@apache.org>.
sl2026 commented on issue #27439:
URL: https://github.com/apache/shardingsphere/issues/27439#issuecomment-1651373125

   this is shardingsphere-jdbc config
   ```
     # shardingspere 配置
     shardingsphere:
       datasource:
         names: w0,r0
         w0:
           type: com.alibaba.druid.pool.DruidDataSource
           url: jdbc:mysql://localhost:3306/db1
           username: username
           password: pwd
           driver-class-name: com.mysql.cj.jdbc.Driver
         r0:
           type: com.alibaba.druid.pool.DruidDataSource
           url: jdbc:mysql://localhost:3307/db2
           username: username
           password: pwd
           driver-class-name: com.mysql.cj.jdbc.Driver
       rules:
         readwrite-splitting:
           data-sources:
             rw_db:
               static-strategy:
                 write-data-source-name: w0
                 read-data-source-names: r0
               load-balancer-name: rw_round
           load-balancers:
             rw_round:
               type: ROUND_ROBIN
       mode:
         type: Standalone
         repository:
           type: JDBC
       props:
         sql-show: true
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zhaojinchao95 commented on issue #27439: An error occurs after use shadingsphere-jdbc

Posted by "zhaojinchao95 (via GitHub)" <gi...@apache.org>.
zhaojinchao95 commented on issue #27439:
URL: https://github.com/apache/shardingsphere/issues/27439#issuecomment-1651006786

   Please provider your configuration and `SQL`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] sl2026 commented on issue #27439: An error occurs after use shadingsphere-jdbc

Posted by "sl2026 (via GitHub)" <gi...@apache.org>.
sl2026 commented on issue #27439:
URL: https://github.com/apache/shardingsphere/issues/27439#issuecomment-1652802602

   ok,plase close,
   no database name,only tables name


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] sl2026 commented on issue #27439: An error occurs after use shadingsphere-jdbc

Posted by "sl2026 (via GitHub)" <gi...@apache.org>.
sl2026 commented on issue #27439:
URL: https://github.com/apache/shardingsphere/issues/27439#issuecomment-1652123639

   this is ready running sql
   `
   SELECT t2.mname      AS baseName,
          t3.ename      AS entName,
          t1.id,
          t1.uname     AS unitName,
          t1.synch_update_state,
          t1.unit_risk_level,
          IFNULL(NULL, '') AS pname,
          IFNULL(NULL, '') AS rlevel
   FROM  t1
            LEFT JOIN  t2 ON t2.id = t1.baseid
            LEFT JOIN  t3 ON t3.id = t2.entid
   WHERE t1.unit_source = '1'
     AND t1.baseid = '123'
   ORDER BY t1.create_time DESC LIMIT 1;
   
   
   SELECT t3.post_risk_level     AS riskLevelText,
          t4.duty                  AS duty,
          t4.id                    AS postId,
          t4.post_name             AS postName,
          t4.shift                 AS shift,
          (SELECT COUNT(1)
           FROM  t1
                    LEFT JOIN  t2 ON t1.staff_Id = t2.id
           WHERE t1.post_id = t4.id
             AND t2.delflag = '0') AS staffNum,
          d.accident_name,
          e.area_name,
          t4.main_device           AS mainDevice
   FROM  t3
            LEFT JOIN  t4 ON t4.id = t3.post_id
            LEFT JOIN (SELECT GROUP_CONCAT(`txt`.`accidentName` SEPARATOR ',') AS `accident_name`,
                              `txt`.`postId`                                   AS `postId`
                       FROM (SELECT `pc`.`post_id` AS `postId`, `dt`.`item_text` AS `accidentName`
                             FROM ((  `pc` LEFT JOIN  `dt` ON ((`pc`.`accident_type` = CONVERT(`dt`.`item_value` USING utf8mb4))) )
                                      LEFT JOIN  `d` ON ((`dt`.`dict_id` = `d`.`id`)) )
                             WHERE (`d`.`dict_code` = 'dtype')) `txt`
                       GROUP BY `txt`.`postId`) `d` ON `d`.`postId` = t4.`id`
            LEFT JOIN (SELECT GROUP_CONCAT(`area`.`area_name` SEPARATOR ',') AS `area_name`, `area`.`post_id` AS `post_id`
                       FROM (SELECT `pa`.`post_id` AS `post_id`, `a`.`area_name` AS `area_name`
                             FROM ( `pa`
                                      LEFT JOIN  `a` ON ((`a`.`id` = `pa`.`area_id`)) )) `area`
                       GROUP BY `area`.`post_id`) `e` ON ((`e`.`post_id` = t4.`id`))
   WHERE t3.risk_unit_id = '123456'
   ORDER BY t3.post_risk_level ASC`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zhaojinchao95 commented on issue #27439: An error occurs after use shadingsphere-jdbc

Posted by "zhaojinchao95 (via GitHub)" <gi...@apache.org>.
zhaojinchao95 commented on issue #27439:
URL: https://github.com/apache/shardingsphere/issues/27439#issuecomment-1651564909

   What is `SQL`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] sl2026 closed issue #27439: An error occurs after use shadingsphere-jdbc

Posted by "sl2026 (via GitHub)" <gi...@apache.org>.
sl2026 closed issue #27439: An error occurs after use shadingsphere-jdbc
URL: https://github.com/apache/shardingsphere/issues/27439


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org