/** * Helper function intended to be overwritten by subclasses. Thsi is where the real requiest for * IDs happens */ protected void performIDRequest() throws Exception { Connection dbConnection = null; try { try { dbConnection = dataSource.getConnection(); Statement stmt = dbConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); ResultSet set = null; set = stmt.executeQuery( "SELECT id, " + dbColumn + " FROM " + dbTable); // $NON-NLS-1$ //$NON-NLS-2$ if (!set.next()) { set.moveToInsertRow(); set.insertRow(); set.updateLong(dbColumn, NUM_IDS_GRABBED); set.moveToCurrentRow(); set.next(); } long nextID = set.getLong(dbColumn); long upTo = nextID + mCacheQuantity; set.updateLong(dbColumn, upTo); set.updateRow(); stmt.close(); setMaxAllowedID(upTo); setNextID(nextID); } finally { if (dbConnection != null) { dbConnection.close(); } } } catch (SQLException e) { throw new NoMoreIDsException(e); } }
protected void index(ResultSet rs, ILinguist linguist, long sid, String sent) throws LoadException { if (rs == null) throw new LoadException("Index ResultSet null"); try { // System.out.println(sent); String[] words = linguist.indexkeys(sent); if (words.length > 0) { Map<String, String> dup = new HashMap<String, String>(); int i = 0; for (String word : words) { // System.out.print(word+" "); if (!dup.containsKey(word)) { dup.put(word, word); rs.moveToInsertRow(); rs.updateString("F_Word", word); rs.updateLong("F_SID", sid); rs.updateInt("F_Offset", i++); rs.insertRow(); } } // System.out.println(); } } catch (SQLException se) { throw new LoadException("SQLException occurred: " + se.getMessage()); } catch (LanguageException le) { throw new LoadException("LanguageException occurred indexing: " + le.getMessage()); } }