Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to to connect to a database?

 
Vedhas Pitkar
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How do I connect to a database say oracle using Struts & perform some inserts?Any code plz?
Thanks,VEdhas
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic