This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Datasource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Datasource" Watch "Datasource" New topic


J Craig

Joined: May 04, 2004
Posts: 15
Hello is there any restriction in where you can access your datasource?
I mean does it have to be from servlet or jsp or can any class access it?
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
Any class can access a datasource. You can create a Java bean that encapsulates your business logic, and then the servlet (or JSP) can access that bean.

In fact, I believe that the preferred architecture is to use JSPs mainly for doing UI stuff, with either no or minimal Java logic. The servlet then acts as a traffic cop, creating the appropriate beans based on the request, and calling the appropriate JSP for displaying the results.
I agree. Here's the link:
subject: Datasource
It's not a secret anymore!