hey all,
i am using firebird and i need to make a SQL statement so that i can search a column called 'headerkeywords'.
and to make it handle multiple words
this is what i got.
private static final String SQL_SEARCH_HEADERS = "SELECT * FROM KBARTICLES WHERE HEADERKEYWORDS LIKE";
public Vector getArticlesByHeaderSearch(String searchstring) throws Exception {
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
Vector articles = new Vector();
try {
conn = getConnection();
String likeStr = "'%" + searchstring + " %'";
ps = conn.prepareStatement(SQL_SEARCH_HEADERS + " " + likeStr);
rs = ps.executeQuery();
while(rs.next()) {
KBArticle article = new KBArticle();
article.setId(rs.getInt(1));
article.setHeader(rs.getString(2));
article.setCreated(rs.getDate(3));
article.setLastUpdate(rs.getDate(4));
article.setStatus(getKBStatus(rs.getInt(5)));
article.setCat(getKBCat(rs.getInt(6)));
articles.add(article);
}
} finally {
try {rs.close();} catch (NullPointerException ex) {}
try {ps.close();} catch (NullPointerException ex) {}
try {closeConnection(conn);} catch (NullPointerException ex) {}
}
return articles;
}
the error i get is:
org.firebirdsql.jdbc.FBSQLException: GDS Exception. Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, char 79
LIKE
at org.firebirdsql.jdbc.FBPreparedStatement.<init>(FBPreparedStatement.java:82)