在计算字段中找不到数据

时间:2014-12-30 11:09:48

标签: java sql ms-access odbc

我遇到计算行的问题,但仍然没有得到它:

SQLException at ln 1381: No data found
java.sql.SQLException: No data found
   at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
   at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(Unknown Source)
   at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(Unknown Source)
   at sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
   at sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
   at main.EngineDueList.LdgsDueList(EngineDueList.java:1263)
   at main.EngineDueList.createPDF(EngineDueList.java:93)
   at main.AircraftList.<init>(AircraftList.java:187)
   at Launch.main(Launch.java:13)

在请求中,我有一个计算的行:

[...][NextLdgs] - (([MaxDeTotalCycles] - [Cycle_A/C]) + [Cycle_engine]) AS RemainLdgs[...]

当我在访问中执行请求时,我有一个好结果:

Result

当我搜索有关此行的信息时,这似乎并不奇怪:

此代码:

System.out.println(data.getMetaData().getColumnName(8)+" is a type : "+data.getMetaData().getColumnTypeName(8));

在控制台中写下

RemainLdgs is a type : DOUBLE

我没有两次阅读该字段(已经过验证)。

为什么我无法阅读此字段?

编辑1:

这是Java代码:

Connection c = ConnectDB.doConnect();
        String selectString = "SELECT [Task Engine Program Landing Select].NextLdgs, [Task Engine Program Landing Select].[Engine S/N], [Task Engine Program Landing Select].Position, [Task Engine Program Landing Select].Itemnum, [Task Engine Program Landing Select].InputNumber, [Task Engine Program Landing Select].InputDescription, [Task Engine Program Landing Select].SS_Critical, [Task Engine Program Landing Select].RemainLdgs, [Task Engine Program Landing Select].PN, [Task Engine Program Landing Select].SN, [Task Engine Program Landing Select].LastCompLdgs, [Task Engine Program Landing Select].AIP_Revision, [Task Engine Program Landing Select].PMT_Description, [Task Engine Program Landing Select].PMT_ID, [Task Engine Program Landing Select].Category_Description, [Task Engine Program Landing Select].TYPE_DESCRIPTION, [Task Engine Program Landing Select].InputAircraftLandings, [Task Engine Program Landing Select].EPS_Why, [Task Engine Program Landing Select].CTAL_Item_Number, [Task Engine Program Landing Select].TSR_Item_Number, [Task Engine Program Landing Select].EPS_Seria_Number, [Task Engine Program Landing Select].Part_PN, [Task Engine Program Landing Select].Part_SN, [Task Engine Program Landing Select].TSR_TSS, [Task Engine Program Landing Select].TSR_HSS, [Task Engine Program Landing Select].TSR_CSS, [Task Engine Program Landing Select].PartStatus_Status, [Task Engine Program Landing Select].PartStatus_Date, [Task Engine Program Landing Select].PartStatus_TSN, [Task Engine Program Landing Select].PartStatus_HSN, [Task Engine Program Landing Select].PartStatus_CSN, [Task Engine Program Landing Select].PartStatus_TSO, [Task Engine Program Landing Select].PartStatus_HSO, [Task Engine Program Landing Select].PartStatus_CSO, [Task Engine Program Landing Select].Task_Part, [Task Engine Program Landing Select].InputDateOUT, [Task Engine Program Landing Select].TMT_Item_Number, [Task Engine Program Landing Select].MaxDeInputDateOUT1, [Task Engine Program Landing Select].TE_Engine, [Task Engine Program Landing Select].ECT_WO_Remove, [Task Engine Program Landing Select].[A/C VAR], [Task Engine Program Landing Select].TES_EngineSN, [Task Engine Program Landing Select].MaxTESEngine, [Task Engine Program Landing Select].TE_Item_number, [Task Engine Program Landing Select].TES_Item_Number, [Task Engine Program Landing Select].IntLdgs, [Task Engine Program Landing Select].[TE_Interval (Mos)], [Task Engine Program Landing Select].[TE_Interval (Hrs)], [Task Engine Program Landing Select].[TE_Interval (Ldgs)], [Task Engine Program Landing Select].AircraftCurrentTSN, [Task Engine Program Landing Select].AircraftCurrentCSN, [Task Engine Program Landing Select].TMT_Task_Number, [Task Engine Program Landing Select].TMT_Origin, [Task Engine Program Landing Select].TMT_Type, [Task Engine Program Landing Select].TMT_Cat, [Task Engine Program Landing Select].TMT_Description, [Task Engine Program Landing Select].[TMT_Interval(Hrs)], [Task Engine Program Landing Select].[TMT_Interval(Mos)], [Task Engine Program Landing Select].[TMT_Interval(Ldgs)], [Task Engine Program Landing Select].TMT_AMTOSS, [Task Engine Program Landing Select].TMT_ATA_IPC "
                    +"FROM (SELECT IIf([Task_Part] Is Null,[TES_EngineCycle]+[IntLdgs],IIf([Task_Part]=False,[TES_EngineCycle]+[IntLdgs],IIf([TMT_Type]='SVC',[TES_EngineCycle]+[IntLdgs]-[TSR_CSS],IIf([TMT_Type]='DIS',[TES_EngineCycle]+[IntLdgs]-[PartStatus_CSN],[TES_EngineCycle]+[IntLdgs]-[PartStatus_CSO])))) AS NextLdgs, [Task Engine Program Landings].MaxDeTotalCycles, [Task Engine Program Landings].TES_EngineCycle, [Task Engine Program Landings].Cycle_engine, [Task Engine Program Landings].[Cycle_A/C], [Task Engine Program Landings].[Engine S/N], [Task Engine Program Landings].Position, [Task Engine Program Landings].InputNumber,[Task Engine Program Landings].InputDescription, [Task Engine Program Landings].SS_Critical, Mid([TE_Item_number],7,9) AS Itemnum, [NextLdgs]-(([MaxDeTotalCycles]-[Cycle_A/C])+[Cycle_engine]) AS RemainLdgs, IIf([Task_Part]=False,[Part_PN],IIf([Part_PN] Is Null,'Removed',[Part_PN])) AS PN, IIf([Task_Part]=False,[Part_SN],IIf([Part_PN] Is Null,'Removed',[Part_SN])) AS SN, IIf([Task_Part] Is Null,[TES_EngineCycle],IIf([Task_Part]=False,[TES_EngineCycle],IIf([TMT_Type]='SVC',[TES_EngineCycle]-[TSR_HSS],IIf([TMT_Type]='SVC',[TES_EngineCycle]-[PartStatus_CSN],[TES_EngineCycle]-[PartStatus_CSO])))) AS LastCompLdgs, [Task Engine Program Landings].AIP_Revision, [Task Engine Program Landings].PMT_Description, [Task Engine Program Landings].PMT_ID, [Task Engine Program Landings].Category_Description, [Task Engine Program Landings].TYPE_DESCRIPTION, [Task Engine Program Landings].InputAircraftLandings, [Task Engine Program Landings].EPS_Why, [Task Engine Program Landings].CTAL_Item_Number, [Task Engine Program Landings].TSR_Item_Number, [Task Engine Program Landings].EPS_Seria_Number, [Task Engine Program Landings].Part_PN, [Task Engine Program Landings].Part_SN, [Task Engine Program Landings].TSR_TSS, [Task Engine Program Landings].TSR_HSS, [Task Engine Program Landings].TSR_CSS, [Task Engine Program Landings].PartStatus_Status, [Task Engine Program Landings].PartStatus_Date, [Task Engine Program Landings].PartStatus_TSN, [Task Engine Program Landings].PartStatus_HSN, [Task Engine Program Landings].PartStatus_CSN, [Task Engine Program Landings].PartStatus_TSO, [Task Engine Program Landings].PartStatus_HSO, [Task Engine Program Landings].PartStatus_CSO, [Task Engine Program Landings].Task_Part, [Task Engine Program Landings].InputDateOUT, [Task Engine Program Landings].TMT_Item_Number, [Task Engine Program Landings].MaxDeInputDateOUT1, [Task Engine Program Landings].TE_Engine, [Task Engine Program Landings].ECT_WO_Remove, [Task Engine Program Landings].[A/C VAR], [Task Engine Program Landings].TES_EngineSN, [Task Engine Program Landings].MaxTESEngine, [Task Engine Program Landings].TE_Item_number, [Task Engine Program Landings].TES_Item_Number, [Task Engine Program Landings].IntLdgs, [Task Engine Program Landings].[TE_Interval (Mos)], [Task Engine Program Landings].[TE_Interval (Hrs)], [Task Engine Program Landings].[TE_Interval (Ldgs)], [Task Engine Program Landings].AircraftCurrentTSN, [Task Engine Program Landings].AircraftCurrentCSN, [Task Engine Program Landings].TMT_Task_Number, [Task Engine Program Landings].TMT_Origin, [Task Engine Program Landings].TMT_Type, [Task Engine Program Landings].TMT_Cat, [Task Engine Program Landings].TMT_Description, [Task Engine Program Landings].[TMT_Interval(Hrs)], [Task Engine Program Landings].[TMT_Interval(Mos)], [Task Engine Program Landings].[TMT_Interval(Ldgs)], [Task Engine Program Landings].TMT_AMTOSS, [Task Engine Program Landings].TMT_ATA_IPC "
                    +"FROM (SELECT [Aircraft Inspection Program].AIP_Revision, [Aircraft Hours and Landings program].MaxDeTotalCycles, [Task Engine Status].TES_EngineCycle, [Engine Change Table].Cycle_engine, [Engine Change Table].[Cycle_A/C], [Engine Change Table].[Engine S/N], [Engine Change Table].Position, [Maintenance input table].InputNumber, [Maintenance input table].InputDescription, [Source Section Table].SS_Critical, [Parts Master Table].PMT_Description, [Parts Master Table].PMT_ID, [Task Categories].Category_Description, [Task Type].TYPE_DESCRIPTION, [Engine Parts Status].EPS_WO, [Part Status Table].PartStatus_WO, [Maintenance input table].InputAircraftLandings, [Engine Parts Status].EPS_Why, [Check Aircraft Select input program].CTAL_Item_Number, [Task Service Relation].TSR_Item_Number, [Task Master Table].TMT_Type, [Engine Parts Status].EPS_Seria_Number, [Parts Table].Part_PN, [Parts Table].Part_SN, [Task Service Relation].TSR_TSS, [Task Service Relation].TSR_HSS, [Task Service Relation].TSR_CSS, [Part Status Table].PartStatus_Status, [Part Status Table].PartStatus_Date, [Part Status Table].PartStatus_TSN, [Part Status Table].PartStatus_HSN, [Part Status Table].PartStatus_CSN, [Part Status Table].PartStatus_TSO, [Part Status Table].PartStatus_HSO, [Part Status Table].PartStatus_CSO, [Task Part Relation].Task_Part, [Maintenance input table].InputDateOUT, [Task Master Table].TMT_Item_Number, [Task Engine Status Max Requete program].MaxDeInputDateOUT1, [Task Engine].TE_Engine, [Engine Change Table].ECT_WO_Remove, [Engine Change Table].[A/C VAR], [Task Engine Status].TES_EngineSN, [Task Engine Status Max Requete program].MaxTESEngine, [Task Engine].TE_Item_number, [Task Engine Status].TES_Item_Number, IIf([TE_Interval (Mos)] Is Null And [TE_Interval (Hrs)] Is Null And [TE_Interval (Ldgs)] Is Null,[TMT_Interval(Ldgs)],[TE_Interval (Ldgs)]) AS IntLdgs, [Task Engine].[TE_Interval (Mos)], [Task Engine].[TE_Interval (Hrs)], [Task Engine].[TE_Interval (Ldgs)], [Aircraft Hours and Landings program].MaxDeHcel AS AircraftCurrentTSN, [Aircraft Hours and Landings program].MaxDeTotalCycles AS AircraftCurrentCSN, [Task Master Table].TMT_Task_Number, [Task Master Table].TMT_Origin, [Task Master Table].TMT_Cat, [Task Master Table].TMT_Description, [Task Master Table].[TMT_Interval(Hrs)], [Task Master Table].[TMT_Interval(Mos)], [Task Master Table].[TMT_Interval(Ldgs)], [Task Master Table].TMT_AMTOSS, [Task Master Table].TMT_ATA_IPC "
                    +"FROM [Source Section Table] INNER JOIN (([Parts Table] RIGHT JOIN (([Parts Master Table] LEFT JOIN [Engine Parts Status] ON [Parts Master Table].PMT_ID = [Engine Parts Status].EPS_PMT_ID) RIGHT JOIN ((([Task Categories] RIGHT JOIN ([Aircraft Inspection Program] INNER JOIN (([Task Type] RIGHT JOIN ([Task Master Table] LEFT JOIN [Task Part Relation] ON [Task Master Table].TMT_Item_Number = [Task Part Relation].Task_ID) ON [Task Type].TASK_TYPE = [Task Master Table].TMT_Type) INNER JOIN (((SELECT [Tech Log Pages].TLAircraft, Max(Flights.Hcel) AS MaxDeHcel, Max(Flights.TotalCycles) AS MaxDeTotalCycles "
                    +"FROM [Tech Log Pages] INNER JOIN Flights ON [Tech Log Pages].TLNumber = Flights.FlightTL "
                    +"GROUP BY [Tech Log Pages].TLAircraft HAVING ((([Tech Log Pages].TLAircraft)='"+ac.getAicraftVAR()+"'))) AS [Aircraft hours and landings program] "
                    +"INNER JOIN ([Engine Change Table] INNER JOIN [Task Engine] ON [Engine Change Table].[Engine S/N] = [Task Engine].TE_Engine) ON [Aircraft Hours and Landings program].TLAircraft = [Engine Change Table].[A/C VAR]) LEFT JOIN (SELECT [Check Task Aircraft Listing].CTAL_Item_Number, [Check Task Aircraft Listing].CTAL_Check, [Check Task Aircraft Listing].CTAL_Delete, [Check Task Aircraft Listing].CTAL_Effective, [Check Task Aircraft Listing].CTAL_CheckSelect, [Check Table].Aircraft "
                    +"FROM [Check Table] INNER JOIN [Check Task Aircraft Listing] ON [Check Table].Check = [Check Task Aircraft Listing].CTAL_Check "
                    +"WHERE ((([Check Task Aircraft Listing].CTAL_Effective)=True) AND (([Check Table].Aircraft)='"+ac.getAicraftVAR()+"'))) AS [Check Aircraft select input program] "
                    +"ON [Task Engine].TE_Item_number = [Check Aircraft Select input program].CTAL_Item_Number) ON [Task Master Table].TMT_Item_Number = [Task Engine].TE_Item_number) ON [Aircraft Inspection Program].AIP_ID = [Task Engine].TE_Rev_ID) ON [Task Categories].Cat = [Task Master Table].TMT_Cat) INNER JOIN (((SELECT [Task Engine Status Max program].TES_Item_Number AS MaxTESItem, [Task Engine Status Max program].TES_EngineSN AS MaxTESEngine, Max([Task Engine Status Max program].InputDateOUT) AS MaxDeInputDateOUT1 "
                    +"FROM (SELECT [Task Engine Status].TES_Item_Number, [Task Engine Status].TES_EngineSN, [Maintenance input table].InputDateOUT, [Maintenance input table].InputAircraft, [Engine Change Table].ECT_WO_Remove, [Engine Change Table].[A/C VAR] "
                    +"FROM ([Maintenance input table] INNER JOIN [Work Order table] ON [Maintenance input table].InputNumber = [Work Order table].WOInput) INNER JOIN ([Engine Change Table] INNER JOIN [Task Engine Status] ON [Engine Change Table].[Engine S/N] = [Task Engine Status].TES_EngineSN) ON [Work Order table].WONumber = [Task Engine Status].TES_WO "
                    +"WHERE ((([Engine Change Table].ECT_WO_Remove) Is Null) AND (([Engine Change Table].[A/C VAR])='"+ac.getAicraftVAR()+"'))) AS [Task Engine Status Max program] "
                    +"GROUP BY [Task Engine Status Max program].TES_Item_Number, [Task Engine Status Max program].TES_EngineSN) AS [task engine status max requete program] "
                    +"INNER JOIN [Task Engine Status] ON [Task Engine Status Max Requete program].MaxTESItem = [Task Engine Status].TES_Item_Number) INNER JOIN [Maintenance input table] ON [Task Engine Status Max Requete program].MaxDeInputDateOUT1 = [Maintenance input table].InputDateOUT) ON [Task Master Table].TMT_Item_Number = [Task Engine Status].TES_Item_Number) INNER JOIN [Work Order table] ON ([Work Order table].WONumber = [Task Engine Status].TES_WO) AND ([Maintenance input table].InputNumber = [Work Order table].WOInput)) ON [Parts Master Table].PMT_ID = [Task Part Relation].PMT_ID) ON [Parts Table].Part_ID = [Engine Parts Status].EPS_PART_ID) LEFT JOIN ([Part Status Table] RIGHT JOIN [Task Service Relation] ON [Part Status Table].PartStatus_ID = [Task Service Relation].TSR_PartStatusID) ON [Parts Table].Part_ID = [Task Service Relation].TSR_Part_ID) ON [Source Section Table].N° = [Task Master Table].TMT_Section "
                    +"WHERE ((([Part Status Table].PartStatus_WO)=[EPS_WO] Or ([Part Status Table].PartStatus_WO) Is Null) AND (([Engine Parts Status].EPS_Why) Is Null) AND (([Check Aircraft Select input program].CTAL_Item_Number) Is Null) AND (([Task Service Relation].TSR_Item_Number)=[TMT_Item_Number]) AND (([Task Master Table].TMT_Type)='SVC') AND (([Engine Parts Status].EPS_Seria_Number)=[TES_EngineSN] Or ([Engine Parts Status].EPS_Seria_Number) Is Null) AND (([Task Engine].TE_Engine)=[TES_EngineSN]) AND (([Engine Change Table].ECT_WO_Remove) Is Null) AND (([Engine Change Table].[A/C VAR])='"+ac.getAicraftVAR()+"') AND (([Task Engine Status Max Requete program].MaxTESEngine)=[TES_EngineSN]) AND ((IIf([TE_Interval (Mos)] Is Null And [TE_Interval (Hrs)] Is Null And [TE_Interval (Ldgs)] Is Null,[TMT_Interval(Ldgs)],[TE_Interval (Ldgs)])) Is Not Null) AND (([Task Master Table].TMT_Origin)<>53200)) OR ((([Part Status Table].PartStatus_WO)=[EPS_WO] Or ([Part Status Table].PartStatus_WO) Is Null) AND (([Engine Parts Status].EPS_Why) Is Null) AND (([Check Aircraft Select input program].CTAL_Item_Number) Is Null) AND (([Task Service Relation].TSR_Item_Number) Is Null) AND (([Task Master Table].TMT_Type)<>'SVC') AND (([Engine Parts Status].EPS_Seria_Number)=[TES_EngineSN] Or ([Engine Parts Status].EPS_Seria_Number) Is Null) AND (([Task Engine].TE_Engine)=[TES_EngineSN]) AND (([Engine Change Table].ECT_WO_Remove) Is Null) AND (([Engine Change Table].[A/C VAR])='"+ac.getAicraftVAR()+"') AND (([Task Engine Status Max Requete program].MaxTESEngine)=[TES_EngineSN]) AND ((IIf([TE_Interval (Mos)] Is Null And [TE_Interval (Hrs)] Is Null And [TE_Interval (Ldgs)] Is Null,[TMT_Interval(Ldgs)],[TE_Interval (Ldgs)])) Is Not Null) AND (([Task Master Table].TMT_Origin)<>53200)) "
                    +"ORDER BY [Task Master Table].TMT_Task_Number) AS [Task Engine Program Landings] "
                    +"ORDER BY IIf([Task_Part] Is Null,[TES_EngineCycle]+[IntLdgs],IIf([Task_Part]=False,[TES_EngineCycle]+[IntLdgs],IIf([TMT_Type]='SVC',[TES_EngineCycle]+[IntLdgs]-[TSR_CSS],IIf([TMT_Type]='DIS',[TES_EngineCycle]+[IntLdgs]-[PartStatus_CSN],[TES_EngineCycle]+[IntLdgs]-[PartStatus_CSO]))))) AS [Task Engine Program Landing Select] "
                    +"WHERE ((([Task Engine Program Landing Select].RemainLdgs)<"+ldgsEstimation*AircraftList.getMonth()+")); ";
