Answers for "who to use like in sql in java prepared statement"

0

jdbc where like parameter

private List getTopics (Connection conn, String searchCriteria)
throws SQLException
{
  List blogs = new LinkedList();
  String query = "SELECT id, text FROM blogs WHERE UPPER(text) LIKE ?";
  try
  {
    // going to do a search using "upper"
    searchCriteria = searchCriteria.toUpperCase();

    // create the preparedstatement and add the criteria
    PreparedStatement ps = conn.prepareStatement(query);
    ps.setString(1, "%" + searchCriteria + "%");
    
 ...
 
}
Posted by: Guest on January-03-2021

Code answers related to "who to use like in sql in java prepared statement"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language