I am doing a project on Hotel Management whose GUI is being designed using Swings and SQl Server Management Studio,2008 to store the data.But the problem I am facing is,i am getting an exception as "Driver does not support this function"...I am not able to sort out this problem...kindly enlighten me where I am going wrong..Thanks in advance..:)
I have created 2 forms:SignUp form and Login form...Here is my SignUp form where I am stuck...
btnSubmit = new JButton("SUBMIT");
btnSubmit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
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");
Connection con=DriverManager.getConnection("jdbc:odbc:SignUp_DSN");
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();
if(!password.equals(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!!!");
}
String sql="insert into Sign_Up(`Firstname`,`Lastname`,`Email_id`,`Password`,`Retype_Password`,`Country`,`State`,`Phone_no`) values(?,?,?,?,?,?,?,?)";
PreparedStatement 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) );
ResultSet rs=ps.executeQuery(sql);
while(rs.next()){ }
con.close();
ps.close();
//rs.close();
}
}catch(Exception ex){
String str=ex.toString();
JOptionPane.showMessageDialog(null,str);
}
}
});
And also the condition for Password matching is not working...I get a Dialogue message saying passwords doesn't match always;whether the password match or not!!!