File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Database connectivity in struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Database connectivity in struts 2" Watch "Database connectivity in struts 2" New topic

Database connectivity in struts 2

SanjayR Jain
Ranch Hand

Joined: Mar 05, 2009
Posts: 43
I want to connect my application to Database.
This is what I have done yet:

Is there any other way to connect the database in struts 2 Application?
Ankit Garg

Joined: Aug 03, 2008
Posts: 9462

What kind of solution are you looking for?? You can use Hibernate with your Struts application. You can also create a database connection pool (without hibernate)...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
SanjayR Jain
Ranch Hand

Joined: Mar 05, 2009
Posts: 43
No I am not using hibernate.
It is just a simple application of jsp servlets.
Is there any way using web.xml or struts.xml
I am using Struts 2.
Joe Ess

Joined: Oct 29, 2001
Posts: 9188

No. Struts is an implementation of the front controller pattern. It has nothing to do with back-end tasks like database connectivity.
That said, it is common to encapsulate common tasks like obtaining a database connection and put it into an interceptor.
You may also want to look at your container's documentation and see if it can manage database connections. I know Tomcat and Weblogic do.

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: Database connectivity in struts 2
It's not a secret anymore!