• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in inserting data from one table to another table

 
sunaina agarwal
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a list of users registered on a website and when the admin clicks to approve, it must be inserted into another table called login. I have the code for you, its not throwing any exception or any error but it's simply not transferring row data from one table to another.

Below is my servlet:

Class Client is my DTO.




Below is my service class:




And my DAO:


 
Paul Clapham
Sheriff
Posts: 21554
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that your SQL statement is well-formed and valid -- which it seems like it is, since you say there are no exceptions thrown -- then that implies the "select * from ..." part returns zero rows. This is a perfectly legitimate situation, and what happens is that zero rows would be inserted into the 'login' table.

You can check this by examining the value returned by the executeUpdate() method, which tells you how many rows were inserted. My prediction is that the value would be zero; if I'm wrong then the problem lies elsewhere. However your comment in the Client class suggests you're already suspicious about the 'id' being passed through to the SQL, so perhaps your suspicion is correct and the wrong value is being passed.
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to specify the columns you are selecting from the "register" table, so you can be sure they line up with the ones you are trying to populate in the "login" table. For example:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic