Square Bracket Wildcard not functioning when trying to make SQL selection in UcanAccess JDBC

244 views Asked by At

I'm making a project in Java that requires a selection query from an MS Access database using UCanAccess. When I try to create an SQL statement using [] brackets (in order to specify a list of chars as wildcards), I keep getting back 0 results. Here's the code (I use Guava library for the joiner class in order to make a string out of char array 'yellow'):

String y1 = Joiner.on("").join(yellow);
String q2 = "SELECT * FROM Wordlist WHERE Words LIKE '*["+y1+"]*'";
Statement stmt2 = connection.createStatement();
ResultSet rs2 = stmt2.executeQuery(q2);
int wcount1 = 0;
while (rs2.next()) {
    wcount1++;
}
System.out.println(wcount1);

My variable wcount1 comes up as zero whenever I run this program. The weird part is when I only use the * with variable y1 I get the correct number of records, but the square brackets keep showing up zero. Is this a syntax error? Do I need to do some kind of escape sequence?

0

There are 0 answers