thebarslider
Programmer
Hello,
I am attempting to run a wildcard match in a Prepared Statement using a Placeholder, unfortunatley this doesnt seem to work. I think the statement is trying to match the entire string dis. Does anyone have a suggestion of how this should be done, i cannot find any examples on the Internet.
My Code is below.
Thank you in advance for your help.
Mark.
String dis = "'%"+district.trim()+"%'";
try {
// build and execute procedure
PreparedStatement findStmt = con.prepareStatement("SELECT DISTINCT (venuid) FROM venue WHERE street LIKE ?");
findStmt.setString(1,dis);
ResultSet rs = findStmt.executeQuery();
while (rs.next()) {
v.add(rs.getString(1));
}
con.commit();
findStmt.close();
} catch (SQLException e) {
e.printStackTrace();
con.rollback();
System.out.println("ERROR 2702: CLASS DistrictDB:" +e);
}
I am attempting to run a wildcard match in a Prepared Statement using a Placeholder, unfortunatley this doesnt seem to work. I think the statement is trying to match the entire string dis. Does anyone have a suggestion of how this should be done, i cannot find any examples on the Internet.
My Code is below.
Thank you in advance for your help.
Mark.
String dis = "'%"+district.trim()+"%'";
try {
// build and execute procedure
PreparedStatement findStmt = con.prepareStatement("SELECT DISTINCT (venuid) FROM venue WHERE street LIKE ?");
findStmt.setString(1,dis);
ResultSet rs = findStmt.executeQuery();
while (rs.next()) {
v.add(rs.getString(1));
}
con.commit();
findStmt.close();
} catch (SQLException e) {
e.printStackTrace();
con.rollback();
System.out.println("ERROR 2702: CLASS DistrictDB:" +e);
}