try 
        {
            stmt = c.createStatement();
            ResultSet data = stmt.executeQuery(selectString);
            while(data.next()) 
            {
                int position = data.getInt("Position");
                String itemNum = data.getString("Itemnum");
                String tmt = data.getString("TMT_Description");
                object = ac.getAircraftRegistration()+" - Engine "+position+" - task - "+itemNum;
                description=tmt+"\n Scheduled for : ";
                Integer remainldgs = (int)data.getDouble("RemainLdgs");
                System.out.println(data.getMetaData().getColumnName(8)+" est de type : "+data.getMetaData().getColumnTypeName(8));
                /*
                read some other stuff
                */
        }
catch (SQLException e) 
        {
            ErrorFile.writeError(Thread.currentThread().getStackTrace()[2].getLineNumber(), e);
            System.err.println("SQLException at ln 1381: " + e.getMessage());
            e.printStackTrace();
        } 

1 个答案:

答案 0 :(得分:0)

解决了,我不知道为什么,但我改变了这个:

while(data.next()) 
        {
            int position = data.getInt("Position");
            String itemNum = data.getString("Itemnum");
            String tmt = data.getString("TMT_Description");
            object = ac.getAircraftRegistration()+" - Engine "+position+" - task - "+itemNum;
            description=tmt+"\n Scheduled for : ";
            Integer remainldgs = (int)data.getDouble("RemainLdgs");
            System.out.println(data.getMetaData().getColumnName(8)+" est de type : "+data.getMetaData().getColumnTypeName(8));
            /*
            read some other stuff
            */
    }

对此:

while(data.next()) 
        {
            Integer remainldgs = (int)data.getDouble("RemainLdgs");
            int position = data.getInt("Position");
            String itemNum = data.getString("Itemnum");
            String tmt = data.getString("TMT_Description");
            object = ac.getAircraftRegistration()+" - Engine "+position+" - task - "+itemNum;
            description=tmt+"\n Scheduled for : ";
            System.out.println(data.getMetaData().getColumnName(8)+" est de type : "+data.getMetaData().getColumnTypeName(8));
            /*
            read some other stuff
            */
    }

它的工作!