java - UcanaccessSQLException: UCAExc:::3.0.1 data type of expression is not boolean -
i have table following image
i need english words kurdish word contains "بةرز",
cant use
select english table1 kurdish '%بةرز%';
because accepts words sub-string in word these ،يبلبةرز ، سيس بةرز ,
, when try use regular expression in query:
query = "select english table1 kurdish regexp '^[.، ]*("+"بةرز" +")[ ،.]*$'"; s.execute(query);
it shows following exception
net.ucanaccess.jdbc.ucanaccesssqlexception: ucaexc:::3.0.1 data type of expression not boolean
is problem regular expression or what?
note i'am using ucanaccess database connection
instead of
columnname regexp 'pattern'
i believe need use
regexp_matches(columnname, 'pattern')
this seems work me ...
string targetstring = "بةرز"; try (preparedstatement ps = conn.preparestatement( "select english table1 " + "where kurdish = ? " + "or regexp_matches(kurdish, ?) " + "or regexp_matches(kurdish, ?) " + "or regexp_matches(kurdish, ?) ")) { ps.setstring(1, targetstring); ps.setstring(2, "^" + targetstring + "[.، ]+.*"); ps.setstring(3, ".*[.، ]+" + targetstring + "$"); ps.setstring(4, ".*[.، ]+" + targetstring + "[.، ]+.*"); try (resultset rs = ps.executequery()) { while (rs.next()) { system.out.println(rs.getstring(1)); } } }
... although there might more elegant way of doing it.
Comments
Post a Comment