我正在做一個酒店管理項目,其GUI是使用Swings和SQl Server Management Studio,2008來設計的,用於存儲數據。但是我面臨的問題是,我得到一個異常作爲「驅動程序不支持此功能」...我無法解決這個問題...請指教我在哪裏我錯了..預先感謝.. :)java.sql.SQLException:「驅動程序不支持此功能」
我已經創建了2種形式:註冊表單和登錄表單......這是我的註冊表格我在哪裏卡住了...
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);
}
}
});
,也爲密碼匹配的條件是不工作...我得到迪說明密碼總是不匹配的alogue消息;密碼是否匹配!!!
無關,但:不要使用JDBC/ODBC橋。它一直是越界越慢,並且它在Java 8中不再可用。請改用真正的JDBC驅動程序。 –