设一个变量String 类型 付一个默认值

解决方案 »

  1.   

    一个比较麻烦、效率不高的方法:你可以自己加一个判断,如果为null,就把?替换为a的最小值。这个最小值可以用SQL查询得出。
      

  2.   

    呵呵,只能解决这类问题的一个特例啊
    如果〉变成=呢?或者其他?
    呵呵,两位的办法不管用了吧:)问题的实质是如何解决动态sql运行期发现条件过多的情况呵呵,还请大家多多考虑多多指教:)
      

  3.   

    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!