Here you can find the source of createUpdateTemplate(String table, Iterable
public static String createUpdateTemplate(String table, Iterable<String> columns)
//package com.java2s; import java.util.Iterator; public class Main { /**/*from w w w. ja v a 2s .c o m*/ * A static helper method for generating SQL templates for UPDATE * statements for the provided column colection or array * * @note: This method returns templates that do not have WHERE clauses. It's * up to the caller to append an appropriate WHERE clause, or else executing * the resulting query will update every single row in the table. */ public static String createUpdateTemplate(String table, Iterable<String> columns) { // StringBuilder builder = new StringBuilder(); builder.append("update ").append(table).append(" set "); Iterator<String> it = columns.iterator(); while (it.hasNext()) { builder.append(it.next()).append(" = ?"); if (it.hasNext()) builder.append(", "); } return builder.append(" ").toString(); } }