Tabnine Logo
ConnectionPool
Code IndexAdd Tabnine to your IDE (free)

How to use
ConnectionPool
in
snaq.db

Best Java code snippets using snaq.db.ConnectionPool (Showing top 20 results out of 315)

origin: zendesk/maxwell

private ConnectionPool getConnectionPool(MaxwellBootstrapUtilityConfig config) {
  String name = "MaxwellBootstrapConnectionPool";
  int maxPool = 10;
  int maxSize = 0;
  int idleTimeout = 10;
  String connectionURI = config.getConnectionURI();
  return new ConnectionPool(name, maxPool, maxSize, idleTimeout, connectionURI, config.mysql.user, config.mysql.password);
}
origin: zendesk/maxwell

public Connection getMaxwellConnection() throws SQLException {
  return this.maxwellConnectionPool.getConnection();
}
origin: zendesk/maxwell

private void shutdown(AtomicBoolean complete) {
  try {
    taskManager.stop(this.error);
    this.replicationConnectionPool.release();
    this.maxwellConnectionPool.release();
    this.rawMaxwellConnectionPool.release();
    complete.set(true);
  } catch (Exception e) {
    LOGGER.error("Exception occurred during shutdown:", e);
  }
}
origin: net.snaq/dbpool

 pool = new ConnectionPool(poolName, minPool, maxPool, maxSize, idleTimeout, url, poolProps);
else
 pool = new ConnectionPool(poolName, minPool, maxPool, maxSize, idleTimeout, url, user, pass);
 pool.registerMBean();
  else if (!f.exists() && !f.createNewFile())
   log_warn("Invalid logfile specified for pool " + poolName + " - cannot create file " + f.getAbsolutePath());
  pool.setLog(new PrintWriter(new FileOutputStream(f, true), true));
   pool.setLog(logUtil.getLogWriter());
 pool.setLog(logUtil.getLogWriter());
if (poolDebug)
 log_info("Enabling debug info on pool " + poolName);
  pool.getCustomLogger().setDateFormat(df);
pool.setCaching(!noCache);
if (async)
 log_info("Enabling asynchronous destruction on pool " + poolName);
pool.setAsyncDestroy(async);
if (releaseTimeout > -1)
 log_info(String.format("Enabling release timeout (%dms) on pool %s", releaseTimeout, poolName));
if (recycleAfterDelegateUse)
 log_info("Enabling recycling after raw connection use on pool " + poolName);
pool.setRecycleAfterDelegateUse(recycleAfterDelegateUse);
origin: net.snaq/dbpool

pool = new ConnectionPool(poolName, getMinPool(), getMaxPool(), getMaxSize(), getIdleTimeout(), getUrl(), props);
pool.addConnectionPoolListener(this);
if (getLogWriter() != null)
 pool.setLog(getLogWriter());
if (shutdownHook)
 pool.registerShutdownHook();
  pool.setValidator(cv);
 pool.setValidator(cv);
  pool.setPasswordDecoder(pd);
   pool.setSelectionStrategy(ObjectPool.Strategy.SELECT_FIFO);
   break;
  case "RANDOM":
   pool.setSelectionStrategy(ObjectPool.Strategy.SELECT_RANDOM);
   break;
  case "LIFO":
origin: zendesk/maxwell

