2016-04-22 25 views
0

請我有一個病人的病歷在餐桌 代碼傳輸數據使用了一點問題:問題的病人記錄在表檔案傳輸數據

try { 
     //Statement mystt = (Statement) conn.createStatement(); 
     int row= affichagetable_pt.getSelectedRow(); 
     String Table_click=(affichagetable_pt.getModel().getValueAt(row, 0).toString()); 
     String query="insert into archives_pt (numfiche_pt,datefiche_pt,nom_pt,prenom_pt,datenaissance_pt,gsm_pt,cin_pt,profession_pt,sexe_pt,adresse_pt,nomsons_pt,cinsons_pt) select numfiche_pt,datefiche_pt,nom_pt,prenom_pt,datenaissance_pt,gsm_pt,cin_pt,profession_pt,sexe_pt,adresse_pt,nomsons_pt,cinsons_pt from patient where patient.numfiche_pt='"+Table_click+"'"; 
     pst=conn.prepareStatement(query); 
     rs=pst.executeQuery(); 
     JOptionPane.showMessageDialog(null,"Effacement OK"); 
     pst.close(); 
    } catch (Exception e2) { 
     // TODO: handle exception 
     JOptionPane.showMessageDialog(null,e2); 

    } 

錯誤:

enter image description here

E2消息 「的說法,並沒有返回結果集」

+2

你需要了解,理解和在bobby表訪問之前開始使用參數化查詢。 http://bobby-tables.com/ –

+0

你能把這個錯誤信息翻譯成英文嗎? –

+0

請發佈您的e2而不是隻是消息的完整堆棧跟蹤。使用e2.printStackTrace();並在這裏複製控制檯日誌。 –

回答

0

使用execute用於像插入,更新和刪除等數據操作的聲明,以及用於像select一樣的數據檢索的executeQuery。 更換

pst.executeQuery

pst.execute();

+0

您能否在此處寫plzz bro謝謝 – AnouarLouardighi

+0

pst.executeQuery(); ??? – AnouarLouardighi

+0

pst.execute(); –

0

結束你的INSERT語句用分號開始你的SELECT語句前:

...,cinsons_pt); select... 
+0

我認爲這不是真的,他想從select語句插入值。 –

+0

哦,你可能是對的。如果是這樣的話,那麼Mojtaba的解決方案就近了。他需要使用ExecuteNonQuery(),而不是嘗試填充結果集。 (完全刪除'rs =') –