The code itself is simple. When splicing sql? Not easy to count, simply used for assignment.
Copy the code code as follows:
/**
* TODO circular assignment, missing types can be added at any time
* @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));
}
}