Ejemplo n.º 1
0
  public VehicleCategory searchCategory(String searchText)
      throws SQLException, ClassNotFoundException {
    Connection connection = DataBaseConnection.getConnection();
    Statement createStatement = connection.createStatement();
    String sql =
        "SELECT description FROM VEHICLECATEGORY where vehiclecategoryid = '" + searchText + "';";
    ResultSet set = createStatement.executeQuery(sql);

    VehicleCategory category = new VehicleCategory();

    while (set.next()) {
      category.setDescription(set.getString("description"));
    }
    return category;
  }
Ejemplo n.º 2
0
 public boolean addVehicleCAtegory(VehicleCategory vehicleCategory)
     throws SQLException, ClassNotFoundException {
   Connection connection = DataBaseConnection.getConnection();
   Statement createStatement = connection.createStatement();
   String sql =
       "INSERT INTO VEHICLECATEGORY(vehiclecategoryid, description) values('"
           + vehicleCategory.getVehicleCategoryId()
           + "','"
           + vehicleCategory.getDescription()
           + "');";
   int res = createStatement.executeUpdate(sql);
   if (res == 1) {
     return true;
   } else {
     return false;
   }
 }