The simplest thing you can do is to have database handle at the object
level, set it to null, and just initialize it in eval() if you see that it's
null.
You can also init the connection in the constructor.
A static dbh will let you share it across tasks, if you persist the jvm.
Naturally you will want to throw in some code to handle dropped connections
and all that.


On Thu, Jul 1, 2010 at 9:01 AM, Dave Viner <[email protected]> wrote:

> In a custom UDF, what's the most appropriate way to initialize and connect
> to a old-fashioned rdbms?
>
> I wrote a simple UDF which opens/closes a connection on each exec(), but
> this feels a bit like overkill.  Is there an "init()" method that is
> invoked
> in a UDF to help with one-time initialization (like a database connection
> or
> sql query preparation)?
>
> Thanks
> Dave Viner
>

Reply via email to