Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JJAVA Can someone help me get rid of the database and instead check for username and password in a file(.txt) ? please keep in mind

JJAVA Can someone help me get rid of the database and instead check for username and password in a file(.txt) ?

please keep in mind that this is GUI

try { String driver = "com.mysql.jdbc.Driver"; Class.forName(driver); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/crm", "root", "3366"); System.out.println(con.toString()); String nm=jTextField1.getText(); String paas=jPasswordField1.getText(); String query = "SELECT * FROM login WHERE username='"+nm +"';";

System.out.println("Query :" + query); Statement st = con.createStatement(); ResultSet rs = st.executeQuery(query); int flag = 0; while (rs.next()) { String passw = rs.getString("password"); if (passw.equals(paas)) { JOptionPane.showMessageDialog(this,"Congrts U are authenticated" ); flag = 1; this.setVisible(false); Home frame = new Home(); frame.setDefaultCloseOperation( EXIT_ON_CLOSE ); frame.pack(); frame.setVisible(true); } }

if (flag == 0) JOptionPane.showMessageDialog(this,"Wrong Username or password" ); //System.out.println(); con.close();

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Describe how to train managers to coach employees. page 404

Answered: 1 week ago

Question

Discuss the steps in the development planning process. page 381

Answered: 1 week ago