File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes problem accessing two tables from servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem accessing two tables from servlet" Watch "problem accessing two tables from servlet" New topic
Author

problem accessing two tables from servlet

deepak borole
Greenhorn

Joined: Nov 13, 2005
Posts: 25
i have to update a table from few tables using executeUpdate() from a servlet....from the previous page i am selecting the table to be updated and then in the servlet using if and else if i hav written code to update the table but only one table is getting updated...the code written in else if is not working means the executeUpdate() is not working....what must be the problem.


Winners Dont Do Different Things, They Do Things Differently !!!
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

How do get the table names in your servlet ? getParameter ?
How do you select the tables ? Please give us some clues


[My Blog]
All roads lead to JavaRanch
deepak borole
Greenhorn

Joined: Nov 13, 2005
Posts: 25
i have taken hardcoded string in which table names are there like ...
insert into tablename values(?,?,?,?)......but the executeUpdate() is not working.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

If you are using the same variable for the tablename, it will match only one "if" !



If you are doing this, it will only match one branch.

It is difficult to imagine what you are realy doing without seeing a bit of code.
deepak borole
Greenhorn

Joined: Nov 13, 2005
Posts: 25
ya it will match only one if....
if(subject.equals("mechanical"))
{
....
....
i = p_stmt.executeUpdate();
}
else if(subject.equals("electrical"))
{
....
....
i = p_stmt1.executeUpdate();
}
now what is happenin is that if mechanical is selected then it is going in the if loop and updating the table but if electrical is selected it does not execute the executeUpdate()....here different tables are updated when in any of the if loops i.e. if in mechanical then mechanical table is updated n so on....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem accessing two tables from servlet