You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
at java.math.BigDecimal.divide(BigDecimal.java:1742)
at java.math.BigDecimal.divideToIntegralValue(BigDecimal.java:1792)
at java.math.BigDecimal.divideAndRemainder(BigDecimal.java:1948)
at com.snowalker.shardingjdbc.snowalker.demo.complex.sharding.util.StringUtil.getDbIndexByMod(StringUtil.java:103)
at com.snowalker.shardingjdbc.snowalker.demo.complex.sharding.sequence.KeyGenerator.getDbIndexAndTbIndexMap(KeyGenerator.java:82)
at com.snowalker.shardingjdbc.snowalker.demo.complex.sharding.sequence.KeyGenerator.generateKey(KeyGenerator.java:51)
at com.snowalker.shardingjdbc.snowalker.demo.SnowalkerShardingjdbcDemoApplicationTests.testGenerateId(SnowalkerShardingjdbcDemoApplicationTests.java:87)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)`
错误断点 public static long getDbIndexByMod(Object obj,int dbCount,int tbCount) { long tbRange = getModValue(obj, tbCount); BigDecimal bc = new BigDecimal(tbRange); // ==这个位置dbCount/tbCount--> 4/16=0 BigDecimal[] results = bc.divideAndRemainder(new BigDecimal(dbCount/tbCount)); return (long)results[0].intValue(); }
The text was updated successfully, but these errors were encountered:
`java.lang.ArithmeticException: Division by zero
错误断点
public static long getDbIndexByMod(Object obj,int dbCount,int tbCount) { long tbRange = getModValue(obj, tbCount); BigDecimal bc = new BigDecimal(tbRange); // ==这个位置dbCount/tbCount--> 4/16=0 BigDecimal[] results = bc.divideAndRemainder(new BigDecimal(dbCount/tbCount)); return (long)results[0].intValue(); }
The text was updated successfully, but these errors were encountered: