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



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


megha singhal
fetch values from database into text field
1 Answer(s)      2 years and 6 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..


Advertisement
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 Tutorials/Questions & Answers:
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
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..  
Advertisements
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
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
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
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
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
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
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
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
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
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
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
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
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
Fetching database field from servlet to jsp page ?
Fetching database field from servlet to jsp page ?  Hello Java... field. I wanted to pass some of the database field from servlet to jsp... (i am opening my database in servlet init() method ) how to pass rs.getString(8
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
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
Retrive data from databse to a text field - Java Server Faces Questions
Retrive data from databse to a text field  Hi, Can you give me a source code to rertrve data from Mysql databse to a text field using JSF.....by selecting option from a dropdown option
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
how can i store text box values as it is in database table
how can i store text box values as it is in database table  CUSTOMER DESCRIPTION
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'/> <
how to make drop down list in JSF & fetch data Item from database
how to make drop down list in JSF & fetch data Item from database  how to make drop down list in JSF & fetch data Item from database
Getting text values from a NodeList
Getting text values from a NodeList       This Example shows you how to Get Text values from... are:- File f = new File("Document3.xml"):-Creates a File From which Text
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... JSP code separately.If it will not display database values then try your code
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
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... from that created views and display on form . I am trying to do so but its
 

 

 

DMCA.com