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 2019/09/13 16:01:41 UTC

[GitHub] [incubator-shardingsphere] beijing-penguin opened a new issue #3035: run sql "select * from pp"....exception is "java.sql.SQLSyntaxErrorException: Table 'test.pp' doesn't exist"

beijing-penguin opened a new issue #3035: run sql "select * from pp"....exception is "java.sql.SQLSyntaxErrorException: Table 'test.pp' doesn't exist"
URL: https://github.com/apache/incubator-shardingsphere/issues/3035
 
 
   1、my databases have two table: pp_0 and pp_1.
   2、i use the project version code is incubator-shardingsphere's dev.
   3、sharding config is:
   		// 配置真实数据源
   	    Map<String, DataSource> dataSourceMap = new HashMap<>();
   	    // 配置第一个数据源
   	    DruidDataSource dataSource1 = new DruidDataSource();
   	    dataSource1.setUrl("jdbc:mysql://localhost:3306/test?userSSL=true&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT");
   	    dataSource1.setUsername("root");
   	    dataSource1.setPassword("123456");
   	    dataSourceMap.put("ds0", dataSource1);
   	    
   	    TableRuleConfiguration testTableRuleConfig = new TableRuleConfiguration("pp");
   	    testTableRuleConfig.setTableShardingStrategyConfig(new InlineShardingStrategyConfiguration("id", "pp_${id % 2}"));
   	    ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
   	    shardingRuleConfig.getTableRuleConfigs().add(testTableRuleConfig);
   	    // 获取数据源对象
   	    DataSource dataSource = ShardingDataSourceFactory.createDataSource(dataSourceMap, shardingRuleConfig, new Properties());
   try {
   		    DbHelper db = new DbHelper(dataSource);
   		    List<Map<String,Object>> list = db.selectList("select * from pp");
   		    System.out.println(JSON.toJSONString(list));
   	    }catch (Exception e) {
   	    	e.printStackTrace();
   		}
   	    ConnectionManager.closeConnectionAll();
   ---------------------------------------------------------------------------------------------
   4、
   
   java.sql.SQLSyntaxErrorException: Table 'test.pp' doesn't exist
   	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
   	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
   	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
   	at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
   	at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1003)
   	at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:227)
   	at org.apache.shardingsphere.shardingjdbc.executor.PreparedStatementExecutor.getQueryResult(PreparedStatementExecutor.java:116)
   	at org.apache.shardingsphere.shardingjdbc.executor.PreparedStatementExecutor.access$2(PreparedStatementExecutor.java:114)
   	at org.apache.shardingsphere.shardingjdbc.executor.PreparedStatementExecutor$2.executeSQL(PreparedStatementExecutor.java:108)
   	at org.apache.shardingsphere.shardingjdbc.executor.PreparedStatementExecutor$2.executeSQL(PreparedStatementExecutor.java:1)
   	at org.apache.shardingsphere.core.execute.sql.execute.SQLExecuteCallback.execute0(SQLExecuteCallback.java:68)
   	at org.apache.shardingsphere.core.execute.sql.execute.SQLExecuteCallback.execute(SQLExecuteCallback.java:57)
   	at org.apache.shardingsphere.core.execute.ShardingExecuteEngine.syncGroupExecute(ShardingExecuteEngine.java:125)
   	at org.apache.shardingsphere.core.execute.ShardingExecuteEngine.parallelExecute(ShardingExecuteEngine.java:102)
   	at org.apache.shardingsphere.core.execute.ShardingExecuteEngine.groupExecute(ShardingExecuteEngine.java:83)
   	at org.apache.shardingsphere.core.execute.sql.execute.SQLExecuteTemplate.executeGroup(SQLExecuteTemplate.java:73)
   	at org.apache.shardingsphere.core.execute.sql.execute.SQLExecuteTemplate.executeGroup(SQLExecuteTemplate.java:56)
   	at org.apache.shardingsphere.shardingjdbc.executor.AbstractStatementExecutor.executeCallback(AbstractStatementExecutor.java:133)
   	at org.apache.shardingsphere.shardingjdbc.executor.PreparedStatementExecutor.executeQuery(PreparedStatementExecutor.java:111)
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.executeQuery(ShardingPreparedStatement.java:116)
   	at org.dc.jdbc.core.utils.JDBCUtils.setParamsReturnRS(JDBCUtils.java:55)
   	at org.dc.jdbc.core.DbHelper.selectList(DbHelper.java:88)
   	at org.dc.jdbc.core.DbHelper.selectList(DbHelper.java:98)
   	at com.dc.shardingtest.App.main(App.java:44)
   

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


With regards,
Apache Git Services