Use session bean to hold datasource connection

31 views Asked by At

I have made a database wrapper in java to connect to a datasource. The way I connect to the datasource is with the following line:

DB db = new DB();

Then I can just start doing queries like

db.setQuery("select * from...");
db.setParams(String...);
db.executeQuery();

Is it ok to hold that db object on a session scoped bean and then access that object from other request scoped beans that are form controllers?

I think that there's a better way of doing it than create a new DB instance every time the form's bean is requested.

I'm not using any persistence API.

0

There are 0 answers