Please watch the video because there are some task to be done beside code
Find the original video on youtube
Below is the code for login Formprivate void signinActionPerformed(java.awt.event.ActionEvent evt) {
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url="jdbc:sqlserver://localhost:1433;databaseName=testdb;user=sa;password=orchid";
Connection con = DriverManager.getConnection(url);
String sql = "Select * from test where username=? and password = ?";
PreparedStatement pst = con.prepareStatement(sql);
pst.setString(1, username.getText());
pst.setString(2, password.getText());
ResultSet rs = pst.executeQuery();
if(rs.next()){
JOptionPane.showMessageDialog(null, "Username and Password Matched");
Succes field= new Succes();
field.setVisible(true);
setVisible(false);
}
else{
JOptionPane.showMessageDialog(null, "Username and password not Correct");
username.setText("");
password.setText("");
}
con.close();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
}
For Reset Button:
private void resetActionPerformed(java.awt.event.ActionEvent evt) {
username.setText("");
password.setText("");
}
Please don't forget To Like, Share and Subscribe my Youtube video and Channel.
where did user=sa come please ?
ReplyDeletewhen i copied the test and changed the database and table name it says that user=sa not found , what should i do?
User sa is a primary key in database it automatically increment so when you have 2 3 values it also increment from 1 2 3 4 so it's not come
Delete(1,1) in a code
hello
ReplyDelete