Hello all...I am doing a project on Hotel Management in JDBC...Front end is being designed using Swings in Eclipse and SQL Server Management 2008 fo the back end...My problem is i am getting the above mentioned exception...I dont know where i am getting wrong...Please help me out to solve this problem as soon as possible...i need to submit the project within 31st of july... Thanks in advance...
Here is my code:
btnSubmit = new JButton("SUBMIT"); btnSubmit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Connection con=null; PreparedStatement ps=null; //ResultSet rs=null; try{ if(textField.getText().equals("") || textField_2.getText().equals("") || textField_5.getText().equals("") || textField_6.getText().equals("") || textField_7.getText().equals("") || passwordField.getPassword().equals("") || passwordField_1.getPassword().equals("")){ JOptionPane.showMessageDialog(null,"Fields cannot be left empty!!!"); } else{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:SignUp_DSN"); con.setAutoCommit(false); String firstname=textField.getText(); String lastname=textField_1.getText(); String email_id=textField_2.getText(); String country=textField_5.getText(); String state=textField_6.getText(); String ph_no=textField_7.getText(); char[] password=passwordField.getPassword(); char[] retype_password=passwordField_1.getPassword(); String sql="insert into Sign_Up(Firstname, Lastname, Email_id, Password, " + "Retype_Password, Country, State, Phone_no)values(?,?,?,?,?,?,?,?)"; ps=con.prepareStatement(sql); ps.setString(1, firstname); ps.setString(2, lastname); ps.setString(3, email_id); ps.setString(6, country); ps.setString(7, state); ps.setString(8,ph_no); ps.setString(4, new String(password)); ps.setString(5, new String(retype_password) ); ps.executeUpdate(); JOptionPane.showMessageDialog(null, "Data is successfully inserted into database"); if(!(Arrays.equals(password, retype_password))){ JOptionPane.showMessageDialog(null,"Passwords are not matching.Enter again!!!"); } if(password.length<8 || retype_password.length<8){ JOptionPane.showMessageDialog(null,"Password should be more than 8 characters!!!"); } // while(rs.next()){ } con.close(); ps.close(); } }catch(Exception ex){ String str=ex.toString(); JOptionPane.showMessageDialog(null,str); } } });