Dyapa Srikanth
Dyapa Srikanth

Reputation: 1241

lookup datasource in context every time, Is it right?

In my application i configured more than one datasource (for diff databases). Whenever user sends a request depends upon user category i need to look up for the respective datasource in the context and get a connection from that datasource to execute queries which are assigned to that user. Is it right way to achieve my requirement? I am using tomcat 6, struts 1.3. The databases may be oracle or mysql or both.

Give me an optimized solution.

Thanks in advance.

Upvotes: 1

Views: 330

Answers (1)

Buhake Sindi
Buhake Sindi

Reputation: 89209

Alternatively, you can create a Service Locator where you can cache every JNDI objects retrieved. That way, you don't have to invoke the JNDI lookup every time but pull out from the cache.

Upvotes: 1

Related Questions