public List<Product> getListOfProductsWhere(String name, int productscol, double cost, String check) { List<Product> listOfProducts = jdbcTemplateObject.query(SELECT * FROM products WHERE name LIKE %?%, returnArray(name, productscol, cost, check), new RowMapper<Product>() { @Override public Product mapRow(ResultSet rs, int rowNum) throws SQLException { Product product = new Product(); product.setId(rs.getInt("id")); product.setName(rs.getString("name")); product.setDate(rs.getDate("date")); product.setProductscol(rs.getInt("productscol")); product.setCost(rs.getDouble("cost")); product.setId_user(rs.getInt("users_user_id")); return product; } }); return listOfProducts; } Mistake
Mon Apr 25 23:40:21 SAMT 2016 There was an unexpected error (type = Internal Server Error, status = 500). PreparedStatementCallback; bad SQL grammar [SELECT * FROM products WHERE name LIKE%?%]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the syntax for your right syntax to use the '%' chocolate '% at line 1