private static final String SQL_INSERT = "INSERT INTO ${table}(${keys}) VALUES(${values})";
private static final String SQL_CREATE = "CREATE TABLE ${table}(${keys} VARCHAR(20) NOT NULL)";
private static final String TABLE_REGEX = "\\$\\{table\\}";
private static final String KEYS_REGEX = "\\$\\{keys\\}";
private static final String VALUES_REGEX = "\\$\\{values\\}";
String[] headerRow = csvReader.readNext();//getting(Machine Name , Value)
String[] stripedHeaderRow = StringUtils.stripAll(headerRow);
String query2 = SQL_CREATE.replaceFirst(TABLE_REGEX, tableName);
query2 = query2.replaceFirst(KEYS_REGEX, StringUtils.join(headerRow, " VARCHAR(20) NOT NULL,"));
结果:
"Machine Name, Value"
预期结果:
"MachineName , Value"