create one table into SQL 8i

create one table into SQL 8i

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:25 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:
How to read textfile and create SQL server table ?
How to read textfile and create SQL server table ?  hi sir, your site... trying to read textfile and create table in sql server but it gives error.../questions/16415498/creating-a-table-in-sql-database-by-reading-textfile-in-java
Create table and insert data by sql query
Create table and insert data by sql query... to connect java application and execute sql query like create table in mysql database, insert some values and retrieve values from the table. Before running
Advertisements
create webpage with table sql database using netbeans 6.8 with struts complete tutorial.(include username and password)
create webpage with table sql database using netbeans 6.8 with struts complete... as software trainee in reputed concern.our company gave one project to me.create... us,employee login,user profile upload login, everything stored on sql database.i
PHP SQL Table
PHP SQL Table       PHP SQL Table is used to create table in PHP. To create a table in PHP... covers an example on 'PHP SQL Table'. To grasp the example we create a sql_table.php
SQL Create View
an example from SQL Create View. In this Tutorial, we create a table 'Stu_Table... want to show in view table. The Syntax used to create view table in SQL... SQL Create View      
How To Create a Table.
_config.php"; $sql = "CREATE TABLE user_info(" . " id INTEGER NOT NULL" . ", name...How To Create a Table.  How To Create a Table?   Hi friends, If you want to create a table, you can run the CREATE TABLE statement
create webpage with table sql database using netbeans 6.8 with struts complete tutorial.(include username and password) 0 Answer(s)
create webpage with table sql database using netbeans 6.8 with struts complete tutorial.(include username and password) 0 Answer(s)  create webpage with table sql database using netbeans 6.8 with struts complete tutorial.(include
create a one web page
create a one web page  create a one web page with stored values in a database
Create Before Update Trigger in SQL
Create Before Update Trigger in SQL       Create Before Update Trigger in SQL is used in SQL, if a trigger monitoring for changes to a column of the table
SQL Alter Table Name
SQL Alter Table Name       SQL Alter Table Name is used to change or modify  name of the existing table. To understand how to change the name of created table in SQL
create .tar.gz in one command
create .tar.gz in one command  Hi, I have a big file on Linux server and I want to crate the tar.gz file so that size can be reduced and taken for backup. I want the command to that i can create .tar.gz in one command. Give me
revinfo table sql
revinfo table sql  Hi, I want to create revinfo table manually in my MySQL Database. What is the create sql of revinfo table? Thanks   Hi, Here is the sql for creating the revinfo table: CREATE TABLE `revinfo
syntax for create a table
syntax for create a table  syntax for create a table
SQL Create View
an example from SQL Create View. In this Tutorial, we create a table 'Stu_Table... want to show in view table. The Syntax used to create view table in SQL... SQL Create View      
how to insert one table to anothere table
how to insert one table to anothere table  i have insert the record one table then i retrve the value of that table i insert one value at a time
Create Before Insert Trigger in SQL
Trigger in SQL'. To grasp this example, we create a table 'Stu_Table... Create Before Insert Trigger in SQL       The Create Before Insert Trigger in SQL fires
SQL Alter Table
SQL Alter Table  What is alter table statement in sql? Can u please show me an example of SQL Alter Table?? Thanks!   ALTER TABLE... also be used to modifiy, add or deleate a column in the existing table. SQL
Java Table Create
Java Table Create  hi........ thanks 4 ur reply......... but i... month in columns its okkkkkk but in row i want parameters which are one below... the following is the table Jan Feb Mar........... pH 2 3 4
how to create a table
how to create a table  create table tablename (name varchar(10),name.... Use the following query: create table tablename (name varchar(10),address varchar(10)); For more information, visit the following link: Java Create
Create a Table - Java Beginners
Create a Table in Java  How can i create table in Java?  Java Example Code - Creating table in JAVA... CreateTable(); } public CreateTable(){ JFrame frame = new JFrame("Create table
Create a Table in Mysql database through SQL Query in JSP
Create a Table in Mysql database through SQL Query in JSP...; This is detailed java code to connect a jsp page to mysql database and create a table of given... named 'usermaster' in mysql and create table "user_master". Create
update one table from another table
update one table from another table  hello, i need to update one table fields by using another table fields. I have to tables Products... enter the Quantity field in table 'Products_Purchased'In table 'Products' one item
MySQL Create Table
work in any sql database. Query:  CREATE TABLE table_example... MySQL Create Table       Here, you will read the brief description about the MySQL create table
SQL Backup Table
SQL Backup Table. In this Example, we create a table 'Stu_Table'. The create table statement create a table 'Stu_Table'.  Create Table Stu... SQL Backup Table      
how to take a backup of a table in sql
how to take a backup of a table in sql  how to take a backup of a table in sql?   SQL BackUp Table example
SQL Alter Table Name
SQL Alter Table Name       SQL Alter Table Name is used to change or modify  name of the existing table. To understand how to change the name of created table in SQL
SQL AND Operators
AND Operator. In this Tutorial, Table Stu_Table is created using create table... Stu_TableCreate Table Stu_TableADS_TO_REPLACE_2 create table Stu_Table... SQL AND Operators      
SQL Alter Table Primary Key
SQL Alter Table Primary Key       Alter a Table Primary Key in SQL modifies the existing table and adds a primary key. Create Table Stu_TableADS_TO_REPLACE_1 SQL
print the multiplication table up to one
print the multiplication table up to one  My problem is that I have... be the highest one. An example: if the user tells the program that the highest...; System.out.println("Enter an integer to print it's multiplication table
alter table create index mysql
alter table create index mysql  Hi, What is the query for altering table and adding index on a table field? Thanks
mysql table construction - SQL
mysql table construction  In MySql there is no pivot function. using a function or Stored Procedure, I want to loop through a column of data and create a another table that uses the row value as Column labels from the row
jdk6 and oracle 8i
jdk6 and oracle 8i  I connecte oracle 8i and jdk6 I notice that why can not connect
JDBC: Create Table Example
= con.createStatement(); String sql = "CREATE TABLE student(roll_no int,name varchar(30...JDBC: Create Table Example In this section, we are going to create table using JDBC and using database MySql. Create Table : Database table is collection
alter table create index mysql
alter table create index mysql  Hi, What is the query for altering table and adding index on a table field? Thanks   Hi, Query is: ALTER TABLE account ADD INDEX (accounttype); Thanks
Create Database in SQL,SQL Tutorial
in the names of the database.  Create a Table: the following query creates a table CREATE TABLE table_name ( column_name1 data_type... example we show the use of the create to make a table email and populate
What is the syntax for a CREATE TABLE statement?
What is the syntax for a CREATE TABLE statement?  What is the syntax for a CREATE TABLE statement
Bridge table in SQL
); } %> For the above code, we have created two database tables: CREATE TABLE..., PRIMARY KEY (`prof_id`)); CREATE TABLE `courses...Bridge table in SQL  I have 2 tables: professors(professorid INT PK
Create After Update Trigger in SQL
Create After Update Trigger in SQL   ... The Tutorial illustrate an example from 'Create After Update Trigger in SQL'. In order to understand this example, we create a table Stu_Table and Stu
updating a table in a database - SQL
updating a table in a database  give me complete source code in java to execute the sqlquery such that (update table_name set phone no=? where cous_id=?). or in simple way give me source code to update my table in MsAccess
Mysqldump one table - Taking dump of only one table
Use of mysqldump for taking backup of one table In this section you will see the example of mysqldump function which takes the backup of only one table... to take the backup of only one table from the database
Copy One Database Table to Another
Copy One Database Table to Another       In this section, you will learn to copy one database table to another database table. That means we copy one table to a different table
Create Table in SWT
Create Table in SWT       In this section, you will study how to create a table. SWT provides... to create a table. In the given example, we have create an ArrayList of Tennis players
SQL Alter Table
an example from 'SQL Alter Table'. To understand and grasp the example we create... SQL Alter Table       SQL Alter Table is used to modify the existing table definition
Create Dynamic Table using Hubernate
Create Dynamic Table using Hubernate  Thank's for reading my Post. I...: How to create seperate table for all users they sign up for my web app. i need to create 2 table's 1.User Details - Store user mail address,username
Create Delete Trigger in SQL
Trigger in SQL'. To understand this example, we create a table 'Stu_Table... Create Delete Trigger in SQL       Create Delete Trigger in SQL fire this trigger before
SQL Alter Table Syntax
SQL Alter Table Syntax       SQL Alter Table Syntax modifies the existing table definition... an example from SQL Alter Table Syntax. The list of Syntax performs the following
PHP How to Create Table
opening the database we can create table by one of the  following way...PHP Create Table: In every database we need to create table, tables... by a row. To create a table we need to create a database first and then open
Php Sql Table
Php Sql Table  This example illustrates how to create table in php. In this example we create a table "emp_table" with three fields, "...: emp_table  ADS_TO_REPLACE_2 Source Code of sql_table.php 
retrieve the records from one table to another table by using cursors
retrieve the records from one table to another table by using cursors  ... from one table to another table by using cursors.The following is my procedure and tables.After execution it insert one extra record to another table. empproc
Deleting a Row from SQL Table Using EJB
Deleting a Row from SQL Table Using EJB   ... to delete a row from the SQL Table. Find out the steps given below that describes how to delete a particular row from the database table using EJB. The steps

Ads