假设你的参数有name,age,city但是不知道有么有值。
StringBuffer sql = new StringBuffer("select * from tab where 1=1")if (name != null && !"".equals(name)){
sql.append(" and name="+name)
}
if (age != null && !"".equals(age)){
sql.append(" and age="+age)
}
if (city!= null && !"".equals(city)){
sql.append(" and city="+city)
}
这样拼接出sql语句。
组装数据就好了
Connection conn = 链接Statement stmt = conn.createStatementI()
String table = "PFO_ANALYSE_BRANCH"//我这里定义的table在你那边应该是用户传过来的数据
String sql = "CREATE TABLE "+table +" ( "
+" NODE_NAME_S VARCHAR2(50 BYTE), "
+ 其他字段
+")"
stmt.execute(sql)