Results 1 to 3 of 3
  1. #1
    danpotter is offline Member
    Join Date
    May 2011
    Posts
    43
    Rep Power
    0

    Default Database probelm:No Data found

    well,im not soooo familiar with JDBC concepts,especially dealing with MS Access 2007

    well,im working on Library management in Frames and i have to add students for that i took add button and i have student id and student name to add in database and i have dont all required [connecting ODBC etc..] and i wrote the code,but when i click add,it is showing me a error box sayong "NO DATA FOUND" please help me ASAP...this is my code:-

    Java Code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.io.*;
    import java.awt.event.*;
    import java.sql.*;
    class students extends Frame implements ActionListener,ItemListener{
    	
    	Button ad,bck;
    	Label stn,stid,hd,conf;
    	TextField sin,sii;
    	Choice up;
    	 ResultSet rs;
          
    students(){
    
    		up=new Choice();
    		Font f=new Font("Arial",Font.BOLD,15);
    		Font n=new Font("Arial",Font.PLAIN,15);
    		Font g=new Font("Arial",Font.BOLD+Font.ITALIC,30);
    		
    		hd=new Label("STUDENTs SESSION",Label.CENTER);
    		stid=new Label("Student ID:",Label.LEFT);
    		stn=new Label("Student Name:",Label.LEFT);
    		conf=new Label();
    
    		sii=new TextField(20);
    		sin=new TextField(20);
    		
    		ad=new Button("Add");
    		bck=new Button("Back");
    
    		
    
    		hd.setFont(g);
    		bck.setFont(f);
    		ad.setFont(n);
    		stn.setFont(f);
    		conf.setFont(f);
    		stid.setFont(f);
    		sii.setFont(n);
               sin.setFont(n);
    
    		hd.setBounds(80,50,300,100);
              	stid.setBounds(80,200,100,40);
    		stn.setBounds(60,245,120,40);
    		sii.setBounds(180,205,150,26);
    		sin.setBounds(180,250,150,26);
    		up.setBounds(180,300,150,26);
    		conf.setBounds(180,350,200,26);		
    		bck.setBounds(100,410,60,40);
    		ad.setBounds(330,410,60,40);
    
    		setLayout(null);
    	
    
    		add(up);
    		add(ad);
    		add(bck);
    		add(stn);
    		add(stid);
    		add(hd);
    		add(sin);
    		add(sii);
    		add(conf);
    		ad.addActionListener(this);
    		up.addItemListener(this);
    		bck.addActionListener(this);
    
    
    
    }
    
               
    public void itemStateChanged(ItemEvent e){
    		repaint();
    	}
    
    		public void actionPerformed(ActionEvent ae){
    	
    		
    if(ae.getSource()==ad){
    
    addOperation();
    String snme=sin.getText();
    up.add(snme);
    
    }
    if(ae.getSource()==bck){
    	GetFrame2 f2=new GetFrame2();
    		f2.setVisible(true);
    		f2.setSize(500,500);
    		this.dispose();
    
    
    }
    
    }
    public void addOperation()
    { 
    try
            {	        
    	
        //Load Jdbc Odbc Driver
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                Connection con = DriverManager.getConnection("jdbc:odbc:mydb");
    	 
    	            String sql = "INSERT INTO mydb (ID,Name) " +
                        "Values ('"+sii.getText()+"'," +
    	                            "'"+sin.getText()+"')";
    		Integer.parseInt(sii.getText());
    	 
                 Statement st = con.createStatement();
    	            st.execute(sql);
    }
    catch(Exception e)
    	        {
    e.printStackTrace();
    	           
          }
    }
    public static void main(String args[]){
    students sts=new students();
    
    
    	}
    	}
    Last edited by danpotter; 04-06-2012 at 07:17 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: Database probelm:No Data found

    Use code tags, not quote tags, for posting code.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    danpotter is offline Member
    Join Date
    May 2011
    Posts
    43
    Rep Power
    0

    Default Re: Database probelm:No Data found

    ok..now done..please help me...

Similar Threads

  1. Replies: 16
    Last Post: 04-02-2012, 10:52 AM
  2. JDBC_Servlet: Data not found
    By mithcool in forum Java Servlet
    Replies: 3
    Last Post: 06-24-2011, 06:32 PM
  3. SQLException caught:No data found
    By jttslg in forum Java Servlet
    Replies: 20
    Last Post: 05-20-2011, 05:21 PM
  4. SQLException caught:No data found
    By jttslg in forum NetBeans
    Replies: 0
    Last Post: 04-20-2011, 04:07 PM
  5. data.txt not found
    By RedSix in forum Eclipse
    Replies: 4
    Last Post: 04-23-2009, 02:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •