Exemple #1
0
  public void actionPerformed(ActionEvent ae) {

    try {
      if (ae.getSource() == b7) {

        rs = st.executeQuery("select count(*) from employeemaster");
        if (rs.next()) {
          t6.setText(rs.getString(1));
        }

        rs = st.executeQuery("select * from Head");
        if (rs.next()) {
          t1.setText(rs.getString(1));
          t2.setText(rs.getString(2));
          t7.setText(rs.getString(3));
          t4.setText(rs.getString(4));
          t5.setText(rs.getString(5));
          t3.setText(rs.getString(6));
        }
      } else if (ae.getSource() == b6) {
        dispose();
      }

    } catch (Exception e) {
      JOptionPane.showMessageDialog(this, "Error is" + e);
    }
  }
 private boolean AidedIn(SaoWorker w)
 {
   BatSQL bSQL = new BatSQL();
   boolean success = false;
   String id    = w.getUserID();
   String q = "select * from aidedin where USERID='" + id + "'";
   ResultSet rs = bSQL.query(q);
       
   try
   {
     boolean more = rs.next();
     if (more) { success = true; }
   } //end of try
   catch (SQLException ex)
   {
     System.out.println("!*******SQLException caught*******!");
     while (ex != null)
     {
       System.out.println ("SQLState: " + ex.getSQLState ());
       System.out.println ("Message:  " + ex.getMessage ());
       System.out.println ("Vendor:   " + ex.getErrorCode ());
       ex = ex.getNextException ();
       System.out.println ("");
     }
     System.exit(0);
   } //end catching SQLExceptions
   catch (java.lang.Exception ex)
   {
     System.out.println("!*******Exception caught*******!");
     System.exit(0);
   } //end catching other Exceptions
   bSQL.disconnect();
   return success;
 } //end of AidedIn?
    public void actionPerformed(ActionEvent ae) {
      try {

        Integer num = Integer.parseInt(tfdid.getText());
        String name;
        String addr;
        String contact;
        String spec;
        String workf;
        String workt;

        Statement st = cn.createStatement();
        ResultSet rs = st.executeQuery("SELECT * FROM DOC WHERE did=" + num);

        if (rs.next()) {
          num = rs.getInt("did");
          name = rs.getString("name");
          addr = rs.getString("address");
          contact = rs.getString("contact");
          spec = rs.getString("specialization");
          workf = rs.getString("workfrom");
          workt = rs.getString("workto");

          tfname.setText(name);
          taadd.setText(addr);
          tftel.setText(contact);
          taspecial.setText(spec);
          tfworkf.setText(workf);
          tfworkt.setText(workt);
        }

      } catch (SQLException sq) {
        System.out.println(sq);
      }
    }
  stab(ResultSet k) {
    super("PATIENT FOUND");
    String[] chd = {
      "Date",
      "Patient ID",
      "Name",
      "Gender",
      "Age",
      "Weight",
      "Address",
      "Contact No.",
      "Doctor Name",
      "Symptoms",
      "Dignosis",
      "Fee: Rs.",
      "Blood Group"
    };
    // DefaultTableModel dtm=new DefaultTableModel();
    // jt.setModel(new DefaultTableModel(arr,chd));
    jt = new JTable();
    jsp = new JScrollPane(jt);
    btn = new JButton("CLOSE");
    btn.addActionListener(this);
    int i = 0;

    try {
      while (k.next()) {

        arr[i][0] = k.getString(1);
        // System.out.println("ddddddddddddd"+arr[i][0]);
        arr[i][1] = "" + k.getInt(2);
        arr[i][2] = k.getString(3) + " " + k.getString(4) + " " + k.getString(5);
        arr[i][3] = k.getString(6);
        arr[i][4] = "" + k.getInt(7);
        arr[i][5] = k.getString(8);
        arr[i][6] = k.getString(9);
        arr[i][7] = k.getString(10);
        arr[i][8] = k.getString(11);
        arr[i][9] = k.getString(12);
        arr[i][10] = k.getString(13);
        arr[i][11] = "" + k.getInt(14);
        arr[i][12] = k.getString(15);
        arr[i][13] = k.getString(16);
        // dtm.insertRow(i,new Object[]{patient.rs.getString(1),
        // patient.rs.getInt(2),patient.rs.getString(3)+patient.rs.getString(4)+patient.rs.getString(5),patient.rs.getString(6),patient.rs.getInt(7),patient.rs.getString(8),patient.rs.getString(9),patient.rs.getString(10),patient.rs.getString(11),patient.rs.getString(12),patient.rs.getString(13),patient.rs.getInt(14)});
        i++;
      }
    } catch (Exception e12) {
      System.out.println("" + e12);
    }
    jt.setModel(new DefaultTableModel(arr, chd));
    Container con = getContentPane();
    con.setLayout(null);
    jsp.setBounds(20, 20, 1230, 600);
    btn.setBounds(685, 630, 100, 30);
    add(jsp);
    add(btn);
    setSize(1330, 800);
    setVisible(true);
  }
