public class Main { public static void main(String[] args) { String[] fields = { "name", "position", "salary" }; String table = "employee"; String insert = buildInsertSql(table, fields); System.out.println(insert); String s = "INSERT INTO employee (name, position, salary) VALUES (?, ?, ?)"; System.out.println(s.equals(insert) ? "Success" : "Fail"); } static String buildInsertSql(String table, String[] fields) { // TODO: StringBuilder sb = new StringBuilder(1024); sb.append("INSERT INTO employee (") .append(String.join(", ", fields)) .append(") VALUES (?, ?, ?)"); return sb.toString(); } }
~(@^_^@)~
Sign in to make a reply
清尘