예제 #1
0
    public void actionPerformed(ActionEvent e) {
      try {
        String name = JOptionPane.showInputDialog("Enter the UserId:");
        String name1 = JOptionPane.showInputDialog("Enter the Password:"******"Enter the MobileNo:");
        // int name2=Integer.parseInt(name22);
        String name3 = JOptionPane.showInputDialog("Enter the DOB(dd/mm/yyyy):");
        DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
        Connection con =
            DriverManager.getConnection(
                "jdbc:oracle:thin:@localhost:1521:xe", "system", "9696030257");
        Statement st = con.createStatement();
        st.executeUpdate(
            "insert into database values('"
                + name
                + "','"
                + name1
                + "','"
                + name2
                + "','"
                + name3
                + "')");
        st.executeUpdate("commit");
        JOptionPane.showMessageDialog(
            null,
            "Hi !! Welcome in Our Database.Your userId is  < "
                + name
                + " > And Password is < ******* >");

      } catch (Exception ex) {
        System.out.print(ex);
        JOptionPane.showMessageDialog(null, "Please Fill All Entry OR choose another UsetId.");
      }
    }
예제 #2
0
    public void actionPerformed(ActionEvent e) {
      String name4 = JOptionPane.showInputDialog("Enter the UserId:");
      String name5 = JOptionPane.showInputDialog("Enter the DOB(dd/mm/yyyy):");
      try {
        DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
        Connection con =
            DriverManager.getConnection(
                "jdbc:oracle:thin:@localhost:1521:xe", "system", "9696030257");
        Statement st = con.createStatement();
        ResultSet rs =
            st.executeQuery(
                "select * from database where userid='" + name4 + "' and dob='" + name5 + "'");
        rs.next();
        String z = rs.getString("password");
        JOptionPane.showMessageDialog(null, "Your  Password  is  <  " + z + "  >");

      } catch (Exception ex) {
        System.out.print(ex);
        JOptionPane.showMessageDialog(null, "Please Enter valid UserId and DOB(dd/mm/yyyy) .");
      }
    }
예제 #3
0
 public void actionPerformed(ActionEvent e) {
   String name6 = JOptionPane.showInputDialog("Enter old Password:"******"Enter New Password:"******"jdbc:oracle:thin:@localhost:1521:xe", "system", "9696030257");
     Statement st = con.createStatement();
     ResultSet rs = st.executeQuery("select * from database where password='******'");
     rs.next();
     String k8 = rs.getString("password");
     if (k8.equals(name6)) {
       st.executeUpdate(
           "update database set password='******' where password='******'");
       JOptionPane.showMessageDialog(null, "Your  Password  has  been  Reset");
       new Jf();
     }
   } catch (Exception ex) {
     System.out.print(ex);
     JOptionPane.showMessageDialog(null, "Please Enter valid DATA .");
   }
 }
예제 #4
0
  InsertData(Graphics g, int time) {

    // ***************************************************
    String response = JOptionPane.showInputDialog(null, "INPUT YOUR INTIALS.");
    String initials = response.substring(0, 3);
    Date date = new Date();

    String dateString = "" + date;

    String name = initials;
    String maze = "EASY";
    int score = time;
    try {
      String url = "jdbc:mysql://pascobulldogs.com:3306/web?user=webuser&password=w0506r";

      String sqlInsert =
          "INSERT INTO maze VALUES ('','"
              + name
              + "','"
              + maze
              + "','"
              + score
              + "','"
              + dateString
              + "');";
      g.drawString("SCORE RECORED. REFRESH TO START OVER!", 10, 380);

      // System.out.println(sqlInsert);
      //	System.out.println (url);
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      conn = DriverManager.getConnection(url);
      // cwc added this
      stmt = conn.createStatement();
      stmt.executeUpdate(sqlInsert);
      // i added this
      conn.close();
    } catch (Exception e) {
      // System.err.println ("Cannot connect to database server.");
    } finally {
      if (conn != null) {
        try {
          conn.close();
          //   System.out.println ("Database connection terminated");
        } catch (Exception e) {
          /* ignore close errors */
        }
      }
    }
  }
예제 #5
0
    public void actionPerformed(ActionEvent e) {

      String name8 = JOptionPane.showInputDialog("Enter old MobileNo:");
      String name9 = JOptionPane.showInputDialog("Enter New MobileNo:");
      try {
        DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
        Connection con =
            DriverManager.getConnection(
                "jdbc:oracle:thin:@localhost:1521:xe", "system", "9696030257");
        Statement st = con.createStatement();
        ResultSet rs = st.executeQuery("select * from database where mob='" + name8 + "'");
        rs.next();
        String k9 = rs.getString("mob");
        if (k9.equals(name8)) {
          st.executeUpdate("update database set mob='" + name9 + "' where mob='" + name8 + "'");
          JOptionPane.showMessageDialog(
              null, "Your  Mobile is  Reset . Now Your mobile no is <  " + name9 + "  >");
          new Jf();
        }
      } catch (Exception ex) {
        System.out.print(ex);
        JOptionPane.showMessageDialog(null, "Please Enter valid DATA.");
      }
    }
  public void read() {
    try {
      // patient.dt=""+tdt.getText();
      patient.pid = Integer.parseInt(tpid.getText());
      patient.pfnm = tpfnm.getText();
      patient.pmnm = tpmnm.getText();
      patient.plnm = tplnm.getText();
      patient.gen = cbg.getSelectedCheckbox().getLabel();

      try {
        patient.age = Integer.parseInt(tage.getText());
        tage.setText("" + patient.age);

      } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Invalid age inputed.");
        patient.age = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid age:"));
        tage.setText("" + patient.age);
      }

      try {
        int wet = Integer.parseInt(twt.getText());
        twt.setText("" + wet);
      } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Invalid weight inputed.");
        int wet = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid weight:"));
        twt.setText("" + wet);
      }
      patient.wt = twt.getText();
      patient.addr = tadd.getText();
      this.ad = tadd.getText();
      System.out.println(tadd.getText());

      while (true) {
        patient.cno = tcno.getText();
        if (patient.cno.length() == 10) break;
        else {
          JOptionPane.showMessageDialog(null, "Invalid Phone No.");
          patient.cno = JOptionPane.showInputDialog("Please enter valid 10-digit Phone No.:");
          tcno.setText(patient.cno);
        }
      }
      patient.dnm = tdnm.getText();
      patient.sym = tsym.getText();
      System.out.println(tsym.getText());

      patient.dig = tdig.getText();
      try {
        patient.fee = Integer.parseInt(tfee.getText());
        tfee.setText("" + patient.fee);

      } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Invalid Fee inputed.");
        patient.fee = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid Fee:"));
        tfee.setText("" + patient.fee);
      }

      patient.bg = tbg.getText();
      patient.path = str;
    } catch (Exception e) {
    }
  }