The setCurrentConnection and unsetConnection Functions

Use setCurrentConnection() once before performing any database operation. Use unsetConnection() once after all database operations are performed.

In your rule or rule function, you must first connect to the database.

Database.setCurrentConnection ("/MyDbConnection");
Operations
Database.unsetConnection();

You must call unsetConnection() even in case of a failure within the rule function. If you do not unset the connection, the connection is not returned to the database connection pool.

Use of setCurrentConnection() may result in an exception if the underlying database is disconnected. You can first use getConnectionStatus() to determine if the database (specified by a JDBC connection resource URI) is connected.