First , make a Stringbuffer: StringBuffer sqlStr = new StringBuffer("select a from tba where")then base on the user's input , append where clause like this: sqlStr.append("a = ?"); sqlStr.append("c = ?"); and put the user's input value in a collectionlast step, iterator the collection to set up the PreparedStatement's value.Hope help!
如果〉变成=呢?或者其他?
呵呵,两位的办法不管用了吧:)问题的实质是如何解决动态sql运行期发现条件过多的情况呵呵,还请大家多多考虑多多指教:)
StringBuffer sqlStr = new StringBuffer("select a from tba where")then base on the user's input , append where clause like this:
sqlStr.append("a = ?");
sqlStr.append("c = ?");
and put the user's input value in a collectionlast step, iterator the collection to set up the PreparedStatement's value.Hope help!