title: c3p0 "getConnection" is slow
body: <p>I'm using c3p0 connection pool for communication between my (unsigned) Java applet and MySql db.
  I have this code for initializing pool:</p>
  
  <pre><code>DataSource pool = pools.get(db_name);
  if(pool == null) 
      pool = initializePool(db_name);
  return pool.getConnection();
  </code></pre>
  
  <p>Initialize pool method looks like this:</p>
  
  <pre><code>protected DataSource initializePool(String db_name) throws SQLException {
      try {
          ComboPooledDataSource cpds = new ComboPooledDataSource();
          cpds.setDriverClass("com.mysql.jdbc.Driver");
          cpds.setJdbcUrl(connectionDetails.getConnectionString(db_name));
          cpds.setUser(connectionDetails.getUsername()); 
          cpds.setPassword(connectionDetails.getPassword());
          pools.put(db_name, cpds);
          return cpds;
      } catch (PropertyVetoException e) {
          e.printStackTrace();
          throw new SQLException("JDBC driver could not be initialized propertly");   
      }
  }
  </code></pre>
  
  <p>My c3p0-config.xml is simple:</p>
  
  <pre><code>&lt;c3p0-config&gt;&lt;default-config&gt;
  &lt;property name="acquireIncrement"&gt;1&lt;/property&gt;
  &lt;property name="initialPoolSize"&gt;5&lt;/property&gt;
  &lt;property name="minPoolSize"&gt;1&lt;/property&gt;
  &lt;property name="maxPoolSize"&gt;7&lt;/property&gt;
  &lt;property name="maxConnectionAge"&gt;0&lt;/property&gt;
  &lt;property name="maxIdleTime"&gt;600&lt;/property&gt;
  &lt;property name="maxIdleTimeExcessConnections"&gt;120&lt;/property&gt; 
  &lt;property name="automaticTestTable"&gt;C3p0_test_table&lt;/property&gt;
  &lt;property name="idleConnectionTestPeriod"&gt;60&lt;/property&gt;
  &lt;property name="testConnectionOnCheckin"&gt;true&lt;/property&gt;&lt;/default-config&gt;&lt;/c3p0-config&gt;
  </code></pre>
  
  <p>The problem is that "getConnection" call takes sometimes even 10 or more seconds to respond when i call a database for the first time (second time i contact a db it's faster). I've been looking all over the net and "c3p0" manual for way to speedup connection pool without luck.</p>
  
  <p>When i run my applet (from server) java console output looks like this:</p>
  
  <pre><code>Jan 16, 2013 12:57:14 PM com.mchange.v2.log.MLog &lt;clinit&gt;
  INFO: MLog clients using java 1.4+ standard logging.
  Jan 16, 2013 12:57:16 PM com.mchange.v2.c3p0.C3P0Registry &lt;clinit&gt;
  INFO: jdk1.5 management interfaces unavailable... JMX support disabled.
  java.security.AccessControlException: access denied ("javax.management.MBeanServerPermission" "createMBeanServer")
      at java.security.AccessControlContext.checkPermission(Unknown Source)
      at java.security.AccessController.checkPermission(Unknown Source)
      at java.lang.SecurityManager.checkPermission(Unknown Source)
      at java.lang.management.ManagementFactory.getPlatformMBeanServer(Unknown Source)
      at com.mchange.v2.c3p0.management.ActiveManagementCoordinator.&lt;init&gt;(ActiveManagementCoordinator.java:42)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at java.lang.Class.newInstance0(Unknown Source)
      at java.lang.Class.newInstance(Unknown Source)
      at com.mchange.v2.c3p0.C3P0Registry.&lt;clinit&gt;(C3P0Registry.java:134)
      at com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase.&lt;init&gt;(PoolBackedDataSourceBase.java:228)
      at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.&lt;init&gt;(AbstractPoolBackedDataSource.java:62)
      at com.mchange.v2.c3p0.ComboPooledDataSource.&lt;init&gt;(ComboPooledDataSource.java:109)
      at com.mchange.v2.c3p0.ComboPooledDataSource.&lt;init&gt;(ComboPooledDataSource.java:105)
      ...
  
  Jan 16, 2013 12:57:16 PM com.mchange.v2.c3p0.C3P0Registry banner
  INFO: Initializing c3p0-0.9.1.2 [built 21-May-2007 15:05:05; debug? true; trace: 10]
  Jan 16, 2013 12:57:16 PM com.mchange.v2.c3p0.PoolConfig &lt;clinit&gt;
  WARNING: Read of system Properties blocked -- ignoring any c3p0 configuration via System properties! (But any configuration via a c3p0.properties file is still okay!)
  java.security.AccessControlException: access denied ("java.util.PropertyPermission" "*" "read,write")
      at java.security.AccessControlContext.checkPermission(Unknown Source)
      at java.security.AccessController.checkPermission(Unknown Source)
      at java.lang.SecurityManager.checkPermission(Unknown Source)
      at java.lang.SecurityManager.checkPropertiesAccess(Unknown Source)
      at java.lang.System.getProperties(Unknown Source)
      at com.mchange.v2.c3p0.PoolConfig.&lt;clinit&gt;(PoolConfig.java:101)
      at com.mchange.v2.c3p0.impl.C3P0ImplUtils.defaultConnectionTester(C3P0ImplUtils.java:283)
      at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.&lt;init&gt;(WrapperConnectionPoolDataSource.java:47)
      at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.&lt;init&gt;(WrapperConnectionPoolDataSource.java:67)
      at com.mchange.v2.c3p0.ComboPooledDataSource.&lt;init&gt;(ComboPooledDataSource.java:114)
      at com.mchange.v2.c3p0.ComboPooledDataSource.&lt;init&gt;(ComboPooledDataSource.java:105)
      ...
  
  started taking connection - Wed Jan 16 12:57:16 CET 2013
  Jan 16, 2013 12:57:20 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
  INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ some connection info and params for DB1]
  Connection taken - Wed Jan 16 12:57:23 CET 2013
  started taking connection - Wed Jan 16 12:57:23 CET 2013
  Jan 16, 2013 12:57:24 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
  INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ some connection info and params for DB2]
  Connection taken - Wed Jan 16 12:57:24 CET 2013
  </code></pre>
  
  <p>What am i missing? Is there a way to speed up process of getting connection? I thought that it might be a server issue, but i'm having those lags even when i run my applet from eclipse (and make it contact remote database at server). Please help, or at least explain me why getting connection is so slow?</p>