gab06
gab06

Reputation: 610

Use session bean to hold datasource connection

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.

Upvotes: 0

Views: 27

Answers (0)

Related Questions