5 Replies Latest reply: Jun 14, 2011 9:45 PM by Linda Lee RSS

    Truncate data in replication


      I have a problem with functions removeDatabase and truncateClass, now I want to clear all data in a database with a small cost and I found these two APIs can meet my needs, but it awalys give me com.sleepycat.je.rep.DatabasePreemptedException when a request comes to replicated node, the master node works fine. Below is my code:

      trans = env.beginTransaction(null, null);
                     closeDatabase(); //Close database and entity store





      private Database reOpenDatabase(String dbName) throws Exception {
                Transaction trans = null;
                Database db = null;
                try {
                     trans = env.beginTransaction(null, null);
                     DatabaseConfig dc = new DatabaseConfig();
                     db = env.openDatabase(trans, dbName, dc);
                } catch (Exception e) {
                     if (trans != null) {
                     throw e;
                return db;

      Please do help me!
        • 1. Re: Truncate data in replication
          No one can help me or I didn't make myself understood? If this is a common issue, please tell me where can I find the answer.

          Your help will be really appreciated.
          • 2. Re: Truncate data in replication
            Questions about JE should be posted to the Berkeley DB Java Edition forum.
            • 3. Re: Truncate data in replication
              Yes, but my question is how to truncate data in a replicated environment correctly, so I think I come to the right place for my question.
              • 4. Re: Truncate data in replication
                Nobody can help me out? It is very important for me to resolve this problem.
                • 5. Re: Truncate data in replication
                  Linda Lee
                  You are using Berkeley DB, Java Edition, High Availability, which is a different product from Berkeley DB, (C version). That's why we suggested that you move your question to the Berkeley DB, Java Edition forum. I know that the product names are confusing.

                  Please read the javadoc for DatabasePreemptedException at http://download.oracle.com/docs/cd/E17277_02/html/java/com/sleepycat/je/rep/DatabasePreemptedException.html. There you will find out that this happens when a database has been truncated, renamed, or deleted on the master. You will get this exception on the replica node. It tells you that the database has had a major change, and you must close and reopen your cursors, database and environment handles. Please read the javadoc for more details.