0 Replies Latest reply on Jul 4, 2010 11:43 PM by ChakraYNVA

    Issues with SQLite DB operations after upgrading from AIR 1.5 to AIR 2.0

    ChakraYNVA

      Hi,

       

      Our AIR 1.0 application creates 4 db files to store/read information synchronously. It was working perfectly fine on AIR 1.5, recently our clients upgraded to AIR 2.0 and our application crashed with having issues in storing/reading information from these DB files.

       

      1. Just before inserting data into one of the DB files, to delete the existing data in tables we are dropping the tables and recreating them and then inserting the data into the tables. All this (dropping tables, creating them and inserting data) happens in a transaction. This was working perfectly fine AIR 1.5 and in AIR 2.0 I am getting error "Table doesn't exist" while inserting data. When I have removed the drop and create tables operation to another transaction everything came back to normal. Not sure what's the change in AIR 2.0 that triggered this.

       

      2. Once the data is filled into the tables if user re-opens the application, the first fetch operation is crashing with an error "SQLError: 'Error #3119: Database file is currently locked.', details:'', operation:'close'". Our application is live and because of this compatibility issue we are facing a critical downtime. PLEASE HELP AT THE EARLIEST...

      Here is what we are doing:

      line# 40: private var em:EntityManager = EntityManager.getInstance();

       

      line# 100: //within the fetch method

      em.openDatabase(false);
                 
      var loginAC:ArrayCollection = em.findAll(EmployeeBio);
                             
      em.closeDatabase(); // I am getting the above error here.

       

      EntityManager.as

         /**
               * Opens the connection to the database
               */
              public function openDatabase():void
              {
                  // Bail out if the database is already open
                  if ( sqlConnection.connected )
                  {
                      return;
                  }
                 
                  var dbFile:File = File.applicationStorageDirectory.resolvePath("dataFile4");
                     
                  if (!dbFile.exists)
                  {
                      dbFile = new File(
                          File.applicationStorageDirectory.nativePath.toString() +
                          File.separator +
                          "dataFile4");
                  }
                 
                  sqlConnection.open( dbFile );
              }

       

              /**
               * Closes the connection to the database.
               */
              public function closeDatabase():void
              {
                  if ( sqlConnection != null && sqlConnection.connected )
                  {
                      sqlConnection.close();
                  }
              }

       

           public function findAll(c:Class):ArrayCollection
              {
                  // If not yet done, load the metadata for this class
                  if (!map[c]) logger.info("Metadata not loaded, call createTable to load Metadata");
                  var stmt:SQLStatement = map[c].findAllStmt;
                  stmt.sqlConnection = sqlConnection;
                  stmt.execute();
                  // Return typed objects
                  var result:Array = stmt.getResult().data;
                  stmt.sqlConnection = null;
                  return typeArray(result, c);
              }