This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JDBC and the fly likes How to prompt if there is no match in database using servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to prompt if there is no match in database using servlet?" Watch "How to prompt if there is no match in database using servlet?" New topic
Author

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

lisy jessica
Ranch Hand

Joined: Oct 27, 2010
Posts: 47
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



Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5



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


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
lisy jessica
Ranch Hand

Joined: Oct 27, 2010
Posts: 47
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

Joined: Feb 24, 2006
Posts: 6662
    
    5

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

Joined: Oct 27, 2010
Posts: 47
ok will try this. Thanks for the help.
Sudheer Bhat
Ranch Hand

Joined: Feb 22, 2011
Posts: 75
Since you are making use of Oracle DB, check the MERGE statement for your case.
 
 
subject: How to prompt if there is no match in database using servlet?