Background

ShardingSphere-JDBC Supports all JDBC drivers and database connection pools.

In this example, the database driver is MySQL, and the connection pool is HikariCP, which can be replaced with other database drivers and connection pools. When using ShardingSphere JDBC, the property name of the JDBC pool depends on the definition of the respective JDBC pool and is not defined by ShardingSphere. For related processing, please refer to the class org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCreator. For example, with Alibaba Druid 1.2.9, using url instead of jdbcUrl in the example below is the expected behavior.

Parameters

  1. dataSources: # Data sources configuration, multiple <data-source-name> available
  2. <data-source-name>: # Data source name
  3. dataSourceClassName: # Data source class name
  4. driverClassName: # The database driver class name is subject to the configuration of the database connection pool itself
  5. jdbcUrl: # The database URL connection is subject to the configuration of the database connection pool itself
  6. username: # Database user name, subject to the configuration of the database connection pool itself
  7. password: # The database password is subject to the configuration of the database connection pool itself
  8. # ... Other properties of data source pool

Sample

  1. dataSources:
  2. ds_1:
  3. dataSourceClassName: com.zaxxer.hikari.HikariDataSource
  4. driverClassName: com.mysql.jdbc.Driver
  5. jdbcUrl: jdbc:mysql://localhost:3306/ds_1
  6. username: root
  7. password:
  8. ds_2:
  9. dataSourceClassName: com.zaxxer.hikari.HikariDataSource
  10. driverClassName: com.mysql.jdbc.Driver
  11. jdbcUrl: jdbc:mysql://localhost:3306/ds_2
  12. username: root
  13. password:
  14. # Configure other data sources