this.metrics = new MaxwellMetrics(config);
this.replicationConnectionPool = new ConnectionPool("ReplicationConnectionPool", 10, 0, 10,
    config.replicationMysql.getConnectionURI(false), config.replicationMysql.user, config.replicationMysql.password);
  this.schemaConnectionPool = null;
} else {
  this.schemaConnectionPool = new ConnectionPool(
      "SchemaConnectionPool",
      10,
this.rawMaxwellConnectionPool = new ConnectionPool("RawMaxwellConnectionPool", 1, 2, 100,
  config.maxwellMysql.getConnectionURI(false), config.maxwellMysql.user, config.maxwellMysql.password);
this.maxwellConnectionPool = new ConnectionPool("MaxwellConnectionPool", 10, 0, 10,
      config.maxwellMysql.getConnectionURI(), config.maxwellMysql.user, config.maxwellMysql.password);
this.maxwellConnectionPool.setCaching(false);
origin: net.snaq/dbpool

/**
 * Sets the minimum number of pooled connections in the underlying {@link ConnectionPool}.
 * @param minPool minimum number of pooled connections
 */
public synchronized void setMinPool(int minPool)
{
 this.minPool = minPool;
 if (pool != null)
  pool.setParameters(this.minPool, pool.getMaxPool(), pool.getMaxSize(), pool.getIdleTimeout());
}
origin: net.snaq/dbpool

/**
 * Sets the maximum number of connections in the underlying {@link ConnectionPool}.
 * @param maxSize maximum number of connections
 */
public synchronized void setMaxSize(int maxSize)
{
 this.maxSize = maxSize;
 if (pool != null)
  pool.setParameters(pool.getMinPool(), pool.getMaxPool(), this.maxSize, pool.getIdleTimeout());
}
origin: net.snaq/dbpool

@Override
public synchronized void poolParametersChanged(ConnectionPoolEvent evt)
{
 synchronized(pool)
 {
  this.minPool = pool.getMinPool();
  this.maxPool = pool.getMaxPool();
  this.maxSize = pool.getMaxSize();
  this.idleTimeout = (int)pool.getIdleTimeout();
 }
}
origin: net.snaq/dbpool

/**
 * Sets the maximum number of pooled connections in the underlying {@link ConnectionPool}.
 * @param maxPool maximum number of pooled connections
 */
public synchronized void setMaxPool(int maxPool)
{
 this.maxPool = maxPool;
 if (pool != null)
  pool.setParameters(pool.getMinPool(), this.maxPool, pool.getMaxSize(), pool.getIdleTimeout());
}
origin: net.snaq/dbpool

/**
 * Creates a new {@code ConnectionPool} instance.
 * @param name pool name
 * @param minPool minimum number of pooled connections, or 0 for none
 * @param maxPool maximum number of pooled connections, or 0 for none
 * @param maxSize maximum number of possible connections, or 0 for no limit
 * @param idleTimeout idle timeout (seconds) for idle pooled connections, or 0 for no timeout
 * @param url JDBC connection URL
 * @param username database username
 * @param password password for the database username supplied
 */
public ConnectionPool(String name, int minPool, int maxPool, int maxSize, long idleTimeout, String url, String username, String password)
{
 super(name, minPool, maxPool, maxSize, idleTimeout);
 this.url = url;
 this.user = username;
 this.pass = password;
 this.props = null;
 setCaching(true);
 addObjectPoolListener(new EventRelay<>());
}
origin: net.snaq/dbpool

 pool.releaseImmediately();
else
 pool.release(timeout);
origin: net.snaq/dbpool

/**
 * Creates a new {@link CacheConnection} object, using the supplied {@link Connection}.
 * @param pool {@link ConnectionPool} to which this {@code CacheConnection} belongs
 * @param con {@link Connection} instance to which database calls should be delegated
 */
public CacheConnection(ConnectionPool pool, Connection con)
{
 this.pool = pool;
 this.con = con;
 setCacheAll(true);
 ssReq = ssHit = psReq = psHit = csReq = csHit = 0;
 // Send log output to same logger as the pool uses.
 logger = LoggerFactory.getLogger(pool.getClass().getName() + "." + pool.getName());
 logUtil = pool.getCustomLogger();
}
origin: net.snaq/dbpool

/**
 * Validates a {@link CacheConnection} object.
 * @param cc connection to validate
 * @return true if cc is valid, false otherwise
 */
@Override
protected boolean isValid(final CacheConnection cc)
{
 if (cc == null)
  return false;
 if (validator == null)
  return true;
 try
 {
  boolean valid = validator.isValid(cc.getRawConnection());
  if (!valid)
   firePoolEvent(ConnectionPoolEvent.Type.VALIDATION_ERROR);
  return valid;
 }
 catch (SQLException sqlx)
 {
  log_debug("SQLException during validation", sqlx);
  return false;
 }
}
origin: net.snaq/dbpool

/**
 * Overrides method to provide caching support.
 */
@Override
public void close() throws SQLException
{
 if (!open)
  return;  // Uphold the descriptive contract of Connection interface.
 open = false;
 closing = true;
 // Hand connection (self) back to the pool for reuse.
 pool.freeConnection(this);
 closing = false;
}
origin: zendesk/maxwell

public Connection getReplicationConnection() throws SQLException {
  return this.replicationConnectionPool.getConnection();
}
origin: net.snaq/dbpool

/**
 * Releases the delegate {@link ConnectionPool} instance.
 */
public void release()
{
 if (pool != null)
  pool.release();
}
origin: zendesk/maxwell

public Connection getRawMaxwellConnection() throws SQLException {
  return rawMaxwellConnectionPool.getConnection();
}
origin: net.snaq/dbpool

/**
 * Releases the delegate {@link ConnectionPool} instance allowing the
 * specified timeout before forcibly destroying connections.
 * A negative timeout is equivalent to no timeout, and the method will wait
 * for items to be checked in before destruction. If timeout &gt;= 0 then
 * items will be forcibly destroyed after the specified time has elapsed.
 * @param timeout timeout after which to forcibly destroy items (-1 for no timeout)
 */
public void release(long timeout)
{
 if (pool != null)
  pool.release(timeout);
}
origin: zendesk/maxwell

protected List<RecoveryInfo> getAllRecoveryInfos() throws SQLException {
  try ( Connection c = connectionPool.getConnection() ) {
    return getAllRecoveryInfos(c);
  }
}
snaq.dbConnectionPool

Javadoc

Implementation of a database connection pool.

Most used methods

  • <init>
    Creates a new ConnectionPool instance (with minPool=0).
  • getConnection
    Gets a Connection from the pool, waiting a maximum of timeout milliseconds for one to become availab
  • release
  • setCaching
    Determines whether to perform statement caching.
  • addConnectionPoolListener
    Adds a ConnectionPoolListener to the event notification list.
  • addObjectPoolListener
  • firePoolEvent
    Fires an ConnectionPoolEvent to all listeners. 'type' should be one of ConnectionPoolEvent types.
  • freeConnection
    Returns a Connection to the pool (for internal use only). Connections obtained from the pool should
  • getCustomLogger
  • getIdleTimeout
  • getMaxPool
  • getMaxSize
  • getMaxPool,
  • getMaxSize,
  • getMinPool,
  • getName,
  • init,
  • isRecycleAfterDelegateUse,
  • log_debug,
  • log_info,
  • log_warn,
  • registerMBean

Popular in Java

  • Parsing JSON documents to java classes using gson
  • compareTo (BigDecimal)
  • setScale (BigDecimal)
  • getExternalFilesDir (Context)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now