2014-02-19 67 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

相關問題