Getting Textbox data from database

Getting Textbox data from database

When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown below.

<%
String empid=(String) session.getAttribute("empid");
ResultSet rs=null;
Statement stmt=null;

try{
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","adm","adm");
    stmt=con.createStatement();
    rs=stmt.executeQuery("select fname,empid from cremp where empid='"+empid+"'");
    rs.next();
}

catch(Exception e){}
finally {
    rs.close();
    stmt.close();
}
%>

     <table width="309" border="1" align="center">
      <tr>
    <td width="108">Name:</td>
    <td width="185"><label>
      <input type="text" name="fname" value="<%=rs.getString(1)%>" readonly/>
    </label></td>
      </tr>
      <tr>
    <td>Id:</td>
    <td><label>
      <input type="text" name="empid" value="<%=rs.getString(6)%>" readonly/>
    </label></td>
      </tr>

org.apache.jasper.JasperException: Exception in JSP: /raisereq.jsp:72
<tr>
<td width="108">Name:</td>
<td width="185"><label>
<input type="text" name="fname" value="<%=rs.getString(1)%>" readonly/>
</label></td>
</tr>
<tr>
View Answers

September 22, 2012 at 5:22 PM

Here is a jsp code that retrieves data from database and display it on the textboxes.

<%@page language="java"%>
<%@page import="java.sql.*"%>
<table border="1">
<%
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='1'";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
if(rs.next()){
%>
<tr>
<tr><td>Name</td><td><input type="text" name="name" value="<%=rs.getString("name")%>"></td></tr>
<tr><td>Address</td><td><input type="text" name="address" value="<%=rs.getString("address")%>"></td></tr>
<tr><td>Contact No</td><td><input type="text" name="contact" value="<%=rs.getInt("contactNo")%>"></td></tr>
<tr><td>Email</td><td><input type="text" name="email" value="<%=rs.getString("email")%>"></td></tr>
<%
}
}
catch(Exception e){}
%>
</table>









Related Tutorials/Questions & Answers:
Getting Textbox data from database
Getting Textbox data from database  When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown... data from database and display it on the textboxes. <%@page language="java
Getting Textbox data from database
Getting Textbox data from database  When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown...;Here is a jsp code that retrieves data from database and display
Advertisements
display data from database in textbox when id entered in textbox
display data from database in textbox when id entered in textbox  i wanted to enter data in textbox .depending on entered data in textbox data from database should be displayed dynamically in textbox
How to show data from database in textbox in jsp
How to show data from database in textbox in jsp   How to show data from database in textbox in jsp   Here is an example that retrieve the particular record from the database and display it in textbox using JSP. <
By dropdownlist retrive data from database and show in textbox in jsp.
By dropdownlist retrive data from database and show in textbox in jsp.  Hello Sir, I am doing project in jsp.I have to retrive data from database, when I select value from dropdownlist, and that data I want to show in textbox
retrieving data from database to the textbox depending upon the id in jsp
retrieving data from database to the textbox depending upon the id in jsp  Hi, our project involves fetching of data from database into textbox depending upon another textbox value which is productid.First the id entered by us
Dynamically Update textbox from database
Dynamically Update textbox from database  I have a database as shown below.(database created using SQL Server 2005) name : george,simon address... to that typed value from database has to be displayed in another text box
Getting data from servlet into javascript
Getting data from servlet into javascript  How do i get json data from my servlet on to a variable in javascript n bind the data to display onto sigma grid.Has anyone Idea how to do
retrive data from database?
retrive data from database?  hellow i have a database sheet name..... now i want retrive sn,roll no and name and textbox like... from db1 and enter value in text box according there name,rollno and save
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database.  Hii Sir, Lots of thnx to ur reply .I went through both... of selecting value from autocomplete textbox using jquery in jsp from mysql database
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database. ... but was unable to find out exact way to fullfill the solution of selecting value from autocomplete textbox using jquery in jsp from mysql database. Kindly send me
getting values from database - JSP-Servlet
getting values from database  I tried the following code abc.html aaa.jsp I am not getting exceptions now. But I am not getting output also. Plz help.   Hi Friend, Run your
How to Retrieve data from database in jsp
How to Retrieve data from database in jsp In this section we will discuss about how to fetch data from database table. We will give a simple example which will demonstrate you about fetching data from database table. Example We
populating textbox value from the database using onchange function,
populating textbox value from the database using onchange function,  .... but the next textbox value is populated from database. plz help me guys... dynamically from the database(mysql). after selecting the value from the dropd
selecting data from database
selecting data from database  how to select data from database using Dao in struts   Hi, You have to load the data from database using hibernate and send the data in a Java file object to jsp page.ADS_TO_REPLACE_1
retrive data from database
retrive data from database   hi.. i made a application form. it's have attribute s.no,name,roll no and i enter a few records. now i want to view all record not in database access sheet i want to view it at any another
Autopopulate values into textbox from database on pressing tab or on clicking
Autopopulate values into textbox from database on pressing tab... to be searched into database. if it already exists then it will autopopulate its... on the producttype(which is first textbox related to product_id).This is need
Getting mysql table in textbox
Getting mysql table in textbox  how to get mysql table values into textbox in java using ajax and servlets
To retrive data from database - Struts
To retrive data from database  How to get values ,when i select a select box in jsp and has to get values in textbox automatically from database? eg... come to jsp page automatically from database
Getting and sending data to and from mobile and the system
Getting and sending data to and from mobile and the system  Hi, For getting and sending data to mobile from system.make system is a server.From mobile send a request to the server and get response.Then process the response
Getting Json data from servlet to javascript variable
Getting Json data from servlet to javascript variable  How do i get json data from my servlet on to a variable in javascript n bind the data to display onto sigma grid.Has anyone Idea how to do
fetch data from database in javascript
fetch data from database in javascript   How to fetch data from database in JavaScript when it is a leap year
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
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
How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB:student; @table:stu_info; Combobox values:(class1,class2,class3); textbox1
the last data entered into database is getting stored again after refreshing
if the data is deleted from the database the last data entered is getting posted plz help...the last data entered into database is getting stored again after refreshing  hey all i made a shout box using php and mysql but the last data
Which splunk component is used for getting data from data source
Which splunk component is used for getting data from data source  Hi... for getting data from a data source. Which splunk component is used for getting data from data source? Thanks   Hi, You can configure the datasource
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
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
delete data from database - SQL
delete data from database  HOw to delete specific data from table> I want to delete one record from database. Thnx  Hi friend, -------------------------------------------- Visit for more information
Problem in accessing data from Database
Problem in accessing data from Database  hi..... i'm making a project on servlet and jsp with ms access 2007 at the backend. One field in my database is text and all others are of currency data type. If i enter 0 or null value
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 and show in browser and if we click hyperlink its shows his sub categories....how
showing the information of database in textbox
showing the information of database in textbox  how to make a information of a database make appear to the user in the textbox
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>
how to display data from database in jsp
how to display data from database in jsp  how to display data from database in jsp
retreive integer data from database
retreive integer data from database  i made a table named result...=lalit&database=mydb"); String url="select marks from student where rollno... and two buttons "ok" and "cancel" i want to take input from textfield
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
Why you are not getting value from your data science?
Why you are not getting value from your data science?  Hi, I am... for the tutorials to learn: Why you are not getting value from your data science? Try...;Why you are not getting value from your data science?". Also tell me which
GWT -- retrive the data from Database
GWT -- retrive the data from Database  the user can create an event. In the create page, we have three buttons. Save as draft, preview and save... button, you have to create a dynamic jsp which should read the contents from
getting int values from form and insert it in data base in jsp
getting int values from form and insert it in data base in jsp  how can i get form input such as id convert it to int insert it into database   Hi, You can get the parameter from the request object: String s
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file
Solution field from database and display in the textbox of the jsp.   1...how to retreive values from MS Access Database based on the values entered... * from item where itemid='"+id+"'"); while(rs.next()) { data = ":" + rs.getString
I want to display the quantity of the selected item of a drop down list in a textbox. The data is stored in database.
in a textbox. The data is stored in database.  The code for retrieving data from database into Drop Down List. <% DataSource data = new... = con.prepareStatement("select * from library.booklist"); ResultSet result
Retrieval data from database against timer
Retrieval data from database against timer  Please send me a sample timer code which retrieve data from the database against timer in JSP
data insertion from xml file to database table
data insertion from xml file to database table  Hi all, I have data in the XML file. I need to insert it into table in the database using servlet. so please reply me . ThankYou
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
error for getting the data from an api using br.readLine - Development process
error for getting the data from an api using br.readLine  hi the application is hanging while reading the data using readLine() function . actually the data is coming from remote using particular api call see the following code
retrieve the data to text fields from database on clicking the value of combo box
getting data into textarea from database table by clicking on the button...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
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... * from data"); String name = ""; String address = ""; while (rs.next

Ads