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 2020/11/26 10:10:35 UTC

[GitHub] [shardingsphere] thinwonton removed a comment on issue #8333: java.lang.NullPointerException: Can not get connection from datasource pr_ds. (version 5.0.0)

thinwonton removed a comment on issue #8333:
URL: https://github.com/apache/shardingsphere/issues/8333#issuecomment-734203926


   This problem mentioned above also happen at the sharding-jdbc version 4.x, 5.0.
   It seems that the problem is relation to the springboot version which is responsibility for resoving the configuration name. I soloved the problem with changing the datasource name using '**-**' not the '**_**' .
   
   my exception message bellows:
   ![image](https://user-images.githubusercontent.com/6516187/100337428-5182c000-3012-11eb-8c60-f9a44693f235.png)
   
   
   and the profile is :
   `
   spring.shardingsphere.datasource.names=ds_master,ds_slave
   
   #主库
   spring.shardingsphere.datasource.ds_master.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.ds_master.driver-class-name=com.mysql.cj.jdbc.Driver
   spring.shardingsphere.datasource.ds_master.jdbc-url=jdbc:mysql://localhost:3306/sjdbc-master-slave-m?serverTimezone=GMT%2B8&useSSL=false&useUnicode=true&characterEncoding=UTF-8
   spring.shardingsphere.datasource.ds_master.username=root
   spring.shardingsphere.datasource.ds_master.password=123456
   spring.shardingsphere.datasource.ds_master.hikari.connection-init-sql=select 1
   
   #从库
   spring.shardingsphere.datasource.ds_slave.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.ds_slave.driver-class-name=com.mysql.cj.jdbc.Driver
   spring.shardingsphere.datasource.ds_slave.jdbc-url=jdbc:mysql://localhost:3306/sjdbc-master-slave-s?serverTimezone=GMT%2B8&useSSL=false&useUnicode=true&characterEncoding=UTF-8
   spring.shardingsphere.datasource.ds_slave.username=root
   spring.shardingsphere.datasource.ds_slave.password=123456
   spring.shardingsphere.datasource.ds_slave.hikari.connection-init-sql=select 1
   
   #主从配置
   spring.shardingsphere.masterslave.load-balance-algorithm-type=round_robin
   spring.shardingsphere.masterslave.name=ds_ms
   spring.shardingsphere.masterslave.master-data-source-name=ds_master
   spring.shardingsphere.masterslave.slave-data-source-names=ds_slave
   `
   


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

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