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 2021/07/27 02:52:19 UTC
[GitHub] [shardingsphere] 18435753200 opened a new issue #11522: java.lang.NullPointerException: Inline sharding algorithm expression cannot be null.
18435753200 opened a new issue #11522:
URL: https://github.com/apache/shardingsphere/issues/11522
### Error updating database. Cause: java.lang.NullPointerException: Inline sharding algorithm expression cannot be null.
### The error may exist in com/zcc/myshardingjdbc/mapper/OrderMapper.java (best guess)
### The error may involve com.zcc.myshardingjdbc.mapper.OrderMapper.insert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO t_order ( id, order_no, order_type ) VALUES ( ?, ?, ? )
### Cause: java.lang.NullPointerException: Inline sharding algorithm expression cannot be null.] with root cause
java.lang.NullPointerException: Inline sharding algorithm expression cannot be null.
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:897) ~[guava-29.0-jre.jar:na]
at org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineShardingAlgorithm.createClosure(InlineShardingAlgorithm.java:54) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineShardingAlgorithm.doSharding(InlineShardingAlgorithm.java:67) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy.doSharding(StandardShardingStrategy.java:68) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy.doSharding(StandardShardingStrategy.java:57) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeTables(ShardingStandardRoutingEngine.java:214) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route0(ShardingStandardRoutingEngine.java:194) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeByShardingConditionsWithCondition(ShardingStandardRoutingEngine.java:114) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeByShardingConditions(ShardingStandardRoutingEngine.java:107) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.getDataNodes(ShardingStandardRoutingEngine.java:84) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route(ShardingStandardRoutingEngine.java:69) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:61) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:47) ~[shardingsphere-sharding-core-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:62) ~[shardingsphere-infra-route-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:52) ~[shardingsphere-infra-route-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.route(KernelProcessor.java:54) ~[shardingsphere-infra-context-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:46) ~[shardingsphere-infra-context-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionContext(ShardingSpherePreparedStatement.java:363) ~[shardingsphere-jdbc-core-5.0.0-beta.jar:5.0.0-beta]
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:271) ~[shardingsphere-jdbc-core-5.0.0-beta.jar:5.0.0-beta]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_291]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_291]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_291]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_291]
at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59) ~[mybatis-3.5.7.jar:3.5.7]
at com.sun.proxy.$Proxy182.execute(Unknown Source) ~[na:na]
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:194) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:181) ~[mybatis-3.5.7.jar:3.5.7]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_291]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_291]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_291]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_291]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427) ~[mybatis-spring-2.0.6.jar:2.0.6]
at com.sun.proxy.$Proxy171.insert(Unknown Source) ~[na:na]
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) ~[mybatis-spring-2.0.6.jar:2.0.6]
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59) ~[mybatis-plus-core-3.4.3.1.jar:3.4.3.1]
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) ~[mybatis-plus-core-3.4.3.1.jar:3.4.3.1]
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) ~[mybatis-plus-core-3.4.3.1.jar:3.4.3.1]
at com.sun.proxy.$Proxy174.insert(Unknown Source) ~[na:na]
at com.baomidou.mybatisplus.extension.service.IService.save(IService.java:63) ~[mybatis-plus-extension-3.4.3.1.jar:3.4.3.1]
at com.baomidou.mybatisplus.extension.service.IService$$FastClassBySpringCGLIB$$f8525d18.invoke(<generated>) ~[mybatis-plus-extension-3.4.3.1.jar:3.4.3.1]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.9.jar:5.3.9]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) ~[spring-aop-5.3.9.jar:5.3.9]
at com.zcc.myshardingjdbc.service.OrderService$$EnhancerBySpringCGLIB$$87fa1762.save(<generated>) ~[classes/:na]
at com.zcc.myshardingjdbc.controller.OrderController.add(OrderController.java:37) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_291]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_291]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_291]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_291]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197) ~[spring-web-5.3.9.jar:5.3.9]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141) ~[spring-web-5.3.9.jar:5.3.9]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) ~[spring-webmvc-5.3.9.jar:5.3.9]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.9.jar:5.3.9]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.9.jar:5.3.9]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.9.jar:5.3.9]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1064) ~[spring-webmvc-5.3.9.jar:5.3.9]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.9.jar:5.3.9]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.9.jar:5.3.9]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.9.jar:5.3.9]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) ~[tomcat-embed-core-9.0.50.jar:4.0.FR]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.9.jar:5.3.9]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[tomcat-embed-core-9.0.50.jar:4.0.FR]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:228) ~[tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.50.jar:9.0.50]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.50.jar:9.0.50]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.9.jar:5.3.9]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.9.jar:5.3.9]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.50.jar:9.0.50]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.9.jar:5.3.9]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.9.jar:5.3.9]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.50.jar:9.0.50]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.9.jar:5.3.9]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.9.jar:5.3.9]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) [tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) [tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357) [tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382) [tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893) [tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1723) [tomcat-embed-core-9.0.50.jar:9.0.50]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.50.jar:9.0.50]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_291]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_291]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.50.jar:9.0.50]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_291]
--
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] 18435753200 commented on issue #11522: java.lang.NullPointerException: Inline sharding algorithm expression cannot be null.
Posted by GitBox <gi...@apache.org>.
18435753200 commented on issue #11522:
URL: https://github.com/apache/shardingsphere/issues/11522#issuecomment-887167956
spring:
shardingsphere:
datasource:
names: ds0 # 指定数据源名字,多数据源以逗号分隔
ds0:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/order_0?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: zxcvbnm&123
rules:
sharding:
tables:
# 配置 t_order 表规则
t_order:
actual-data-nodes: ds0.t_order_$->{0..2}
table-strategy:
standard:
sharding-column: id
sharding-algorithm-name: table_inline
# 配置分片算法
sharding-algorithms:
table_inline:
type: INLINE
props:
algorithm-expression: t_order_$->{id % 3}
# 绑定表规则,即逻辑表名。(例如t_user代表了t_user_0, t_user_1, t_user_2 ...)
binding-tables: t_order
props:
sql.show: true # 是否开启SQL显示
--
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] zjcnb edited a comment on issue #11522: java.lang.NullPointerException: Inline sharding algorithm expression cannot be null.
Posted by GitBox <gi...@apache.org>.
zjcnb edited a comment on issue #11522:
URL: https://github.com/apache/shardingsphere/issues/11522#issuecomment-888146840
@18435753200 Hi,Can you try use this config:
```
spring:
shardingsphere:
datasource:
names: ds0
ds0:
username: root
password: 123456
url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
rules:
sharding:
tables:
t_user:
actual-data-nodes: ds0.t_user$->{0..1}
table-strategy:
standard:
sharding-column: id
sharding-algorithm-name: table-inline
sharding-algorithms:
table-inline:
type: INLINE
props:
algorithm-expression: t_user$->{id % 2}
props:
sql.show: true
```
By the way,If you have not solved your problem, you can provide more information!
--
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] 18435753200 commented on issue #11522: java.lang.NullPointerException: Inline sharding algorithm expression cannot be null.
Posted by GitBox <gi...@apache.org>.
18435753200 commented on issue #11522:
URL: https://github.com/apache/shardingsphere/issues/11522#issuecomment-887167495
Is it the wrong 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
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] zjcnb edited a comment on issue #11522: java.lang.NullPointerException: Inline sharding algorithm expression cannot be null.
Posted by GitBox <gi...@apache.org>.
zjcnb edited a comment on issue #11522:
URL: https://github.com/apache/shardingsphere/issues/11522#issuecomment-888146840
@18435753200 Hi,Can you try use this config:
`spring:
shardingsphere:
datasource:
names: ds0
ds0:
username: root
password: 123456
url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
rules:
sharding:
tables:
t_user:
actual-data-nodes: ds0.t_user$->{0..1}
table-strategy:
standard:
sharding-column: id
sharding-algorithm-name: table-inline
sharding-algorithms:
table-inline:
type: INLINE
props:
algorithm-expression: t_user$->{id % 2}
props:
sql.show: true
`
By the way,If you have not solved your problem, you can provide more information!
--
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] 18435753200 commented on issue #11522: java.lang.NullPointerException: Inline sharding algorithm expression cannot be null.
Posted by GitBox <gi...@apache.org>.
18435753200 commented on issue #11522:
URL: https://github.com/apache/shardingsphere/issues/11522#issuecomment-887168159