Exemple #5
0
  public void setQuery(String q) {
    cache = new Vector();
    try {
      ResultSet rs = statement.executeQuery(q);
      ResultSetMetaData meta = rs.getMetaData();
      colCount = meta.getColumnCount();
      headers = new String[colCount];
      for (int h = 1; h <= colCount; h++) {
        headers[h - 1] = meta.getColumnName(h);
      }
      while (rs.next()) {
        String[] record = new String[colCount];
        for (int i = 0; i < colCount; i++) {
          record[i] = rs.getString(i + 1);
        }
        cache.addElement(record);
      } // while sonu

      fireTableChanged(null);
    } // try sonu
    catch (Exception e) {
      cache = new Vector();
      e.printStackTrace();
    }
  } // setQuery sonu
 public void actionPerformed(ActionEvent evt) {
   // 删除原来的JTable(JTable使用scrollPane来包装)
   if (scrollPane != null) {
     jf.remove(scrollPane);
   }
   try (
   // 根据用户输入的SQL执行查询
   ResultSet rs = stmt.executeQuery(sqlField.getText())) {
     // 取出ResultSet的MetaData
     ResultSetMetaData rsmd = rs.getMetaData();
     Vector<String> columnNames = new Vector<>();
     Vector<Vector<String>> data = new Vector<>();
     // 把ResultSet的所有列名添加到Vector里
     for (int i = 0; i < rsmd.getColumnCount(); i++) {
       columnNames.add(rsmd.getColumnName(i + 1));
     }
     // 把ResultSet的所有记录添加到Vector里
     while (rs.next()) {
       Vector<String> v = new Vector<>();
       for (int i = 0; i < rsmd.getColumnCount(); i++) {
         v.add(rs.getString(i + 1));
       }
       data.add(v);
     }
     // 创建新的JTable
     JTable table = new JTable(data, columnNames);
     scrollPane = new JScrollPane(table);
     // 添加新的Table
     jf.add(scrollPane);
     // 更新主窗口
     jf.validate();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  public void actionPerformed(ActionEvent ae) {
    if (ae.getSource() == b1) {
      try {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        Connection con =
            DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "123");
        PreparedStatement ps =
            con.prepareStatement("select * from LoginForm where username=? and password=?");
        String UserName = t1.getText();
        String Password = jp1.getText();
        ps.setString(1, UserName);
        ps.setString(2, Password);
        ResultSet rs = ps.executeQuery();
        boolean flag = rs.next();
        if (flag) {
          new Main();
          f.setVisible(false);
        } else {
          JOptionPane.showMessageDialog(null, "Please Enter valid Name And Password");
        }

      } catch (Exception e) {
        System.out.println("Error:" + e);
      }
    } else if (ae.getSource() == b2) {
      t1.setText("");
      jp1.setText("");
    } else if (ae.getSource() == b3) {

      f.setVisible(false);
    }
  }
  public void display(ResultSet rs) {
    try {
      boolean recordNumber = rs.next();
      if (recordNumber) {
        payNo = rs.getString(1);
        pasNo = rs.getString(2);
        pasName = rs.getString(3);
        mode = rs.getString(4);
        dt = rs.getString(5);
        amount = rs.getString(6);
        rev = rs.getString(7);

        text1.setText(payNo);
        combo1.setSelectedItem(pasNo);
        combo2.setSelectedItem(pasName);
        combo4.setSelectedItem(mode);
        p_date.setText(dt);
        combo8.setSelectedItem(amount);
        combo3.setSelectedItem(rev);

      } else {
        JOptionPane.showMessageDialog(
            null, "Record Not found", "ERROR", JOptionPane.DEFAULT_OPTION);
      }
    } catch (SQLException sqlex) {
      sqlex.printStackTrace();
    }
  }
 private void ListValueChanged(
     javax.swing.event.ListSelectionEvent evt) { // GEN-FIRST:event_ListValueChanged
   // TODO add your handling code here:
   // String part=partno.getText();
   try {
     String sql =
         "SELECT  TYPE,ITEM_NAME,QUANTITY,MRP FROM MOTORS WHERE ITEM_NAME='"
             + List.getSelectedValue()
             + "'";
     Class.forName("com.mysql.jdbc.Driver");
     Connection con =
         (Connection)
             DriverManager.getConnection("jdbc:mysql://localhost:3306/bharatmotors", "root", "");
     Statement stmt = con.createStatement();
     ResultSet rs = stmt.executeQuery(sql);
     while (rs.next()) {
       partno.setText(rs.getString("TYPE"));
       name.setText(rs.getString("ITEM_NAME"));
       qty.setText(rs.getString("QUANTITY"));
       rate.setText(rs.getString("MRP"));
     }
   } catch (Exception e) {
     JOptionPane.showMessageDialog(null, e.toString());
   }
 } // GEN-LAST:event_ListValueChanged
  public void connectItems(String query)
        // PRE:  query must be initialized
        // POST: Updates the list of Items based on the query.
      {
    String driver = "org.apache.derby.jdbc.ClientDriver"; // Driver for DB
    String url = "jdbc:derby://localhost:1527/ShopDataBase"; // Url for DB
    String user = "******"; // Username for db
    String pass = "******"; // Password for db
    Connection myConnection; // Connection obj to db
    Statement stmt; // Statement to execute a result appon
    ResultSet results; // A set containing the returned results
    int rowcount; // Num objects in the resultSet
    int i; // Index for the array

    try { // Try connection to db

      Class.forName(driver).newInstance(); // Create our db driver

      myConnection = DriverManager.getConnection(url, user, pass); // Initalize our connection

      stmt =
          myConnection.createStatement(
              ResultSet.TYPE_SCROLL_INSENSITIVE,
              ResultSet.CONCUR_UPDATABLE); // Create a new statement
      results = stmt.executeQuery(query); // Store the results of our query

      rowcount = 0;
      if (results.last()) // Go to the last result
      {
        rowcount = results.getRow();
        results.beforeFirst();
      }
      itemsArray = new Item[rowcount];

      i = 0;
      while (results.next()) // Itterate through the results set
      {
        itemsArray[i] =
            new Item(
                results.getInt("item_id"),
                results.getString("item_name"),
                results.getString("item_type"),
                results.getInt("price"),
                results.getInt("owner_id"),
                results.getString("item_path")); // Creat new Item
        i++;
      }

      results.close(); // Close the ResultSet
      stmt.close(); // Close the statement
      myConnection.close(); // Close the connection to db

    } catch (Exception e) // Cannot connect to db
    {
      System.err.println(e.toString());
      System.err.println("Error, something went horribly wrong in connectItems!");
    }
  }
Exemple #11
0
  public boolean dbOpenList(Connection connection, String sql) {
    dbClearList();
    this.oldSql = sql;
    this.oldConnection = connection;
    // apre il resultset da abbinare
    ResultSet resu = null;
    ResultSetMetaData meta;
    try {
      stat = connection.createStatement();
      resu = stat.executeQuery(sql);
      meta = resu.getMetaData();

      if (meta.getColumnCount() > 1) {
        this.contieneChiavi = true;
      }

      // righe
      while (resu.next()) {
        for (int i = 1; i <= meta.getColumnCount(); ++i) {
          if (i == 1) {
            dbItems.add((Object) resu.getString(i));
            lm.addElement((Object) resu.getString(i));
          } else if (i == 2) {
            dbItemsK.add((Object) resu.getString(i));

            // debug
            // System.out.println("list:" + String.valueOf(i) + ":" + resu.getString(i));
          } else if (i == 3) {
            dbItemsK2.add((Object) resu.getString(i));
          }
        }
      }
      this.setModel(lm);

      // vado al primo
      if (dbTextAbbinato != null) {
        // debug
        // javax.swing.JOptionPane.showMessageDialog(null,this.getKey(0).toString());
        dbTextAbbinato.setText(this.getKey(0).toString());
      }

      return (true);
    } catch (Exception e) {
      javax.swing.JOptionPane.showMessageDialog(null, e.toString());
      e.printStackTrace();
      return (false);
    } finally {
      try {
        stat.close();
      } catch (Exception e) {
      }
      try {
        resu.close();
      } catch (Exception e) {
      }
      meta = null;
    }
  }
  private void jButton3ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton3ActionPerformed
    try {
      Connection con =
          (Connection)
              DriverManager.getConnection("jdbc:mysql://localhost:3306/bharatmotors", "root", "");
      Statement stmt = con.createStatement();

      ResultSet resultSet = stmt.executeQuery("select Bill_No from bill;");

      String productCode = null;

      while (resultSet.next()) {
        productCode = resultSet.getString("Bill_No");
      }
      int pc = Integer.parseInt(productCode);
      System.out.println(pc);
      no.setText((String.valueOf(++pc)));
      // TODO add your handling code here:

      String part = partno.getText();
      String itemname = name.getText();
      String qty1 = qty.getText();
      String rate1 = rate.getText();
      // String amo=amount.getText();
      String noo = no.getText();
      no1 = Integer.parseInt(noo);
      cname = custname.getText();
      bill1 = bill.getText();
      addr1 = addr.getText();

      String ta = tax.getText();
      int a = Integer.parseInt(qty1);
      int b = Integer.parseInt(rate1);
      int c = a * b;
      String str = Integer.toString(c);
      amount.setText(str);
      String str1 = amount.getText();
      /* String sql1="select Quantity from lubricants";
      String sql2="UPDATE LUBRICANTS SET QUANTITY=QUANTITY-qty1 WHERE PART_NO='"+partno+"'";
      Statement stmt1=con.createStatement();
      ResultSet rs1= stmt1.executeQuery(sql1);

      String ch=rs1.getString("QUANTITY");
      int q=Integer.parseInt(qty1);
      int r=Integer.parseInt(ch);
      if(q >r)
      {
          JOptionPane.showMessageDialog(this,"STOCK UNAVAILABLE");
      }
      else
      {
          stmt1.executeUpdate(sql2);
      }*/
    } catch (SQLException ex) {
      Logger.getLogger(Billspare.class.getName()).log(Level.SEVERE, null, ex);
    }
  } // GEN-LAST:event_jButton3ActionPerformed
