public int updateStockInfoYahooFlag() throws ClassNotFoundException, SQLException { // TODO Auto-generated method stub StringBuilder sql = new StringBuilder(); sql.append( "insert into stockdatayahooflag (stockname, stockcode, stockexchangecode, DataLoadCount,CreateTime,UpdateTime) "); sql.append( " SELECT s.stockname , s.stockcode, s.stockexchangecode , 0, now(), now() FROM stock s "); sql.append(" where ( s.stockname, s.stockcode, s.stockexchangecode ) not in ( "); sql.append(" select stockname, stockcode, stockexchangecode from stockdatayahooflag) "); // sql.append(" order by t.updatetime"); Connection connection = null; Statement sSta = null; connection = DBFactory.CreateConnection(); int resultCount = 0; try { sSta = connection.createStatement(); resultCount = sSta.executeUpdate(sql.toString()); } finally { try { if (connection != null) { connection.close(); } if (sSta != null) { sSta.close(); } } catch (SQLException e) { e.printStackTrace(); } } return resultCount; }
private int updateStockDataSinaBlockByStock() throws Exception { // TODO Auto-generated method stub int resultCount = 0; StringBuilder sql = new StringBuilder(); sql.append("select t.* from Stock t where 1=1 order by createtime desc "); Connection connection = null; Statement sSta = null; ResultSet resultSet = null; List<StockDo> result = new ArrayList<StockDo>(); connection = DBFactory.CreateConnection(); try { sSta = connection.createStatement(); resultSet = sSta.executeQuery(sql.toString()); SinaVendor sinaVendor = new SinaVendor(); while (resultSet.next()) { if (m_Terminate) { break; } else { // Do Nothing } // 检索遍历股票 // 获得分析开始日 Date startDate = getBlockCheckStartDay( resultSet.getString("STOCKCODE"), resultSet.getString("STOCKEXCHANGECODE")); // 获得从分析开始日后20条数据 List<SinaDailyStockDataDo> sinaDailyStockDataList = getStockSinaDataList(startDate); if (sinaDailyStockDataList != null && sinaDailyStockDataList.size() > 0) { SinaDailyStockDataDo firstDayData = sinaDailyStockDataList.remove(0); SinaDailyStockDataBlockDo block = new SinaDailyStockDataBlockDo(firstDayData, firstDayData.isDown()); for (SinaDailyStockDataDo dayStock : sinaDailyStockDataList) { // 遍历分析保存block if (block.isIsdown() == dayStock.isDown()) { // 都是同一趋势的 // if() } } } else { // Do Nothing } do { SinaDailyStockDataDo startDayStock = null; SinaDailyStockDataDo endDayStock = null; boolean isdown = false; sinaDailyStockDataList = getStockSinaDataList(startDate); } while (true); // resultCount++; // m_Progress++; } } finally { try { if (connection != null) { connection.close(); } if (sSta != null) { sSta.close(); } if (resultSet != null) { resultSet.close(); } } catch (SQLException e) { e.printStackTrace(); } } return resultCount; }