You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "renjiancheng (via GitHub)" <gi...@apache.org> on 2023/10/17 01:56:28 UTC

[I] How to change the dataSource to Druid on Shardingsphere JDBC5.4.0? [shardingsphere]

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

   ## Question
   i try to use Shardingsphere JDBC 5.4.0 with Druid datasource in a springboot project, but it's not woking.
    
   my application.yml 
   ```yaml
   spring:
     datasource:
       driver-class-name: org.apache.shardingsphere.driver.ShardingSphereDriver
       url: jdbc:shardingsphere:classpath:shardingJdbc.yml
     autoconfigure:
       exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
   ```
   
   my shardingJdbc.yml
   ```yaml
   mode: # 不配置默认单机
     type: Standalone # 运行模式类型。可选配置:Standalone、Cluster
     repository:
       type: JDBC # 持久化仓库类型
   dataSources:
     test:
       type: com.alibaba.druid.pool.DruidDataSource
       dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
       driverClassName: com.mysql.jdbc.Driver
       url: jdbc:mysql://localhost:3306/test
       username: root
       password: zard
   rules:
     - !SHARDING
       tables: # 数据分片规则配置
         customer:
           actualDataNodes: test.customer
           tableStrategy:
             standard:
               shardingColumn: customer_id
               shardingAlgorithmName: customer_id
           keyGenerateStrategy: # 分布式序列策略
             column: id
             keyGeneratorName: snowflake
       keyGenerators:
         snowflake:
           type: SNOWFLAKE
       shardingAlgorithms:
         customer_id:
           type: CLASS_BASED
           props:
             strategy: standard
             algorithmClassName: com.example.shardingjdbclearn.config.CspShardingAlgorithms
   props:
     sql-show: true
   ```
   
   my pom.xml
   ```xml
   <?xml version="1.0" encoding="UTF-8"?>
   <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
       <modelVersion>4.0.0</modelVersion>
       <parent>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-parent</artifactId>
           <version>2.6.15</version>
           <relativePath/> <!-- lookup parent from repository -->
       </parent>
       <groupId>com.example</groupId>
       <artifactId>sharding-jdbc-learn</artifactId>
       <version>0.0.1-SNAPSHOT</version>
       <name>sharding-jdbc-learn</name>
       <description>sharding-jdbc-learn</description>
       <properties>
           <java.version>1.8</java.version>
           <snakeyaml.version>1.33</snakeyaml.version>
           <shardingsphere.version>5.4.0</shardingsphere.version>
       </properties>
       <dependencies>
   ......
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter-web</artifactId>
           </dependency>
   
           <dependency>
               <groupId>com.mysql</groupId>
               <artifactId>mysql-connector-j</artifactId>
               <scope>runtime</scope>
           </dependency>
   
           <dependency>
               <groupId>com.baomidou</groupId>
               <artifactId>mybatis-plus-boot-starter</artifactId>
               <version>3.5.3.2</version>
           </dependency>
   
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>shardingsphere-jdbc-core</artifactId>
               <version>${shardingsphere.version}</version>
           </dependency>
   
           <dependency>
               <groupId>com.alibaba</groupId>
               <artifactId>druid-spring-boot-starter</artifactId>
               <version>1.2.16</version>
           </dependency>
       </dependencies>
    .....
   </project>
   
   ```
   the running log
   ```text
   Connected to the target VM, address: '127.0.0.1:56172', transport: 'socket'
   
     .   ____          _            __ _ _
    /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
   ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
    \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
     '  |____| .__|_| |_|_| |_\__, | / / / /
    =========|_|==============|___/=/_/_/_/
    :: Spring Boot ::               (v2.6.15)
   
   2023-10-16 17:59:24.532  INFO 93363 --- [           main] c.e.s.ShardingJdbcLearnApplication       : Starting ShardingJdbcLearnApplication using Java 1.8.0_381 on mbp.local with PID 93363 (/Users/renjiancheng/github/sharding-jdbc-learn/target/classes started by renjiancheng in /Users/renjiancheng/github/sharding-jdbc-learn)
   2023-10-16 17:59:24.534  INFO 93363 --- [           main] c.e.s.ShardingJdbcLearnApplication       : No active profile set, falling back to 1 default profile: "default"
   2023-10-16 17:59:25.103  INFO 93363 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
   2023-10-16 17:59:25.107  INFO 93363 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
   2023-10-16 17:59:25.107  INFO 93363 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.75]
   2023-10-16 17:59:25.200  INFO 93363 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
   2023-10-16 17:59:25.200  INFO 93363 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 525 ms
    _ _   |_  _ _|_. ___ _ |    _ 
   | | |\/|_)(_| | |_\  |_)||_|_\ 
        /               |         
                           3.5.3.2 
   2023-10-16 17:59:25.587  INFO 93363 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
   2023-10-16 17:59:25.592  INFO 93363 --- [           main] c.e.s.ShardingJdbcLearnApplication       : Started ShardingJdbcLearnApplication in 1.344 seconds (JVM running for 1.692)
   2023-10-16 17:59:28.842  INFO 93363 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
   2023-10-16 17:59:28.842  INFO 93363 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
   2023-10-16 17:59:28.843  INFO 93363 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
   2023-10-16 17:59:28.893  INFO 93363 --- [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
   2023-10-16 17:59:29.041  INFO 93363 --- [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Starting...
   2023-10-16 17:59:29.115  INFO 93363 --- [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Start completed.
   2023-10-16 17:59:29.204  INFO 93363 --- [nio-8080-exec-1] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} inited
   2023-10-16 17:59:30.960  INFO 93363 --- [nio-8080-exec-1] com.zaxxer.hikari.pool.PoolBase          : HikariPool-1 - Driver does not support get/set network timeout for connections. (getNetworkTimeout)
   2023-10-16 17:59:30.961  INFO 93363 --- [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
   2023-10-16 17:59:35.362 ERROR 93363 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: 
   ### Error updating database.  Cause: java.sql.SQLException: Table 'user' doesn't exist
   ### The error may exist in com/example/shardingjdbclearn/mapper/UserMapper.java (best guess)
   ### The error may involve com.example.shardingjdbclearn.mapper.UserMapper.insert-Inline
   ### The error occurred while setting parameters
   ### SQL: INSERT INTO user  ( id, csp_id, name, age, create_time )  VALUES  ( ?, ?, ?, ?, ? )
   ### Cause: java.sql.SQLException: Table 'user' doesn't exist
   ; bad SQL grammar []; nested exception is java.sql.SQLException: Table 'user' doesn't exist] with root cause
   
   java.sql.SQLException: Table 'user' doesn't exist
   	at org.apache.shardingsphere.dialect.mysql.mapper.MySQLDialectExceptionMapper.toSQLException(MySQLDialectExceptionMapper.java:120) ~[shardingsphere-mysql-dialect-exception-5.4.0.jar:5.4.0]
   	at org.apache.shardingsphere.dialect.mysql.mapper.MySQLDialectExceptionMapper.convert(MySQLDialectExceptionMapper.java:72) ~[shardingsphere-mysql-dialect-exception-5.4.0.jar:5.4.0]
   	at org.apache.shardingsphere.dialect.SQLExceptionTransformEngine.toSQLException(SQLExceptionTransformEngine.java:59) ~[shardingsphere-dialect-exception-core-5.4.0.jar:5.4.0]
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:416) ~[shardingsphere-jdbc-core-5.4.0.jar:5.4.0]
   	at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44) ~[HikariCP-4.0.3.jar:na]
   	at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java) ~[HikariCP-4.0.3.jar:na]
   	at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:48) ~[mybatis-3.5.13.jar:3.5.13]
   	at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:75) ~[mybatis-3.5.13.jar:3.5.13]
   	at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) ~[mybatis-3.5.13.jar:3.5.13]
   	at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) ~[mybatis-3.5.13.jar:3.5.13]
   	at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) ~[mybatis-3.5.13.jar:3.5.13]
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197) ~[mybatis-3.5.13.jar:3.5.13]
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184) ~[mybatis-3.5.13.jar:3.5.13]
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_381]
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_381]
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_381]
   	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_381]
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:425) ~[mybatis-spring-2.1.1.jar:2.1.1]
   	at com.sun.proxy.$Proxy58.insert(Unknown Source) ~[na:na]
   	at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) ~[mybatis-spring-2.1.1.jar:2.1.1]
   	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59) ~[mybatis-plus-core-3.5.3.2.jar:3.5.3.2]
   	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) ~[mybatis-plus-core-3.5.3.2.jar:3.5.3.2]
   	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) ~[mybatis-plus-core-3.5.3.2.jar:3.5.3.2]
   	at com.sun.proxy.$Proxy59.insert(Unknown Source) ~[na:na]
   	at com.example.shardingjdbclearn.web.TestController.register(TestController.java:33) ~[classes/:na]
   	at com.example.shardingjdbclearn.web.TestController$$FastClassBySpringCGLIB$$d7258042.invoke(<generated>) ~[classes/:na]
   	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.27.jar:5.3.27]
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) ~[spring-aop-5.3.27.jar:5.3.27]
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.27.jar:5.3.27]
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.27.jar:5.3.27]
   	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123) ~[spring-tx-5.3.27.jar:5.3.27]
   	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388) ~[spring-tx-5.3.27.jar:5.3.27]
   	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) ~[spring-tx-5.3.27.jar:5.3.27]
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.27.jar:5.3.27]
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.27.jar:5.3.27]
   	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) ~[spring-aop-5.3.27.jar:5.3.27]
   	at com.example.shardingjdbclearn.web.TestController$$EnhancerBySpringCGLIB$$1129f82f.register(<generated>) ~[classes/:na]
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_381]
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_381]
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_381]
   	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_381]
   	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.27.jar:5.3.27]
   	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.27.jar:5.3.27]
   	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.27.jar:5.3.27]
   	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.27.jar:5.3.27]
   	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.27.jar:5.3.27]
   	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.27.jar:5.3.27]
   	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1072) ~[spring-webmvc-5.3.27.jar:5.3.27]
   	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:965) ~[spring-webmvc-5.3.27.jar:5.3.27]
   	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.27.jar:5.3.27]
   	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) ~[spring-webmvc-5.3.27.jar:5.3.27]
   	at javax.servlet.http.HttpServlet.service(HttpServlet.java:555) ~[tomcat-embed-core-9.0.75.jar:4.0.FR]
   	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.27.jar:5.3.27]
   	at javax.servlet.http.HttpServlet.service(HttpServlet.java:623) ~[tomcat-embed-core-9.0.75.jar:4.0.FR]
   	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209) ~[tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) ~[tomcat-embed-websocket-9.0.75.jar:9.0.75]
   	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.27.jar:5.3.27]
   	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.27.jar:5.3.27]
   	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.27.jar:5.3.27]
   	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.27.jar:5.3.27]
   	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.27.jar:5.3.27]
   	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.27.jar:5.3.27]
   	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167) ~[tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) [tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:481) [tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130) [tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) [tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:390) [tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) [tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:926) [tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1791) [tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) [tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.75.jar:9.0.75]
   	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.75.jar:9.0.75]
   	at java.lang.Thread.run(Thread.java:750) [na:1.8.0_381]
   
   Disconnected from the target VM, address: '127.0.0.1:56172', transport: 'socket'
   2023-10-16 18:01:22.423  INFO 93363 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
   2023-10-16 18:01:22.425  INFO 93363 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
   ```
   
   i only config  a singe datasource of druid , but every time i try to use a database connection the druid and hikari  are both inited,
   <img width="1423" alt="image" src="https://github.com/apache/shardingsphere/assets/59160257/b302b21a-b893-4ae7-ba0e-8c458a4266c2">
   
   why hikari datasource inited?  how to disable it? and the table `user` is truly exsit, but why sql execute error and print 'Cause: java.sql.SQLException: Table 'user' doesn't exist'?
   
   the project is [here](https://github.com/renjiancheng/sharding-jdbc-learn.git)
   
   thank you!
   


-- 
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


Re: [I] How to change the dataSource to Druid on Shardingsphere JDBC5.4.0? [shardingsphere]

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

   - @zzyReal666 I suggest you open a new issue and provide unit tests - because using Alibaba Druid does involve a bug in ShardingSphere 5.4.1 and is fixed by an unknown commit on the master branch.


-- 
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


Re: [I] How to change the dataSource to Druid on Shardingsphere JDBC5.4.0? [shardingsphere]

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

   > 谢谢,按照你提醒的配置了单表以后确实程序能正常运行了,但是我之前看官方文档说是如果表不需要分库分表不需要单独配置呀?现在是变了吗? ![image](https://user-images.githubusercontent.com/59160257/276191351-a6ba365c-9b11-4800-abec-0b4263fb7952.png)
   > 
   > [如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?](https://shardingsphere.apache.org/document/current/cn/faq/#%E5%88%86%E7%89%87-%E5%A6%82%E6%9E%9C%E5%8F%AA%E6%9C%89%E9%83%A8%E5%88%86%E6%95%B0%E6%8D%AE%E5%BA%93%E5%88%86%E5%BA%93%E5%88%86%E8%A1%A8%E6%98%AF%E5%90%A6%E9%9C%80%E8%A6%81%E5%B0%86%E4%B8%8D%E5%88%86%E5%BA%93%E5%88%86%E8%A1%A8%E7%9A%84%E8%A1%A8%E4%B9%9F%E9%85%8D%E7%BD%AE%E5%9C%A8%E5%88%86%E7%89%87%E8%A7%84%E5%88%99%E4%B8%AD) 数据源同时加载的问题,我也还没头绪,解决了第一时间通知你。
   
   5.4应该是更新了


-- 
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


Re: [I] How to change the dataSource to Druid on Shardingsphere JDBC5.4.0? [shardingsphere]

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

   i also try to find answer at official document 、blog 、github issuses , i found nothing about this.  


-- 
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


Re: [I] How to change the dataSource to Druid on Shardingsphere JDBC5.4.0? [shardingsphere]

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

   > i also try to find answer at official document 、blog 、github issuses , i found nothing about this.
   
   user表没有配置分表规则说明是默认表加上这个配置:
   rules:
   - !SINGLE
     tables:
       - test.user # 加载指定单表
   hikari和druid同时初始化,我也在找答案,不知道怎么解决
   
   


-- 
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


Re: [I] How to change the dataSource to Druid on Shardingsphere JDBC5.4.0? [shardingsphere]

Posted by "renjiancheng (via GitHub)" <gi...@apache.org>.
renjiancheng closed issue #28779: How to change the dataSource to Druid on Shardingsphere JDBC5.4.0?
URL: https://github.com/apache/shardingsphere/issues/28779


-- 
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


Re: [I] How to change the dataSource to Druid on Shardingsphere JDBC5.4.0? [shardingsphere]

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

   I could not change HikarCP to Druid either.Cloud you please show me complete config? Here is my configuration file:
    pom:
   ![image](https://github.com/apache/shardingsphere/assets/34822229/ea79cff3-3b57-4bb6-9678-5aea574ad6a5)
   
   application:
   ![image](https://github.com/apache/shardingsphere/assets/34822229/d45f85e0-d0be-4a73-ab64-a62e81b225e0)
   
   config.xml:
   ![image](https://github.com/apache/shardingsphere/assets/34822229/a0fdbb8b-dfa1-4ed3-858a-de8f4b2879c0)
   
   ERROR:
   ![image](https://github.com/apache/shardingsphere/assets/34822229/516f81f1-6d2d-41b3-b477-5185d89d3006)
   
   


-- 
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


Re: [I] How to change the dataSource to Druid on Shardingsphere JDBC5.4.0? [shardingsphere]

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

   > > ```
   > > <dependency>
   > >         <groupId>com.alibaba</groupId>
   > >         <artifactId>druid-spring-boot-starter</artifactId>
   > >         <version>1.2.16</version>
   > > </dependency>
   > > ```
   > 
   > * To be honest, after looking at your example in [renjiancheng/sharding-jdbc-learn@ce5ae40](https://github.com/renjiancheng/sharding-jdbc-learn/commit/ce5ae4084c27324ec1a07498298352644de15cdb) , I don't understand why you need to use `com.alibaba:druid-spring-boot-starter` instead of `com.alibaba:druid`. You don't configure Druid-specific Spring Boot Starter content in `application.yml` or a Spring Bean. You even actively excluded the configuration in `com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure`.
   > 
   > > 谢谢,按照你提醒的配置了单表以后确实程序能正常运行了,但是我之前看官方文档说是如果表不需要分库分表不需要单独配置呀?现在是变了吗?
   > 
   > * FAQ-related content in https://shardingsphere.apache.org/document/5.4.0/en/faq/ is obsolete, and all FAQ-related content is now located directly on the Github Wiki. This FAQ has not been removed only because [Move FAQ from document to wiki page #19383](https://github.com/apache/shardingsphere/issues/19383) is not completed.
   > * Call @Swastyy, can we remove the FAQ page at the milestone of ShardingSphere 5.4.2?
   > 
   > > and the table user is truly exsit, but why sql execute error and print 'Cause: java.sql.SQLException: Table 'user' doesn't exist'?
   > 
   > * Starting with ShardingSphere 5.4.0, all database tables that are not configured with `RULES` are not automatically loaded into ShardingSphere's metadata. Refer to https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-jdbc/yaml-config/rules/single/ .
   > 
   > > i only config a singe datasource of druid , but every time i try to use a database connection the druid and hikari are both inited, why hikari datasource inited?
   > 
   > * This is completely reasonable. In fact, inside the initialized HikariCP DataSource you see is the ShardingSphere Standalone Mode initialized H2Database DataSource, which holds ShardingSphere metadata. If you switch to ShardingSphere Cluster Mode that uses any third-party metadata center, you will find that the same structure of data is stored in Zookeeper, Etcd, or another third-party metadata center. ShardingSphere implements reading and dynamic refresh of ShardingSphere's configuration through an SPI from a separate metadata center. This is reflected in the use of ContextManager within ShardingSphere JDBC and is further wrapped in DistSQL in ShardingSphere Proxy.
   > * In general, HikariCP's DataSources were created because Standalone Mode required it, and ShardingSphere relies on HikariCP. If you don't want to see HikariCP data sources created, you'll need to implement SPI for Standalone Mode.
   @zhanglinsong 加载hikari数据源是因为使用了standalone模式,默认使用它来连接h2维护shardingsphere元数据的,初始化逻辑在`org.apache.shardingsphere.mode.repository.standalone.jdbc.JDBCRepository`类里。
   @linghengqian thank you! it's very helpful, wish you good luck!


-- 
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


Re: [I] How to change the dataSource to Druid on Shardingsphere JDBC5.4.0? [shardingsphere]

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

   > i also try to find answer at official document 、blog 、github issuses , i found nothing about this.
   
   mode: # 不配置默认单机
     type: Standalone # 运行模式类型。可选配置:Standalone、Cluster
     repository:
       type: JDBC # 持久化仓库类型
   dataSources:
     test:
       type: com.alibaba.druid.pool.DruidDataSource
       dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
       driverClassName: com.mysql.jdbc.Driver
       url: jdbc:mysql://localhost:3306/test
       username: root
       password: zard
   rules:
     - !SHARDING
       tables: # 数据分片规则配置
         customer:
           actualDataNodes: test.customer
           tableStrategy:
             standard:
               shardingColumn: customer_id
               shardingAlgorithmName: customer_id
           keyGenerateStrategy: # 分布式序列策略
             column: id
             keyGeneratorName: snowflake
       keyGenerators:
         snowflake:
           type: SNOWFLAKE
       shardingAlgorithms:
         customer_id:
           type: CLASS_BASED
           props:
             strategy: standard
             algorithmClassName: com.example.shardingjdbclearn.config.CspShardingAlgorithms
   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


Re: [I] How to change the dataSource to Druid on Shardingsphere JDBC5.4.0? [shardingsphere]

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

   > i also try to find answer at official document 、blog 、github issuses , i found nothing about this.
   ### user表没有配置规则, 说明是单表,不需要分库,加入以下配置
   ```yml
   rules:
   - !SINGLE
     tables:
       - test.user # 加载指定库指定单表
   ```
   不清楚为什么会同时初始化hikari和druid,解决了说下
   
   


-- 
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


Re: [I] How to change the dataSource to Druid on Shardingsphere JDBC5.4.0? [shardingsphere]

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

   > > > * @zzyReal666 I suggest you open a new issue and provide unit tests - because using Alibaba Druid does involve a bug in ShardingSphere 5.4.1 and is fixed by an unknown commit on the master branch.
   > > 
   > > 
   > > Hello, may I know what bug it is? I also plan to use ShardingSphere 5.4.1 with Alibaba Druid...
   > 
   > * Verification of the fix status for that bug is at [v5.2, If a druid datasource has some filters, then create a ShardingSphereDataSource will occur exception #21211 (comment)](https://github.com/apache/shardingsphere/issues/21211#issuecomment-1932123528) . That was a bug about using a custom alibaba druid plugin in the ShardingSphere configuration file.
   > * Other existing open issues related to druid actually lack a reproducible example git.
   
   Get it, Thank you. I will review the issues submitted in the recent period.


-- 
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


Re: [I] How to change the dataSource to Druid on Shardingsphere JDBC5.4.0? [shardingsphere]

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

   > * @zzyReal666 I suggest you open a new issue and provide unit tests - because using Alibaba Druid does involve a bug in ShardingSphere 5.4.1 and is fixed by an unknown commit on the master branch.
   
   Hello, may I know what bug it is? I also plan to use ShardingSphere 5.4.1 with Alibaba Druid...


-- 
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


Re: [I] How to change the dataSource to Druid on Shardingsphere JDBC5.4.0? [shardingsphere]

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

   > > * @zzyReal666 I suggest you open a new issue and provide unit tests - because using Alibaba Druid does involve a bug in ShardingSphere 5.4.1 and is fixed by an unknown commit on the master branch.
   > 
   > Hello, may I know what bug it is? I also plan to use ShardingSphere 5.4.1 with Alibaba Druid...
   
   - Verification of the fix status for that bug is at https://github.com/apache/shardingsphere/issues/21211#issuecomment-1932123528 . That was a bug about using a custom alibaba druid plugin in the ShardingSphere configuration file.
   
   - Other existing open issues related to druid actually lack a reproducible example git.


-- 
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


Re: [I] How to change the dataSource to Druid on Shardingsphere JDBC5.4.0? [shardingsphere]

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

   谢谢,按照你提醒的配置了单表以后确实程序能正常运行了,但是我之前看官方文档说是如果表不需要分库分表不需要单独配置呀?现在是变了吗?
   ![image](https://github.com/apache/shardingsphere/assets/59160257/a6ba365c-9b11-4800-abec-0b4263fb7952)
   
   [如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?](https://shardingsphere.apache.org/document/current/cn/faq/#%E5%88%86%E7%89%87-%E5%A6%82%E6%9E%9C%E5%8F%AA%E6%9C%89%E9%83%A8%E5%88%86%E6%95%B0%E6%8D%AE%E5%BA%93%E5%88%86%E5%BA%93%E5%88%86%E8%A1%A8%E6%98%AF%E5%90%A6%E9%9C%80%E8%A6%81%E5%B0%86%E4%B8%8D%E5%88%86%E5%BA%93%E5%88%86%E8%A1%A8%E7%9A%84%E8%A1%A8%E4%B9%9F%E9%85%8D%E7%BD%AE%E5%9C%A8%E5%88%86%E7%89%87%E8%A7%84%E5%88%99%E4%B8%AD)
   数据源同时加载的问题,我也还没头绪,解决了第一时间通知你。


-- 
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


Re: [I] How to change the dataSource to Druid on Shardingsphere JDBC5.4.0? [shardingsphere]

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

   >  ```xml
   > <dependency>
   >          <groupId>com.alibaba</groupId>
   >          <artifactId>druid-spring-boot-starter</artifactId>
   >          <version>1.2.16</version>
   >  </dependency>
   > ```
   
   - To be honest, after looking at your example in https://github.com/renjiancheng/sharding-jdbc-learn/commit/ce5ae4084c27324ec1a07498298352644de15cdb , I don't understand why you need to use `com.alibaba:druid-spring-boot-starter` instead of `com.alibaba:druid`. You don't configure Druid-specific Spring Boot Starter content in `application.yml` or a Spring Bean. You even actively excluded the configuration in `com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure`.
   
   > 谢谢,按照你提醒的配置了单表以后确实程序能正常运行了,但是我之前看官方文档说是如果表不需要分库分表不需要单独配置呀?现在是变了吗?
   
   - FAQ-related content in https://shardingsphere.apache.org/document/5.4.0/en/faq/ is obsolete, and all FAQ-related content is now located directly on the Github Wiki. This FAQ has not been removed only because https://github.com/apache/shardingsphere/issues/19383 is not completed.
   
   - Call @Swastyy, can we remove the FAQ page at the milestone of ShardingSphere 5.4.2?
   
   > and the table user is truly exsit, but why sql execute error and print 'Cause: java.sql.SQLException: Table 'user' doesn't exist'?
   
   - Starting with ShardingSphere 5.4.0, all library tables that are not configured with `RULES` are not automatically loaded into ShardingSphere's metadata. Refer to https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-jdbc/yaml-config/rules/single/ .
   
   > i only config a singe datasource of druid , but every time i try to use a database connection the druid and hikari are both inited, why hikari datasource inited?
   
   - This is completely reasonable. In fact, inside the initialized HikariCP DataSource you see is the ShardingSphere Standalone Mode initialized H2Database DataSource, which holds ShardingSphere metadata. If you switch to ShardingSphere Cluster Mode that uses any third-party metadata center, you will find that the same structure of data is stored in Zookeeper, Etcd, or another third-party metadata center. ShardingSphere implements reading and dynamic refresh of ShardingSphere's configuration through an SPI from a separate metadata center. This is reflected in the use of ContextManager within ShardingSphere JDBC and is further wrapped in DistSQL in ShardingSphere Proxy.
   
   - In general, HikariCP's DataSources were created because Standalone Mode required it, and ShardingSphere relies on HikariCP. If you don't want to see HikariCP data sources created, you'll need to implement SPI for Standalone Mode.


-- 
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