Question
here is the code here is the code package testPackl; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import
here is the code
here is the code
package testPackl; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField;
public class one { JFrame mainFrame = new JFrame("ghar hisab"); JButton button = new JButton("save"); JPanel panel = new JPanel(); JTextField feild1 = new JTextField(20); JTextField feild2 = new JTextField(20); JLabel lable1 = new JLabel("UserName"); JLabel lable2 = new JLabel("Password");
void display() throws Exception{ panel.add(lable1); panel.add(feild1); panel.add(lable2); panel.add(feild2); panel.add(button); mainFrame.setSize(400,400); mainFrame.setVisible(true); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainFrame.getContentPane().add(panel); try {
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/SchemaName?user=root&password=root"); Statement st = con.createStatement(); st.executeUpdate("insert into UserData VALUES("+feild1.getText() + "','" + feild2.getText() + "')"); JOptionPane.showConfirmDialog(null, "User credentials successfully iinserted", "Result", JOptionPane.DEFAULT_OPTION,JOptionPane.PLAIN_MESSAGE); st.close(); con.close(); } catch (Exception e1) { System.out.println("Exception:" + e1); } } public static void main(String args[]) throws Exception { one one= new one(); one.display(); } }
Here is the code
Create a Java client code to submit the username/password to a server code. This is done when the client user clicks on the Login button. On the server side, the code will check if the username and password received from the client are valid. Let the valid username/password pairs be stored in an array of Strings in the server code. The array should consist of 10 pairs and having the following structure String [] logins=new String[] {"user1", "pass1", "user2", "pass2", ..., "user 10", "pass 10"} The server should check if the username/password received from the client is part of its array. If this is the case, it sends a yes response to the client, else it sends a no response. When the client receives the server's response, it will inform the user via a show MessageDialog message if the authentication is successful or not. Username: Password: Login Create a Java client code to submit the username/password to a server code. This is done when the client user clicks on the Login button. On the server side, the code will check if the username and password received from the client are valid. Let the valid username/password pairs be stored in an array of Strings in the server code. The array should consist of 10 pairs and having the following structure String [] logins=new String[] {"user1", "pass1", "user2", "pass2", ..., "user 10", "pass 10"} The server should check if the username/password received from the client is part of its array. If this is the case, it sends a yes response to the client, else it sends a no response. When the client receives the server's response, it will inform the user via a show MessageDialog message if the authentication is successful or not. Username: Password: LoginStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started