• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Insert/Update recordset

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

How can I make a JSP page view or update the recordset if there is any in the DB, or allow the user to insert a new recordset?

thanx,
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Yes you can obviously do. You can do some JDBC coding in JSP itself by scriptlets or adopt a design pattern like MVC and put the JDBC code in your model part.
[ January 20, 2006: Message edited by: Bimal Patel ]
 
Bashar Ayyash
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you help me and give me some code or links that explains inserting JDBC code in JSP, to make the page update/insert recordset?

Thanx,
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Putting code, especially database code, on a JSP is not considered a very good practice. It's a much better idea to factor such code into model classes as Bimal indicated.
 
Bimal Patel
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

That is the same way as you access a DB from JDBC from a stand alone class. 1. Load the drivers, 2. Aquire a connection object, 3. Get a simple/prepared statement object and 4. execute your sql update/insert by executeUpdate() method. But you should do this in the model layer rather then the view/presentation one.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bashar Ayyash:
can you help me and give me some code or links that explains inserting JDBC code in JSP, to make the page update/insert recordset?

Thanx,



I would start out with a few Google searches on JDBC Tutorial.
There are quite a few out there so you should be able to find one that suits your taste pretty easily.
http://www.google.com/search?q=JDBC+TUTORIAL&start=0&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official

There is also a JDBC forum on this list.

As always, I recommend getting your database calls working in a simple, standalone Java class from the command line. Once you've done that, you can easily call that class from your JSP.
 
reply
    Bookmark Topic Watch Topic
  • New Topic