ashwini koli
create one table into SQL 8i
1 Answer(s)      4 years and 3 months ago
Posted in : Java Beginners

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..

Ads

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
jdk6 and oracle 8i
jdk6 and oracle 8i  I connecte oracle 8i and jdk6 I notice that why can not connect
PHP SQL Table
PHP SQL Table       PHP SQL Table is used to create table in PHP. To create a table in PHP... on 'PHP SQL Table'. To grasp the example we create a sql_table.php begins with <
SQL Create View
SQL Create View       A View is a imaginary and virtual table in SQL. In SQL, a view is defined  as a virtual table outcome as a result of an SQL statement. A view
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
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
SQL Create View
table in SQL is given as: CREATE VIEW Stu_View( Stu_id... SQL Create View       A View is a imaginary and virtual table in SQL. In SQL, a view
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
create a one web page
create a one web page  create a one web page with stored values in a database
connexion oracle 8i et jdk6
connexion oracle 8i et jdk6   j'ai connexion oracle 8i et jdk6 je remarque que connexion impossible comment
syntax for create a table
syntax for create a table  syntax for create a table
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
SQL Backup Table
SQL Backup Table      .... Understand with Example The Tutorial illustrate a example from SQL Backup Table. In this Example, we create a table 'Stu_Table'. The create table statement
Create Before Insert Trigger in SQL
Create Before Insert Trigger in SQL       The Create Before Insert Trigger in SQL fires... The given Tutorial describe you a code on 'Create Before Insert Trigger in SQL
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 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
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
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
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
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_Table SQL statement to create
MySQL Create Table
MySQL Create Table       Here, you will read the brief description about the MySQL create table. The CREATE TABLE statement is used for creating a table in database. 
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
SQL AND Operators
. In this Tutorial, Table Stu_Table is created using create table statement. The insert...; Create Table Stu_Table create table Stu_Table(Stu_Id integer(2), Stu_Name... a table, if  both the condition are to be true. In case, any one
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
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
Java Table Create
Java Table Create  hi........ thanks 4 ur reply......... but i... its okkkkkk but in row i want parameters which are one below the other and then avalues in front of them. Eg: suppose the following is the table
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 Database in SQL,SQL Tutorial
; Create a Table: the following query creates a table CREATE... of the create to make a table email and populate it with the field named LName, FName and email_add. CREATE TABLE email ( LName varchar(20

Ads

Advertisement