1

从版本 8 Java 不再支持 JDBC:ODBC 驱动程序。我尝试更改我的应用程序的源代码以使用 UcanAccess Ver.2.0.9.3 但这会引发许多异常,例如:

net.ucanaccess.jdbc.UcanaccessSQLException: unknown token:
---
net.ucanaccess.jdbc.UcanaccessSQLException: unexpected token: AS required: )

这是错误代码的示例:

    String selectString = "SELECT [Maintenance input Check Due List].InputRepairStation, [Maintenance input Check Due List].[Interval (Mos)], [Maintenance input Check Due List].InputAircraftHours, [Maintenance input Check Due List].InputAircraftLandings,  [Maintenance input Check Due List].Check, [Maintenance input Check Due List].Title, [Maintenance input Check Due List].InputNumber,[Maintenance input Check Due List].InputDescription, [Maintenance input Check Due List].AircraftCurrentTSN, [Maintenance input Check Due List].AircraftCurrentCSN, [Maintenance input Check Due List].Aircraft, [Maintenance input Check Due List].InputDateOUT, [Maintenance input Check Due List].[Interval (Hrs)], [Maintenance input Check Due List].[Interval(Ldgs)], [Maintenance input Check Due List].NextDueCheckMonth, [Maintenance input Check Due List].NextDueCheckHours, [Maintenance input Check Due List].NextDueCheckLdgs, [Maintenance input Check Due List].RemainCheckMonth, [Maintenance input Check Due List].RemainCheckHours,[Maintenance input Check Due List].RemainCheckLdgs, [Maintenance Schedule Check].MSC_Input, [Maintenance input Check Due List].Check "
            + "FROM [Maintenance input table] RIGHT JOIN ([Maintenance Schedule Check] RIGHT JOIN ("
            + "SELECT  [Maintenance input table].InputRepairStation, [Maintenance input table].InputAircraftHours, [Maintenance input table].InputAircraftLandings, [Check Table].Check, [Check Table].Title, [Maintenance input table].InputNumber, [Maintenance input table].InputDescription,[Aircraft].AircraftCurrentTSN,[Aircraft].AircraftCurrentCSN, [Check Table].Aircraft, [Maintenance input table].InputDateOUT,  [Check Table].[Interval (Mos)], [Check Table].[Interval (Hrs)], [Check Table].[Interval(Ldgs)], IIf([Interval (Mos)] Is Null,Null,DateAdd('m',[Interval (Mos)],[InputDateOUT])) AS NextDueCheckMonth, [Interval (Hrs)]+[InputAircraftHours] AS NextDueCheckHours, [Interval(Ldgs)]+[InputAircraftLandings] AS NextDueCheckLdgs, IIf([NextDueCheckMonth] Is Null,Null,DateDiff('d',Now(), [NextDueCheckMonth],1,1)) AS RemainCheckMonth, IIf([NextDueCheckHours] Is Null,Null,[NextDueCheckHours]-[AircraftCurrentTSN]) AS RemainCheckHours, [NextDueCheckLdgs]-[AircraftCurrentCSN] AS RemainCheckLdgs "
            + "FROM (([Aircraft] INNER JOIN [Check Table] ON [Aircraft].AicraftVar = [Check Table].Aircraft) INNER JOIN (((SELECT [Check Aircraft Status].CAS_Check, Max([Maintenance input table].InputDateOUT) AS MaxDeInputDateOUT "
            + "FROM ([Maintenance input table] INNER JOIN [Work Order table] ON [Maintenance input table].InputNumber = [Work Order table].WOInput) "
            + "INNER JOIN [Check Aircraft Status] ON [Work Order table].WONumber = [Check Aircraft Status].CAS_WO "
            + "GROUP BY [Check Aircraft Status].CAS_Check) AS [Maintenance input check wo select] "
            + "INNER JOIN [Maintenance input table] ON [Maintenance input check wo select].MaxDeInputDateOUT = [Maintenance input table].InputDateOUT)  INNER JOIN [Check Aircraft Status] ON [Maintenance input check wo select].CAS_Check = [Check Aircraft Status].CAS_Check) ON [Check Table].Check = [Check Aircraft Status].CAS_Check) INNER JOIN [Work Order table] ON ([Work Order table].WONumber = [Check Aircraft Status].CAS_WO) AND ([Maintenance input table].InputNumber = [Work Order table].WOInput) "
            + "WHERE ((([Check Table].Aircraft)='"
            + ac.getAicraftVAR()
            + "') AND (([Check Table].[Interval (Mos)]) Is Not Null)) "
            + "OR ((([Check Table].Aircraft)='"
            + ac.getAicraftVAR()
            + "') AND (([Check Table].[Interval (Hrs)]) Is Not Null)) "
            + "OR ((([Check Table].Aircraft)='"
            + ac.getAicraftVAR()
            + "') AND (([Check Table].[Interval(Ldgs)]) Is Not Null)) "
            + "ORDER BY [Check Table].[Interval (Mos)]) AS [Maintenance input Check Due List] "
            + "ON [Maintenance Schedule Check].MSC_Check = [Maintenance input Check Due List].Check) "
            + "ON [Maintenance input table].InputNumber = [Maintenance Schedule Check].MSC_Input "
            + "WHERE ((([Maintenance input Check Due List].RemainCheckMonth)<"
            + AircraftList.getMonth()
            + "*30) AND (([Maintenance input table].InputAircraft)='"
            + ac.getAicraftVAR()
            + "' Or ([Maintenance input table].InputAircraft) Is Null)) OR  "
            + "((([Maintenance input Check Due List].RemainCheckHours)<"
            + ac.hoursEstimation * AircraftList.getMonth()
            + ") AND (([Maintenance input table].InputAircraft)='"
            + ac.getAicraftVAR()
            + "' Or ([Maintenance input table].InputAircraft) Is Null)) OR "
            + "((([Maintenance input Check Due List].RemainCheckLdgs)<"
            + ac.ldgsEstimation
            * AircraftList.getMonth()
            + ") AND (([Maintenance input table].InputAircraft)='"
            + ac.getAicraftVAR()
            + "' Or ([Maintenance input table].InputAircraft) Is Null)) "
            + "ORDER BY IIf([RemainCheckMonth] IS Null, IIf([RemainCheckHours] IS Null, IIf([RemainCheckLdgs] IS Null, null, [RemainCheckLdgs]/"
            + ac.ldgsEstimation
            + "*30), IIf([RemainCheckLdgs] IS Null, [RemainCheckHours]/"
            + ac.hoursEstimation
            + "*30, IIF([RemainCheckHours]/"
            + ac.hoursEstimation
            + "*30< [RemainCheckLdgs]/"
            + ac.ldgsEstimation
            + "*30, [RemainCheckHours]/"
            + ac.hoursEstimation
            + "*30, [RemainCheckLdgs]/"
            + ac.ldgsEstimation
            + "*30))), IIf([RemainCheckHours] IS Null, IIf([RemainCheckLdgs] IS Null, RemainCheckMonth, IIF(RemainCheckMonth < [RemainCheckLdgs]/"
            + ac.ldgsEstimation
            + "*30, RemainCheckMonth, [RemainCheckLdgs]/"
            + ac.ldgsEstimation
            + "*30)), IIf([RemainCheckLdgs] IS Null, IIF(RemainCheckMonth <[RemainCheckHours]/"
            + ac.hoursEstimation
            + "*30, RemainCheckMonth, [RemainCheckHours]/"
            + ac.hoursEstimation
            + "*30), IIf([RemainCheckMonth] < [RemainCheckLdgs]/"
            + ac.ldgsEstimation
            + "*30, IIf([RemainCheckMonth] < [RemainCheckHours]/"
            + ac.hoursEstimation
            + "*30, [RemainCheckMonth], [RemainCheckHours]/"
            + ac.hoursEstimation
            + "*30), IIf([RemainCheckLdgs]/"
            + ac.ldgsEstimation
            + "*30<[RemainCheckHours]/"
            + ac.hoursEstimation
            + "*30, [RemainCheckLdgs]/"
            + ac.ldgsEstimation
            + "*30, [RemainCheckHours]/"
            + ac.hoursEstimation + "*30)))))";

这会引发以下异常:

net.ucanaccess.jdbc.UcanaccessSQLException: unexpected token: AS required: )

我的问题如下:

  • 是否有任何解决方案可以找到旧的和坏的但功能强大的 JDBC:ODBC 库,因此我可以将它导入我的代码中?

  • 有没有一种解决方案可以绕过这些异常而不更改查询(那里有很多查询)?

4

1 回答 1

1

请尝试用当前的 2.3.2 替换 ucanaccess 发行版中的 hsqldb.jar。(从 hsqldb 网站下载)。请注意,到 hsqldb 2.3.2 的移植尚未完成,但在您的特定情况下,它可能会起作用。无论如何,感谢 Gord 能够在 ucanaccess 帮助论坛上重现该问题。

于 2015-01-23T21:52:19.987 回答