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

ucanaccess ディストリビューションの hsqldb.jar を現在の 2.3.2 に置き換えてみてください (hsqldb Web サイトからダウンロードしてください)。hsqldb 2.3.2 への移植はまだ完了していませんが、特定のケースではうまくいく可能性が高いことに注意してください。とにかく、ucanaccess ヘルプ フォーラムで問題を再現できた Gord に感謝します。

于 2015-01-23T21:52:19.987 に答える