Results 1 to 3 of 3
Thread: Database probelm:No Data found
- 04-06-2012, 04:41 PM #1
Member
- Join Date
- May 2011
- Posts
- 43
- Rep Power
- 0
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 08:17 PM.
- 04-06-2012, 06:17 PM #2
Re: Database probelm:No Data found
Use code tags, not quote tags, for posting code.
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 04-06-2012, 08:17 PM #3
Member
- Join Date
- May 2011
- Posts
- 43
- Rep Power
- 0
Similar Threads
-
Java Database : Column not Found Problem ...
By LogicBrix in forum JDBCReplies: 16Last Post: 04-02-2012, 11:52 AM -
JDBC_Servlet: Data not found
By mithcool in forum Java ServletReplies: 3Last Post: 06-24-2011, 07:32 PM -
SQLException caught:No data found
By jttslg in forum Java ServletReplies: 20Last Post: 05-20-2011, 06:21 PM -
SQLException caught:No data found
By jttslg in forum NetBeansReplies: 0Last Post: 04-20-2011, 05:07 PM -
data.txt not found
By RedSix in forum EclipseReplies: 4Last Post: 04-23-2009, 03:43 AM
Bookmarks