registerBean.java
public void onEdit(RowEditEvent event) {
Connection con = null;
PreparedStatement stat = null;
ResultSet rs = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/db", "root", "");
stat = con.prepareStatement("update regtbl set fname=? where rno=?") ;
stat.setString(1, fname);
stat.setInt(2, rno);
stat.executeUpdate();
con.close();
} catch (Exception e) {
e.printStackTrace();
}
}
**
std.xhtml
**
<p:dataTable value="#{registerBean.list}" var="rb" rows="10" paginator="true"
paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,15,20" rowKey="#{rb.fname}" selectionMode="single" selection="#{registerBean.selectedStudent}"
scrollable="true" resizableColumns="true" editable="true" >
<p:ajax event="rowEdit" listener="#{registerBean.onEdit}" update=":form:messages" />
<p:ajax event="rowEditCancel" listener="#{registerBean.onCancel}" update=":form:messages" />
<p:column headerText="Roll No" filterBy="#{rb.rno}" sortBy="#{rb.rno}" width="124">
<h:outputText value="#{rb.rno}" />
</p:column>
<p:column headerText="First Name" filterBy="#{rb.fname}" sortBy="#{rb.fname}" width="124">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{rb.fname}" />
</f:facet>
<f:facet name="input">
<h:inputText value="#{rb.fname}" />
</f:facet>
</p:cellEditor>
</p:column>
..........
Am i going wrong some where here ..... this method is called to save the edited rows of datatable.... but database records are not getting updated....