hey im working on web application in netbeans and i use the jdbc to store info , im working on search function - the user enter name in string the name could be the exact name or it could be substring of the name i write this function but its not working i may do something wrong :
public List<Book> getListOfBooks(String value) throws SQLException{
PreparedStatement pStatement ;
List<Book> List = new ArrayList<>();
try {
pStatement = connection.prepareStatement("select * from BOOKS where BOOK_NAME like %?%");
pStatement.setString(1, value);
ResultSet rs =pStatement.executeQuery();
while (rs.next()) {
Book book = new Book();
book.setIsbn(rs.getString("ISBN"));
book.setName(rs.getString("BOOK_NAME"));
book.setAuthor(rs.getString("AUTHOR"));
book.setCategory(rs.getString("CATEGORY"));
book.setPublishing(rs.getString("PUBLISHING"));
List.add(book);
}
} catch (SQLException ex) {
Logger.getLogger(BookDB.class.getName()).log(Level.SEVERE, null, ex);
}
return List;
}
the function return empty list and i dont find whats wrong , ty for help.