Home Answers Viewqa JSP-Servlet fetch values from database into text field

 
 


megha singhal
fetch values from database into text field
1 Answer(s)      a year and 2 months ago
Posted in : JSP-Servlet

please provide the example for fetching values from database into text field of table

as if i am trying following

String query = "select * from LTCINFO.PERSONS";
st1 = con.createStatement();
 rs = st1.executeQuery(query);


while(rs.next())
{
out.println("<tr>");
out.println("<td><input type=\"hidden\" name=\"P_ID\" value=\"rs.getString(1)\"></td>");
out.println("<td><input type=\"text\" name=\"LASTNAME\" value=\"rs.getString(2)"></td>");
out.println("<td><input type=\"text\" name=\"FIRSTNAME\"value=\"rs.getString(3)\"></td>");
out.println("<td><input type=\"text\" name=\"ADDRESS\" value=\"rs.getString(4)\"></td>");

the i am getting "rs.getString" in the text field also..

View Answers

March 23, 2012 at 5:08 PM


import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;

class FormDemo{
    public static void main(String[]args){
    JFrame f=new JFrame();
JPanel panel;
JLabel label1,label2;
final JTextField text1,text2;
label1 = new JLabel();
label1.setText("Name:");
text1 = new JTextField(20);

label2 = new JLabel();
label2.setText("Address:");
text2 = new JTextField(20);


panel=new JPanel(new GridLayout(2,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
f.add(panel);
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root");
        Statement st=conn.createStatement();
        ResultSet rs=st.executeQuery("select * from data where id=1");
        while(rs.next()){
        text1.setText(rs.getString("name"));
        text2.setText(rs.getString("address"));
        }
  }
catch(Exception e){}
f.pack();
f.setVisible(true);
}
}









Related Pages:
fetch values from database into text field
fetch values from database into text field  please provide the example for fetching values from database into text field of table wth edit...;/td>"); the i am getting "rs.getString" in the text field also..  
fetch values from database into text field
fetch values from database into text field  please provide the example for fetching values from database into text field of table as if i am... "rs.getString" in the text field also..   import java.awt.*; import
retrive record from the text field and insert into to database
retrive record from the text field and insert into to database  the following code is inserting values in the my sql database but i want to insert the data into oracle database , i want what changes i have to make
MySql Databse query to fetch results from database
MySql Databse query to fetch results from database  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values... the field table. Actually they are separated by comma. I want to take the values
Fetch user records from a table in database
Fetch user records from a table in database  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai... the field table. Actually they are separated by comma. I want to take the values
MySql Databse query to fetch results from database and display it in HTML File
MySql Databse query to fetch results from database and display it in HTML File  Hi. I have a field in database named stages. its datatype is varchar... to retrieve these data from the field table. Actually they are separated by comma
How to fetch entries/values from database to a jsp page one by one?
How to fetch entries/values from database to a jsp page one by one?  I have a table in Microsoft SQL server Management Studio with two columns title... to display different database entries of the each column in different blocks. Now
fetch record from MYsql table query
fetch record from MYsql table query  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
PDO Fetch Execute
PDO Fetch Mode: We have studied before in the earlier tutorials that how to connect with a database and how to fetch data from the tables, in many times we... from the result and returns the column names and field values of the resulting
JSP combo and text field related questio
JSP combo and text field related questio  in JSP,i had stored data from database in a textboxes usin combo..now i want to use these values of text... and name given to that text field..but its showing somethimng null pointer exception
fetch values in dropdown
fetch values in dropdown  in my application i want fetch dropdown values in jsp page through servlet. means i have to fetch the database fields values in array variable of servlet and then i have to print those values in dropdown
Fetched Record from database show into text field of html page
Fetched Record from database show into text field of html page  hi, i have a database with field merchant_code, merchant_name, city, region, and also have html page with all above mentioned field i have submit 20 record from
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
text field
text field  How to retrieve data from text field   Hi Friend, Try the following code: import java.awt.*; import javax.swing.*; import java.awt.event.*; class RetrieveDataFromTextFields{ public static void main
get values from Excel to database
get values from Excel to database   hi i want to insert values from Excel file into database.Whatever field and contents are there in excel file that should go to database which exists. am using SQL Server management studio
how to fetch values from .properties to a html file
how to fetch values from .properties to a html file  I have a .properties file with some key value pairs in it. I need to fetch the values from this .properties file into a html file.Please let me know how to do
PDO Fetch Lazy
and the field names and their respective values. Example: <?php header('...PDO Fetch Lazy: PDO::FETCH_LAZY is the combination of PDO::FETCH_OBJ and PDO::FETCH_BOTH. It displays the query which has been made along with the object
focus text field - Swing AWT
focus text field  i want to move cursor to next text field... patientdetails() { initComponents(); } /** This method is called from...,name,age,sex,place,towncity,phoneno,mobileno,emailid) values
SQL fetch value
SQL fetch value  how to get ( 15 march 2011) and (15/03/2011) output using SQL   Use the following queries to get the data from database.../%Y') FROM patient; where patient is our table name and dob is a field of date
focus text field - Swing AWT
focus text field  i want to move cursor to next text field... patientdetails() { initComponents(); } /** This method is called from...,name,age,sex,place,towncity,phoneno,mobileno,emailid) values
fetch and insert multiple rows into mysql database using jsp servlet
fetch and insert multiple rows into mysql database using jsp servlet  hello!!! I am building a attendance sheet in which, I am getting data from one jsp form and want inserting it into my mysql database table. but i am having
Fetch Records from SQL database and convert into XML file
Fetch Records from SQL database and convert into XML file  Hi Experts... provide me the code to FULFIL my requirement.... 1) Fetch all the records from... selected rows those only needs to be update the Signature field SIGN from 'AAA
PDO Fetch Object
PDO Fetch Object: This is another way to access the data of a table... as anonymous object and this object represents the field names of the table as object properties (fields) with their respective values. This method represent 
PHP SQL Fetch
; PHP SQL Fetch is used to fetch the records from Mysql database to PHP... The Tutorial illustrate an example from PHP SQL Fetch. To understand and grasp...',12); php_sql_fetch.php: The code below is used to fetch the records from
problem in setting the values from database
the values from database. here is the code: private JTextField getJTextField1() { if(text == null) { text = new JTextField...problem in setting the values from database  hello friends, can
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file  Hi am new to java. i need to create... Solution field from database and display in the textbox of the jsp.   1
automatically move next page when data fetched from database is stored in text field
automatically move next page when data fetched from database is stored in text... are stored in database wherein when the in the first text field the data is already... from database and entered the next page should load without the user clicking
to fetch data from ms word and storing into database
to fetch data from ms word and storing into database  i want to know how to fetch datafields from ms word and storing into database??? please answer soon .its urgent
retrieve record from the field table
retrieve record from the field 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
converting field to text sql
the field to TEXT works SELECT CONVERT(TEXT,fld_name) FROM TABLE_NAME...converting field to text sql  I wanted to convert the field to TEXT in SQL.. is it possible?   SQL - Converting the field to TEXT works
insert values from excel file into database
insert values from excel file into database   hi i want to insert values from Excel file into database.Whatever field and contents are there in excel... the following link: Insert values from excel file to database
how can retrieve more than one values in text field using ajax?
how can retrieve more than one values in text field using ajax?  im... first then in mysql db retrieve seat numbers 1,2,3,4 in text boxes problem in while loop why if write this so it is unsuccessful while($row=mysql_fetch_array
fetch database value to text box based on selected value my code given below pls correct my code
fetch database value to text box based on selected value my code given below... code for me jsp file... <%@page contentType="text/html" pageEncoding...;<input type="text" value =" " property= "amount" id='pricecheck'/> <
fetch database value to text box based on selected value my code given below pls correct my code
fetch database value to text box based on selected value my code given below... code for me jsp file... <%@page contentType="text/html" pageEncoding...;<input type="text" value =" " property= "amount" id='pricecheck'/>
Select tag to fetch data from oracle database
Select tag to fetch data from oracle database  I created a select box... of a student and when regnno is selected from the drop down list by a user... oracle database.Similarly when address will be selected by the user from
I have to retrieve these data from the field table
I have to retrieve these data from the field table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values... the field table. Actually they are separated by comma. I want to take the values
how to display data from database according to entered value in search field
how to display data from database according to entered value in search...(); System.out.println("Disconnected from database"); } catch (Exception e... contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C
How to update,Delete database values from jtable cells ..
How to update,Delete database values from jtable cells ..  Hello Sir, I am working on a project in which i have to fetch the values... the database records from the table cells by entering new values there only
How to update,Delete database values from jtable cells ..
How to update,Delete database values from jtable cells ..  Hello Sir, I am working on a project in which i have to fetch the values from database... records from the table cells by entering new values there only ... Sir,plz send me
PDO Fetch Num
PDO Fetch Num: We've discussed in the previous tutorial about PDO::FETCH... index of the result unlike the PDO::FETCH_ASSOC which returns the name of the field. To make the differences clear please compare the previous result
fetch record from oracle database using jsp-servlet?
fetch record from oracle database using jsp-servlet?  how can i fetch data from oracle database by using jsp-servlet. i'm using eclipse, tomcat server and oracle database and creating jsp pages and also using servlet
Want solution to get values for xml namespace tags from database in java
Want solution to get values for xml namespace tags from database in java ...:loc=" "/> now i need to get values from sql database for values in the blank field(" "). how do i get these values.. already connected database and created
Database values in JComboBox
Database values in JComboBox In this section, you will learn how to display values in JComboBox from database. For this, we have allowed the user to enter any character as a key in the textbox .Based on this key value, the results from
Why the null values are stored in Database when I am sending proper values?
Why the null values are stored in Database when I am sending proper values...; the imagepath into the Database (MySQL) from the JSP. Along with the ImagePath I am also sending the name, Rate, Dimension to the Database through the text
How to update,Delete database values from jtable cells ..
How to update,Delete database values from jtable cells ..  hello Sir... from database into jtable of a jpanel.. Now Sir, According to my need i have to update the cell values from there only means that whatever values i ma entering
Java Password Field
of text field which allows to enter password only. Due to the security reason... values into it. Source Code Create Database Table CREATE TABLE `user... the wrong entry in either of the text field or password field and then if you
How To Fetch Data From Database Into JTextArea
How To Fetch Data From Database Into JTextArea In this section we will read about how to get the data from database table into JTextArea... have defined for fetching the data from database and set the database table value
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
Text Field in HTML
Text Field in HTML       The Text Field in HTML are one line areas, which enable the user to enter input text. Understand with Example The Tutorial illustrates an example from
JDBC Fetch
describe you a code that fetch the elements from a database. In this Tutorial we want to describe you an example from Jdbc Fetch. In this program code, the System.println print the fetch data from database. The code illustrates

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.