DatabaseException, OperationStatus.KEYEXIST, secondary DB handling

Hello

If I insert a record in my primary db I could do something like:

OperationStatus status = db.put (null, key, data);
If (OperationStatus.SUCCESS! = status) {}
handle
}

However, if I have one also have a secondary database, and if the operation of investment above should lead to a duplicate on the secondary database key, then a DatabaseException is thrown:

Exception in thread "main" com.sleepycat.je.DatabaseException: (I 3.3.82) could not insert secondary key in SecDb OperationStatus.KEYEXIST

My question is how to manage this exception gracefully and test the OperationStatus of the secondary db insert? I could catch it:

OperationStatus status = null;
try {}
status = db.put (null, key, data);
If (OperationStatus.SUCCESS! = status) {}
X: treat the error primary db
}
} catch (DatabaseException e) {}
If (OperationStatus.KEYEXIST == status) {}
Y: manage db secondary duplicate
} else
throw e;
}

The State is always null and does not reflect the OperationStatus code from the secondary database put, so the X line above will never trigger. Is there another method I should use to test for inserts failed on a secondary database because of duplicate keys?

Thank you

Joel

Joel,

In the new version, I 4.0, we have tried to help with this problem by developing all the exception classes. In this case, you should get a UniqueConstraintException, which is a subclass of DatabaseException. See http://www.oracle.com/technology/documentation/berkeley-db/je/java/com/sleepycat/je/UniqueConstraintException.html.

Kind regards

Linda

Tags: Database

