2013-08-01 2 views
1

나는 XML 형식의 YQL 테이블 yahoo.finance.quotes에서 재무 데이터를 다운로드 한 다음이 데이터를 MS Access 데이터베이스에 씁니다. Jackcess를 사용하여 데이터베이스와 상호 작용하지만 행을 추가하는 데 이상한 문제가 있습니다.Jackcess 열의 순서가 잘못 되었습니까?

을 호출하면 .addRow() 전환 된 일부 필드를 제외하고 모든 필드가 올바르게 파일에 기록됩니다. 여기

<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" generated="2013-08-01T13:28:55"> 
    <GOOG> 
    <ID>1375380249345</ID> 
    <BOOK_VALUE>901.9</BOOK_VALUE> 
    <EARNINGS_SHARE>3.75</EARNINGS_SHARE> 
    <EPS_ESTIMATE_CURRENT_YEAR>34.565</EPS_ESTIMATE_CURRENT_YEAR> 
    <ESP_ESTIMATE_NEXT_YEAR>43.54</ESP_ESTIMATE_NEXT_YEAR> 
    <EPS_ESTIMATE_NEXT_QUARTER>51.34</EPS_ESTIMATE_NEXT_QUARTER> 
    <DAYS_LOW>11.82</DAYS_LOW> 
    <DAYS_HIGH>895</DAYS_HIGH> 
    <YEAR_LOW>903.07</YEAR_LOW> 
    <YEAR_HIGH>623.41</YEAR_HIGH> 
    <LAST_TRADE_PRICE_ONLY>1.9</LAST_TRADE_PRICE_ONLY> <!-- Offending column --> 
    <FIFTYDAY_MOVING_AVERAGE>928</FIFTYDAY_MOVING_AVERAGE> 
    <TWO_HUNDREDDAY_MOVING_AVERAGE>901.83</TWO_HUNDREDDAY_MOVING_AVERAGE> 
    <OPEN>893.586</OPEN> 
    <PRICE_SALES>856.999</PRICE_SALES> 
    <PRICE_BOOK>895.67</PRICE_BOOK> 
    <PE_RATIO>5.3</PE_RATIO> 
    <PEG_RATIO>3.75</PEG_RATIO> 
    <PRICE_EPSESTIMATE_CURRENT_YEAR>25.68</PRICE_EPSESTIMATE_CURRENT_YEAR> 
    <PRICE_EPS_ESTIMATE_NEXT_YEAR>1.41</PRICE_EPS_ESTIMATE_NEXT_YEAR> 
    <ONEYR_TARGET_PRICE>985.32</ONEYR_TARGET_PRICE> 
    <SHORT_RATIO>1460983</SHORT_RATIO> <!-- Offending column --> 
    <VOLUME>2330360</VOLUME> <!-- Offending column --> 
    <ASK>20.39</ASK> 
    <AVERAGE_DAILY_VOLUME>901</AVERAGE_DAILY_VOLUME> <!-- Offending column --> 
    <BID>17.29</BID> 
    </GOOG> 
</dataroot> 

... 내가 다운로드 (JAXB와 함께) 사용하는 것이 XML 파일의 예 ...

<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="1" yahoo:created="2013-08-01T18:03:53Z" yahoo:lang="en-US"> 
    <results> 
    <quote> 
     <BookValue>236.698</BookValue> 
     <EarningsShare>34.565</EarningsShare> 
     <EPSEstimateCurrentYear>43.54</EPSEstimateCurrentYear> 
     <EPSEstimateNextYear>51.34</EPSEstimateNextYear> 
     <EPSEstimateNextQuarter>11.82</EPSEstimateNextQuarter> 
     <DaysLow>895.00</DaysLow> 
     <DaysHigh>903.07</DaysHigh> 
     <YearLow>623.41</YearLow> 
     <YearHigh>928.00</YearHigh> 
     <LastTradePriceOnly>901.83</LastTradePriceOnly> 
     <FiftydayMovingAverage>893.586</FiftydayMovingAverage> 
     <TwoHundreddayMovingAverage>856.999</TwoHundreddayMovingAverage> 
     <Open>895.67</Open> 
     <PreviousClose>887.75</PreviousClose> 
     <PriceSales>5.30</PriceSales> 
     <PriceBook>3.75</PriceBook> 
     <PERatio>25.68</PERatio> 
     <PEGRatio>1.41</PEGRatio> 
     <PriceEPSEstimateCurrentYear>20.39</PriceEPSEstimateCurrentYear> 
     <PriceEPSEstimateNextYear>17.29</PriceEPSEstimateNextYear> 
     <ShortRatio>1.90</ShortRatio> 
     <OneyrTargetPrice>985.32</OneyrTargetPrice> 
     <Volume>1460983</Volume> 
     <Ask>901.90</Ask> 
     <AverageDailyVolume>2330360</AverageDailyVolume> 
     <Bid>901.54</Bid> 
    </quote> 
    </results> 
