Package org.tmatesoft.sqljet.core.table

Examples of org.tmatesoft.sqljet.core.table.ISqlJetCursor


    {
      @Override
      public void execute(SqlJetDb db) throws SqlJetException
      {
        ISqlJetTable table = db.getTable(STATE_TABLE);
        ISqlJetCursor cursor = table.lookup(table.getPrimaryKeyIndexName(), event.getSource());
        try
        {
          if (!cursor.eof())
          {
            cursor.delete();
          }
        }
        finally
        {
          close(cursor);
View Full Code Here


      @Override
      public Set<String> execute(SqlJetDb database) throws SqlJetException
      {
        Set<String> set = new TreeSet<String>();
        ISqlJetTable table = database.getTable(STATE_TABLE);
        ISqlJetCursor cursor = table.lookup(table.getPrimaryKeyIndexName());
        try
        {
          if (!cursor.eof())
          {
            do
            {
              set.add(cursor.getString(DATABASE_COLUMN));
            }
            while (cursor.next());
          }
          return set;
        }
        finally
        {
View Full Code Here

    {
      @Override
      public Map<InvocationEvent, Map<String, InvokerEvent>> execute(SqlJetDb database) throws SqlJetException
      {
        Map<InvocationEvent, Map<String, InvokerEvent>> map = new HashMap<InvocationEvent, Map<String, InvokerEvent>>();
        ISqlJetCursor cursor = database.getTable(INVOCATION_TABLE).open();
        try
        {
          if (!cursor.eof())
          {
            do
            {
              Object txId = txIdFactory.deserialize(cursor.getBlobAsArray(TRANSACTION_COLUMN));
              Durability.Phase phase = Durability.Phase.values()[(int) cursor.getInteger(PHASE_COLUMN)];
              ExceptionType type = ExceptionType.values()[(int) cursor.getInteger(EXCEPTION_COLUMN)];
              map.put(new InvocationEventImpl(txId, phase, type), new HashMap<String, InvokerEvent>());
            }
            while (cursor.next());
          }
        }
        finally
        {
          cursor.close();
        }
        cursor = database.getTable(INVOKER_TABLE).open();
        try
        {
          if (!cursor.eof())
          {
            do
            {
              Object txId = txIdFactory.deserialize(cursor.getBlobAsArray(TRANSACTION_COLUMN));
              Durability.Phase phase = Durability.Phase.values()[(int) cursor.getInteger(PHASE_COLUMN)];
             
              Map<String, InvokerEvent> invokers = map.get(new InvocationEventImpl(txId, phase, null));
              if (invokers != null)
              {
                String databaseId = cursor.getString(DATABASE_COLUMN);
                InvokerEvent event = new InvokerEventImpl(txId, phase, databaseId);
               
                if (!cursor.isNull(RESULT_COLUMN))
                {
                  byte[] result = cursor.getBlobAsArray(RESULT_COLUMN);
                  event.setResult(Objects.<InvokerResult>deserialize(result));
                }

                invokers.put(databaseId, event);
              }
            }
            while (cursor.next());
          }
        }
        finally
        {
          cursor.close();
        }
        return map;
      }
    };
    try
View Full Code Here

    {
      @Override
      public void execute(SqlJetDb db) throws SqlJetException
      {
        ISqlJetTable table = db.getTable(INVOCATION_TABLE);
        ISqlJetCursor cursor = table.lookup(table.getPrimaryKeyIndexName(), transactionId, phase);
        try
        {
          if (!cursor.eof())
          {
            cursor.delete();
          }
        }
        finally
        {
          close(cursor);
        }
        table = db.getTable(INVOKER_TABLE);
        cursor = table.lookup(INVOKER_TABLE_INDEX, transactionId, phase);
        try
        {
          if (!cursor.eof())
          {
            do
            {
              cursor.delete();
            }
            while (cursor.next());
          }
        }
        finally
        {
          close(cursor);
View Full Code Here

    {
      @Override
      public void execute(SqlJetDb db) throws SqlJetException
      {
        ISqlJetTable table = db.getTable(INVOKER_TABLE);
        ISqlJetCursor cursor = table.lookup(table.getPrimaryKeyIndexName(), transactionId, phase, databaseId);
        try
        {
          if (!cursor.eof())
          {
            cursor.updateByFieldNames(Collections.<String, Object>singletonMap(RESULT_COLUMN, result));
          }
        }
        finally
        {
          close(cursor);
View Full Code Here

     
      try {
        table = podsalinanDB.getTable("downloads");
        podsalinanDB.beginTransaction(SqlJetTransactionMode.READ_ONLY);
        if (table!=null){
          ISqlJetCursor currentDBLine = table.order(table.getPrimaryKeyIndexName());
          if (!currentDBLine.eof()){
            do {
              URLDownload newDownload = new URLDownload(currentDBLine.getString("url"),
                                    currentDBLine.getString("size"),
                                      currentDBLine.getString("destination"),
                                      currentDBLine.getString("podcastSource"),
                                      (int)currentDBLine.getInteger("status"));
                newDownload.setAdded(true);
                downloads.addDownload(newDownload, (int)currentDBLine.getInteger("priority"));
            } while (currentDBLine.next());
          }
        }
      } catch (SqlJetException e){
        debugOutput.printStackTrace(e.getStackTrace());
        return -1;
      } finally {
        try {
          podsalinanDB.commit();
        } catch (SqlJetException e) {
          debugOutput.printStackTrace(e.getStackTrace());
          return -1;
        }
      }
       
      try {
        table = podsalinanDB.getTable("settings");
        podsalinanDB.beginTransaction(SqlJetTransactionMode.READ_ONLY);
       
        if (table!=null){
          ISqlJetCursor currentDBLine = table.order(table.getPrimaryKeyIndexName());
          if (!currentDBLine.eof()){
            do {
              settings.addSetting(currentDBLine.getString("name"), currentDBLine.getString("value"));
            } while (currentDBLine.next());
          }
        }
      } catch (SqlJetException e) {
        debugOutput.printStackTrace(e.getStackTrace());
        return -1;
      } finally {
        try {
          podsalinanDB.commit();
        } catch (SqlJetException e) {
          debugOutput.printStackTrace(e.getStackTrace());
          return -1;
        }
      }

      try {
        table = podsalinanDB.getTable("podcasts");
        podsalinanDB.beginTransaction(SqlJetTransactionMode.READ_ONLY);
        if (table!=null){
          ISqlJetCursor currentDBLine = table.order(table.getPrimaryKeyIndexName());
          if (!currentDBLine.eof()){
            do {
              Podcast newPodcast = new Podcast(currentDBLine.getString("name"),
                               currentDBLine.getString("url"),
                               currentDBLine.getString("directory"),
                               currentDBLine.getString("localFile").replaceAll("&apos;", "\'"),
                               currentDBLine.getInteger("auto_queue")==1);
              newPodcast.setAdded(true);
              podcasts.add(newPodcast);
            } while (currentDBLine.next());
          }
        }
       
      } catch (SqlJetException e) {
        debugOutput.printStackTrace(e.getStackTrace());
View Full Code Here

            {
                db.beginTransaction(SqlJetTransactionMode.READ_ONLY);
                try
                {
                    ISqlJetTable table = db.getTable("RssReader");
                    ISqlJetCursor cursor = table.open();
                    try
                    {
                        do
                        {
                            final String feedLanguage = cursor.getString("language");
                            final String feedTitle = cursor.getString("title");
                            final String feedUrl = cursor.getString("url");
                           
                            JMenu parent = FindMenu(rssFeedsMenu, feedLanguage);
                            JMenuItem item = new JMenuItem(feedTitle);
                           
                            item.addActionListener( new ActionListener()
                            {
                                @Override
                                public void actionPerformed(ActionEvent ae)
                                {
                                    addRssReader(feedTitle, feedUrl);
                                }
                            });
                           
                            parent.add(item);

                        }while( cursor.next() );
                    }
                    finally
                    {
                        cursor.close();
                    }
                }
                finally
                {
                    db.rollback();
View Full Code Here

            {
                db.beginTransaction(SqlJetTransactionMode.READ_ONLY);
                try
                {
                    ISqlJetTable table = db.getTable("HtmlReader");
                    ISqlJetCursor cursor = table.open();
                    try
                    {
                        do
                        {
                            final String siteLanguage = cursor.getString("language");
                            final String siteTitle = cursor.getString("title");
                            final String siteUrl = cursor.getString("url");
                            final String xpathToFrontPageTitle = cursor.getString("xp_fp_title");
                            final String xpathToArticleNodes = cursor.getString("xp_a_nodes");
                            final String xpathToArticleTitle = cursor.getString("xp_a_title");
                            final String xpathToArticleContent = cursor.getString("xp_a_content");
                            final String xpathToArticleUrl = cursor.getString("xp_a_url");
                            final String xpathToArticleGuid = cursor.getString("xp_a_guid");
                            final String xpathToArticleImageUrl = cursor.getString("xp_a_img");
                            final String xpathToArticlePubDate = cursor.getString("xp_a_date");
                           
                            JMenu parent = FindMenu(websitesMenu, siteLanguage);
                            JMenuItem item = new JMenuItem(siteTitle);
                           
                            item.addActionListener( new ActionListener()
                            {
                                @Override
                                public void actionPerformed(ActionEvent ae)
                                {
                                    addHtmlReader(siteTitle, siteUrl,
                                            xpathToFrontPageTitle,
                                            xpathToArticleNodes,
                                            xpathToArticleTitle,
                                            xpathToArticleContent,
                                            xpathToArticleUrl,
                                            xpathToArticleGuid,
                                            xpathToArticleImageUrl,
                                            xpathToArticlePubDate);
                                }                           
                            });
                           
                            parent.add(item);

                        }while( cursor.next() );
                    }
                    finally
                    {
                        cursor.close();
                    }
                }
                finally
                {
                    db.rollback();
View Full Code Here

    throws SqlJetException
    {

        BasicFrontPage fp = new BasicFrontPage();
        ISqlJetTable table = db.getTable("front_pages");
        ISqlJetCursor cursor = table.lookup(null, frontPageName);       
       
       
        try
        {
            fp.setUserTitle( cursor.getString("key") );
            fp.frontPageTitle = cursor.getString("title");
            return fp;
        }
        finally
        {
            cursor.close();
        }
    }
View Full Code Here

                {
                    db.beginTransaction(SqlJetTransactionMode.READ_ONLY);
                    try
                    {
                        ISqlJetTable table = db.getTable("articles");
                        ISqlJetCursor cursor = table.order("published_article_index"/*table.getPrimaryKeyIndexName()*/);
                        long rowCount = cursor.getRowCount();
                        try
                        {
                            if( cursor.goToRow(index) == false )
                            {
                                return null;
                            }

                            // the front page name of this first article
                            // will be memorized, because all the following
                            // articles will have to match the same.
                            String frontPageName = cursor.getString("front_page");

                            // build the front page from database:
                            BasicFrontPage fp = getFrontPage(db, frontPageName);

                            do
                            {
                                if( frontPageName.compareTo( cursor.getString("front_page"))!=0)
                                {
                                    break;
                                }

                                // build article from the cursor's current
                                // position:

                                try
                                {
                                    Article a = getArticle(cursor);
                                    fp.articles.add(a);
                                }
                                catch (IOException ex)
                                {
                                    Logger.getLogger(NewsSafe.class.getName()).log(Level.SEVERE, null, ex);
                                    break;
                                }


                                if( cursor.next() == false )
                                {
                                    break;
                                }

                            }while( fp.articles.size()<count);

                            return fp;
                        }
                        finally
                        {
                            cursor.close();
                        }
                    }
                    finally
                    {
                        db.rollback();
View Full Code Here

TOP

Related Classes of org.tmatesoft.sqljet.core.table.ISqlJetCursor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.