jQuery in Action, 3rd edition
The moose likes Struts and the fly likes how to to connect to a database? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to to connect to a database?" Watch "how to to connect to a database?" New topic

how to to connect to a database?

Vedhas Pitkar
Ranch Hand

Joined: Jan 27, 2001
Posts: 445
How do I connect to a database say oracle using Struts & perform some inserts?Any code plz?
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
You go about doing this from Struts the same way you would any other web application. You could use connection pooling or create a connection directly from the JDBC driver.

Matthew Phillips
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16909

Maybe someday I'll get the annotated version of the website I published recreated. The guy who wrote Slapper worm did us a big favor -- NOT!
Anyway, here's code for struts-config.xml:

This is used to build a database connection pool by the Struts ActionServlet, which can then be referenced by the Action processors (via parent member "servlet" or the getServlet() method). The ActionServlet has a set of methods you use to get the connection from the pool. In most cases, you can use the one that requires no parameters.
[ December 18, 2002: Message edited by: Tim Holloway ]
... and how DO you turn off the graemlins when you want a ":" and a "p" next to each other without spacing? I thought the CODE tag was supposed to handle that!
[ December 18, 2002: Message edited by: Tim Holloway ]

Customer surveys are for companies who didn't pay proper attention to begin with.
wood burning stoves
subject: how to to connect to a database?
It's not a secret anymore!