Exemple #13
0
 private void passwordTextBoxKeyPressed(
     java.awt.event.KeyEvent evt) { // GEN-FIRST:event_passwordTextBoxKeyPressed
   // TODO add your handling code here:
   int key = evt.getKeyCode();
   if (key == KeyEvent.VK_ENTER) {
     boolean verify = false;
     String user = usernameTextBox.getText();
     String passwd = passwordTextBox.getText();
     if (user.equals("") || passwd.equals("")) {
       JOptionPane.showMessageDialog(
           AdminLogin.this, "Sorry! You must enter a Username and Password to login ");
       usernameTextBox.requestFocus();
     } else {
       Connection con = getConnection();
       try {
         ResultSet rows;
         Statement s =
             con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
         String select = "Select * from admin;";
         rows = s.executeQuery(select);
         while (rows.next()) {
           String username = rows.getString("Username");
           String password = rows.getString("Password");
           if (user.equals(username) && passwd.equals(password)) {
             verify = true;
             this.dispose();
             //                       btn.btnEnabled();
             break;
           }
         }
         if (verify == false) {
           verify = false;
           JOptionPane.showMessageDialog(
               AdminLogin.this, "Access Denied! Invalid Username or Password");
           usernameTextBox.setText("");
           passwordTextBox.setText("");
           usernameTextBox.requestFocus();
         }
       } catch (SQLException e) {
         System.out.println(e.getMessage());
       }
       if (verify == false) {
         JOptionPane.showMessageDialog(
             AdminLogin.this, "Access Denied!  Invalid Username or Password");
         usernameTextBox.setText("");
         passwordTextBox.setText("");
         usernameTextBox.requestFocus();
       } // TODO add your handling code here:
     }
   }
   if (key == KeyEvent.VK_UP) {
     usernameTextBox.grabFocus();
   }
   if (key == KeyEvent.VK_KP_UP) {
     usernameTextBox.grabFocus();
   }
 } // GEN-LAST:event_passwordTextBoxKeyPressed
  private void fullAssociated() {

    boolean associated = true;

    String SQL =
        "Select * "
            + "from XX_VMR_REFERENCEMATRIX "
            + "where M_product IS NULL AND XX_VMR_PO_LINEREFPROV_ID="
            + LineRefProv.get_ID();

    try {
      PreparedStatement pstmt = DB.prepareStatement(SQL, null);
      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        associated = false;
      }

      rs.close();
      pstmt.close();

    } catch (Exception a) {
      log.log(Level.SEVERE, SQL, a);
    }

    if (associated == true) {
      String SQL10 =
          "UPDATE XX_VMR_PO_LineRefProv "
              + " SET XX_ReferenceIsAssociated='Y'"
              + " WHERE XX_VMR_PO_LineRefProv_ID="
              + LineRefProv.getXX_VMR_PO_LineRefProv_ID();

      DB.executeUpdate(null, SQL10);

      //			LineRefProv.setXX_ReferenceIsAssociated(true);
      //			LineRefProv.save();

      int dialog = Env.getCtx().getContextAsInt("#Dialog_Associate_Aux");

      if (dialog == 1) {
        ADialog.info(m_WindowNo, m_frame, "MustRefresh");
        Env.getCtx().remove("#Dialog_Associate_Aux");
      }

    } else {
      String SQL10 =
          "UPDATE XX_VMR_PO_LineRefProv "
              + " SET XX_ReferenceIsAssociated='N'"
              + " WHERE XX_VMR_PO_LineRefProv_ID="
              + LineRefProv.getXX_VMR_PO_LineRefProv_ID();

      DB.executeUpdate(null, SQL10);
      //			LineRefProv.setXX_ReferenceIsAssociated(false);
      //			LineRefProv.save();
    }
  }
