Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Insert/Update recordset

 
Bashar Ayyash
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • 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,
 
Bimal Patel
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • 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
  • 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,
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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.
fficial" target="_blank" >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-USfficial

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic