I am trying to query a Firebird database from a Java application. This query contains 2 integer variables and 1 string. The query looks like this:
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery("select * from table where
column1 < " + intvariable1 + " and (
column2 > " + intvariable2 +" or column2 = 0) and
column3 = '" + stringvariable + "' ";
Rs.next();
syso(rs.getInt(1));
It appears that the ResultSet
is empty but when I use a hardcoded string value instead of a variable I get the expected result.
I also tried this with preparedstatements
with the same result - it is only working without string variable.
Any ideas what I am doing wrong?
EDIT: Problem solved! The Stringvariable came from a BLOB Field and had some empty values within it. Calling the trim function deleted those.