java - UcanaccessSQLException: UCAExc:::3.0.1 data type of expression is not boolean -


i have table following image

enter image description here

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

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -