Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JDBC and Relational Databases
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Resilient Oracle PL/SQL: Building Resilient Database Solutions for Continuous Operation
this week in the
JDBC and Relational Databases
forum!
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Liutauras Vilda
Ron McLeod
Jeanne Boyarsky
Paul Clapham
Sheriffs:
Junilu Lacar
Tim Cooke
Saloon Keepers:
Carey Brown
Stephan van Hulst
Tim Holloway
Peter Rooke
Himai Minh
Bartenders:
Piet Souris
Mikalai Zaikin
Forum:
JDBC and Relational Databases
handling Exceptions
arjun gaur
Ranch Hand
Posts: 39
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
After clicking on update button i'm getting the error : java.sql.SQLException :General error
import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import java.sql.*; class BlankException extends Exception{} public class Modify_appointment extends JFrame implements ActionListener { JFrame frame1; JLabel logo, heading, underline, app_id, doctor_id, patient_id; JLabel app_date, app_time, app_charges; JButton update, reset, exit; JPanel panel1; JTextField text1, text2, text3, text4; JComboBox combo_time, combo_charges; final String[] sTime = { "10:00", "10:15", "10:30", "10:45", "11:00", "11:15", "11:30", "11:45", "12:00", "12:15", "12:30", "12:45", "13:00", "13:15", "13:30", "13:45", "14:00", "14:15", "14:30", "14:45", "15:00", "15:15", "15:30", "15:45", "16:00", "16:15", "16:30", "16:45", "17:00", "17:15", "17:30", "17:45", "18:00", "18:15", "18:30", "18:45", "19:00", "19:15", "19:30", "19:45", "20:00", "20:15", "20:30", "20:45", "21:00", }; final String[] sCharges = { "300", "500", "700", "900", "1100", "1300", "1500", }; Modify_appointment() { frame1 = new JFrame("Medicare Hospital - Modify an Appointment"); panel1 = new JPanel(); frame1.getContentPane().add(panel1); panel1.setLayout(null); panel1.setBackground(new Color(181,230,29)); logo = new JLabel(); logo.setBounds(200,0,950,250); logo.setIcon(new ImageIcon("l.png")); panel1.add(logo); heading = new JLabel("Modify an Appointment"); heading.setBounds(500,270,400,60); heading.setFont(new Font("Calibri",Font.BOLD,40)); panel1.add(heading); underline = new JLabel("____________________"); underline.setBounds(500,275,440,60); underline.setFont(new Font("Calibri",Font.BOLD,40)); panel1.add(underline); app_id = new JLabel("Enter the App. ID"); app_id.setBounds(200,375,200,30); app_id.setFont(new Font("Calibri",Font.BOLD,20)); panel1.add(app_id); text1 = new JTextField(20); text1.setBounds(400,375,200,30); text1.setFont(new Font("Calibri",Font.BOLD,20)); panel1.add(text1); patient_id = new JLabel("Enter the Patient ID"); patient_id.setBounds(200,425,250,30); patient_id.setFont(new Font("Calibri",Font.BOLD,20)); panel1.add(patient_id); text2 = new JTextField(20); text2.setBounds(400,425,200,30); text2.setFont(new Font("Calibri",Font.BOLD,20)); panel1.add(text2); doctor_id = new JLabel("Enter the Doctor ID"); doctor_id.setBounds(200,475,250,30); doctor_id.setFont(new Font("Calibri",Font.BOLD,20)); panel1.add(doctor_id); text3 = new JTextField(20); text3.setBounds(400,475,200,30); text3.setFont(new Font("Calibri",Font.BOLD,20)); panel1.add(text3); app_date = new JLabel("Enter the App. date"); app_date.setBounds(675,375,250,30); app_date.setFont(new Font("Calibri",Font.BOLD,20)); panel1.add(app_date); text4 = new JTextField(20); text4.setBounds(910,375,200,30); text4.setFont(new Font("Calibri",Font.BOLD,20)); panel1.add(text4); app_time = new JLabel("Enter the App. time (hrs)"); app_time.setBounds(675,425,250,30); app_time.setFont(new Font("Calibri",Font.BOLD,20)); panel1.add(app_time); combo_time = new JComboBox(); combo_time.setBounds(910,425,200,30); combo_time.setFont(new Font("Calibri",Font.BOLD,20)); panel1.add(combo_time); for( int iCtr = 0; iCtr < sTime.length; iCtr++ ) { combo_time.addItem( sTime[iCtr] ); } app_charges = new JLabel("Enter the App. charges (Rs)"); app_charges.setBounds(675,475,250,30); app_charges.setFont(new Font("Calibri",Font.BOLD,20)); panel1.add(app_charges); combo_charges = new JComboBox(); combo_charges.setBounds(910,475,200,30); combo_charges.setFont(new Font("Calibri",Font.BOLD,20)); panel1.add(combo_charges); for( int iCtr = 0; iCtr < sCharges.length; iCtr++ ) { combo_charges.addItem( sCharges[iCtr] ); } update = new JButton("UPDATE"); update.setBounds(475,550,180,30); update.setFont(new Font("Calibri",Font.BOLD,20)); panel1.add(update); reset = new JButton("RESET"); reset.setBounds(675,550,200,30); reset.setFont(new Font("Calibri",Font.BOLD,20)); panel1.add(reset); exit = new JButton("CANCEL & GO BACK"); exit.setBounds(475,600,400,30); exit.setFont(new Font("Calibri",Font.BOLD,20)); panel1.add(exit); exit.addActionListener(this); reset.addActionListener(this); update.addActionListener(this); frame1.setExtendedState(Frame.MAXIMIZED_BOTH); frame1.setVisible(true); frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public void actionPerformed(ActionEvent e) { if(e.getSource()==reset) { text1.setText(""); text2.setText(""); text3.setText(""); text4.setText(""); } if(e.getSource()==exit) { frame1.setVisible(false); //System.exit(0); } if(e.getSource()==update) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:Hospital"); PreparedStatement st= con.prepareStatement("Update Appointment Set App_ID=?,Doctor_ID=?,Patient_ID=?,App_Date=?,App_Time=?,App_Charges=?"); String id=text1.getText(); st.setInt(1,Integer.parseInt(id)); String pid=text2.getText(); st.setInt(3,Integer.parseInt(pid)); String did=text3.getText(); st.setInt(2,Integer.parseInt(did)); String a=text4.getText(); st.setString(4,a); String s1=combo_time.getSelectedItem().toString(); st.setString(5,s1); String t2=combo_charges.getSelectedItem().toString(); st.setInt(6,Integer.parseInt(t2)); st.executeUpdate(); JOptionPane.showMessageDialog(null, "Data successfully updated"); } catch (Exception ee) { System.out.println("error " + ee); } } } public static void main(String args[]) { new Modify_appointment(); } }
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Create Bar Chart
NullpointerException while inserting
NullpointerException in Frame.
Store contents from JTable into a text file.
10,000 random numbers between 1 and the users choosen number
More...