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/08/26 06:29:49 UTC

[GitHub] [shardingsphere] 1260328762 opened a new issue, #20551: How do I configure multiple types of databases in one project

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

   ## How do I configure multiple types of databases in one project
   
   sharding.sphere.version: 5.1.2
   configuration file:
   ```properties
   spring.shardingsphere.datasource.names=geo,default
   
   spring.shardingsphere.mode.type=Standalone
   spring.shardingsphere.mode.repository.type=File
   spring.shardingsphere.mode.overwrite=true
   
   spring.shardingsphere.datasource.geo.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.geo.driver-class-name=org.postgresql.Driver
   spring.shardingsphere.datasource.geo.url=jdbc:postgresql://localhost:5432/test
   spring.shardingsphere.datasource.geo.username=root
   spring.shardingsphere.datasource.geo.password=root
   
   spring.shardingsphere.datasource.default.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.default.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.default.jdbc-url=jdbc:mysql://localhost:3306/test?useUnicode=true&useSSL=false&characterEncoding=utf8&rewriteBatchedStatements=true
   spring.shardingsphere.datasource.default.username=root
   spring.shardingsphere.datasource.default.password=root
   
   spring.shardingsphere.props.sql.show=true
   ```
   
   In this project, I configured two type of database,MySQL and PostgreSQL,an error occurred when I tried to run this project
   here is the stack trace
   ```text
   Caused by: java.lang.IllegalStateException: Database type inconsistent with 'org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType@7d7888a5' and 'org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType@6dcdc378'
   	at com.google.common.base.Preconditions.checkState(Preconditions.java:824) ~[guava-30.0-jre.jar:na]
   	at org.apache.shardingsphere.infra.database.type.DatabaseTypeEngine.getDatabaseType(DatabaseTypeEngine.java:91) ~[shardingsphere-infra-common-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.infra.database.type.DatabaseTypeEngine.getProtocolType(DatabaseTypeEngine.java:57) ~[shardingsphere-infra-common-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.mode.metadata.MetaDataContextsBuilder.build(MetaDataContextsBuilder.java:59) ~[shardingsphere-mode-core-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.mode.manager.standalone.StandaloneContextManagerBuilder.build(StandaloneContextManagerBuilder.java:59) ~[shardingsphere-standalone-mode-core-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.createContextManager(ShardingSphereDataSource.java:85) ~[shardingsphere-jdbc-core-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.<init>(ShardingSphereDataSource.java:68) ~[shardingsphere-jdbc-core-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory.createDataSource(ShardingSphereDataSourceFactory.java:77) ~[shardingsphere-jdbc-core-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration.shardingSphereDataSource(ShardingSphereAutoConfiguration.java:93) ~[shardingsphere-jdbc-core-spring-boot-starter-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration$$EnhancerBySpringCGLIB$$1f8c5010.CGLIB$shardingSphereDataSource$2(<generated>) ~[shardingsphere-jdbc-core-spring-boot-starter-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration$$EnhancerBySpringCGLIB$$1f8c5010$$FastClassBySpringCGLIB$$b6eb33bf.invoke(<generated>) ~[shardingsphere-jdbc-core-spring-boot-starter-5.1.2.jar:5.1.2]
   	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.2.15.RELEASE.jar:5.2.15.RELEASE]
   	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
   	at org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration$$EnhancerBySpringCGLIB$$1f8c5010.shardingSphereDataSource(<generated>) ~[shardingsphere-jdbc-core-spring-boot-starter-5.1.2.jar:5.1.2]
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_231]
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_231]
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_231]
   	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_231]
   	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
   	... 95 common frames omitted
   ```
   
   It looks like I can not configure different type of databases. Is my configuration incorrect or ShardingJDBC don't support different types of databases configuration


-- 
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] TeslaCN commented on issue #20551: How do I configure multiple types of databases in one project

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

   ShardingSphere 5.3.0 has allowed this operation.


-- 
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] Gszekt commented on issue #20551: How do I configure multiple types of databases in one project

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

   I had the same error. 


-- 
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] Gszekt commented on issue #20551: How do I configure multiple types of databases in one project

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

   DatabaseTypeEngine.java 
   `
   public static DatabaseType getDatabaseType(final Collection<DataSource> dataSources) {
           DatabaseType result = null;
           for (DataSource each : dataSources) {
               DatabaseType databaseType = getDatabaseType(each);
               Preconditions.checkState(null == result || result == databaseType, "Database type inconsistent with '%s' and '%s'", result, databaseType);
               result = databaseType;
           }
           return null == result ? DatabaseTypeFactory.getInstance(DEFAULT_DATABASE_TYPE) : result;
       }
   `
   Is the source code means that shardingsphere is not support multi database type in one project?


-- 
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] TeslaCN closed issue #20551: How do I configure multiple types of databases in one project

Posted by GitBox <gi...@apache.org>.
TeslaCN closed issue #20551: How do I configure multiple types of databases in one project
URL: https://github.com/apache/shardingsphere/issues/20551


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