Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
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: 9327

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: 9069

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]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Database connectivity in struts 2