I've done something similar to this in .NET but the concept should be about the same.
I would set a timer up with a delay long enough to be a sign that input has stopped but not too long to cause delay - so say 500ms.
On text box update event you ensure both that the timer is enabled and that you reset the timer essentially giving you another 500ms to enter more information.
On the timer tick event or equivalent you do your action (in your case save to the DB) and disable the timer, ensuring you don't affect focus during the processing obviously.
Assuming you also clear the text box, you can then after whatever delay you specify scan something else and trigger the exact same functionality.
Note this may fall down if you ever have to fall back to using a keyboard instead of barcode scanning. At the very least if this was the case you would need to research a better delay value that would accommodate both or maybe provide a way to disable the timer and revert back to using the enter key
Hope this helps