You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/05/08 04:04:26 UTC

[GitHub] [shardingsphere] Jiutwo opened a new issue, #17440: "url not set" probleam with Druid connection pool

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

   ## Bug Report
   
   
   ### Which version of ShardingSphere did you use?
   5.1.1
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   ### Expected behavior
   Execute a simple sql statement
   ### Actual behavior
   Throw a Exception
   ~~~
   org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shardingSphereDataSource' defined in class path resource [org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'shardingSphereDataSource' threw exception; nested exception is java.lang.IllegalArgumentException: url not set
   ~~~
   ### Reason analyze (If you can)
   There may be a problem in reading the configuration of sharding
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   The environment is `SpringBoot:2.6.7 + Durid:1.29 + Mybatis-Plus:3.5.1` .
   
   The configuration of shardingsphere
   ~~~properties
   spring.shardingsphere.datasource.names=write-ds,read-ds
   
   
   spring.shardingsphere.datasource.write-ds.type=com.alibaba.druid.pool.DruidDataSource
   spring.shardingsphere.datasource.write-ds.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.write-ds.jdbc-url=jdbc:mysql://192.168.200.130:3307/user_db?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
   spring.shardingsphere.datasource.write-ds.username=root
   spring.shardingsphere.datasource.write-ds.password=root
   
   
   spring.shardingsphere.datasource.read-ds.type=com.alibaba.druid.pool.DruidDataSource
   spring.shardingsphere.datasource.read-ds.driver-class-name=com.mysql.cj.jdbc.Driver
   spring.shardingsphere.datasource.read-ds.jdbc-url=jdbc:mysql://192.168.200.130:3308/user_db?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
   spring.shardingsphere.datasource.read-ds.username=root
   spring.shardingsphere.datasource.read-ds.password=root
   
   
   spring.shardingsphere.rules.sharding.tables.t_user.actual-data-nodes=readwrite_ds.t_user
   spring.shardingsphere.props.sql-show=true
   
   
   spring.shardingsphere.rules.readwrite-splitting.data-sources.readwrite_ds.type=Static
   
   spring.shardingsphere.rules.readwrite-splitting.data-sources.readwrite_ds.props.write-data-source-name=write-ds
   spring.shardingsphere.rules.readwrite-splitting.data-sources.readwrite_ds.props.read-data-source-names=read-ds
   
   spring.shardingsphere.rules.readwrite-splitting.data-sources.readwrite_ds.load-balancer-name=round_robin
   spring.shardingsphere.rules.readwrite-splitting.load-balancers.round_robin.type=ROUND_ROBIN
   ~~~
   I call the selectById() method provided by Mybatis-Plus. For example: 
   ~~~java
   @Test
   public void select() {
       User user = userMapper.selectById(43242324L);
       System.out.println(user);
   }
   ~~~
   
   --------------------
   When I change the datasource configuration as follows: 
   ~~~properties
   # change 'jdbc-url' to 'url'
   spring.shardingsphere.datasource.write-ds.url=jdbc:mysql://192.168.200.130:3307/user_db?
   spring.shardingsphere.datasource.read-ds.url=jdbc:mysql://192.168.200.130:3308/user_db?
   ~~~
   It works well. 
   If I use HikariCP connection poll, either 'jdbc-url' or 'url' will work well.
   ### Example codes for reproduce this issue (such as a github link).
   


-- 
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] Jiutwo closed issue #17440: "url not set" probleam with Druid connection pool

Posted by GitBox <gi...@apache.org>.
Jiutwo closed issue #17440: "url not set" probleam with Druid connection pool
URL: https://github.com/apache/shardingsphere/issues/17440


-- 
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] linghengqian commented on issue #17440: "url not set" probleam with Druid connection pool

Posted by GitBox <gi...@apache.org>.
linghengqian commented on issue #17440:
URL: https://github.com/apache/shardingsphere/issues/17440#issuecomment-1126725212

   A documentation related PR is ready.


-- 
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] linghengqian commented on issue #17440: "url not set" probleam with Druid connection pool

Posted by GitBox <gi...@apache.org>.
linghengqian commented on issue #17440:
URL: https://github.com/apache/shardingsphere/issues/17440#issuecomment-1120406305

   - You can refer to `shardingsphere/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json` and its corresponding execution class `org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCreator` . The JDBC pool property name depends entirely on the connection pool itself. 
   - So for `alibaba druid`, use `url` instead of `jdbc-url` is predictable.


-- 
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] linghengqian commented on issue #17440: "url not set" probleam with Druid connection pool

Posted by GitBox <gi...@apache.org>.
linghengqian commented on issue #17440:
URL: https://github.com/apache/shardingsphere/issues/17440#issuecomment-1120431559

   This is actually related to the `5.1.0` change, and it might be better to include appropriate instructions in the documentation.🤔


-- 
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] Jiutwo commented on issue #17440: "url not set" probleam with Druid connection pool

Posted by GitBox <gi...@apache.org>.
Jiutwo commented on issue #17440:
URL: https://github.com/apache/shardingsphere/issues/17440#issuecomment-1120433219

   Thank you for your answer. 
   That what I think, the documen in official website is too simple to fully understand. And it would be better if there were more examples.


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