retrieve from database........

retrieve from database........

<p>hi i am not able to retrieve string from database to a text box in web page my code is as follows:-</p>

<p>&lt;HTML>
<link rel="stylesheet" type="text/css" href="format.css" >
&lt;HEAD>
&lt;TITLE>Modify Profile </TITLE>
</HEAD></p>

<p>&lt;%@ include file="connect.jsp"%>
&lt;%
int aa,ab,ac,ad,ae,ag;</p>

<p>String ia="0",ib="0",ic="0",id="0",ie="0",ig="0";
try{
String username=request.getParameter("username");
re=stmt.executeQuery("select * from userreg where username='"+username+"' ");
while(re.next())
{
ia=re.getString("name");
ib=re.getString("surname");
ic=re.getString("dob");
id=re.getString("email");
ie=re.getString("hintques");
ig=re.getString("hintans");
}
aa=Integer.parseInt(ia);
aa=aa;
ab=Integer.parseInt(ib);
ab=ab;
ac=Integer.parseInt(ic);
ac=ac;
ad=Integer.parseInt(id);
ad=ad;
ae=Integer.parseInt(ie);
ae=ae;
ag=Integer.parseInt(ig);
ag=ag;</p>

<p>%>  </p>

<p>&lt;BODY></p>

<div id="header">
<p align="center"> <font face="Times New Roman, Times, serif"  size="15"> <b><u>PASSPORT SERVICE</u></b></font></p>
<p align="center"> <font face="Times New Roman, Times, serif"  size="4"> <b>REPUBLIC OF INDIA</b></font></p>
</div>

<div id="nav">
<center>
<pre><font face="Times New Roman, Times, serif" size="3"><a href="index.html"><font color="#000066">HOME</font></a>    <a href="login.html"><font color="#000066">LOGIN</font></a>    <a href="process.html"><font color="#000066">PASSPORT PROCESS</font></a>    <a href="cont.html"><font color="#000066">CONTACT</font></a>    <a href="help.html" ><font color="#000066">HELP</font></a>    <a href="adminlog.html" ><font color="#000066">ADMIN LOGIN</font></a></font></pre>
</center>
</div>

<div id="nav1">
<p align="center"> <font face="Times New Roman, Times, serif"  size="5" color="#000066"> <b><u>SERVICES</u></b></font><br><br><br>
<font face="Times New Roman, Times, serif"  size="4">
<a href="fpptstep1.html"><font color="#000066">FRESH/REISSUE OF PASSPORT</font></a><br><br>
<a href=""><font color="#000066">VIEW APPOINTMENT AVAILABLITY</font></a><br><br> 
<a href="locatepsk.html"><font color="#000066">LOCATE PASSPORT OFFICE</font></a><br><br> 
<a href=""><font color="#000066">DOCUMENTS REQUIRED</font></a><br><br>
<a href="feecalcu.html"><font color="#000066">FEE CALCULATOR</font></a><br><br>
<a href=""><font color="#000066">FEEDBACK</font></a><br><br>
<a href=""><font color="#000066">FAQ's</font></a>
</font>
</p>
</div>

<form action="modifypro.jsp" method="get" method="post">
<div id="content">
<br><img align="right"  src="ts.jpg"  height="230" width="150" >
<pre>
<font face="Georgia, Times New Roman, Times, serif">
<h2><b>                  <u>MODIFY PROFILE</u></b></h2>

<table cellspacing="15">
<tr><td>Username*:</td><td><input type="text" name="username" value=""></td></tr>
<tr><td>Given Name*:</td><td><input type="text" name="name" value="<%=aa%>"></td></tr>
<tr><td>Surname:</td><td><input type="text" name="surname" value="<%=ab%>"></td></tr>
<tr><td>Date of Birth:</td><td><input type="date" name="dob" value="<%=ac%>"></td></tr>
<tr><td>Email:</td><td><input type="text" name="email" value="<%=ad%>"></td></tr>
<tr><td>Hint Question:</td><td><select name="st" value="<%=ae%>" > <option>--select--</option><option>Birth Place</option><option>Fav Color</option><option>Fav Cricketer</option><option>Fav Food</option><option>First School</option><option>Fav Food</option><option>Make Of First Car Owened</option><option>Make Of First Bike Owened</option> </select></td></tr>
<tr><td>Hint Answer*:</td><td><input type="text" name="hint ans" value="<%=ag%>"></td></tr>
</table>                      
                <input type="Button" name="b1" value="submit" >     <input type="Button" name="b1" value="Modify" onClick="val(form)" ",">     <input type="reset" name="b2" value="Clear">
</p>
</font>
</pre>
</div>
</form>

<div id="footer">
<center> © Copyright and Design by: Chandan and Indrajeet </center>
</div>

<p></BODY>
&lt;%}
catch(Exception e)
{ <br />
out.println(e);</p>

<p>}%></p>

