updations on data in mysql

updations on data in mysql

sir ,i want to retreive data from mysql as a table format and after retreiving the data i want to edit the data and update the data into mysql using jsp

View Answers

March 13, 2013 at 5:16 PM

hi friend,

Try the following sample code may, this will be helpful for you

application.jsp

<%@ page import="java.sql.*" %>
<html>
<head>
<script language="javascript">
function editRecord(id){
    var f=document.form;
    f.method="post";
    f.action='edit.jsp?id='+id;
    f.submit();
}
</script>
</head>
<body>

<br><br>
<form method="post" name="form">
<table border="1">
<tr><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th></tr>
<%
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "record";
String driver = "com.mysql.jdbc.Driver";
String userName ="root";
String password="root";

int sumcount=0;
Statement st;
try{
Class.forName(driver).newInstance();
con = DriverManager.getConnection(url+db,userName,password);
String query = "select * from employee1";
st = con.createStatement();
ResultSet rs = st.executeQuery(query);
%>
<%
while(rs.next()){
%>
<tr><td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><%=rs.getString(4)%></td>
<td><%=rs.getString(5)%></td>
<td><input type="button" name="edit" value="Edit" style="background-color:green;font-weight:bold;color:white;" onclick="editRecord(<%=rs.getString(1)%>);" ></td>
</tr>
<%
}
%>
<%
}
catch(Exception e){
e.printStackTrace();
}
%>
</table>
</form>
</body>
</html>

Continue......


March 13, 2013 at 5:17 PM

edit.jsp

<%@page language="java"%>
<%@page import="java.sql.*"%>
<form method="post" action="update.jsp">
<table border="1">
<tr><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th></tr>
<%
String id=request.getParameter("id");
int no=Integer.parseInt(id);
int sumcount=0;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/record", "root", "root");
String query = "select * from employee1 where id='"+no+"'";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
while(rs.next()){
%>
<tr>
<td><input type="text" name="name" value="<%=rs.getString("name")%>"></td>
<td><input type="text" name="address" value="<%=rs.getString("address")%>"></td>
<td><input type="text" name="contact" value="<%=rs.getInt("contactNo")%>"></td>
<td><input type="text" name="email" value="<%=rs.getString("email")%>"></td>
<td><input type="hidden" name="id" value="<%=rs.getString(1)%>"></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Update" style="background-color:#49743D;font-weight:bold;color:#ffffff;"></td>
</tr>
<%
}
}
catch(Exception e){}
%>
</table>
</form>

March 13, 2013 at 5:18 PM

Continue......

update.jsp

<%@page import="java.sql.*"%>
<%
String ide=request.getParameter("id");
int num=Integer.parseInt(ide);
String name=request.getParameter("name");
String address=request.getParameter("address");
int contact=Integer.parseInt(request.getParameter("contact"));
String email=request.getParameter("email");
try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/record","root", "root");
Statement st=null;
st=conn.createStatement();
st.executeUpdate("update employee1 set name='"+name+"',address='"+address+"',contactNo="+contact+",email='"+email+"' where id='"+num+"'");
response.sendRedirect("application.jsp");
}
catch(Exception e){
System.out.println(e);
}
%>









