The straightforward approach would be to allocate your handles from a pool other than main (most likely from subquery, or from a pool you set up for this port.)
https://openacs.org/doc/common-errors.html.
Or you can try the backport of the db API and see what happens. I imagine though that while the backport works, you still cannot mix code from the two paradigms: your page either needs to use the db api, or not.