public void close() { Base.close(); }
public void open() { Base.open(globalProps.getProperty("jdbcClass"), globalProps.getProperty("jdbcUrl"), globalProps.getProperty("jdbcUser"), globalProps.getProperty("jdbcPwd")); }
@Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { long before = System.currentTimeMillis(); try{ Base.open(jndiName); Base.openTransaction(); chain.doFilter(req, resp); Base.commitTransaction(); } catch (IOException e){ Base.rollbackTransaction(); throw e; } catch (ServletException e){ Base.rollbackTransaction(); throw e; } finally{ Base.close(); } LOGGER.info("Processing took: {} milliseconds", System.currentTimeMillis() - before); }
@Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { long before = System.currentTimeMillis(); try{ Base.open(jndiName); Base.openTransaction(); chain.doFilter(req, resp); Base.commitTransaction(); } catch (IOException e){ Base.rollbackTransaction(); throw e; } catch (ServletException e){ Base.rollbackTransaction(); throw e; } finally{ Base.close(); } logger.info("Processing took: {} milliseconds", System.currentTimeMillis() - before); }
@Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { long before = System.currentTimeMillis(); try{ Base.open(jndiName); Base.openTransaction(); chain.doFilter(req, resp); Base.commitTransaction(); } catch (IOException e){ Base.rollbackTransaction(); throw e; } catch (ServletException e){ Base.rollbackTransaction(); throw e; } finally{ Base.close(); } LOGGER.info("Processing took: {} milliseconds", System.currentTimeMillis() - before); }
@Override protected void afterExecute(Runnable r, Throwable t) { if (t != null) { Base.close(); } }
public static void connect(String[] db_connection) { Base.open("com.mysql.jdbc.Driver", "jdbc:mysql://" + db_connection[0] + "/" + db_connection[1] + "", db_connection[2], db_connection[3]); }
/** * @param command command to execute. */ @Override public <T extends Command> void onCommand(T command) { try { if(jndiConnection != null){ Base.open(jndiConnection); }else{ Base.open(); } Base.openTransaction(); command.execute(); Base.commitTransaction(); } catch (Exception e) { try { if (Base.hasConnection()) { Base.rollbackTransaction(); } } catch (Exception ignore) {} onException(command, e); } finally { try { Base.close(); } catch (Exception ignore) {} } }
public void disconnect() { Base.close(); }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); Base.open("com.mysql.jdbc.Driver", "jdbc:mysql://" + db_connection[0] + "/" + db_connection[1] + "", db_connection[2], db_connection[3]); processed = 0; inserted = 0; }
/** * @param command command to execute. */ @Override public <T extends Command> void onCommand(T command) { try { if(jndiConnection != null){ Base.open(jndiConnection); }else{ Base.open(); } Base.openTransaction(); command.execute(); Base.commitTransaction(); } catch (Exception e) { try { if (Base.hasConnection()) { Base.rollbackTransaction(); } } catch (Exception ignore) {} onException(command, e); } finally { try { Base.close(); } catch (Exception ignore) {} } }
@Override public void destroy() { try { Base.close(); } catch (Exception e) { LOG.warn("could not close conn", e); } } }
TLibDataSource() { Properties properties = new Properties(); properties.put("jdbcUrl", TLib.getTLib().getConfig().getJdbcUrl()); properties.put("username", TLib.getTLib().getConfig().getUsername()); properties.put("password", TLib.getTLib().getConfig().getPassword()); properties.put("dataSourceClassName", TLib.getTLib().getConfig().getDataSourceClassName()); properties.put("driverClassName", TLib.getTLib().getConfig().getDriverClassName()); TLib.getTLib().getConfig().getSettings().forEach((k, v) -> properties.put("dataSource." + k, v)); dataSource = new HikariDataSource(new HikariConfig(properties)); Base.open(dataSource); }
public static void reConnect(String[] db_connection) { try { Base.close(); } catch (Exception e) {// nope } connect(db_connection); }
private Pool() { super(TLib.getTLib().getConfig().getMaximumPoolSize(), TLib.getTLib().getConfig().getMaximumPoolSize(), 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>()); try { dataSource = new TLibDataSource(); this.setThreadFactory(r -> new Thread(() -> { Base.open(dataSource.getDataSource()); r.run(); }, "TabooLib-DbPool-" + number.getAndIncrement())); prestartAllCoreThreads(); TLocale.sendToConsole("DATABASE.CONNECTION-ESTABLISHED", dataSource.getDataSource().getConnection().getMetaData().getDatabaseProductName(), String.valueOf(TLib.getTLib().getConfig().getMaximumPoolSize())); } catch (Exception e) { TLocale.sendToConsole("DATABASE.CONNECTION-ERROR", e.toString()); throw new RuntimeException(); } }