display data on text field

display data on text field

I have created one table into SQL 8i. table contains 4 number data type columns. I want to retrieve data from that column and display that data on text field.

    String q="select * from Result1 where UserName='"+t1f.getText()+"'";
       rs=st.executeQuery(q);
       if(rs.next())
         {
                    int x=rs.getInt(2); 
                    int y=rs.getInt(3);
                    int p=rs.getInt(4); 
                    int qq=rs.getInt(5);
                    int r=rs.getInt(6); 
                    String s2=new Integer(x).toString();
                    String s3=new Integer(y).toString();
                    String s4=new Integer(p).toString();
                    String s5=new Integer(qq).toString();
                    String s6=new Integer(r).toString();
a22.setText(s2);
a33.setText(s3);
a44.setText(s4);
a55.setText(s5);
a66.setText(s6);

} This is my code for retrieving data from table setting to textfield. This throws exception as

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state

please give me solution for this as early as possible..

View Answers

April 17, 2012 at 11:26 AM

Follow these steps:

1)Go to the start>>Control Panel>>Administrative Tools>> data sources.

2)Click Add button and select the driver Microsoft Access Driver(*.mdb).

3)After selecting the driver, click finish button.

4)Then give Data Source Name(DSN) and click ok button.

5)Your DSN will get created.

6)Restart your compiler and compile the given code.

Here our dsn is college.

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

class Form extends JFrame
{
JButton ADD;
JPanel panel;
JLabel label1,label2;
final JTextField text1,text2;
Form(){
label1 = new JLabel();
label1.setText("Email Id:");
text1 = new JTextField(20);

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

ADD=new JButton("Add");

panel=new JPanel(new GridLayout(3,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(ADD);
add(panel);
setTitle("FORM");
ADD.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String value1=text1.getText();
String value2=text2.getText();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         Connection conn=DriverManager.getConnection("jdbc:odbc:college");
        Statement st=conn.createStatement();
             st.executeUpdate("insert into data(email,contactNo) values('"+value1+"','"+value2+"')");
            JOptionPane.showMessageDialog(null,"Inserted Successfully!");
        }

catch(Exception e){}
    }
});
}
}
class FormDemo{
public static void main(String arg[]){
try
{
Form frame=new Form();
frame.pack();
frame.setVisible(true);
}
catch(Exception e)
{}
}
}









