You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "brizd (via GitHub)" <gi...@apache.org> on 2023/08/28 07:24:27 UTC
[GitHub] [shardingsphere] brizd opened a new issue, #28282: shardingshpere 5.4: Prompt table does not exist for non database allocation
brizd opened a new issue, #28282:
URL: https://github.com/apache/shardingsphere/issues/28282
Hi,
I configured the data source and database and table splitting strategy through the JAVA API, upgrading from 5.3.0 to 5.4.0. The default database splitting rule is NoneShardingStrategyConfiguration。
Currently, there is no problem with single data sources for table queries that do not participate in database partitioning. When there are multiple data sources, it is prompted that the table does not exist.
this is sphere config:
`@Configuration
public class ShardingSphereConfig {
@Value("${spring.db.url}")
private String url;
@Value("${spring.db.username}")
private String username;
@Value("${spring.db.password}")
private String password;
@Bean
public ShardingSphereDataSource shardingSphereDataSource() throws SQLException {
// 创建ShardingSphereDataSource
Map<String, DataSource> dataSourceMap = new HashMap<>();
// 配置数据源
dataSourceMap.put("ds-aa", createDataSource("order_aa"));
dataSourceMap.put("ds-bb", createDataSource("order_bb"));
StringBuffer actualNodeBuffer = new StringBuffer("${[");
dataSourceMap.keySet().forEach(datasource->actualNodeBuffer.append("'"+datasource+"',"));
String actualNodeStr = actualNodeBuffer.toString().substring(0, actualNodeBuffer.toString().length()-1)+"]}";
// 配置分片规则
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
//设置默认分库规则
shardingRuleConfig.setDefaultDatabaseShardingStrategy(new NoneShardingStrategyConfiguration());
//设置分片算法
shardingRuleConfig.setShardingAlgorithms(createAlgorithmConfigurations());
// 配置分表规则
ShardingTableRuleConfiguration orderRuleConfiguration = new ShardingTableRuleConfiguration("order", actualNodeStr+".order_$->{0..4}");
orderRuleConfiguration.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("order_no", "database-split"));
orderRuleConfiguration.setTableShardingStrategy(new StandardShardingStrategyConfiguration("order_no", "order-no-split"));
shardingRuleConfig.getTables().add(orderRuleConfiguration);
return (ShardingSphereDataSource) ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, Collections.singleton(shardingRuleConfig), new Properties());
}
private Map<String, AlgorithmConfiguration> createAlgorithmConfigurations(){
Map<String, AlgorithmConfiguration> algorithmConfigurations = new HashMap<>();
Properties databaseProperties = new Properties();
databaseProperties.setProperty("strategy","standard");
databaseProperties.setProperty("algorithmClassName", "com.uni.sharding.DBShardingAlgorithm");
AlgorithmConfiguration dbConfiguration = new AlgorithmConfiguration("CLASS_BASED", databaseProperties);
algorithmConfigurations.put("database-split", dbConfiguration);
Properties orderNoProperties = new Properties();
orderNoProperties.setProperty("strategy","standard");
orderNoProperties.setProperty("algorithmClassName", "com.uni.sharding.TableFulfillmentNoShardingAlgorithm");
AlgorithmConfiguration orderNoConfiguration = new AlgorithmConfiguration("CLASS_BASED", orderNoProperties);
algorithmConfigurations.put("order-no-split", orderNoConfiguration);
return algorithmConfigurations;
}
private DataSource createDataSource(final String dataSourceName){
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
dataSource.setUrl(String.format(url, dataSourceName));
dataSource.setUsername(username);
dataSource.setPassword(password);
dataSource.setMaxActive(500);
dataSource.setInitialSize(5);
dataSource.setMaxWait(60000);
dataSource.setMinIdle(10);
dataSource.setTimeBetweenEvictionRunsMillis(60000);
dataSource.setMinEvictableIdleTimeMillis(300000);
dataSource.setValidationQuery("SELECT 1");
dataSource.setTestWhileIdle(true);
dataSource.setTestOnBorrow(false);
dataSource.setTestOnReturn(false);
return dataSource;
}
}`
there is an error when query table of no separate database:

--
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] github-actions[bot] commented on issue #28282: shardingshpere 5.4: Prompt table does not exist for non database allocation
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #28282:
URL: https://github.com/apache/shardingsphere/issues/28282#issuecomment-1738003944
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
--
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] RaigorJiang closed issue #28282: shardingshpere 5.4: Prompt table does not exist for non database allocation
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang closed issue #28282: shardingshpere 5.4: Prompt table does not exist for non database allocation
URL: https://github.com/apache/shardingsphere/issues/28282
--
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] RaigorJiang commented on issue #28282: shardingshpere 5.4: Prompt table does not exist for non database allocation
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on issue #28282:
URL: https://github.com/apache/shardingsphere/issues/28282#issuecomment-1695552910
@brizd
Similar to other rules, just construct a `SingleRuleConfiguration` and put it in the `ruleConfiguration` collection.
By the way, after verification, you can help supplement the Java API documentation of single table and become a contributor.
--
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] brizd commented on issue #28282: shardingshpere 5.4: Prompt table does not exist for non database allocation
Posted by "brizd (via GitHub)" <gi...@apache.org>.
brizd commented on issue #28282:
URL: https://github.com/apache/shardingsphere/issues/28282#issuecomment-1695281034
Hi @RaigorJiang,
Thanks for your answer. I don't see configure single table rule with java API, can you give me some java API configure demo?

--
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] RaigorJiang commented on issue #28282: shardingshpere 5.4: Prompt table does not exist for non database allocation
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on issue #28282:
URL: https://github.com/apache/shardingsphere/issues/28282#issuecomment-1695212488
@brizd
From 5.4.0 onwards, users can specify which single tables need to be managed by SS, please configure single rule to let SS load these tables.
https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/single/
--
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] brizd commented on issue #28282: shardingshpere 5.4: Prompt table does not exist for non database allocation
Posted by "brizd (via GitHub)" <gi...@apache.org>.
brizd commented on issue #28282:
URL: https://github.com/apache/shardingsphere/issues/28282#issuecomment-1695595483
@RaigorJiang
OK, I’ll try. Thanks.
--
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