<p></HTML></p>
View Answers

March 15, 2011 at 12:14 PM

1)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 = "test";
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 employee";
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:#49743D;font-weight:bold;color:#ffffff;" onclick="editRecord(<%=rs.getString(1)%>);" ></td>
</tr>
<%
}
%>
<%
}
catch(Exception e){
e.printStackTrace();
}
%>
</table>
</form>
</body>
</html>

2)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/test", "root", "root");
String query = "select * from employee 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 15, 2011 at 12:14 PM

continue..

3)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/test","root", "root");
Statement st=null;
st=conn.createStatement();
st.executeUpdate("update employee set name='"+name+"',address='"+address+"',contactNo="+contact+",email='"+email+"' where id='"+num+"'");
response.sendRedirect("/examples/jsp/application.jsp");
}
catch(Exception e){
System.out.println(e);
}
%>

March 15, 2011 at 11:25 PM

thank u its working............thank u very much....









Related Tutorials/Questions & Answers:
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
Advertisements
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
retrieve from database........
retrieve from database........  <p>hi i am not able to retrieve string from database to a text box in web page my code is as follows:-</p>...("username"); re=stmt.executeQuery("select * from userreg where username='"+username
how to retrieve data from database
how to retrieve data from database  unable to retrieve data from database using mySQL by using jsp sessions and beans for editing
How to retrieve image from database
How to retrieve image from database  hi........ How to retrieve image from database when it is stored. I have stored image in postgresql and want to retrieve in java form. Can u tel me hw to do? I am trying n able to do also
retrieve data from database with hyperlink
retrieve data from database with hyperlink  sir....i have one table called 'name' having two values i have to retrieve those data with a hyperlink... have values C C++ i have to retrieve and if i click C its sub categories should
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 database using php.... below my code is that.. <html> <head>
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
how to use bean to retrieve data from database
how to use bean to retrieve data from database  how to use bean to retrieve data from database   poda sendru
How to retrieve image from database in Servlet?
How to retrieve image from database in Servlet?  Hi, How to retrieve image from database in Servlet? Thanks   Hi, Please check the tutorial Retrieve image from database using Servlet. Thanks
How to retrieve blob image from database in JSP?
How to retrieve blob image from database in JSP?  Hello, JSP is used... the blog image from database. How to retrieve blob image from database in JSP?   Hi, Please check the tutorial Retrieve image from database using
How to retrieve and display image from database in Java?
How to retrieve and display image from database in Java?  Hi, I am writing a web application for reading the data from database and displaying.... Please check the it at How to store and retrieve image from database in JSP
How to store and retrieve image from database in JSP?
How to store and retrieve image from database in JSP?  Hi, In one... and retrieve image from database in JSP? Thanks   HI, You can use... the image. Check this example: Retrieve image from database using Servlet. Thanks
Retrieve multiple data from database into Table.....
Retrieve multiple data from database into Table.....   hi........... I want to Retrieve multiple data from database into Table but i am not able to.... i am only able to retrieve one value not more than that. means in my
How to retrieve image from mysql database in JSP?
How to retrieve image from mysql database in JSP?  Hi, I need JSP... to retrieve image from mysql database in JSP? Thanks   Hi, You can write SQL query to find the data from database and get the image from resultset using
retrieve data from database using jsf
retrieve data from database using jsf  Hello I want an example of source code to retrieve data from database i have a database (oracle) name as db1...),, name ,and city I want after enter value in textbox according idauthor i retrieve
Retrieve values from database using views
Retrieve values from database using views  hi......... I have a huge database so i have created views in database where i am selecting only the columns which are required. As my front end is java swings i want to retrieve data
Retrieve value of radio button from database to form
Retrieve value of radio button from database to form  var gn=document.getElementsByName("empg"); //empg is name of radio input type. for(var i=0;i
Retrieve date from MYSQL database
Retrieve date from MYSQL database In this tutorial, you will learn how to retrieve date from database. Storing and Retrieving dates from the database... to retrieve the date of birth of persons from the database table. For this, we have
Dropdown code to retrieve result from oracle database
that will retrieve values from the database into dropdown. As the user choose any option...Dropdown code to retrieve result from oracle database  Hi Friends, I... retrieve the result from Oracle database.We have procedures created already.Just
how to store and retrieve image from database
how to store and retrieve image from database  how to store and retrieve images into database(oracle) and how to retrive images from database using jsp   Here is a jsp code that insert and retrieve image from mysql
retrieve data from mysql database and store it in a variable ?
retrieve data from mysql database and store it in a variable ?  sir... that retrieve the integer values from the database and stored in the integer variables. In addition to it, we have added numbers that are retrieved from
Retrieve database from the table dynamically in jsp from oracle using servlet
Retrieve database from the table dynamically in jsp from oracle using... columns dynamically. I want to retrieve the table with all columns dynamically using java servlet from the database in the jsp page
Retrieve data from database in swing application
Retrieve data from database in swing application  I want to retrive data(doctor name,specilization,date) from my sql database...(); ResultSet rs=st.executeQuery("select * from data where id=1"); while
how to retrieve images from database to jsp?
how to retrieve images from database to jsp?  Hi sir,i want to stores images along with the name and price with database and retrieve it on jsp.and...=con.createStatement(); String strQuery = "select * from data"; ResultSet rs
how we retrieve image from database
how we retrieve image from database  my code is:- $search=$_POST... from mysql database: <?php mysql_connect("localhost","username","password... not connect to Database"); $query = "SELECT content,size,type FROM upload WHERE id=1
how to store and retrieve images int and from the database using php
how to store and retrieve images int and from the database using php  please anyone can help me in storing the images and retrieve it back from the Mysql database using php
<img src=""> using retrieve image from database using jsp
using retrieve image from database using jsp  how to <img src="" > tag using retrieve image from database and display in jsp
How to retrieve image from database using jsp and servlet?
How to retrieve image from database using jsp and servlet?  Hi, I am trying to find code for displaying the image from database in a JSP page. How to retrieve image from database using jsp and servlet
How to Retrieve Data from the database and write into excel file using Java
How to Retrieve Data from the database and write into excel file using Java  Hi, I am trying to develop an small application where i trying to retrieve Data from the database and store the details in excel file. Please can
retrieve value from database on the basis of maximum id number
retrieve value from database on the basis of maximum id number  hi, i want to retrieve value of maximum id number from the database and show that value in jTextField.when the user clicks on the button that maximum id number
retrieve the data to text fields from database on clicking the value of combo box
retrieve the data to text fields from database on clicking the value of combo box   retrieve the data to text fields from database on clicking... getting data into textarea from database table by clicking on the button
Retrieve image from database using servlet and display in JSP
Retrieve image from database using servlet and display in JSP  Hi, I am total new to JSP although I am learning it for the last few days. Now I want to use MySQL Database from JSP page. How to retrieve image from database using
retrieve related data from database using jsp and mysql
retrieve related data from database using jsp and mysql  Hi sir, please give some example of jsp code for retrieving mysql database values in multiple dropdown list. if we change a value in a dropdown its related value must
To retrieve image from SQL Server Database - Java Server Faces Questions
To retrieve image from SQL Server Database  Sir/Madam, I am trying to retrieve image from SQL Server 2000 database in Visual Web JSF Page using... or in Image Component. please help me in retrieving and displaying image from SQL Server
Retrieve image from mysql database through jsp
Retrieve image from mysql database through jsp... to retrieve image from mysql database through jsp code. First create a database... Note : In the jsp code given below, image will be retrieved from database
Retrieve data from the database and write into ppt file
Java Retrieve data from the database & write into ppt file In this section, we are going to retrieve data from the database and write into the .ppt file... of setText() method, we have inserted database values into it. Here is the code
Retrieve Data from the database and write into excel file
Retrieve Data from the database and write into excel file. In this section, we are going to retrieve data from the database and write into the excel file..., we have inserted the database table values in the excel sheet. Here
how to retrieve data into combo from database in java applet?
how to retrieve data into combo from database in java applet?  hi,. i have written applet codes for linking two frames and database connectivity but the problem is, the database is not retrieving data into the combo..please
how to send and retrieve image along with text to and from database
how to send and retrieve image along with text to and from database  im using app engine and i have two logics from different sources and i want to combine them. ive used the greeting example from app engine and i have a random
how to retrieve image from mysql database using java and show it in HTML img tag ?
how to retrieve image from mysql database using java and show it in HTML img tag ?  how to retrieve image from mysql database using java and show it in HTML img tag
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
Retrieve data from database by using sql tag of JSTL SQL library
Retrieve data from database by using sql tag of JSTL SQL library... we will see how retrieve data from database using sql query given by user...; Structure of the table: retrieve_database
retrieve data from database in java swing form using prev n next buttons
retrieve data from database in java swing form using prev n next buttons  i have a database having columns id(int),path(text),width(int),height(int... of various rows from database in labels by clicking previous and next
retrieve data from database in java swing form using prev n next buttons
retrieve data from database in java swing form using prev n next buttons  i have a database having columns id(int),path(text),width(int),height(int... of various rows from database in labels by clicking previous and next
retrieve record from table
retrieve record from 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 table. Actually
how to retrieve the id value itself from the access database to drop down listbox in jsp
how to retrieve the id value itself from the access database to drop down listbox in jsp  how to retrieves the id which is an int datatype, from access database to drop down list box in jsp...plz send the code for that.....plz
how to retrieve text and images from mysql database and show on html page using jsp servlet
how to retrieve text and images from mysql database and show on html page using jsp servlet  <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> Insert title here h3

Ads