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 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);
}
}
Ads
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
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
Advertisements
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
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
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
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
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 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
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 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
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
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
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
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
how to display values from database into table using jsp
how to display
values from database into table using jsp I want to display
values from database into table based on condition in query, how... the
values from database based on the bookname or authorname entered must be display