• 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

How to prompt if there is no match in database using servlet?

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi am trying to compare two columns(serial_no) in two different tables Table1 and Table2, If there is a match I want to update 10 variables to table1 if no match then simply copy the serial_no to table1, I wrote a join for the first part now I don;t have any idea about how to copy if there is no match....Please can anyone look into my code and help me out....here is my code

StatusServlet



 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


You have SQL / Business logic and presentation code all in one servlet ? I would advise the following

1. Treat the servlet as a controller for the flow of code.
2. Create new service classes that will handle your business logic. Call them from the controller.
3. Move the data access logic to DAOs
4. Move the presentation logic to JSPs

I don;t have any idea about how to copy if there is no match



I am not quite sure what that means
 
lisy jessica
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am comparing the columns in two different tables Table1 and Table2 if there is a match then update, otherwise copy the Serial_No to Table1 this is what I mean.....

Thanks for the reply..Which framework I need to use struts or Spring?.

 
Deepak Bala
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

otherwise copy the Serial_No to Table1 this is what I mean.....



This involves the use of a insert or update statement into the DB

I need to use struts or Spring?.



It depends on what you want. You can even get off not using a framework at all. And by that I mean you can use the Servlet / JSP framework
 
lisy jessica
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok will try this. Thanks for the help.
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since you are making use of Oracle DB, check the MERGE statement for your case.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic