2014-02-19 66 views
0

我有一个在网站上注册的用户列表,当管理员单击批准时,它必须插入到名为login的另一个表格中。我有代码,它不会抛出任何异常或任何错误,但它不会将行数据从一个表传输到另一个表。在单击超链接时在mysql中插入一行到另一个表格

下面是我的servlet:

我的DAO:

PreparedStatement ps=conn.prepareStatement("insert into login(id,FirstName,LastName,Gender,Category,Dateofbirth,Age,Address,Country,State,city,PinCode,EmailId,ContactNo,MobileNo)select * from register where id=?"); 
      ps.setInt(1, id); 
      ps.executeUpdate(); 
     } 

请人帮我解决这个问题,在此先感谢。

+0

谢谢你@Pedantic – user3222718

+0

不用谢了,我只是编辑列车上的最后一站。其他人(点击'编辑'链接了解详情)首先帮助你。 – Pedantic

+0

你可以检查你的ID是否得到查询吗?你得到哪个错误或异常?只尝试针对数据库的查询,并确认它是否有效。 –

回答

1

好吧,如果这是getter of parameter Id该变量的声明不应该是这样的 我不知道很多关于Spring MVC的,但吸气声明应该是这样的

private int id;/ * This is the parameter you are expecting from Front End 
public int getId()//*This is the getter of that parameter. 
{ 
    return id; 
} 
public void setId(int id)//Setter of ID parameter which sets the ID value to the local ID parameter 
{ 
     this.id = id; 

    } 

``

在您的代码您正在创建client类的新对象并调用参数getter方法。我在这里的意思是id参数设置在client类的不同对象中,并且您在其他某个类中使用新创建的getId()调用该方法。 我不知道它是如何在spring通常在MVC框架Every fomr will be related to a bean在这个bean中,你将有settergetters的形式.. 所以我建议你尝试使用特定形式的确切对象,你可以得到的值id参数

+0

** ya它的相同事情我已经做了....我忘了发布顶部的ID声明...像**'int id; public int getId() { return id; } public void setId(int id) { this.id = id; }' – user3222718

+0

雅是部分能够理解,但你是什么意思的确切对象的特定形式?你的意思是说特定形式的特定bean的对象? – user3222718

+1

http://www.tutorialspoint.com/spring/spring_mvc_form_handling_example.htm在这个例子中''Student.java'是'bean'在控制器类中调用'getters of parameters'请参考 – Babel

相关问题