--
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 #11522: java.lang.NullPointerException: Inline sharding algorithm expression cannot be null.
Posted by GitBox <gi...@apache.org>.
RaigorJiang closed issue #11522:
URL: https://github.com/apache/shardingsphere/issues/11522
--
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] 18435753200 commented on issue #11522: java.lang.NullPointerException: Inline sharding algorithm expression cannot be null.
Posted by GitBox <gi...@apache.org>.
18435753200 commented on issue #11522:
URL: https://github.com/apache/shardingsphere/issues/11522#issuecomment-887167841
`spring:
shardingsphere:
datasource:
names: ds0 # 指定数据源名字,多数据源以逗号分隔
ds0:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/order_0?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: zxcvbnm&123
rules:
sharding:
tables:
# 配置 t_order 表规则
t_order:
actual-data-nodes: ds0.t_order_$->{0..2}
table-strategy:
standard:
sharding-column: id
sharding-algorithm-name: table_inline
# 配置分片算法
sharding-algorithms:
table_inline:
type: INLINE
props:
algorithm-expression: t_order_$->{id % 3}
# 绑定表规则,即逻辑表名。(例如t_user代表了t_user_0, t_user_1, t_user_2 ...)
binding-tables: t_order
props:
sql.show: true # 是否开启SQL显示
`
--
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] zjcnb commented on issue #11522: java.lang.NullPointerException: Inline sharding algorithm expression cannot be null.
Posted by GitBox <gi...@apache.org>.
zjcnb commented on issue #11522:
URL: https://github.com/apache/shardingsphere/issues/11522#issuecomment-888146840
@18435753200 Hi,Can you try use this config:
spring:
shardingsphere:
datasource:
names: ds0
ds0:
username: root
password: 123456
url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
rules:
sharding:
tables:
t_user:
actual-data-nodes: ds0.t_user$->{0..1}
table-strategy:
standard:
sharding-column: id
sharding-algorithm-name: table-inline
sharding-algorithms:
table-inline:
type: INLINE
props:
algorithm-expression: t_user$->{id % 2}
props:
sql.show: true
By the way,If you have not solved your problem, you can provide more information!
--
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] 18435753200 commented on issue #11522: java.lang.NullPointerException: Inline sharding algorithm expression cannot be null.
Posted by GitBox <gi...@apache.org>.
18435753200 commented on issue #11522:
URL: https://github.com/apache/shardingsphere/issues/11522#issuecomment-887168063

--
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 #11522: java.lang.NullPointerException: Inline sharding algorithm expression cannot be null.
Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #11522:
URL: https://github.com/apache/shardingsphere/issues/11522#issuecomment-924792559
Since this issue has been inactive for more than 30 days, we will close it.
If you still have related questions, please submit a new issue, thank you.
--
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] 18435753200 removed a comment on issue #11522: java.lang.NullPointerException: Inline sharding algorithm expression cannot be null.
Posted by GitBox <gi...@apache.org>.
18435753200 removed a comment on issue #11522:
URL: https://github.com/apache/shardingsphere/issues/11522#issuecomment-887167841
`spring:
shardingsphere:
datasource:
names: ds0 # 指定数据源名字,多数据源以逗号分隔
ds0:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/order_0?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: zxcvbnm&123
rules:
sharding:
tables:
# 配置 t_order 表规则
t_order:
actual-data-nodes: ds0.t_order_$->{0..2}
table-strategy:
standard:
sharding-column: id
sharding-algorithm-name: table_inline
# 配置分片算法
sharding-algorithms:
table_inline:
type: INLINE
props:
algorithm-expression: t_order_$->{id % 3}
# 绑定表规则,即逻辑表名。(例如t_user代表了t_user_0, t_user_1, t_user_2 ...)
binding-tables: t_order
props:
sql.show: true # 是否开启SQL显示
`
--
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