It is divided into single data source configuration and multi data source configuration. ShardingSphere-JDBC Supports all JDBC drivers and database connection pools.

In this example, the database driver is MySQL, and connection pool is HikariCP, which can be replaced with other database drivers and connection pools.

Configuration Item Explanation

  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: # Class name of database driver, ref property of connection pool
  5. jdbcUrl: # Database URL, ref property of connection pool
  6. username: # Database username, ref property of connection pool
  7. password: # Database password, ref property of connection pool
  8. # ... Other properties for data source pool

Example

  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