It's not a secret anymore!*
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
Author

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
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

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
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Database connectivity in struts 2
 
Similar Threads
Struts 2- Database Connectivity
Null pointer exception in con.createStatement();
Null pointer exception in con.createStatement(); (Struts 2 using netbeans6.1 and MYSQL)
missing return statement {
Struts 2 -Eclipse