I am trying to query a MS Access database from my java code and I am having no luck with the % wildcard that I read should work in other posts. The LIKE operator works if I exclude the wild cards from my code and provide the searchText variable with a value that matches exactly to a records Description. Below is the String queries I have tried that have either returned null or an exception:
String tableName = "SSPWO"; String desc = "[Description]";
String query = String.format("SELECT * FROM %s WHERE " + desc + " LIKE '%" searchText + "%' ORDER BY [WorkOrderNo] DESC", tableName);
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
String tableName = "SSPWO"; String desc = "[Description]";
String query = String.format("SELECT * FROM %s WHERE " + desc + " LIKE '*" searchText + "*' ORDER BY [WorkOrderNo] DESC", tableName);
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
String tableName = "SSPWO"; String desc = "[Description]";
String query = String.format("SELECT * FROM %s WHERE " + desc + " LIKE \"%" searchText + "%\" ORDER BY [WorkOrderNo] DESC", tableName);
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
String tableName = "SSPWO"; String desc = "[Description]";
String query = String.format("SELECT * FROM %s WHERE " + desc + " LIKE \'%" searchText + "%\' ORDER BY [WorkOrderNo] DESC", tableName);
Any help is greatly appreciated.