Related Tutorials/Questions & Answers:
updations on data in mysql
updations on data in mysql  sir ,i want to retreive data from mysql as a table format and after retreiving the data i want to edit the data and update the data into mysql using jsp   hi friend, Try the following sample
information updations
information updations  I have created the following interface that allows updations to customer information: public interface validateInfo { public void validate(String empcode, String password); } class updateInfo implements
Advertisements
mysql for data science
mysql for data science  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: mysql for data... the topic "mysql for data science". Also tell me which is the good
updation of data in mysql
updation of data in mysql  http://www.roseindia.net/answers/viewqa/PHP/20822-Edit-the-record-.html sir , i want the above code as retreive of data from mysql ,but based on subject code(varchar) instead of id and my table format
Inserting Data into mysql - SQL
Inserting Data into mysql  My sincere apologize for this post. I noticed there is no category for php. However am hoping my question will fit... (using php)and inserting the details in a mysql database. Lets take for instance
Retrieve The Data From MySql Datbase
Retrieve The Data From MySql Datbase   How to Retrieve The Data From MYSQL database TO Use Select the Emp_id Option.And Also Search Option
Core data and mysql
Core data and mysql  Can any one please explain me the core data and sqlite concept
How to delete data from MySQL?
How to delete data from MySQL?  Hi, How I can conditionally delete the data from MySQL Table? Thanks   Hi, You can use the where clause to conditionally delete the data from MySQL database table. Here is some query
how to post data in mysql php form
how to post data in mysql php form  how to post data in mysql php form
backup your MySQL data using mysqldump:cPanel MYSQL 5.1 to 5.5
backup your MySQL data using mysqldump:cPanel MYSQL 5.1 to 5.5  backup your MySQL data using mysqldump:cPanel MYSQL 5.1 to 5.5
retrieve data from mysql database
retrieve data from mysql database  hi am not familiar in php.....even... selected value on combobox which is to be retrieve the relevant data from mysql...;/html> retcombosearch.php form is <?php mysql_connect ("localhost
store data from a variable in mysql?
store data from a variable in mysql?  sir last time asked you tell me how to retrieve data from a database mysql and store it in an int variable... of the calculation from an int variable into mysql in a new table of database. how
php import data from excel to mysql
php import data from excel to mysql  php import data from excel to mysql
Data is not inserting correctly in mysql database.
Data is not inserting correctly in mysql database.  Hello Sir, below is my code to insert data into database by list iteration... for each data cloumn ..at the time of end of the query... PLz see my code and point my
How to insert data into MySQL Table?
How to insert data into MySQL Table?  Hi, How to insert the data into MySQL Database? Please explain me with the examples and videos thanks. Thanks   Hi, The insert into query is used to insert the data into MySQL
Purge Data from Mysql tables
Purge Data from Mysql tables  Hi, i have to write a mysql procedure to purge data from tables. but written procedure clear entire tables data. Please give me the solution for purging data. CREATE DEFINER=`root`@`localhost
Mysql Alter Data Type
Mysql Alter Data Type       Mysql  Alter Date Type is used to modify or change the Column... an example on 'Mysql Alter Date Type'.To understand this example we create a table
Data retrieve from mysql database
Data retrieve from mysql database  Hi sir, please give some example of jsp code for retrieving mysql database values in multiple dropdown list... from the dropdown, related data will get displayed on the textboxes. Here we have
Fetch the data from mysql and display it on php form
Fetch the data from mysql and display it on php form  when i press on login button, after succesful login the related data of that person should be display in other textbox
update data to mysql database through JTextField
update data to mysql database through JTextField  I am getting an error, when i am updating a data to mysql database through JTextField. Send me...(); JOptionPane.showMessageDialog(null,"Data successfully Updated to the database
problem on jsp, inserting data into table(mysql).
problem on jsp, inserting data into table(mysql).  hello friends, I have a problem in jsp.I want to insert data, which is given by user through... is in mysql.I want to use placeholder("?") to insert data into table.Plsssss help
Mapping MySQL Data Types in Java
Mapping MySQL Data Types in Java    ... mechanism for transferring data between an database using MySQL data types... for the common MySQL data types. We have to confirm that we have proper type information
Exporting data from mysql into csv using jsp
Exporting data from mysql into csv using jsp  Hi friends.... I want to export the data from mysql to csv file using... i am having 30 columns in my database.. Eg- text1,text2,text3,....,upto text30... i want to export this data
MYSQL retrieve record from Data table
MYSQL retrieve record from Data table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from the field
MySQL issue: Table 'data_dictionary.CHARACTER_SETS' doesn't exist
MySQL issue: Table 'data_dictionary.CHARACTER_SETS' doesn't exist  MySQL issue: Table 'datadictionary.CHARACTERSETS' doesn't exist
How to Restore The Lossed data in MYSQL database after the System is formatted
How to Restore The Lossed data in MYSQL database after the System is formatted  How to Restore The Lossed data in MYSQL database after the System is formatted
Read Excel data using JSP and update MySQL databse
Read Excel data using JSP and update MySQL databse  HOw to read excel data using JSP and update MySQl database
retrieve data from mysql database and store it in a variable ?
retrieve data from mysql database and store it in a variable ?  sir , I am working on a project , in which I have to apply operation on input data which is stored in mysql. so to apply some arithmetic operation on it we have
read text file and store the data in mysql - JDBC
read text file and store the data in mysql  when we store the data in mysql table from text file its store the data from new line to new column. how to store the data in different column from a single line of text file. 
Exporting data from mysql to csv file
Exporting data from mysql to csv file  Hi friends.... I want to export the data from mysql to csv file... i am having 30 columns in my database.. Eg- text1,text2,text3,....,upto text30... i want to export this data in csv file
Retriving data from MYSQL without line break using java
Retriving data from MYSQL without line break using java  get data without line breaking from mysql table (i.e data stored as mediumtext )using java
sending data to google chart api from mysql database using java
sending data to google chart api from mysql database using java  how to send data from mysql database to google chart api using java
Maven Repository/Dependency: com.flipkart.aesop | data-layer-mysql
Maven Repository/Dependency of Group ID com.flipkart.aesop and Artifact ID data-layer-mysql. Latest version of com.flipkart.aesop:data-layer-mysql dependencies. # Version Release Date You
Maven Repository/Dependency: org.teiid | spring-data-mysql
Maven Repository/Dependency of Group ID org.teiid and Artifact ID spring-data-mysql. Latest version of org.teiid:spring-data-mysql dependencies. # Version Release Date 1
access data from mysql through struts
access data from mysql through struts  I am Pradeep Kundu. I am making a program in struts in which i want to access data from MySQL through struts. I am using Strut 1.3.8 , Netbean 6.7.1 and MySQL 5.5. In this program ,I want
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.  I am unable to show table data on JSP page using servlet and mysql. only two rows data i showing but in my database I have five fields
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.  I am unable to show table data on JSP page using servlet and mysql. only two rows data i showing but in my database I have five fields
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.  I am unable to show table data on JSP page using servlet and mysql. only two rows data i showing but in my database I have five fields
extract data from excel sheet to mysql
extract data from excel sheet to mysql  sir, i want to extract data from excel sheet and save the data in mysql5.0 database in the form of table
insert data into mysql databse using swing
insert data into mysql databse using swing   Blockquote hi, here is my code, i want code for store data into mysql database when click on submit button from access data from this form, please provide code, import java.awt.
create dropdown cell in csv or excell from mysql data in php
create dropdown cell in csv or excell from mysql data in php  Hello sir i want to create drodown cell in csv from mysql data is this is possible or not? if this is posible please share answer or reference link Thanks
Uploading Excel sheet record in JSP to insert data in MySql
Uploading Excel sheet record in JSP to insert data in MySql  Need Help how to upload Excel (.xls) file and insert data in Mysql using JSP it wil be wonder for me if any help me
How to find MySQL data directory name?
How to find MySQL data directory name? There are various ways to find the data... of the methods to find data directory of the MySQL server. We are discussing..._TO_REPLACE_1 Method 1: Find data directory configuration in mysql ini file
org.molgenis - molgenis-data-mysql version 1.16.3 Maven dependency. How to use molgenis-data-mysql version 1.16.3 in pom.xml?
org.molgenis  - Version 1.16.3 of molgenis-data-mysql Maven dependency? How to use  org.molgenis  - Version 1.16.3 of molgenis-data-mysql in pom.xml? How to use molgenis-data-mysql version 1.16.3 in pom.xml? Learn to use
org.molgenis - molgenis-data-mysql version 1.9.0 Maven dependency. How to use molgenis-data-mysql version 1.9.0 in pom.xml?
org.molgenis  - Version 1.9.0 of molgenis-data-mysql Maven dependency? How to use  org.molgenis  - Version 1.9.0 of molgenis-data-mysql in pom.xml? How to use molgenis-data-mysql version 1.9.0 in pom.xml? Learn to use
Maven Repository/Dependency: org.molgenis | molgenis-data-mysql
Maven Repository/Dependency of Group ID org.molgenis and Artifact ID molgenis-data-mysql. Latest version of org.molgenis:molgenis-data-mysql dependencies. # Version Release Date 1
How to select Data Between Two dates in Java, MySQL
How to select Data Between Two dates in Java, MySQL  How to select Data Between Two dates in Java, MySQL? Thanks in advance.   http://www.v7n.com/forums/coding-forum/294668-how-select-data-between-two-dates-php
MYSQL EXCEPTION -DATA TRUNCATION..pls resolve it
MYSQL EXCEPTION -DATA TRUNCATION..pls resolve it  while running my...; <head> <title>Connection with mysql database</title>...=request.getParameter("Pyop"); try { String connectionURL = "jdbc:mysql://localhost:3306/stu
how to fetch data from mysql database table and draw a bar chart on that data using in jsp
how to fetch data from mysql database table and draw a bar chart on that data using in jsp  how to create bar chart fetch data from mysql database using in jsp.please give me a right code. yhanks in advance
MYSQL EXCEPTION -DATA TRUNCATION..pls resolve it
MYSQL EXCEPTION -DATA TRUNCATION..pls resolve it  while running my program as follows Register1.html <!DOCTYPE html> <html lang="en"><head> <meta charset="utf-8"> <title>JavaScript Form

Ads