In my webapp I'd like to encapsulate database access in a single class, say AppData, that classes in the model can use to populate their own fields. In addition, this would allow me to
test the model classes on their own, isolated from the rest of the application.
But how would you handle database access in the AppData class to do this? For example, from within my
servlet container the <database> declaration makes the datasource available to my application. But from outside the container, I have to load the driver manually with Class.forName() and use the DriverManager to get a Connection.
Is this just a tradeoff I'd have to live with? Seems there should be A Better Way...