java - Having a access database conenction issue -
i'm working on login system compares user inputted values in access data , i'm having issues accessing database. error message dispayed "[microsoft][odbc microsoft access driver]could not find file'(unknown)'." appreciate help, thank you.
here code:
private void btnloginactionperformed(java.awt.event.actionevent evt) { connection conn = null; string sql="select username, password employeedetails"; try { boolean found = false; class.forname("sun.jdbc.odbc.jdbcodbcdriver"); conn = drivermanager.getconnection("jdbc:odbc:driver={microsoft access driver (*.mdb)};dbq=accountdetails.mdb"); statement stmt=conn.createstatement(); resultset rs = stmt.executequery(sql); user = username.gettext(); string pwd = new string (password.getpassword()); while(rs.next()) { string uname=rs.getstring("username"); string password=rs.getstring("password"); if ((user.equals(uname)) && (pwd.equals(password))) { found = true; this.dispose(); } } if(found == false) { joptionpane.showmessagedialog(null,"username or password incorrect. please try again."); username.settext(""); password.settext(""); } } catch (exception e){ joptionpane.showmessagedialog(this, e.getmessage()); }
}
Comments
Post a Comment