Subject How to rollback / autocommit off and on?

I'm setting autocommit off, executing some code, and then if everything
goes okay, turning autocommit on again before returning the connection to
the pool, to commit everything. So far, so good.

My question is what to do if something goes wrong, and I want to rollback
the changes made. As I am using connection pooling I have to set the
autocommit on again, but what's the best way to roll back the changes
before I do so?

Many thanks,