Exemple #15
0
  public static void goer() throws Exception {

    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection con =
        (Connection) DriverManager.getConnection("jdbc:oracle:thin:@localhost", "system", "system");
    String query2 = "select * from logger";
    Statement st2 = con.createStatement();
    ResultSet rs = st2.executeQuery(query2);
    boolean b = false;
    while (rs.next()) {
      if ((rs.getString(3)).equals(p2.str3)) {
        b = true;
      }
    }
    if (b == false) {
      String query1 =
          "insert into logger values('"
              + p2.str1
              + "','"
              + p2.str2
              + "','"
              + p2.str3
              + "','"
              + p2.str4
              + "','"
              + p2.str5
              + "','"
              + p2.str7
              + "','"
              + p2.str8
              + "','"
              + p2.str9
              + "','"
              + p2.str13
              + "')";
      Statement st1 = con.createStatement();
      st1.executeQuery(query1);
      JOptionPane.showMessageDialog(null, "welcome\n now you are a meber of our team ");
    } else {
      JOptionPane.showMessageDialog(null, "this username already exist");
    }
  }
  public void updateTables(String updateQuery1, String updateQuery2, String updateQuery3)
        // PRE:  updateQuery1,updateQuery2, updateQuery3 must be initialized
        // POST: Updates the list of Items based on the querys.
      {
    String driver = "org.apache.derby.jdbc.ClientDriver"; // Driver for DB
    String url = "jdbc:derby://localhost:1527/ShopDataBase"; // Url for DB
    String user = "******"; // Username for db
    String pass = "******"; // Password for db
    Connection myConnection; // Connection obj to db
    Statement stmt; // Statement to execute a result appon
    ResultSet results; // A set containing the returned results
    int i; // Index for the array
    try // Try connection to db
    {

      Class.forName(driver).newInstance(); // Create our db driver

      myConnection = DriverManager.getConnection(url, user, pass); // Initalize our connection

      stmt =
          myConnection.createStatement(
              ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
      stmt.executeUpdate(updateQuery1);

      stmt.executeUpdate(updateQuery2);

      stmt.executeUpdate(updateQuery3);

      results = stmt.executeQuery(previous_query); // Call the previous query

      i = 0;
      while (results.next()) // Itterate through the results set
      {
        itemsArray[i] =
            new Item(
                results.getInt("item_id"),
                results.getString("item_name"),
                results.getString("item_type"),
                results.getInt("price"),
                results.getInt("owner_id"),
                results.getString("item_path"));
        i++;
      }
      results.close(); // Close the ResultSet
      stmt.close(); // Close the statement
      myConnection.close(); // Close the connection to db

    } catch (Exception e) // Cannot connect to db
    {
      System.err.println(e.toString());
      System.err.println("Error, something went horribly wrong! in updateTables");
    }
  }
Exemple #17
0
 public boolean isValidUser() throws SQLException {
   CreateJDBCConnection jdbc = new CreateJDBCConnection();
   Statement stmt = jdbc.getStatement();
   stmt.execute("use jana;");
   String sqlQuery =
       "select password from user_details where idno = '" + nameText.getText() + "';";
   ResultSet rs = stmt.executeQuery(sqlQuery);
   while (rs.next()) {
     if (rs.getString("password").equals(passText.getText())) return true;
   }
   return false;
 }
  public void updateRecord() {
    String totalSeat, alotSeat, vacentSeat, strHostel;
    try {
      rs = statement.executeQuery("select hostelName from hostelStatus");
      while (rs.next()) {
        strHostel = rs.getString(1);

        try {
          rs1 = statement1.executeQuery("select count(*) from " + strHostel + "");
          rs1.next();
          totalSeat = rs1.getString(1);

          rs1 = statement1.executeQuery("select count(*) from " + strHostel + " where status='F'");
          rs1.next();
          alotSeat = rs1.getString(1);

          try {
            vacentSeat = String.valueOf(Integer.parseInt(totalSeat) - Integer.parseInt(alotSeat));
            statement1.executeUpdate(
                "update hostelStatus set totalSeat='"
                    + totalSeat
                    + "',vacentSeat='"
                    + vacentSeat
                    + "'where hostelName='"
                    + strHostel
                    + "'");
            statement1.executeUpdate("commit");
            rs1.close();
          } catch (SQLException sqle) {
            JOptionPane.showMessageDialog(null, sqle);
          }

        } catch (SQLException sqle) {
          JOptionPane.showMessageDialog(null, "Error " + sqle);
        }
      }
    } catch (SQLException sq) {
      JOptionPane.showMessageDialog(null, sq);
    }
  }
  public void actionPerformed(ActionEvent ae) {
    String str = ae.getActionCommand();
    if (str.equals("Ok")) {
      String str1 = (String) jcmname.getSelectedItem();

      Connection con = null;
      Statement stat = null;

      if (str1.equals("Pulsar")
          || str1.equals("CT 100")
          || str1.equals("Discover DTS-i")
          || str1.equals("Wave DTS-i")) {
        try {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          con = DriverManager.getConnection("Jdbc:Odbc:showroom");
          System.out.println("Got Connection :" + con);
          stat = con.createStatement();
          ResultSet rs = stat.executeQuery("select * from vehicle");
          System.out.println("chk1");
          while (rs.next()) {
            if (str1.equals(rs.getString(1))) {

              tfcap.setText("" + rs.getInt(2));
              tfeng.setText("" + rs.getInt(3));
              tfbhp.setText("" + rs.getInt(4));
              tfvolt.setText("" + rs.getInt(5));
              tfrpm.setText("" + rs.getInt(6));
              tfweight.setText("" + rs.getInt(7));
              tfgear.setText("" + rs.getInt(8));
            }
          }

          stat.close();
          con.close();

        } catch (Exception ex) {
        }

      } else {
        JOptionPane.showMessageDialog(
            null, "Please Choose Model Name", "Error", JOptionPane.ERROR_MESSAGE);
      }
    }

    if (str.equals("can")) {
      this.dispose();
      // new menu(1);
    }
  }
  private void setamount() {

    try {
      ResultSet rst =
          DBConnection.getDBConnection()
              .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
              .executeQuery(
                  "SELECT Amount FROM BOOKING  where Pass_No='" + combo1.getSelectedItem() + "'");
      while (rst.next()) {
        combo8.addItem(rst.getString(1));
      }
    } catch (Exception n) {
      n.printStackTrace();
    }
  }
  private void setCombo() {

    try {
      ResultSet rst =
          DBConnection.getDBConnection()
              .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
              .executeQuery(
                  "SELECT Emp.empNo, Emp.Sname, Emp.Fname, Emp.Lname, Emp.Designation FROM Emp WHERE Emp.Designation='Booking Clerk'");
      while (rst.next()) {
        combo3.addItem(rst.getString(3));
      }
    } catch (Exception n) {
      n.printStackTrace();
    }
  }
 public void setJenis() {
   dataJenis = new ArrayList<Jenis>();
   try {
     String qry = "SELECT * from jenis";
     ResultSet rs = stm.executeQuery(qry);
     while (rs.next()) {
       Jenis j = new Jenis();
       j.setIdJenis(rs.getInt("id_jenis"));
       j.setNamaJenis(rs.getString("nama_jenis"));
       dataJenis.add(j);
     }
   } catch (SQLException SQLerr) {
     SQLerr.printStackTrace();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  private void setcbr() {

    try {
      ResultSet rst =
          DBConnection.getDBConnection()
              .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
              .executeQuery(
                  "SELECT * FROM Passenger where Booked_status='Booked' and Pay_Status='Not_Paid'");
      System.out.println("Hello");
      while (rst.next()) {

        combo1.addItem(rst.getString(1));
        combo2.addItem(rst.getString(2));
      }
    } catch (Exception n) {
      n.printStackTrace();
    }
  }
  /**
   * Method declaration
   *
   * @param r
   */
  void formatResultSet(ResultSet r) {

    if (r == null) {
      String g[] = new String[1];

      g[0] = "Result";

      gResult.setHead(g);

      g[0] = "(empty)";

      gResult.addRow(g);

      return;
    }

    try {
      ResultSetMetaData m = r.getMetaData();
      int col = m.getColumnCount();
      String h[] = new String[col];

      for (int i = 1; i <= col; i++) {
        h[i - 1] = m.getColumnLabel(i);
      }

      gResult.setHead(h);

      while (r.next()) {
        for (int i = 1; i <= col; i++) {
          h[i - 1] = r.getString(i);

          if (r.wasNull()) {
            h[i - 1] = "(null)";
          }
        }

        gResult.addRow(h);
      }

      r.close();
    } catch (SQLException e) {
    }
  }
Exemple #25
0
 private boolean isLoggedIn(int id) {
   boolean isLoggedIn = false;
   Connection con = getConnect();
   int personId = getPersonId(id);
   try {
     String SQL = "SELECT * FROM LogInOut WHERE personId = " + personId + " AND TimeOut IS NULL";
     Statement stmt = con.createStatement();
     ResultSet rs = stmt.executeQuery(SQL);
     if (rs != null && rs.next()) {
       rs.last();
       isLoggedIn = true;
     }
   } catch (Exception err) {
     MessageBox.infoBox(err.toString(), "Error from isLoggedIn");
     System.out.println(err);
   }
   closeConnect();
   return isLoggedIn;
   // SELECT * FROM LogInOut WHERE personId = 1 AND TimeOut IS NULL
 }
Exemple #26
0
 public void check_User() {
   String user = "";
   String sql = "Select * from user";
   boolean user_valid = false;
   try {
     PreparedStatement stat = konek.prepareStatement(sql);
     ResultSet rset = stat.executeQuery();
     while (rset.next()) {
       user = rset.getString("username");
       if (user.equalsIgnoreCase(dataUser)) {
         user_valid = true;
         status_Proses(true, "Sukses!!!User Name Valid...", 20);
       }
     }
     if (user_valid == false) {
       status_Proses(false, "Gagal!!!User yang Anda Masukan Salah...", 20);
     }
   } catch (SQLException se) {
   }
 }
Exemple #27
0
 public void check_Password() {
   String password = "******";
   String sql = "Select * from user where user_id = '" + dataUser + "'";
   boolean password_valid = false;
   try {
     PreparedStatement stat = konek.prepareStatement(sql);
     ResultSet rset = stat.executeQuery();
     while (rset.next()) {
       password = rset.getString("psw");
       if (password.equalsIgnoreCase(dataPassword)) {
         password_valid = true;
         status_Proses(true, "Sukses!!!Password Valid...", 20);
       }
     }
     if (password_valid == false) {
       status_Proses(false, "Gagal!!!Password yang Anda Masukan Salah...", 20);
     }
   } catch (SQLException se) {
   }
 }
 /**
  *   Finds out if an aide is covering for another aide
  *   and makes an entry to the AIDELOG to note that
  *   coverage has ended.
  *
  *   @param The SaoWorker who might be covering
  */
 public void Covering(final SaoWorker w)
 {
   BatSQL bSQL = new BatSQL();
   String qc = "select * from AIDEDIN where USERID='" + w.getUserID() + "'";
   ResultSet rs = bSQL.query(qc);
   String cid = new String();
   
   try
   {
     rs.next();
     cid = rs.getString(2);
   }
   catch (SQLException ex)
   {
     System.out.println("!*******SQLException caught*******!");
     System.out.println("Covering");
     while (ex != null)
     {
       System.out.println ("SQLState: " + ex.getSQLState ());
       System.out.println ("Message:  " + ex.getMessage ());
       System.out.println ("Vendor:   " + ex.getErrorCode ());
       ex = ex.getNextException ();
       System.out.println ("");
     }
     System.exit(0);
   } //end catching SQLExceptions
   catch (java.lang.Exception ex)
   {
     System.out.println("!*******Exception caught*******!");
     System.out.println("Covering");      
     System.exit(0);
   } //end catching other Exceptions
   
   if (!cid.equals("No")) //then covering
   {
     String uc = "insert into AIDELOG values ('C', '" + cid + "', \"" + bd.getDate() + "\", " + bd.getStringHours() + bd.getStringMinutes() + ", 'O')"; 
     bSQL.update(uc);
   }
   bSQL.disconnect();
     
 } //end of Covering
Exemple #29
0
  private void fill_combo() {
    try {
      String sql = "select distinct townname from towntrends.trends ";
      pst = conn.prepareStatement(sql);
      rs = pst.executeQuery();

      while (rs.next()) {
        String name = rs.getString("townname");
        jComboBox1.addItem(name);
      }
    } catch (Exception ex) {
      JOptionPane.showMessageDialog(null, ex);
    } finally {
      try {
        pst.close();
        rs.close();
      } catch (Exception ex) {

      }
    }
  }
  private void generator() {

    try {
      ResultSet rst =
          DBConnection.getDBConnection()
              .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
              .executeQuery("SELECT Payment_No FROM Payment");
      text1.setText("1000");
      while (rst.next()) {
        String s;
        int number = rst.getInt(1);
        number = number + 1;

        s = "" + number;
        text1.setText(s);
        int x;
      }
    } catch (Exception n) {
      n.printStackTrace();
    }
  }