public DBUtil getDbUtil () throws Exception { return new DBUtil(getJDBCUrl(), getUserName(), getPassword(), getDriver()); }
public static String getJDBCUrl() { return new StringBuilder().append("jdbc:derby://").append(getHostAddress()).append(":").append(getPort()) .append("/experiment_catalog;create=true;user=").append(getUserName()).append(";password=") .append(getPassword()).toString(); }
public Connection getConnection() throws Exception { DBUtil dbUtil = getDbUtil (); Connection connection = dbUtil.getConnection(); connection.setAutoCommit(true); return connection; }
public static void executeSQL(String sql) throws Exception { DBUtil dbUtil = new DBUtil(getJDBCUrl(), getUserName(), getPassword(), getDriver()); dbUtil.executeSQL(sql); }
public static void waitTillServerStarts() { DBUtil dbUtil = null; try { dbUtil = new DBUtil(getJDBCUrl(), getUserName(), getPassword(), getDriver()); } catch (Exception e) { // ignore } Connection connection = null; try { if (dbUtil != null) { connection = dbUtil.getConnection(); } } catch (Throwable e) { // ignore } while (connection == null) { try { Thread.sleep(1000); try { if (dbUtil != null) { connection = dbUtil.getConnection(); } } catch (SQLException e) { // ignore } } catch (InterruptedException e) { // ignore } } }