You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/01/18 07:37:44 UTC

[GitHub] KomachiSion edited a comment on issue #1774: Couldn't got the db connection

KomachiSion edited a comment on issue #1774: Couldn't got the db connection
URL: https://github.com/apache/incubator-shardingsphere/issues/1774#issuecomment-455453362
 
 
   Hi @jmbkeyes, what's your `BasicDataSource `? It looks like commons-dbcp, but I can not recurrent your problem with commons-dbcp.
   My configuration is following:
   ```
   @Configuration
   public class IssueConfiguration {
       
       @Bean(name = "dataSource")
       @Primary
       public DataSource dataSource() throws SQLException {
           BasicDataSource dataSource = new BasicDataSource();
           dataSource.setInitialSize(8);
           dataSource.setMinIdle(8);
           dataSource.setMaxIdle(12);
           dataSource.setRemoveAbandonedTimeout(10);
           dataSource.setDriverClassName("com.mysql.jdbc.Driver");
           dataSource.setUrl("jdbc:mysql://localhost:3306/demo_ds?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=TRUE");
           dataSource.setUsername("root");
           dataSource.setPassword("");
           ArrayList initSQLs = new ArrayList();
           initSQLs.add("SET NAMES 'utf8mb4'");
           dataSource.setConnectionInitSqls(initSQLs);
       
           Map<String, DataSource> dataSourceMap = new HashMap<>();
           dataSourceMap.put("ds0", dataSource);
       
           // Configure table rule
           TableRuleConfiguration logTableRuleConfig = new TableRuleConfiguration();
           logTableRuleConfig.setLogicTable("center_op_log");
           logTableRuleConfig.setActualDataNodes("ds0.center_op_log${0..4}");
       
           // Configure strategies for database + table sharding
           logTableRuleConfig.setTableShardingStrategyConfig(new InlineShardingStrategyConfiguration("main_center_id", "center_op_log${mainCenterId % 4}"));
       
           // Configure sharding rule
           ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
           shardingRuleConfig.getTableRuleConfigs().add(logTableRuleConfig);
           shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new NoneShardingStrategyConfiguration());
       
           Properties properties = new Properties();
           properties.setProperty("sql.show", "true");
       
           return ShardingDataSourceFactory.createDataSource(dataSourceMap, shardingRuleConfig, new ConcurrentHashMap<String, Object>(), properties);
       }
   }
   ```
   And runtime result:
   ```
     .   ____          _            __ _ _
    /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
   ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
    \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
     '  |____| .__|_| |_|_| |_\__, | / / / /
    =========|_|==============|___/=/_/_/_/
    :: Spring Boot ::       (v1.5.17.RELEASE)
   
   [INFO ] 2019-01-18 15:29:35,540 --main-- [io.shardingsphere.issue.IssueApplication] Starting IssueApplication on yangyideMacBook-Pro.local with PID 1648 (/Users/yangyi/Documents/java/ss-issue/issue1774/target/classes started by yangyi in /Users/yangyi/Documents/java/ss-issue) 
   [INFO ] 2019-01-18 15:29:35,546 --main-- [io.shardingsphere.issue.IssueApplication] No active profile set, falling back to default profiles: default 
   [WARN ] 2019-01-18 15:29:36,158 --main-- [org.mybatis.spring.mapper.ClassPathMapperScanner] No MyBatis mapper was found in '[io.shardingsphere.issue]' package. Please check your configuration. 
   Fri Jan 18 15:29:36 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
   Fri Jan 18 15:29:36 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
   Fri Jan 18 15:29:36 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
   Fri Jan 18 15:29:36 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
   Fri Jan 18 15:29:36 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
   Fri Jan 18 15:29:36 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
   Fri Jan 18 15:29:36 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
   Fri Jan 18 15:29:36 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
   Fri Jan 18 15:29:36 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
   [INFO ] 2019-01-18 15:29:36,936 --main-- [org.hibernate.jpa.internal.util.LogHelper] HHH000204: Processing PersistenceUnitInfo [
   	name: default
   	...] 
   [INFO ] 2019-01-18 15:29:36,980 --main-- [org.hibernate.Version] HHH000412: Hibernate Core {4.3.11.Final} 
   [INFO ] 2019-01-18 15:29:36,981 --main-- [org.hibernate.cfg.Environment] HHH000206: hibernate.properties not found 
   [INFO ] 2019-01-18 15:29:36,982 --main-- [org.hibernate.cfg.Environment] HHH000021: Bytecode provider name : javassist 
   [INFO ] 2019-01-18 15:29:37,053 --main-- [org.hibernate.annotations.common.Version] HCANN000001: Hibernate Commons Annotations {4.0.5.Final} 
   [WARN ] 2019-01-18 15:29:37,072 --main-- [org.hibernate.engine.jdbc.spi.TypeInfo] HHH000362: Unable to retrieve type info result set : java.sql.SQLException: Connection com.mysql.jdbc.JDBC4Connection@432034a is closed. 
   [INFO ] 2019-01-18 15:29:37,075 --main-- [org.hibernate.dialect.Dialect] HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect 
   [WARN ] 2019-01-18 15:29:37,078 --main-- [org.hibernate.engine.jdbc.internal.JdbcServicesImpl] HHH000341: Could not obtain connection metadata : getCatalog 
   [INFO ] 2019-01-18 15:29:37,078 --main-- [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] HHH000422: Disabling contextual LOB creation as connection was null 
   [INFO ] 2019-01-18 15:29:37,119 --main-- [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] HHH000397: Using ASTQueryTranslatorFactory 
   [INFO ] 2019-01-18 15:29:37,259 --main-- [org.hibernate.tool.hbm2ddl.SchemaExport] HHH000227: Running hbm2ddl schema export 
   Hibernate: drop table if exists center_op_log
   [INFO ] 2019-01-18 15:29:37,555 --main-- [ShardingSphere-SQL] Rule Type: sharding 
   [INFO ] 2019-01-18 15:29:37,555 --main-- [ShardingSphere-SQL] Logic SQL: drop table if exists center_op_log 
   [INFO ] 2019-01-18 15:29:37,555 --main-- [ShardingSphere-SQL] SQLStatement: io.shardingsphere.core.parsing.antlr.sql.statement.ddl.DropTableStatement@70730db 
   [INFO ] 2019-01-18 15:29:37,555 --main-- [ShardingSphere-SQL] Actual SQL: ds0 ::: drop table if exists center_op_log0 
   [INFO ] 2019-01-18 15:29:37,555 --main-- [ShardingSphere-SQL] Actual SQL: ds0 ::: drop table if exists center_op_log1 
   [INFO ] 2019-01-18 15:29:37,555 --main-- [ShardingSphere-SQL] Actual SQL: ds0 ::: drop table if exists center_op_log2 
   [INFO ] 2019-01-18 15:29:37,555 --main-- [ShardingSphere-SQL] Actual SQL: ds0 ::: drop table if exists center_op_log3 
   [INFO ] 2019-01-18 15:29:37,555 --main-- [ShardingSphere-SQL] Actual SQL: ds0 ::: drop table if exists center_op_log4 
   Hibernate: create table center_op_log (id integer not null, main_center_id integer, value varchar(255), primary key (id))
   [INFO ] 2019-01-18 15:29:37,613 --main-- [ShardingSphere-SQL] Rule Type: sharding 
   [INFO ] 2019-01-18 15:29:37,613 --main-- [ShardingSphere-SQL] Logic SQL: create table center_op_log (id integer not null, main_center_id integer, value varchar(255), primary key (id)) 
   [INFO ] 2019-01-18 15:29:37,613 --main-- [ShardingSphere-SQL] SQLStatement: io.shardingsphere.core.parsing.antlr.sql.statement.ddl.CreateTableStatement@fb2e3fd 
   [INFO ] 2019-01-18 15:29:37,613 --main-- [ShardingSphere-SQL] Actual SQL: ds0 ::: create table center_op_log0 (id integer not null, main_center_id integer, value varchar(255), primary key (id)) 
   [INFO ] 2019-01-18 15:29:37,613 --main-- [ShardingSphere-SQL] Actual SQL: ds0 ::: create table center_op_log1 (id integer not null, main_center_id integer, value varchar(255), primary key (id)) 
   [INFO ] 2019-01-18 15:29:37,613 --main-- [ShardingSphere-SQL] Actual SQL: ds0 ::: create table center_op_log2 (id integer not null, main_center_id integer, value varchar(255), primary key (id)) 
   [INFO ] 2019-01-18 15:29:37,613 --main-- [ShardingSphere-SQL] Actual SQL: ds0 ::: create table center_op_log3 (id integer not null, main_center_id integer, value varchar(255), primary key (id)) 
   [INFO ] 2019-01-18 15:29:37,613 --main-- [ShardingSphere-SQL] Actual SQL: ds0 ::: create table center_op_log4 (id integer not null, main_center_id integer, value varchar(255), primary key (id)) 
   [INFO ] 2019-01-18 15:29:37,708 --main-- [org.hibernate.tool.hbm2ddl.SchemaExport] HHH000230: Schema export complete 
   [INFO ] 2019-01-18 15:29:38,067 --main-- [io.shardingsphere.issue.IssueApplication] Started IssueApplication in 2.75 seconds (JVM running for 3.327) 
   [INFO ] 2019-01-18 15:29:38,068 --main-- [org.hibernate.tool.hbm2ddl.SchemaExport] HHH000227: Running hbm2ddl schema export 
   Hibernate: drop table if exists center_op_log
   [INFO ] 2019-01-18 15:29:38,068 --main-- [ShardingSphere-SQL] Rule Type: sharding 
   [INFO ] 2019-01-18 15:29:38,068 --main-- [ShardingSphere-SQL] Logic SQL: drop table if exists center_op_log 
   [INFO ] 2019-01-18 15:29:38,069 --main-- [ShardingSphere-SQL] SQLStatement: io.shardingsphere.core.parsing.antlr.sql.statement.ddl.DropTableStatement@2262d6d5 
   [INFO ] 2019-01-18 15:29:38,069 --main-- [ShardingSphere-SQL] Actual SQL: ds0 ::: drop table if exists center_op_log0 
   [INFO ] 2019-01-18 15:29:38,069 --main-- [ShardingSphere-SQL] Actual SQL: ds0 ::: drop table if exists center_op_log1 
   [INFO ] 2019-01-18 15:29:38,069 --main-- [ShardingSphere-SQL] Actual SQL: ds0 ::: drop table if exists center_op_log2 
   [INFO ] 2019-01-18 15:29:38,069 --main-- [ShardingSphere-SQL] Actual SQL: ds0 ::: drop table if exists center_op_log3 
   [INFO ] 2019-01-18 15:29:38,069 --main-- [ShardingSphere-SQL] Actual SQL: ds0 ::: drop table if exists center_op_log4 
   [INFO ] 2019-01-18 15:29:38,113 --main-- [org.hibernate.tool.hbm2ddl.SchemaExport] HHH000230: Schema export complete 
   
   Process finished with exit code 0
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services