コード例 #1
0
ファイル: MessagePan.java プロジェクト: UlTMATE/Lookout
  @Override
  public void actionPerformed(ActionEvent axnEve) {
    Object obj = axnEve.getSource();
    if (obj == replyBut) {
      try {
        if (Home.composeDial != null && Home.composeDial.isShowing()) {

        } else {
          Home.composeDial =
              new ComposeMailDialog(
                  msgID, workingSet.getString("mail_addresses"), workingSet.getString("subject"));
        }
      } catch (SQLException sqlExc) {
        sqlExc.printStackTrace();
      }
    } else if (obj == forwardBut) {
      try {
        if (Home.composeDial != null && Home.composeDial.isShowing()) {

        } else {
          Home.composeDial =
              new ComposeMailDialog(
                  msgID,
                  workingSet.getString("subject") + "\n\n" + workingSet.getString("content"));
        }
      } catch (SQLException sqlExc) {
        sqlExc.printStackTrace();
      }
    }
  }
コード例 #2
0
ファイル: Head.java プロジェクト: thite-amol/payroll
  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);
    }
  }
コード例 #3
0
ファイル: AddEditForm.java プロジェクト: robpuff/2761Login
  private void isEdit(Boolean isEdit) {
    if (isEdit) {
      try {
        Connection con = FrameLogin.getConnect();
        String sql = "SELECT * FROM Persons WHERE personId = " + Id;
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery(sql);
        if (rs.first()) {
          String firstname = rs.getString("FirstName");
          String lastname = rs.getString("LastName");
          String cellphone = rs.getString("CellPhoneNo");
          String homephone = rs.getString("HomePhoneNo");
          String gradyear = rs.getString("Graduation Year");
          String Gender = rs.getString("Gender");

          firstName.setText(firstname);
          lastName.setText(lastname);
          cellPhone.setText(cellphone);
          homePhone.setText(homephone);
          gradYear.setText(gradyear);
          gender.setSelectedItem(Gender);
          jLabel7.setVisible(false);
          studentId.setVisible(false);

        } else {
          MessageBox.infoBox("Error: ID not found", "Error");
        }
      } catch (Exception e) {
        MessageBox.infoBox(e.toString(), "Error in isEdit");
      }
    }
    FrameLogin.closeConnect();
  }
コード例 #4
0
 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
コード例 #5
0
  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!");
    }
  }
コード例 #6
0
ファイル: tnxList.java プロジェクト: njmube/Invoicex
  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;
    }
  }
コード例 #7
0
  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);
  }
コード例 #8
0
  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");
    }
  }
コード例 #9
0
 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();
   }
 }
コード例 #10
0
ファイル: TableDeneme.java プロジェクト: herlixjae/tubes1
  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
コード例 #11
0
  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
コード例 #12
0
ファイル: AdminLogin.java プロジェクト: danteata/sms
 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
コード例 #13
0
ファイル: username.java プロジェクト: anuj1708/Practice
  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");
    }
  }
コード例 #14
0
ファイル: LoginScreen.java プロジェクト: vooratarun/javasis
 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;
 }
コード例 #15
0
  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();
    }
  }
コード例 #16
0
  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);
    }
  }
コード例 #17
0
    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);
      }
    }
コード例 #18
0
ファイル: EchoAWT.java プロジェクト: operationcwal/app
  public void login() {
    String driver = "oracle.jdbc.driver.OracleDriver";
    String url = "jdbc:oracle:thin:@localhost:1521:orcl";
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;

    String id, pw, sql;
    try {
      Class.forName(driver);
      con = DriverManager.getConnection(url, "hr", "hr");
      stmt = con.createStatement();
      sql = "select * from chatuser where id = '" + lid.getText() + "'";
      rs = stmt.executeQuery(sql);
      if (rs.next()) {
        pw = rs.getString(2);
        nick = rs.getString(3);
        if (lpw.getText().equals(pw)) {
          jd.setVisible(false);
          setVisible(true);
        } else {
          lpw.setText("일치하지 않습니다.");
        }
      } else {
        lid.setText("일치하지 않습니다.");
      }
    } catch (Exception e1) {
      e1.printStackTrace();
      System.out.println("데이터 베이스 연결 실패!!");
    } finally {
      try {
        if (rs != null) rs.close();
        if (stmt != null) stmt.close();
        if (con != null) con.close();
      } catch (Exception e1) {
        System.out.println(e1.getMessage());
      }
    }
  }
コード例 #19
0
  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);
    }
  }
コード例 #20
0
  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();
    }
  }
コード例 #21
0
  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();
    }
  }
コード例 #22
0
 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();
   }
 }
コード例 #23
0
  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();
    }
  }
コード例 #24
0
  /**
   * 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) {
    }
  }
コード例 #25
0
ファイル: proses_Login.java プロジェクト: muhlik/overtimeapps
 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) {
   }
 }
コード例 #26
0
ファイル: proses_Login.java プロジェクト: muhlik/overtimeapps
 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) {
   }
 }
コード例 #27
0
 /**
  *   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
コード例 #28
0
ファイル: M.java プロジェクト: saraswatendra/Login-Page
    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) .");
      }
    }
コード例 #29
0
ファイル: city.java プロジェクト: shubhamid/towntrends
  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) {

      }
    }
  }
コード例 #30
0
  public void FillList() {
    try {

      String sql1 = "select  * from motors";
      Class.forName("com.mysql.jdbc.Driver");
      Connection con =
          (Connection)
              DriverManager.getConnection("jdbc:mysql://localhost:3306/bharatmotors", "root", "");
      Statement stmt = con.createStatement();
      ResultSet rs1 = stmt.executeQuery(sql1);
      DefaultListModel DLM = new DefaultListModel();

      while (rs1.next()) {
        DLM.addElement(rs1.getString(3));
        // DLM.addElement(rs1.getString(2));
      }

      List.setModel(DLM);
    } catch (Exception e) {
      JOptionPane.showMessageDialog(null, "e.getString()");
    }
  }