示例#1
0
 private String buildATable(Table[] table, String query) {
   try {
     sb.append("<table border=1>" + "<tr>");
     for (int i = 0; i < table.length; i++) {
       sb.append("<td>" + table[i].toString() + "</td>");
     }
     // TODO REMOVE
     if (query.equals("") || query.equals("null")) query = "SELECT * FROM " + category + ";";
     //
     dbm.setConnectionBehavior(new MySQLServerConnectionBehavior());
     dbm.openConnection();
     ResultSet rs = dbm.ExecuteQueryResultSet(query);
     sb.append("<tr>");
     while (rs.next()) {
       for (int i = 0; i < table.length; i++) {
         sb.append("<td>" + rs.getString(table[i].name()) + "</td>");
       }
       sb.append("</tr>");
       sb.append("</table>");
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   dbm.closeConnection(true);
   return String.valueOf(sb);
 }
示例#2
0
 // todo Request Responde Card
 public boolean checkPassword(String name, String password) {
   String exist = "";
   String passwordFromDB = null;
   try {
     dbm.setConnectionBehavior(new MySQLServerConnectionBehavior());
     dbm.openConnection();
     ResultSet rs =
         dbm.ExecuteQueryResultSet("SELECT * from users where user_name='" + name + ";");
     while (rs.next()) {
       passwordFromDB = rs.getString("user_password");
     }
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return BCrypt.checkpw(password, passwordFromDB);
 }
示例#3
0
 public int getProductAmount(String productName) {
   int amount = 0;
   dbm.setConnectionBehavior(new MySQLServerConnectionBehavior());
   dbm.openConnection();
   try {
     ResultSet rs =
         dbm.ExecuteQueryResultSet(
             "SELECT * from products where product_name='" + productName + ";");
     while (rs.next()) {
       amount = Integer.parseInt(rs.getString("product_amount"));
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   dbm.closeConnection(true);
   return amount;
 }
示例#4
0
 private boolean executeLowLevelCommand(RequestResponseCard rrq) {
   dbm.setConnectionBehavior(new MySQLServerConnectionBehavior());
   dbm.openConnection();
   String correction = null;
   try {
     dbm.ExecuteQueryResultSet(rrq.getRequest());
     ResultSet rs = dbm.ExecuteQueryResultSet(rrq.getRespond());
     while (rs.next()) {
       correction = rs.getString(rrq.getOutputExcludedTargets());
     }
     if (correction == rrq.getOutputExcludedTargets()) ;
   } catch (Exception e) {
     e.printStackTrace();
     return false;
   }
   return false;
 }
示例#5
0
 private boolean changeProductAmount(int modificator, String productName) {
   dbm.setConnectionBehavior(new MySQLServerConnectionBehavior());
   dbm.openConnection();
   boolean executingCommand = false;
   try {
     dbm.ExecuteQueryResultSet(
         "UPDATE products SET `product_amount`='"
             + modificator
             + " 'WHERE `product_name`='"
             + productName
             + ";");
     executingCommand = (modificator == getProductAmount(productName));
   } catch (Exception e) {
     e.printStackTrace();
   }
   dbm.closeConnection(true);
   return executingCommand;
 }