Similar Questions

  • I have some problems with a ONE_TO_MANY relationship, can not insert the record

    I have some problems with a ONE_TO_MANY relationship:

    Imagine the following entities:

    -J' have an operational entity with a relationship to workers one_to_many something like:
    @SecondaryKey(relate = Relationship.ONE_TO_MANY,
        relatedEntity = Worker.class)
        private Set<String> workers;
    -The category of workers is a simple annotated entity.


    Now, I want to do the following and I get the error:

    -Create a bunch of tasks
    -Insert tasks into the entitystore
    -create a set containing all the tasks of primary key
    -involve workers to tasks
    -Insert the task in the database


    The above procedure works fine, but when I try to associate the same set of workers with another task I get an exception like:
    com.sleepycat.je.DatabaseException: (JE 3.3.75) Could not insert secondary key in persist#Sample#sample.Task#workers OperationStatus.KEYEXIST
            at com.sleepycat.je.SecondaryDatabase.insertKey(SecondaryDatabase.java:887)
            at com.sleepycat.je.SecondaryDatabase.updateSecondary(SecondaryDatabase.java:807)
            at com.sleepycat.je.SecondaryTrigger.databaseUpdated(SecondaryTrigger.java:42)
            at com.sleepycat.je.Database.notifyTriggers(Database.java:1735)
            at com.sleepycat.je.Cursor.putInternal(Cursor.java:1368)
            at com.sleepycat.je.Cursor.putNoOverwrite(Cursor.java:498)
            at com.sleepycat.persist.PrimaryIndex.put(PrimaryIndex.java:366)
            at com.sleepycat.persist.PrimaryIndex.put(PrimaryIndex.java:315)
    Can someone please clarify what my problem is and where I should change for this case study work?

    Thank you

    The above procedure works fine, but when I try to associate the same set of workers with another task I get an exception like:

    The table in this javadoc should help. Please think about whether they are 1 of many, many 1 or many is the appropriate link.

    http://www.Oracle.com/technology/documentation/Berkeley-DB/je/Java/COM/Sleepycat/persist/model/SecondaryKey.html#relate)

    -mark

  • Important events down into subgroup of experts?

    I have a sub - VI that has a bunch of controls, I want to map support, so 'a', 'b', 'c', or "d" will turn one of the four controls Boolean.  I wrote the code to handle this event, and it works fine when I run the sub - VI by itself.

    However, I would like to run this VI in a subgroup of experts, and the pressures on the keys sent to event loop of the Subvi.  Before asking this Question, I found two similar queries for a decade, saying it was a "known behavior for the new subgroup of experts of LabVIEW 7.0 feature and is under consideration for a future release.  There was also a mention that suggested that some clever use of registrations for events may be useful.

    I will to try to decipher it, myself, but would appreciate any advice (or downright "solutions"), if others have managed to understand this.

    Bob Schor

    No, I have not.  However, I did some research and found this note (not quite unexpectedly) OR help:

    • When you use the secondary controls, the top-level VI which contains the secondary control handles the event.

    So, I've "inverted" my logic.  I got the key down? Event in the Secondary VI, with a reference to controls (in the secondary, VI) I wanted to affect.  I just moved this event to the event loop in the first level VI, past the reference at the top level before you start the event loop, then used exactly the same event loop button down? code in the first level VI.  He has a little 'twisted' - a key down event (say, 'a') in the Top level VI is trapped by the Down button? Event code, the "a" is processed and associated with a control-to-be-changed in the sub - VI running in the subgroup of experts, I use the reference to the controls of the sub - VI to edit the appropriate control of front panel on the sub - VI, using a Value property (signs) to ensure that the Subvi knows the value has been changed.

    It worked the first time I tried it!  I didn't know it would be so easy.

    Bob Schor

  • Cisco ACS 1113 v4.0.1.44 possibilities of reproduction have 1120 and 2nd 1113

    Hello

    We currently have 1 ACS SE 1113 running the 4.0.1.44 version that we are unable to take the Live service and we want to install a 2nd one for replication and resilience (and have the resilient pair running the 4.2.0.124 version).

    We had the following put at our disposal for this purpose an ACS SE 1113 and a CSACS 1120 times 4.2.0.124 the version currently running.

    Could you please tell if the following downgrade/upgrade process is valid (I see that the CSACS1120 does not suppot version 4.0 or 4.1).

    1. the downgrade 2nd ACS SE 1113 to version 4.0.1.44

    2. the replication between the 1113 establishment is so we now have our on-line data on both boxes.

    3. take the primary ACS out of service and confirm secondary now handles all requests.

    3. switch to level our primary ACS to version 4.1, then to the 4.2.0.124 version

    4. bring the ACS primary in-service and see works then take secondary ACS decommissioned for upgrade to version 4.1 and 4.2.0.124

    5 confirm replication now working at the 4.2.0124 version.

    Are there other methods possible to migrate our existing data directly from our existing of 1113 to one of the other devices (1113 and 1120) 4.2.0.124 running without going through the process of decommissioning/updated above.

    Thanks in advance for your help.

    Jim.

    Hi Jim,.

    I understand that you have 3 devices - 2 ACS ACS 1113 and 1120 1.

    ACS1 - 1113 4.0.1.44 - running in production.

    ACS2 - 1113 4.2.0.124 - lab running.

    ACS3 - 1120 4.2.0.124 - running in the laboratory.

    You want to configure the replication in the production environment and the transfer of the backup of the ACS1 to 4.2.0.124.

    The path mentioned in the post is correct.

    You can try to do the following:

    take backup of the ACS1. Install ACS for windows 4.0.1.44 in the laboratory. Restore the backup of the ACS1. Upgrade the windows of the ACS to 4.1.1.24 and then to 4.2.0.124 in maintaining the database.

    Restore the database on ACS2 and ACS3. Configure replication for ACS2 and ACS3.

    Take a time out and replace ACS1 with the pair of replication of ACS2 and ACS3.

    I hope this helps.

    Kind regards

    Anisha

    P.S.: Please mark this message as answered if you feel that your query is resolved. Note the useful messages.

  • Insert with a double constraint

    Hello guys,.

    Version 5.0.97

    Could I please clarify if it is possible to distinguish an insertion of an update of BerkeleyDB I (Collections API)?

    I can provide a code if you need it, but I figured I could do something stupid, I want to ask the first question.

    In the BerkeleyDB-GSG (page 74), there is this statement:

    • DatabaseConfig.setSortedDuplicates)

      If true , duplicates are allowed in the database. If this value is fake, then to put a duplicate record in database results in an error of the put call returns. Note that this property can be set at database creation time. Default value is fake.

    I put this value under the mechanism of installation:

    {} private void initDBConfig (boolean readOnly)

    dbCfg = new DatabaseConfig();

    dbCfg.setReadOnly (readOnly);                   We want to read/write

    dbCfg.setAllowCreate (true);                 create if does not exist

    dbCfg.setSortedDuplicates (false);           do not duplicate in primaryDB

    dbCfg.setTemporary (false);                  It must be a persistent database, not in memory

    dbCfg.setDeferredWrite (false);              No entry delay, he should be transactional

    dbCfg.setTransactional (true);               do explicitly transactional DB TODO: do! readOnly?

    }

    I can insert an item in the primaryDB, but if I try to insert a second record by using the same key, I find the new record replaces the old one and does not raise an error.

    Have I misinterpreted it or if I'm missing a configuration key somewhere?

    I am pleased to provide you with an example if this can help even if I think that I am not creating things correctly.

    Thanks for any help.

    Clive

    Hi Clive,.

    Well, documentation of BDB I GSG is a little misleading in this particular section, because it does not detail all possible to make calls Database.put* ().

    DatabaseConfig.setSortedDuplicates () configures the database to pick up duplicates (duplicates of records with the same key) or not. Note that this property of database is persistent and it is not editable once set;  the default value is false, in other words, the duplicates are not allowed.

    If the database is configured to support not duplicates - setSortedDuplicates (false) - as in your case, then a call to Database.put () to insert a record of the key that already exists in the database will result in crushing the record with the same key, restoring the data associated with the key (an update);  It will not cause an error.  A call Database.putNoOverwrite () to insert a record of the key that already exists in the database will result in a OperationStatus.KEYEXIST error returned, regardless of if the database is configured to support duplicates or not (it's what you want to try an insert).

    There is also Database.putNoDupData () that records the key/data pair into the database if it is not already in the database, but this method can be called only if the database supports sorted duplicates.

    However, you mentioned that you use the Collections API.  In addition, as your database is a database, then you have successfully configured it so that it does not duplicate.

    In the API of Collection I, if the database is configured to not allow duplicates, then the StoredMap.put () call will result in the insertion of a new record if the key does not already exist in the database or update the data if the key already exists in the database.  Note that the return value will be null if the key was not present, or it will be the previous value associated with the key, if the key was present in the database.

    So, if you have set up to not allow duplicates, and if you want to prevent a call StoredMap.put () to replace/overwrite existing data if the key is already present, then you should check first if the key is present, using Map.containsKey (). See section adding database items in the Java Collections tutorial documentation.

    Kind regards

    Andrei

  • putOverwrite?

    I want to do this:
    1, if the key exists, overwrite
    2, if the key does not exist, no op, back operationstatus.keyexist

    My lame understanding of transaction not did me not a definitive answer. And the existence of putNoOverwrite I wonder if there is something subtle current.

    I think he's asking how to do a upgrade or 'putNoInsert' and the answer if you need to use a cursor:
    1 Cursor.getSearchKey - if NOTFOUND, stop.
    2 Cursor.putCurrent.
    -mark

  • Database API of vacuum

    Hello

    I use the basic API and my data structure requires no data, just key. When I try to put something like:

    the final data of DatabaseEntry = new DatabaseEntry();
    final touch of DatabaseEntry = new DatabaseEntry();
    acBinding.objectToEntry (ac, key);
    If (db.putNoOverwrite (null, key, data) is OperationStatus.KEYEXIST);

    He complains of data can not be zero, so I added something like:

    Empty byte [] = {0};
    the final data of DatabaseEntry = new DatabaseEntry();
    data.setData (empty);

    Is there a more effective way of specifying data of "empty"? In this way, I lose at least one byte per registration type (and I have millions of records).

    Peter

    Empty (length zero) table bye is allowed.
    -mark

  • Secondary

    Hello

    How can I create a secondary on my hand VI?

    I saw an example on the example of the labview library but I do not know how to create the link of my file

    When you place a panel of sup in yout FP, you will get a method using this method, you can call the vi that you want to display in the main façade of vi. Just check the attached example. Select a vi that you want to call in the top panel and run the code.

    Note: This is just an example to show how to get started with a panel of sup, but in the real case, you will need to handle them properly.

  • How to add a secondary axis in a chart excel with labwindowsCVI?

    Hello
    I am currently working on LabWindowsCVI and I treat my data in excel files. I use ExcelReport and Excel2000 instruments to build my data tables and my chart. Track, I use this function:
    ExcelRpt_ChartWizard (chartsheetHandle, ExcelWorksheetHandle, "A1: C619" ExRConst_XYScatterSmoothNoMarkers 0, ExRConst_Columns, 1, 1, 1, ' consumer mobile platform ","TIME (sec)"," current / voltage (in V & A) ", NULL);
     
    In this configuration, column A is X axis and B & C (Y axis) my blood given respective & current.
    My graphics are drawn correctly, but I find a problem, 2 curves are on the main axis and I want a trace on the main axis and the other on the secondary axis. I can not to display a secondary axis.
    This action is possible with LabwindowsCVI function and if so, can you tell me which work?
    Thank you in advance,
    Nicolas

    Thanks a lot dcl9000.

    I wrote these functions after that to trace my chart and the secondary axis appears .  It was necessary to create a second graphic handle to separate both my curve. Thanks to you, now I know a new function of Excel and I think that I will need in the future.

    Kind regards

    Nicolas

  • Drag-drop Subvi on selected secondary

    Hi all

    I have an application where the user creates a 'follow-up' layout by dragging the desired data from the tree. In the front panel, I have several sub-panels allowing users to drag & drop data to any as they wish. Attached VI indicates similar stuff.

    However, deleting data, I can't filter what school must be used (in the vi attached, I try to move the data to the two sub-panels but even couldn't handle success that is) should be used to determine what school should show the Subvi (in this case, it is a waveform graph)? Filter mouse events? If I use the mouse enter, I can't use the event filter to drop at the same time.

    How can I feed the data, that are generated inside the second loop, while in these sub - VI that I loaded to the sub-panels? I have to do in case of timeout I suppose, but how can I join the Subvi from there then?

    Ask if you need more questions. Sorry for any possible incomprehensible sentence above

    BR, Palazzo

    Well Yes, there are many different options to pass data to the slot - loaded VI. At some point, you need to store the reference to the loaded VI and use this reference to manipulate the VI. Here's a quick and easy way to make using a local variable of the table:

    It is not very scalable and it certainly has a disadvantage right off the bat. This table will always grow and never get more small, so you'll get overlap VI references. It should still work, but if you kept Drag and drop you would possibly have a memory problem. With a few adjustments, you can solve this problem (specific table indices may be designated for each school, so clear you always the current reference to this specific location of table before loading the secondary).

    FYI, your 1ms waiting is too small. Isn't that nobody have CPU for this.

  • «.. . handle is invalid': error only when closing the Application, the runtime, everything seems fine...

    Hello

    first of all: I am relatively new to LabWindows, working on it for some practical work as a student

    (Yes and sorry for the bad English, I'm from the Germany)

    The problem:

    The first important Information:

    After searching for a solution, I don't know, what to do,

    My project consists of a Main.uir file with a tab, a 'Main.c' which manages essentially the main .uir-stuff and some stuff-Initiating and in addition to that several Sub-Sourc-files, one for each tab panel of the Main.uir - tab.

    To use the user interface elements on the main tab with secondary Sources, I'm launching tab handles at startup, which can be used by SubSource files, such as:

    GetPanelHandleFromTabPage (PANEL, PANEL_TAB, 2, &BALU);)

    With this controller, I can identify each UI elements when working with secondary sources

    The second important information:

     

    In some of the TabPages in the .uir, there are several ControlArrays. To use them, I create a ControlArrayHandle, such as:

    MWSAverageHandle = GetCtrlArrayFromResourceID (BALU, MWSAverageArray);

    No, I'm able to identify specific paintings, as items:

    SetCtrlVal (BALU, GetCtrlArrayItem (MWSProgressHandle, ActiveBalun), ProgressString);

    Now there is a problem, I am not able to solve:

     

    During execution, everything works fine, I can use all the elements of a ControlArray with this ControlArrayHandle ("MWSProgressHandle"), everything works perfectly, no errors at all. BUT, when you close the program, I get the following error message:

    RUNTIME ERROR NO MORTAL: "Baluns.c", line 313, col 16, id 0x00000AB8 thread:

    Library function error (return value ==-4 [0xfffffffc]). Panel, menu bar or a control table handle is invalid

    But this seems somewhat ridiulous for me, because when executing that each line works perfectly, each element of Array can be used without problem...

    Is it something I'm not able to see?

    Thanks a lot for your help.

    Greeting from Lübeck, Germany!

    Mathias

    In the reminder of your timer, you check for (event == EVENT_TIMER_TICK)? Might get called for various events, not just the one you have in mind...

  • Multi-threaded error handling method

    I have a multi-threaded application.  When an error occurs in one of the wires causing the failed system, all threads will raise an error and display an error dialog box.  I think on the withdrawal of the appeal to the error handler in the secondary threads and instead send the error for the main thread to the provision.  Is this a common model?  Is there a better way to do it?

    kc64 wrote:
    I have a multi-threaded application.  When an error occurs in one of the wires causing the failed system, all threads will raise an error and display an error dialog box.  I think on the withdrawal of the appeal to the error handler in the secondary threads and instead send the error for the main thread to the provision.  Which is a common model?  Is there a better way to do it?

    Not as common as it is MUST.

    We use a logger who passes all errors to a background process that connects to produce for examination later. This is the minimum. If a fatal errors then adjust us the design of the application respond accordingly when bad things happen.

  • The secondary SATA drives fail after two weeks

    Original title: 2nd disc hard failure.

    The tale here is that I use a secondary internal SATA HD for the media. We failed a two weeks after I put it, I put another new. Same thing, about a week later he began to fail. Now I will try to be as specific as possible;

    The readers in question are disks SATA GB 82. I have media files on them. For the first week or two, they play very well conducted. However after that files that have played very well before jump frames, freeze, Ghost or simply crash my computer. Almost as if something is to put a heavy load in data transfer. Although I do not have the hard drive.

    I can't say the HD's are lacking, because I tried 2 new on different ports SATA on the MB.  I check performance, CPU load monitor, the memory usuage is around 50%. I am religious do not have many programs running, even if my computer could handle. Also, I check performance monitor to see which discs were being accessed and very little that was going on with my high school, certainly not enough to explain why it is to be extremely slow.

    Hello

    I suggest you to check the drive for errors:

    http://Windows.Microsoft.com/en-us/Windows-Vista/check-your-hard-disk-for-errors

    It will be useful.

  • Using an iMac as a secondary screen without control F2

    Hello

    I have a few iMacs and I would like to know if there is a way to configure one as secondary display so that I don't have to press 'CTRL + F2' every time.  Help, please.

    To do what you want, you need to leave them connected 24/7.

  • iMac G4 as a secondary screen for MacBook Pro

    I have an old iMac G4 which I would use as a secondary display for my MacBook Pro (13-inch, mid-2012).

    My guess would be to use the VGA port and port G4 mini Thunderbolt of the MBP but can work?

    And what kind of cards can I use?

    Thank you very much

    You must configure Virtual Network Computing.

    (144752)

Maybe you are looking for

  • Where are the 64-bit versions of Firefox beta 8?

    I noticed that Firefox 8 will come out a week, so I wanted to try one of the beta. I heard the advertising a little back on the fact that Firefox 8 will be the first version of 64-bit (Windows). However, there is no 64-bit Installer in any of the bet

  • Camileo H20 stopped zoom

    Hi allFirst time post here. I have a camcorder Camileo H20 HD, I used it very well throughout the week, but just tonight, when I tried filming something just zoom on top button does – whatever way she moves, nothing appears on the screen and the imag

  • How to specify the sampling frequency? Must use "measurement &amp; Automation Explorer '?

    I use to measure the input current analog OR cDAQ-9171 (chassis only location USB) and NOR-9207. I have 2010 NOR-installed DAQmx and LabVIEW. How can I specify the sampling frequency? If I use M & A Explorer to create the task, I can specify the flow

  • Photosmart D7360: Photosmart D7360

    Every time I have to send anything to the printer it just guard crushing the paper up to cancel printing.  Each book has 1 small line of different characters in the upper left corner... Black triangles for most & squares, but also * and ^.  Everyone?

  • button vs commandNavigationItem

    JDeveloper 12.1.3On a page with the table of the tree, I af:inputDate component, then one of the following1 < af:commandNavigationItem text = 'Go' id = 'cni5' actionListener="#{viewScope.backing_dailySchedule.goToDate}"/ >2 < af:button text = 'Go' id