//Drop what is there now, if exists. We want to start fresh.
String sqlCreateCmd = TestEnvironmentUtil.readTextFile(new File(resourceDir.getCanonicalPath() + "/message-store-sql/hsqldb/create_database.sql"));
String sqlDropCmd = TestEnvironmentUtil.readTextFile(new File(resourceDir.getAbsolutePath() + "/message-store-sql/hsqldb/drop_database.sql"));
ConnectionManager mgr = ConnectionManagerFactory.getConnectionManager();
mgr.init();
Connection con = mgr.getConnection();
Statement stmnt = con.createStatement();
System.out.println("Dropping the schema if exist");
stmnt.execute(sqlDropCmd);
System.out.println("Creating the message store schema");
stmnt.execute(sqlCreateCmd);
} else if ("com.mysql.jdbc.Driver".equals(Configuration.getStoreDriver())) {
String sqlCreateCmd = TestEnvironmentUtil.readTextFile(new File(resourceDir.getCanonicalPath() + "/message-store-sql/mysql/create_database.sql"));
String sqlDropCmd = TestEnvironmentUtil.readTextFile(new File(resourceDir.getCanonicalPath() + "/message-store-sql/mysql/drop_database.sql"));
ConnectionManager mgr = ConnectionManagerFactory.getConnectionManager();
mgr.init();
Connection con = mgr.getConnection();
Statement stmnt = con.createStatement();
System.out.println("Dropping the schema if exist");
stmnt.execute(sqlDropCmd);
System.out.println("Creating the message store schema");
stmnt.execute(sqlCreateCmd);
} else if ("org.postgresql.Driver".equals(Configuration.getStoreDriver())) {
String sqlCreateCmd = TestEnvironmentUtil.readTextFile(new File(resourceDir.getCanonicalPath() + "/message-store-sql/postgresql/create_database.sql"));
String sqlDropCmd = TestEnvironmentUtil.readTextFile(new File(resourceDir.getCanonicalPath() + "/message-store-sql/postgresql/drop_database.sql"));
ConnectionManager mgr = ConnectionManagerFactory.getConnectionManager();
mgr.init();
Connection con = mgr.getConnection();
Statement stmnt = con.createStatement();
System.out.println("Dropping the schema if exist");
try {
stmnt.execute(sqlDropCmd);
} catch (Exception e) {}