Skip to content

Commit

Permalink
Add stringbuilder method and check
Browse files Browse the repository at this point in the history
  • Loading branch information
lahiru-rajapakshe committed May 30, 2022
1 parent dfb8526 commit 488745d
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@ public void bootstrap() throws SQLException {
}
if (primaryKey == null) throw new RuntimeException("Entity without a primary key");


StringBuilder sb = new StringBuilder();
sb.append("CREATE TABLE IF NOT EXISTS ").append(tableName).append("(");
for (String column : columns) {
sb.append(column).append(" VARCHAR(255),");
}
sb.append(primaryKey).append(" VARCHAR(255) PRIMARY KEY)");
System.out.println(sb);
Statement stm = connection.createStatement();
stm.execute(sb.toString());
}
}
}

0 comments on commit 488745d

Please sign in to comment.