Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Searching a column with Firebird 1.5

843854Jan 20 2004 — edited Jan 20 2004
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)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 17 2004
Added on Jan 20 2004
1 comment
138 views