</query> 
<!-- total: 222 --> 
<!-- engine4.yql.ne1.yahoo.com --> 

입니다 그리고 여기 결과 액세스 데이터베이스의 XML 내보내기의 여기에 도움이된다면 데이터베이스에 XML에서 값을 추가하려면 코드는 ...입니다

public synchronized void storeData(Query query) throws InterruptedException, IOException { 
    long idL = System.currentTimeMillis(); 
    BigDecimal id = new BigDecimal(idL); 
    double bookValue = query.results.quote.getPriceBook(); 
    double earningsShare = query.results.quote.getEarningsShare(); 
    double epsEstimateCurrentYear = query.results.quote.getEPSEstimateCurrentYear(); 
    double epsEstimateNextYear = query.results.quote.getEPSEstimateNextYear(); 
    double epsEstimateNextQuarter = query.results.quote.getEPSEstimateNextQuarter(); 
    double daysLow = query.results.quote.getDaysLow(); 
    double daysHigh = query.results.quote.getDaysHigh(); 
    double yearLow = query.results.quote.getYearLow(); 
    double yearHigh = query.results.quote.getYearHigh(); 
    double lastTradePriceOnly = query.results.quote.getLastTradePriceOnly(); 
    double fiftydayMovingAverage = query.results.quote.getFiftydayMovingAverage(); 
    double twoHundreddayMovingAverage = query.results.quote.getTwoHundreddayMovingAverage(); 
    double open = query.results.quote.getOpen(); 
    double priceSales = query.results.quote.getPriceSales(); 
    double priceBook = query.results.quote.getPriceBook(); 
    double peRatio = query.results.quote.getPERatio(); 
    double pegRatio = query.results.quote.getPEGRatio(); 
    double priceEPSEstimateCurrentYear = query.results.quote.getPriceEPSEstimateCurrentYear(); 
    double priceEPSEstimateNextYear = query.results.quote.getPriceEPSEstimateNextYear(); 
    double shortRatio = query.results.quote.getShortRatio(); 
    double oneyrTargetPrice = query.results.quote.getOneyrTargetPrice(); 
    int volume = query.results.quote.getVolume(); 
    double ask = query.results.quote.getAsk(); 
    int averageDailyVolume = query.results.quote.getAverageDailyVolume(); 
    double bid = query.results.quote.getBid(); 
    dBTable.addRow(id, bookValue, earningsShare, epsEstimateCurrentYear, epsEstimateNextYear, epsEstimateNextQuarter, daysLow, daysHigh, 
     yearLow, yearHigh, close, fiftydayMovingAverage, twoHundreddayMovingAverage, open, priceSales, priceBook, 
      peRatio, pegRatio, priceEPSEstimateCurrentYear, priceEPSEstimateNextYear, shortRatio, oneyrTargetPrice, volume, ask, averageDailyVolume, bid); 
} 

마지막 거래 가격, Short ratio, 볼륨일일 평균 볼륨은입니다.

아무도 왜이 문제가 무엇인지 어떻게 해결할 수 있습니까? 고맙습니다. 문제의

답변

3

적어도 일부는 강조 그들의, REF (Jackcess의 addRow() 방법은 "표의 열의 순서로 "제공되는 값을 요구하는 것으로 보인다 다음 "이 행을 추가 "섹션 here). 귀하의 addRow() 호출

... shortRatio, oneyrTargetPrice, volume ... 

을 지정하지만 액세스 테이블의 XML 덤프는 열 순서는 또한 확인하기 위해 열 유형에 대해 변수 유형을 다시 한 번 확인 할 수 있습니다

<ONEYR_TARGET_PRICE>985.32</ONEYR_TARGET_PRICE> 
<SHORT_RATIO>1460983</SHORT_RATIO> <!-- Offending column --> 
<VOLUME>2330360</VOLUME> <!-- Offending column --> 

것을 제안 그것들도 일치합니다.

관련 문제