1 Reply Latest reply: Aug 8, 2012 10:26 AM by Greybird-Oracle RSS

    Problem update Database

    954623
      I'm writing a simple add/update method. When adding a new key/value everything works just fine. However, if the key already exist it does not overwrite the data, I just get a lock error.

      I ran several tests and I'm pretty certain it is just an issue with existing keys. I tried using both TransactionRunner and regular transaction. Both time adding key/data works only when there is no identical key in the DB.
      I assume there should be some flag to enable overwriting

      Thanks
      -Yaie

      Here is how I set up my environment

      EnvironmentConfig envConfig = new EnvironmentConfig();
      envConfig.setTransactional(true);
      envConfig.setAllowCreate(true);
      env = new Environment(envHome, envConfig);

      DatabaseConfig dbConfig = new DatabaseConfig();
      dbConfig.setTransactional(true);
      dbConfig.setAllowCreate(true);
      solrDb = env.openDatabase(null, SOLR_DB, dbConfig);
        • 1. Re: Problem update Database
          Greybird-Oracle
          Yaie,
          However, if the key already exist it does not overwrite the data, I just get a lock error.
          A lock error (please always send the stack trace whenever you report an error!) doesn't mean that the record already exists or that you're using the wrong method, it means that another thread or transaction holds a lock on that record. Be sure to read:
          http://docs.oracle.com/cd/E17277_02/html/TransactionGettingStarted/index.html

          And be sure to close your transactions and cursors, or they will hold locks forever.

          --mark