复制代码代码如下:
/**
* TODO 循环赋值,缺少的类型可随时添加
* @author Lucius
* @param pt
* @param list
* @throws SQLException
*/
public static void setParam(PreparedStatement pt, List list) throws SQLException{
for(int i = 0;i<list.size();i++){
if (list.get(i) instanceof String) pt.setString(i+1, list.get(i).toString());
else if(list.get(i) instanceof Integer) pt.setInt(i+1, Integer.parseInt(list.get(i).toString()));
else if(list.get(i) instanceof Short)pt.setShort(i+1, Short.parseShort(list.get(i).toString()));
else pt.setObject(i+1, list.get(i));
}
}