Related Tutorials/Questions & Answers:
regarding out put display in html text field
regarding out put display in html text field  how to dispaly the output coming from servlet in a particular text field of html
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
Advertisements
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... contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C...-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>
text field
text field  How to retrieve data from text field   Hi Friend, Try the following code:ADS_TO_REPLACE_1 import java.awt.*; import javax.swing.*; import java.awt.event.*; class RetrieveDataFromTextFields{ public
how to display data from mysql table in text box using jsp??
how to display data from mysql table in text box using jsp??  <p>hi, i have a written a code to display data from a mysql table into txtboxes...="row">Reference GPC</th> 113: <td><input type="text" name
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 field  hi I have php page where i have two text fields . The data are stored in database wherein when the in the first text field the data is already
converting field to text sql
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... the field to TEXT works (adsbygoogle = window.adsbygoogle || []).push
jsf text field not blank
jsf text field not blank  text field not clear in jsf onclick of reset button in my application initial value not deleted   Hello Friend, Post your code. (adsbygoogle = window.adsbygoogle || []).push
validate text field iPhone
validate text field iPhone  i got two different UITextfield in my iPhone application for user login. Just wondering how to validate
Show text field & check input using jQuery
will discuss about how to display 'text field' by a button click & check... how to display 'text field' by a button click & check input using...; it will display a text field and a question , if the answer is yes then ,we have
CALULATION IN TEXT FIELD
CALULATION IN TEXT FIELD  Suppose 3 text Field first amount ,second amount and third sum of these amount,this amount will appear when tab in next filed(i don't want use any type button) in java swing HOW? PLEASE HELP
Display data
Display data  after successful login how i can fetch my account information from sql database
swing text field problem
swing text field problem  I want to navigate the content of text field from one class to another and viceversa through button but when I am getting the text from first class I am getting null value.please help me..here
swing text field problem
swing text field problem  I want to navigate the content of text field from one class to another and viceversa through button but when I am getting the text from first class I am getting null value.please help me..here
iPhone Text Field Validation
data from user. In this tutorial we are going to limiting the text field input... iPhone Text Field Validation In any user based application "...;. We have also take a Text field on the view to take the input from user
Text field save as word file
Text field save as word file  Dear experts At run how to save set of text field contains text into single Word file. To save in our desktop computer. Solve my problem
Digit Only text field
Digit Only text field  How should we accept digits only in a textbox? (using JSTL only, without Javascript
rich text field - JSP-Servlet
rich text field  Hi, this is jawahar. my question i need rich text field in my program . plz send me the code
clearing text field in spring form
clearing text field in spring form  hi, I have spring form in that i have security question dropdown field and security answer text field ,when i submitted form with errors the answers text field value should be clear, for this i
iPhone Text Field Border 
Text Field Boarder  In this tutorial will learn about the text field Boarder, we can set the boarder of text field by selecting the text field... for the text field. This project is View Based Application and here will take four text
Use of Text Field
Use of Text Field, Text box, Text Area, Checkbox,Dropdownlist and Radio... types of information. A form contains form elements checkbox, text field, radio button etc.) through which users can input their data. A form is created using
Display Data - Java Beginners
Display Data  I need sample how to display data from my table Mysql with swt/jface Thank you
Display data in a chart
Display data in a chart  I have a data in mysql table,i retrieved that data in drop down list and wen i click on particular name on the drop down, the data must display in chat.how to do this plz help me......thank u
Display data in a chart
Display data in a chart  I have a data in mysql table,i retrieved that data in drop down list and wen i click on particular name on the drop down, the data must display in chat.how to do this plz help me......thank u
Display data in a chart
Display data in a chart  I have a data in mysql table,i retrieved that data in drop down list and wen i click on particular name on the drop down, the data must display in chat.how to do this plz help me......thank u
display data in php
display data in php  i want data validation in javascript for my form data and it will display in php. my fields are name,emailid,address,country combobox,state combo box, i want only php page,can u wxplain process how it come
To display suggestions in a text box - Ajax
To display suggestions in a text box  Hi All, I have a requirement, to get the suggestions i mean when i enter the alphabet in a text box(For ex:'A'), the names that starts from 'A' have to display in the text box
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
I am creating one jsp page in which I read in a text file, then display that data in tabular format. Now I need to calculate a total.
I am creating one jsp page in which I read in a text file, then display that data in tabular format. Now I need to calculate a total.  I am reading the file using BufferedReader, then writing the output like this: String
text field validation - Java Beginners
text field validation  hi How to validate allow only decimal number in text box in jsp?  Hi Friend, Try the following code: function isDecimal(str){ if(isNaN(str) || str.indexOf(".")<0){ alert
Automatically display in text box - JSP-Servlet
Automatically display in text box  Dear Deepak Sir, When i enter some text in text box.That corresponding value in database,the value display in another text box using ajax. Thanks & Regards, VijayaBabu.M
Display the data to MS word
Display the data to MS word  i want help with displaying data on to ms word.When i click the button my web page my servlet should get the data from the database(say im searching using an id) and should display it on the ms word
Text Field in HTML
Text Field in HTML       The Text Field in HTML are one line areas, which enable the user... an example from Text Field in HTML.In this Tutorial, the code create a text
ModuleNotFoundError: No module named 'adafruit-circuitpython-display-text'
ModuleNotFoundError: No module named 'adafruit-circuitpython-display-text' ...: ModuleNotFoundError: No module named 'adafruit-circuitpython-display-text' How to remove... to install padas library. You can install adafruit-circuitpython-display-text
ModuleNotFoundError: No module named 'django-storage-text-field'
ModuleNotFoundError: No module named 'django-storage-text-field'  Hi...: No module named 'django-storage-text-field' How to remove the ModuleNotFoundError: No module named 'django-storage-text-field' error? Thanks  
ModuleNotFoundError: No module named 'django-storage-text-field'
ModuleNotFoundError: No module named 'django-storage-text-field'  Hi...: No module named 'django-storage-text-field' How to remove the ModuleNotFoundError: No module named 'django-storage-text-field' error? Thanks  
ModuleNotFoundError: No module named 'django-short-text-field'
ModuleNotFoundError: No module named 'django-short-text-field'  Hi...: No module named 'django-short-text-field' How to remove the ModuleNotFoundError: No module named 'django-short-text-field' error? Thanks   
focus text field - Swing AWT
focus text field  i want to move cursor to next text field by pressing enter.i have created the following coding. but it does nt working.pls help...(); JOptionPane.showMessageDialog(savebutton, "YOUR DATA HAS BEEN SAVED SUCCESSFULLY
focus text field - Swing AWT
focus text field  i want to move cursor to next text field...(); JOptionPane.showMessageDialog(savebutton, "YOUR DATA HAS BEEN SAVED SUCCESSFULLY...(savebutton, "your data has been saved successfully!"); con.close(); } catch
Can i insert image into struts text field
Can i insert image into struts text field  please tell me can i insert image into text field
Simple Text display
Simple Text display         In this tutorial we will come to know that how to display any text in a text input box using a button click. It is very simple
Text Field Midlet Example
Text Field MIDlet Example       This example illustrates how to insert text field in your form... will be run then first of all the startApp() method will called and it display
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..  
how to display webservice response in a text box
how to display webservice response in a text box  Hallo, i have created a webservice and when i sended request to my webservice its sending proper response . the point is how to dispaly the response values in a text box usinj
How to Define Text Field Validation iPhone
How to Define Text Field Validation iPhone  Hi, Can anybody explain me how to define textfield validation iPhone program. please phone online help reference or example. Thanks
how to sort the text file and display it in jtable
how to sort the text file and display it in jtable   my text file is: contig00001 length=586 numreads=4... ctgaggactcctcg i want to display the lines started with ">" symbol to be displayed
display:table export only data
display:table export only data  I am using display:table tag with attribute export="true". Using that I can export table data in excel. Here one of the column is in hyper link. But i need to export only data not html tag . Can
how to display data in excel sheet?
how to display data in excel sheet?  According to the user Id,some links will be generated from the database,and if we click a link,data would... the button and to display the data in excel sheet
set text field appearance to default - Java Beginners
set text field appearance to default  hi, i am doing a program, in which i have a form for the user to input some data. i wanted to change the border color of a text box if the input was incorrect, but when i fail to set

Ads