Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.Statement;
- import java.util.ArrayList;
- import javax.swing.JOptionPane;
- import javax.swing.table.DefaultTableModel;
- import sun.security.util.Password;
- public class pass extends javax.swing.JFrame {
- DefaultTableModel model1;
- //String query = "SELECT *,PosName from employeetbl inner join positiontbl"+" on employeetbl.PosID=positiontbl.PosID";
- String query = "SELECT * from employeetbl";
- public pass() {
- initComponents();
- // Connection connection=getConnection();
- // String query1 = "SELECT * FROM employeetbl where EmpID='"+idT.getText()+"'";
- // Statement st;
- // ResultSet rs;
- // try {
- // st = (Statement) connection.createStatement();
- // rs = st.executeQuery(query1);
- //
- // while(rs.next())
- // {
- //
- // }
- //
- // } catch (Exception e) {
- // e.printStackTrace();
- // return;
- //
- // }
- //
- }
- public void executeSQLQuery (String query)
- {
- Connection con=getConnection();
- Statement st;
- try {
- st= (Statement) con.createStatement();
- if((st.executeUpdate(query))==1)
- {
- }
- else {
- }
- } catch(Exception ex) {
- ex.printStackTrace();
- JOptionPane.showMessageDialog(null, "wrong wrong");
- return;
- }
- }
- public Connection getConnection()
- {
- Connection con;
- try{
- String myDriver = "org.gjt.mm.mysql.Driver";
- String myUrl = "jdbc:mysql://localhost/employeeconnect";
- Class.forName(myDriver);
- con = (Connection) DriverManager.getConnection(myUrl, "root", "");
- return con;
- }
- catch (Exception e){
- e.printStackTrace();
- JOptionPane.showMessageDialog(null,"Error");
- return null;
- }
- }
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- String EmpID= "SELECT * FROM employeetbl where EmpID=? and Password=?";
- String Password=String.valueOf(passT.getPassword());
- Connection con = getConnection();
- String query1 = "SELECT * FROM employeetbl where EmpID='"+passidT.getText()+"'";
- Statement st;
- ResultSet rs;
- try{
- st= (Statement) con.createStatement();
- rs= st.executeQuery(query1);
- while(rs.next())
- {
- EmpID=rs.getString("EmpID");
- Password=rs.getString("Password");
- //JOptionPane.showMessageDialog(null, EmpID+Password);
- }
- if(passidT.getText().equals(EmpID) & Password.equals(Password)){
- JOptionPane.showMessageDialog(null, "Welcome!");
- mainmenu frame = new mainmenu();
- frame.setVisible(true);
- }
- else if(passidT.getText().isEmpty() && passT.getText().isEmpty()){
- JOptionPane.showMessageDialog(null, "Please input sufficient details.");
- }
- else if(passidT.getText().isEmpty()) {
- JOptionPane.showMessageDialog(null, "Please input your ID!");
- }
- else if(passT.getText().isEmpty()){
- JOptionPane.showMessageDialog(null, "Please input your password!");
- }
- else {
- JOptionPane.showMessageDialog(null,"Please input the correct details!");
- }
- } catch(Exception e) {
- JOptionPane.showMessageDialog(null, "a 4th wall breaker, I see..");
- return;
- }
- }
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
- JOptionPane.showMessageDialog(null,"I'll miss you :frowning: ");
- intro frame = new intro ();
- frame.setVisible(true);
- this.dispose();
- public static void main(String args[]) {
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new pass().setVisible(true);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement