Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC editing cell in a table
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


ebuka
editing cell in a table
1 Answer(s)      5 years and 4 months ago
Posted in : JDBC



Advertisement
View Answers

July 1, 2009 at 1:24 PM


Hi Friend,

Try the following code:

1)updateDatabase.jsp

<%@page import="java.sql.*"%>

<form name=myname method=post action="update.jsp">
<table border="1">
<tr>
<td><b><u>RollNo</u></b></td>
<td><b><u>Name</u></b></td>
<td><b><u>Class</u></b></td>
</tr>
<%try{

Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root";, "root");
ResultSet rs = null;
Statement st=null;
st=conn.createStatement();
rs = st.executeQuery("select * from employee where emp_id='2'");
while(rs.next()){ %>
<tr>
<td><input type="text" name="eid" value="<%= rs.getString("emp_id") %>"></td>
<td><input type="text" name="ename" value="<%= rs.getString("empName") %>"></td>
<td><input type="text" name="eadd" value="<%= rs.getString("empAddress") %>"></td>
</tr>
<%}
}
catch(SQLException e){}
%>
</table>
<input type="Submit">

2) update.jsp
<%@page import="java.sql.*"%>
<% String id=request.getParameter("eid");
String name=request.getParameter("ename");
String address=request.getParameter("eadd");
try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root";, "root");

Statement st=null;
st=conn.createStatement();
st.executeUpdate("update employee set empName='"+name+"', empAddress='"+address+"' where emp_id='"+id+"'");
out.println("Data is updated successfully.");
}
catch(Exception e){}
%>

Thanks



Related Tutorials/Questions & Answers:
editing cell in a table - JDBC
editing cell in a table  how can i edit a cell in a table and save the change to a database  Hi Friend, Try the following code: 1)updateDatabase.jsp RollNo Name Class "> "> ">
how to allow table editing
how to allow table editing   1**. hi... l've tried the method isCellEditable(int rowIndex, int colIndex) { return true but it doesn't enabled the user the editing of any cell why????????????? regards
Advertisements
css table cell margin
css table cell margin  How can i put margin between two columns(cell margin)?   In your CSS you can set the desired margin between two cells as given below.. padding-right:10px;   now you need to call
image on div or cell of table
image on div or cell of table  I am using ms access database and I... but it display on browser but I want to display on inside the div tag or table tag pls... is to display on div or table... thnx in advance
image on div or cell of table
image on div or cell of table  I am using ms access database and I... but it display on browser but I want to display on inside the div tag or table tag pls... is to display on div or table... thnx in advance
image on div or cell of table
image on div or cell of table  I am using ms access database and I... but it display on browser but I want to display on inside the div tag or table tag pls... is to display on div or table... thnx in advance
image on div or cell of table
image on div or cell of table  I am using ms access database and I... but it display on browser but I want to display on inside the div tag or table tag pls... is to display on div or table... thnx in advance
image on div or cell of table
image on div or cell of table  I am using ms access database and I... but it display on browser but I want to display on inside the div tag or table tag pls... is to display on div or table... thnx in advance
image on div or cell of table
image on div or cell of table  I am using ms access database and I... but it display on browser but I want to display on inside the div tag or table tag pls... is to display on div or table... thnx in advance
Height for cell in table view - UITableView
Height for cell in table view - UITableView  UITableview height for cell What is the height for cell in table view iPhone mobile application
Table Empty Cell in HTML
Table Empty Cell in HTML       The Table Empty Cell in HTML define no content inside a cell of table. The code is not able to display border around the empty cell in a table
Query on Java Swing - Table Cell Issue - Swing AWT
Query on Java Swing - Table Cell Issue  Hi, I have a query on Java... the key board focus is moving from one cell to another table cell but I am unable to show the cursor in the focused cell which is editable. what do I need do
Editing the Profile
Editing the Profile  how to populate drop-down menu instead of text box in editing the profile
restrict jtable editing
restrict jtable editing  How to restrict jtable from editing or JTable disable editing?   public class MyTableModel extends AbstractTableModel { public boolean isCellEditable(int row, int column
differences between cell spacing and cell padding
differences between cell spacing and cell padding  What are the differences between cell spacing and cell padding
change content of cell javascript
change content of cell javascript  change content of cell javascript
Display of value in Tabel cell
in the table cell by defining the cell editor.The cell is having a text field and calendar.When i select a date in the calendar the date will be displayed in the cell...) The format the cell is showing when its in focus - Mon,dd,yyyy(Mar,01,2011). I
JSP:HTML Form in-place Editing - JSP-Servlet
developer's needs. This is a follow up to the HTML Form in-place editing. The code... an excellent way of editing a form. I just have a few adjustments if any of you could... to be able to open a page instead of a window for the editing which opens
Custom Cell View UITableview
Custom Cell View UITableview  How can i get two custom cell view in UITableView
Auto select cell on mouse hover using 'hover' mouse event
Auto select cell on mouse hover using 'hover' mouse event In this tutorial, we will discuss about how to highlight Table's cell on mouse hover using jQuery 'hover' mouse event. In this example, a table is given
Subtitle in Table View  iPhone
cell of the Table view and index to Table view. As explain about the Table view... using the same concept will add the object into the cell of Table View and added... to the cell of Table View. After that will set the frame of the cell and also
JSP:HTML Form in-place Editing - JSP-Servlet
of a customer search in a small table on the same page using another servlet(also working fine). Once this dynamic table populates with results, I have an onclick... of the rows of the search result table to select it and to edit that particular
JTable - Cell selection - Swing AWT
JTable - Cell selection  How to select a cell of a JTable when I... javax.swing.event.*; public class JTableDemo extends JFrame { JTable table; DefaultTableModel tableModel; public JTableDemo() { table = new JTable(10, 5
Setting Cell Values in JTable
Setting Cell Values in JTable       In this section, we will learn how to set the cell... about JTable. A cell is known as the format of  a row and a column in 
Editing UI components using managed bean
Editing UI components using managed bean  Hello friends... I want to edit the properties of a inputText on JSP page using its managed bean. I have a simple inoutText and commandButton on jsp page and on click of button, i want
Passing td cell id to servlet
Passing td cell id to servlet  Hi all, I am new to JSP/Servlet .Please help. I need to send the table cell index in servlet using javascript and should be able to make a cell index to have a text - "X" / "0"only once. Here
VoIP Cell Phone
VoIP Cell Phone Using VoIP with Cell Phone  Before many of us came to rely on cell phones to make long distance phone calls, our only... and loved ones often living only a few hours away. When cell phones came
How to create a JTable cell containing Image hyperlink?
image (cell) in the last column of my table? so that, when the image link...How to create a JTable cell containing Image hyperlink?  I'm trying to find out how to create a JTable cell which contains Image, which should
WANT TO RESTRICT EDITING AFTER A SET OF DATE
WANT TO RESTRICT EDITING AFTER A SET OF DATE  localhost : Server version: 5.0.51b-community-nt phpMyAdmin - 2.11.7 hello guys, i have to continue my work more complex.. but i dont have any idea to do that... i want
Getting Cell Values in a JTable
Getting Cell Values in a JTable       In this tutorial, you will learn how to get the cell values in a JTable component. It is a same as setting the cell values in a JTable
table
table  multiplicatyion table
Advertisements
 

 

 

DMCA.com