-
Java Beans and Database connection
Hi,
Is there any way by which i can keep my database connectivity in a JavaBean
and make use of this connection in multiple JSP files.
i.e a connection to database is done once and using this connection many
JSP
files interact with the databases.
Regards.
-
Re: Java Beans and Database connection
"vinod" <vinodvishwa@yahoo.com> wrote:
>
>Hi,
>Is there any way by which i can keep my database connectivity in a JavaBean
>
>and make use of this connection in multiple JSP files.
>i.e a connection to database is done once and using this connection many
>JSP
>files interact with the databases.
>
>Regards.
Hello!
The short answer to your question is 'No'. The longer answer to your question
is 'sorta'. There's a couple of ways you could go about this. Depending
upon why you want to do this, the answer could be as simple as connection
pooling. You could take advantage of a JDBC driver that implements connection
pooling, or even roll your own connection pooling mechanism. You could write
your own Connection Manager that only created a single connection and farmed
out a reference to that connection whenever a JavaBean requested one.
The second solution would be to use a servlet that implements the SingleThreadedModel
interface and have it maintain a reference to the Connection object. Then
you could simply have your JSP grab the reference and pass it to the JavaBean.
With a little more information as to what you are trying to do, I could give
you more specific directions.
I hope this is helpful. Happy Coding!
Cordially,
Kyle Gabhart
DevX Java Pro
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks