Insert default group values

This commit is contained in:
gravitylow committed 2013-10-14 18:59:33 -04:00
1 parent 7acdb6b304
commit 9d0248d42a
1 file changed
+10
@@ -52,12 +52,22 @@ public class MySQLGroupsHolder extends ConfigurationTable implements Groups {
" `color` VARCHAR(45) NOT NULL," +
" `actions` VARCHAR(45) NOT NULL," +
" PRIMARY KEY (`id`));";
String sqlPopulate = "INSERT INTO " + getFullTable() +
" SELECT t.*" +
" FROM (" +
" (SELECT 1 as id, 'Medium' as name, 20 as level, 'YELLOW' as color, 'WARN' as actions)" +
" UNION ALL " +
" (SELECT 2 as id, 'High' as name, 50 as level, 'RED' as color, 'KICK' as actions)" +
" ) t" +
" WHERE NOT EXISTS (SELECT * FROM " + getFullTable() + ");";
String sqlLoad = "SELECT * FROM " + getFullTable();
try {
getConnection().prepareStatement(sqlCreate).executeUpdate();
getConnection().prepareStatement(sqlPopulate).executeUpdate();
getConnection().commit();
ResultSet set = getConnection().prepareStatement(sqlLoad).executeQuery();
while (set.next()) {
String name = set.getString("name");