Answers for "jdbc where like parameter"

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 "Java"

Java Answers by Framework

Browse Popular Code Answers by Language