我已将Java项目的数据源从Oracle更改为PostgreSQL。我能够成功更改连接字符串,也能够放置新的postgresql查询。返回的旧查询和新查询的列都是相似的,因此可能会出现任何不匹配的情况。但是会抛出以下异常:
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.math.BigDecimal
at
*.JdbcTrialProvider.mileStoneCountTypeFactory(JdbcTrialProvider.java:425)
at *.tr002.providers.JdbcTrialProvider.milestonesTypeFactory(JdbcTrialProvider.java:360)
at *.providers.JdbcTrialProvider.getTrialCharacteristicsByTrialNumber(JdbcTrialProvider.java:277)
at*test.InfoHubTest.test(InfoHubTest.java:102)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
使用milestone.setForecasted(((BigDecimal) forecasted).intValueExact())
时
请让我知道是否需要更多信息。
替换milestone.setForecasted(((BigDecimal) forecasted).intValueExact())
用milestone.setForecasted((Integer)forecasted)
可以达到目的。