When i run this code it says that resultset object type_forward_only not indentified

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • techno58
    New Member
    • Dec 2009
    • 3

    #1

    When i run this code it says that resultset object type_forward_only not indentified

    Code:
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    class frame1 extends Frame implements ActionListener
    {
    	Button bnext;
    		TextField txtsid;
    		TextField txtsname;
    		TextField txtstream;
    		TextField txtgrade;
    		TextField txtage;
    		frame1()
    	{
    		setLayout(new FlowLayout());
    		bnext =new Button("Next");
    		txtsid=new TextField(20);;
    		txtsname=new TextField(20);
    		txtstream=new TextField(20);
    		txtgrade=new TextField(20);
    		txtage=new TextField(20);
    		bnext.setBounds(80,80,50,20);
    		txtsid.setBounds(200,200,20,20);
    		txtsname.setBounds(200,200,20,20);
    		txtstream.setBounds(200,200,20,20);
    		txtgrade.setBounds(200,200,20,20);
    		txtage.setBounds(200,200,20,20);
    		add(bnext);
    		add(txtsid);
    		add(txtsname);
    		add(txtstream);
    		add(txtgrade);
    		add(txtage);
    		setBackground(Color.gray);
    		addWindowListener(new windowhandler());	
    		bnext.addActionListener(this);
    	}
    	public void actionPerformed(ActionEvent e)
    	{
    		try
    			{
    			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    			Connection con=DriverManager.getConnection("jdbc:odbc:lath","scott","ritika");
    			Statement st=con.createStatement();
    			ResultSet.TYPE_FORWARD_ONLY rs=st.executeQuery("select * from profile");
    			while(rs.next())
    			{
    				rs.relative(1);
    			String s=rs.getString("sname");
    			String sid=rs.getString("sid");
    			String stream=rs.getString("stream");
    			int age=rs.getInt("age");
    			int grade=rs.getInt("grade");
    			txtsid.setText(sid);
    			txtsname.setText(s);
    			txtstream.setText(stream);
    			}
    				//txtgrade.setText(grade);
    				//txtage.setText(age);
    			}
    			catch(Exception ex)
    			{
    				txtsname.setText(ex.getMessage());
    			}
    	}
    	
    	public static void main(String args[])
    	{
    		frame1 f1=new frame1();
    		f1.setVisible(true);
    		f1.setSize(400,300);
    		f1.addWindowListener(new windowhandler());
    		}
    }
    		
    	class windowhandler extends WindowAdapter	
    		{
    		public void windowClosing(WindowEvent e)
    		{
    		System.exit(0);
    		}
    		}
    Also how can i display the data one by one in the textboxes
    it shows only the last record
    Last edited by RedSon; Jan 5 '10, 07:03 PM. Reason: Added [CODE] Tags
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    #2
    could you post the whole generated Stacktrace? ( about the error )

    Comment

    • RedSon
      Recognized Expert Expert
      • Jan 2007
      • 4980

      #3
      Please enclose your posted code in [code] tags (See How to Ask a Question).

      This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

      Please use [code] tags in future.

      MODERATOR

      Comment

      Working...