Repository: brettwooldridge/HikariCP-benchmark
Branch: master
Commit: ede3501d4f55
Files: 23
Total size: 116.8 KB
Directory structure:
gitextract_jdhmdfc8/
├── .gitignore
├── README.md
├── benchmark.cmd
├── benchmark.sh
├── lib/
│ └── one-datasource.jar
├── pom.xml
├── spiketest.sh
└── src/
├── main/
│ ├── java/
│ │ └── com/
│ │ └── zaxxer/
│ │ └── hikari/
│ │ └── benchmark/
│ │ ├── BenchBase.java
│ │ ├── ConnectionBench.java
│ │ ├── StatementBench.java
│ │ └── stubs/
│ │ ├── StubConnection.java
│ │ ├── StubDataSource.java
│ │ ├── StubDriver.java
│ │ ├── StubPreparedStatement.java
│ │ ├── StubResultSet.java
│ │ └── StubStatement.java
│ └── resources/
│ └── log4j2-test.xml
└── test/
└── java/
├── com/
│ └── zaxxer/
│ └── hikari/
│ ├── benchmark/
│ │ ├── BandwidthTest.java
│ │ ├── DbDownTest.java
│ │ └── SpikeLoadTest.java
│ └── pool/
│ └── HikariPoolAccessor.java
└── org/
└── apache/
└── commons/
└── dbcp2/
├── DbcpPoolAccessor.java
└── TomcatPoolAccessor.java
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
target
.classpath
.project
.settings/org.eclipse.core.resources.prefs
.settings/org.eclipse.jdt.core.prefs
.settings/org.eclipse.m2e.core.prefs
.idea
HikariCP-benchmark.iml
jmh.out
================================================
FILE: README.md
================================================
[](https://www.versioneye.com/user/projects/55501400f7db0da74e00017f)

*ConnectionCycle* measures cycles of ``DataSource.getConnection()/Connection.close()``. *StatementCycle* measures cycles of ``Connection.prepareStatement()``, ``Statement.execute()``, ``Statement.close()``.
#### JMH Connection Pool Microbenchmarks
This set of microbenchmaks was developed to refine the [HikariCP](https://github.com/brettwooldridge/HikariCP) JDBC connection pool implementation, but it actually runs the same benchmarks across multiple pools.
We have come to understand that benchmarking on the JVM, which employs Dead Code Elimination (DCE), lock-coalescing, inlining, loop-unrolling, on-stack replacement (OSR) and a myriad of other tricks, renders most attempts at benchmarking completely invalid -- *including our own original benchmarks*. Read all the things that [even smart] [people get wrong](https://groups.google.com/forum/#!msg/mechanical-sympathy/m4opvy4xq3U/7lY8x8SvHgwJ) about benchmarking on the JVM.
The Oracle JVM performance team, primarily Aleksey Shipilёv, developed a microbenchmarking framework called JMH. It provides the infrastructure (if used properly) for accurate comparative measurement of JVM-based execution. If you are interested in microbenchmarking at all, or just curious about all the wonderful things the JVM does, I highly recommend reading [this slideshare](http://www.slideshare.net/ConstantineNosovsky/nosovsky-java-microbenchmarking).
#### How to run?
* ``git clone https://github.com/brettwooldridge/HikariCP-benchmark.git``
* ``cd HikariCP-benchmark``
* ``mvn clean package``
* ``./benchmark.sh``
The ``benchmark.sh`` script is a wrapper around JMH execution. A full run of the benchmark will take about 45 minutes for all pools.
There are several more options you can provide to the ``benchmark.sh``. There are a lot actually, but these are most useful...
**Specify Shorter Runs**<br/>
There are two options provided by the script: ``quick`` and ``medium``. *quick* will take about 5 minutes to run, *medium* will take about 20 minutes -- for all pools. It is extrememly boring to watch, and you can't do anything else on the PC where the benchmark is running without affecting the results, so have dinner, run some errands, etc.
```
./benchmark.sh quick
```
If specified with other options, ``quick`` or ``medium`` must be the first option.
-----------------------------------------------------------
**Specify Specific Pools**<br/>
```
./benchmark.sh -p pool=hikari,bone
```
Where ``pool`` is a comma-separated list (*hikari*, *dbcp2*, *tomcat*, *c3p0*, *vibur*). Specifying a specific pool or subset of pools will shorten run times.
-----------------------------------------------------------
**Specify Pool Size**<br/>
```
./benchmark.sh -p maxPoolSize=16
```
Pool size is only applicable for the *Connection Cycle* test, attempting to run the *Statement Cycle* test with a pool smaller than the number of threads (8) will result in testing failures. The *Connection Cycle* test runs with 8 threads, so to test a contrained pool condition set *maxPoolSize* to a smaller number (eg. 4).
-----------------------------------------------------------
**Specify which Benchmark**<br/>
There are two benchmarks in the suite currently: *ConnectionBench* and *StatementBench*. By default both benchmarks are run, but if you want to run one or the other you can use a JMH option using a regex (regular experession) to do so. For example, to only run the *StatementBench* use:
```
./benchmark.sh ".*Statement.*"
```
-----------------------------------------------------------
All of the options can be combined:
```
./benchmark.sh medium -p pool=hikari,vibur -p maxPoolSize=4 ".*Connection.*"
```
-----------------------------------------------------------
================================================
FILE: benchmark.cmd
================================================
@echo off
setlocal
set JAVA_OPTIONS=-server -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms1096m -Xmx1096m
call mvn clean package
set JMH_THREADS=-t 8
if "%2" == "-t" (
set JMH_THREADS=-t %3
shift /2
shift /2
)
set command=%~1
if "quick" == "%command%" (
java -jar target\microbenchmarks.jar -jvmArgs "%JAVA_OPTIONS%" -wi 3 -i 8 %JMH_THREADS% -f 2 %2 %3 %4 %5 %6 %7
)
if "medium" == "%command%" (
java -jar target\microbenchmarks.jar -jvmArgs "%JAVA_OPTIONS%" -wi 3 -f 8 -i 6 %JMH_THREADS% %2 %3 %4 %5 %6 %7
)
if "long" == "%command%" (
java -jar target\microbenchmarks.jar -jvmArgs "%JAVA_OPTIONS%" -wi 5 -f 20 -i 15 %JMH_THREADS% %2 %3 %4 %5 %6 %7
)
rem java -jar ./target/microbenchmarks.jar -jvmArgs "$JAVA_OPTIONS" -wi 3 -i 15 -t 8 $1 $2 $3 $4 $5 $6 $7 $8 $9
================================================
FILE: benchmark.sh
================================================
#!/bin/bash
JAVA_OPTIONS="-server -XX:-RestrictContended -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms1096m -Xmx1096m"
if [[ "clean" == "$1" ]]; then
mvn clean package
shift
fi
if [[ "gcprof" == "$1" ]]; then
JAVA_OPTIONS="$JAVA_OPTIONS -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps"
shift
fi
JMH_THREADS="-t 8"
if [[ "$2" == "-t" ]]; then
JMH_THREADS="-t $3"
set -- "$1" "${@:4}"
fi
if [[ "quick" == "$1" ]]; then
java -jar ./target/microbenchmarks.jar -jvmArgs "$JAVA_OPTIONS" -wi 3 -i 8 $JMH_THREADS -f 2 $2 $3 $4 $5 $6 $7 $8 $9
elif [[ "medium" == "$1" ]]; then
java -jar ./target/microbenchmarks.jar -jvmArgs "$JAVA_OPTIONS" -wi 3 -f 8 -i 6 $JMH_THREADS $2 $3 $4 $5 $6 $7 $8 $9
elif [[ "long" == "$1" ]]; then
java -jar ./target/microbenchmarks.jar -jvmArgs "$JAVA_OPTIONS" -wi 3 -i 15 $JMH_THREADS $2 $3 $4 $5 $6 $7 $8 $9
elif [[ "profile" == "$1" ]]; then
java -server $JAVA_OPTIONS -agentpath:/Applications/jprofiler8/bin/macos/libjprofilerti.jnilib=port=8849 -jar ./target/microbenchmarks.jar -r 5 -wi 3 -i 8 $JMH_THREADS -f 0 $2 $3 $4 $5 $6 $7 $8 $9
elif [[ "debug" == "$1" ]]; then
java -server $JAVA_OPTIONS -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y -jar ./target/microbenchmarks.jar -r 5 -wi 3 -i 8 -t 8 -f 0 $2 $3 $4 $5 $6 $7 $8 $9
else
java -jar ./target/microbenchmarks.jar -jvmArgs "$JAVA_OPTIONS" -wi 3 -i 15 -t 8 $1 $2 $3 $4 $5 $6 $7 $8 $9
fi
================================================
FILE: pom.xml
================================================
<!-- Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. This code is
free software; you can redistribute it and/or modify it under the terms of
the GNU General Public License version 2 only, as published by the Free Software
Foundation. Oracle designates this particular file as subject to the "Classpath"
exception as provided by Oracle in the LICENSE file that accompanied this
code. This code is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
more details (a copy is included in the LICENSE file that accompanied this
code). You should have received a copy of the GNU General Public License
version 2 along with this work; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. Please contact
Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA or visit www.oracle.com
if you need additional information or have any questions. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP-benchmark</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Auto-generated JMH benchmark</name>
<dependencies>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>3.1.0</version>
</dependency>
<!-- dependency> <groupId>io.dropwizard.metrics</groupId> <artifactId>metrics-core</artifactId>
<version>3.1.2</version> </dependency -->
<dependency>
<groupId>com.jolbox</groupId>
<artifactId>bonecp</artifactId>
<version>0.8.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
<version>8.5.34</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>one.datasource</groupId>
<artifactId>one</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/one-datasource.jar</systemPath>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.42</version>
</dependency>
<dependency>
<groupId>org.vibur</groupId>
<artifactId>vibur-dbcp</artifactId>
<version>22.2</version>
<exclusions>
<exclusion>
<artifactId>log4j</artifactId>
<groupId>log4j</groupId>
</exclusion>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.17.2</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.17.2</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4-1200-jdbc41</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.googlecode.addjars-maven-plugin</groupId>
<artifactId>addjars-maven-plugin</artifactId>
<version>1.0.5</version>
<executions>
<execution>
<goals>
<goal>add-jars</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${basedir}/lib</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<compilerVersion>1.8</compilerVersion>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>microbenchmarks</finalName>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.openjdk.jmh.Main</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/services/javax.annotation.processing.Processor</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: spiketest.sh
================================================
#!/bin/bash
JAVA_OPTIONS="-server -XX:-RestrictContended -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms1096m -Xmx1096m"
if [[ "clean" == "$1" ]]; then
mvn clean package
shift
fi
java -cp ./target/microbenchmarks.jar:./target/test-classes $JAVA_OPTIONS com.zaxxer.hikari.benchmark.SpikeLoadTest $1 $2 $3 $4 $5 $6 $7 $8 $9
================================================
FILE: src/main/java/com/zaxxer/hikari/benchmark/BenchBase.java
================================================
/*
* Copyright (C) 2014 Brett Wooldridge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zaxxer.hikari.benchmark;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
import java.util.concurrent.Executors;
import javax.sql.DataSource;
import com.alibaba.druid.filter.stat.MergeStatFilter;
import com.alibaba.druid.filter.stat.StatFilter;
import com.alibaba.druid.pool.DruidDataSource;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.tomcat.jdbc.pool.PoolProperties;
import org.apache.tomcat.jdbc.pool.PooledConnection;
import org.apache.tomcat.jdbc.pool.Validator;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.infra.BenchmarkParams;
import org.vibur.dbcp.ViburDBCPDataSource;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import one.datasource.DataSourceImpl;
@State(Scope.Benchmark)
public class BenchBase
{
protected static final int MIN_POOL_SIZE = 0;
@Param({ "hikari", "dbcp2", "tomcat", "c3p0", "vibur", "druid", "druid-stat", "druid-stat-merge" })
public String pool;
@Param({ "32" })
public int maxPoolSize;
@Param({ "jdbc:stub" })
public String jdbcUrl;
public static DataSource DS;
@Setup(Level.Trial)
public void setup(BenchmarkParams params)
{
try
{
Class.forName("com.zaxxer.hikari.benchmark.stubs.StubDriver");
System.err.printf("Using driver (%s): %s", jdbcUrl, DriverManager.getDriver(jdbcUrl));
}
catch (Exception e)
{
throw new RuntimeException(e);
}
if (this.getClass().getName().contains("Statement")) {
System.err.println("# Overriding maxPoolSize paramter for StatementBench: maxPoolSize=" + params.getThreads());
maxPoolSize = params.getThreads();
}
switch (pool)
{
case "hikari":
setupHikari();
break;
case "tomcat":
setupTomcat();
break;
case "dbcp":
setupDbcp();
break;
case "dbcp2":
setupDbcp2();
break;
case "c3p0":
setupC3P0();
break;
case "vibur":
setupVibur();
break;
case "one":
setupOne();
break;
case "druid":
setupDruid();
break;
case "druid-stat":
setupDruidStat();
break;
case "druid-stat-merge":
setupDruidStatMerge();
break;
}
}
@TearDown(Level.Trial)
public void teardown() throws SQLException
{
switch (pool)
{
case "hikari":
((HikariDataSource) DS).close();
break;
case "tomcat":
((org.apache.tomcat.jdbc.pool.DataSource) DS).close();
break;
case "dbcp":
((org.apache.commons.dbcp.BasicDataSource) DS).close();
break;
case "dbcp2":
((BasicDataSource) DS).close();
break;
case "c3p0":
((ComboPooledDataSource) DS).close();
break;
case "vibur":
((ViburDBCPDataSource) DS).terminate();
break;
case "druid":
((DruidDataSource) DS).close();
break;
case "druid-stat":
((DruidDataSource) DS).close();
break;
case "druid-stat-merge":
((DruidDataSource) DS).close();
break;
}
}
protected void setupDruid() {
DS = createDruid();
}
protected void setupDruidStat()
{
DruidDataSource druid = createDruid();
try {
druid.addFilters("stat");
} catch (SQLException e) {
throw new RuntimeException(e);
}
DS = druid;
}
protected void setupDruidStatMerge()
{
DruidDataSource druid = createDruid();
StatFilter statFilter = new MergeStatFilter();
druid.getProxyFilters().add(statFilter);
DS = druid;
}
protected DruidDataSource createDruid()
{
DruidDataSource druid = new DruidDataSource();
druid.setInitialSize(MIN_POOL_SIZE);
druid.setMaxActive(maxPoolSize);
druid.setMinIdle(MIN_POOL_SIZE);
druid.setPoolPreparedStatements(true);
druid.setDriverClassName("com.zaxxer.hikari.benchmark.stubs.StubDriver");
druid.setUrl(jdbcUrl);
druid.setUsername("brettw");
druid.setPassword("");
druid.setValidationQuery("SELECT 1");
druid.setTestOnBorrow(true);
druid.setDefaultAutoCommit(false);
druid.setMaxWait(8000);
druid.setUseUnfairLock(true);
return druid;
}
protected void setupTomcat()
{
PoolProperties props = new PoolProperties();
props.setUrl(jdbcUrl);
props.setDriverClassName("com.zaxxer.hikari.benchmark.stubs.StubDriver");
props.setUsername("brettw");
props.setPassword("");
props.setInitialSize(MIN_POOL_SIZE);
props.setMinIdle(MIN_POOL_SIZE);
props.setMaxIdle(maxPoolSize);
props.setMaxActive(maxPoolSize);
props.setMaxWait(8000);
props.setDefaultAutoCommit(false);
props.setRollbackOnReturn(true);
props.setUseDisposableConnectionFacade(true);
props.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState"); //;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
props.setTestOnBorrow(true);
props.setValidationInterval(1000);
props.setValidator(new Validator() {
@Override
public boolean validate(Connection connection, int validateAction)
{
try {
return (validateAction == PooledConnection.VALIDATE_BORROW ? connection.isValid(0) : true);
}
catch (SQLException e)
{
return false;
}
}
});
DS = new org.apache.tomcat.jdbc.pool.DataSource(props);
}
protected void setupDbcp()
{
org.apache.commons.dbcp.BasicDataSource ds = new org.apache.commons.dbcp.BasicDataSource();
ds.setUrl(jdbcUrl);
ds.setUsername("brettw");
ds.setPassword("");
ds.setInitialSize(MIN_POOL_SIZE);
ds.setMinIdle(MIN_POOL_SIZE);
ds.setMaxIdle(maxPoolSize);
ds.setMaxActive(maxPoolSize);
ds.setDefaultAutoCommit(false);
ds.setTestOnBorrow(true);
ds.setValidationQuery("SELECT 1");
DS = ds;
}
protected void setupDbcp2()
{
BasicDataSource ds = new BasicDataSource();
ds.setUrl(jdbcUrl);
ds.setUsername("brettw");
ds.setPassword("");
ds.setInitialSize(MIN_POOL_SIZE);
ds.setMinIdle(MIN_POOL_SIZE);
ds.setMaxIdle(maxPoolSize);
ds.setMaxTotal(maxPoolSize);
ds.setMaxWaitMillis(8000);
ds.setDefaultAutoCommit(false);
ds.setRollbackOnReturn(true);
ds.setEnableAutoCommitOnReturn(false);
ds.setTestOnBorrow(true);
ds.setCacheState(true);
ds.setFastFailValidation(true);
DS = ds;
}
protected void setupHikari()
{
HikariConfig config = new HikariConfig();
config.setJdbcUrl(jdbcUrl);
config.setUsername("brettw");
config.setPassword("");
config.setMinimumIdle(MIN_POOL_SIZE);
config.setMaximumPoolSize(maxPoolSize);
config.setConnectionTimeout(8000);
config.setAutoCommit(false);
DS = new HikariDataSource(config);
}
protected void setupC3P0()
{
try
{
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setJdbcUrl( jdbcUrl );
cpds.setUser("brettw");
cpds.setPassword("");
cpds.setAcquireIncrement(1);
cpds.setInitialPoolSize(MIN_POOL_SIZE);
cpds.setMinPoolSize(MIN_POOL_SIZE);
cpds.setMaxPoolSize(maxPoolSize);
cpds.setCheckoutTimeout(8000);
cpds.setLoginTimeout(8);
cpds.setTestConnectionOnCheckout(true);
// cpds.setPreferredTestQuery("VALUES 1");
DS = cpds;
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
private void setupVibur()
{
ViburDBCPDataSource vibur = new ViburDBCPDataSource();
vibur.setJdbcUrl( jdbcUrl );
vibur.setUsername("brettw");
vibur.setPassword("");
vibur.setConnectionTimeoutInMs(5000);
vibur.setValidateTimeoutInSeconds(3);
vibur.setLoginTimeoutInSeconds(2);
vibur.setPoolInitialSize(MIN_POOL_SIZE);
vibur.setPoolMaxSize(maxPoolSize);
vibur.setConnectionIdleLimitInSeconds(1);
vibur.setAcquireRetryAttempts(0);
vibur.setReducerTimeIntervalInSeconds(0);
vibur.setUseNetworkTimeout(true);
vibur.setNetworkTimeoutExecutor(Executors.newFixedThreadPool(1));
vibur.setClearSQLWarnings(true);
vibur.setResetDefaultsAfterUse(true);
vibur.start();
DS = vibur;
}
private void setupOne()
{
Properties props = new Properties();
props.put("url", jdbcUrl);
props.put("driver", "com.zaxxer.hikari.benchmark.stubs.StubDriver");
DS = new DataSourceImpl("one", props);
}
}
================================================
FILE: src/main/java/com/zaxxer/hikari/benchmark/ConnectionBench.java
================================================
/*
* Copyright (C) 2014 Brett Wooldridge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zaxxer.hikari.benchmark;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.CompilerControl;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Warmup;
//@State(Scope.Benchmark)
//@Warmup(iterations=3, batchSize=1_000_000)
//@Measurement(iterations=8, batchSize=1_000_000)
//@BenchmarkMode(Mode.SingleShotTime)
//@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Warmup(iterations=3)
@Measurement(iterations=8)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
//@Warmup(iterations=3)
//@Measurement(iterations=8)
//@BenchmarkMode(Mode.SampleTime)
//@OutputTimeUnit(TimeUnit.MILLISECONDS)
public class ConnectionBench extends BenchBase
{
@Benchmark
@CompilerControl(CompilerControl.Mode.INLINE)
public static Connection cycleCnnection() throws SQLException
{
Connection connection = DS.getConnection();
connection.close();
return connection;
}
}
================================================
FILE: src/main/java/com/zaxxer/hikari/benchmark/StatementBench.java
================================================
/*
* Copyright (C) 2014 Brett Wooldridge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zaxxer.hikari.benchmark;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.CompilerControl;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;
//@State(Scope.Benchmark)
//@Warmup(iterations=3, batchSize=1_000_000)
//@Measurement(iterations=8, batchSize=1_000_000)
//@BenchmarkMode(Mode.SingleShotTime)
//@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Benchmark)
@Warmup(iterations=3)
@Measurement(iterations=8)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public class StatementBench extends BenchBase
{
@Benchmark
@CompilerControl(CompilerControl.Mode.INLINE)
public Statement cycleStatement(Blackhole bh, ConnectionState state) throws SQLException
{
Statement statement = state.connection.createStatement();
bh.consume(statement.execute("INSERT INTO test (column) VALUES (?)"));
statement.close();
return statement;
}
@State(Scope.Thread)
public static class ConnectionState
{
Connection connection;
@Setup(Level.Iteration)
public void setup() throws SQLException
{
connection = DS.getConnection();
}
@TearDown(Level.Iteration)
public void teardown() throws SQLException
{
connection.close();
}
}
}
================================================
FILE: src/main/java/com/zaxxer/hikari/benchmark/stubs/StubConnection.java
================================================
/*
* Copyright (C) 2014 Brett Wooldridge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zaxxer.hikari.benchmark.stubs;
import java.sql.Array;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.SQLClientInfoException;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Savepoint;
import java.sql.Statement;
import java.sql.Struct;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadLocalRandom;
/**
*
* @author Brett Wooldridge
*/
public class StubConnection implements Connection
{
public static volatile boolean throwRandomExceptions;
private static long foo;
private boolean autoCommit;
private boolean isClosed;
private int isolation;
static {
foo = System.currentTimeMillis();
}
/** {@inheritDoc} */
public <T> T unwrap(Class<T> iface) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public boolean isWrapperFor(Class<?> iface) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public Statement createStatement() throws SQLException
{
return new StubStatement();
}
/** {@inheritDoc} */
public PreparedStatement prepareStatement(String sql) throws SQLException
{
return new StubPreparedStatement();
}
/** {@inheritDoc} */
public CallableStatement prepareCall(String sql) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public String nativeSQL(String sql) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void setAutoCommit(boolean autoCommit) throws SQLException
{
this.autoCommit = autoCommit;
}
/** {@inheritDoc} */
public boolean getAutoCommit() throws SQLException
{
return autoCommit;
}
/** {@inheritDoc} */
public void commit() throws SQLException
{
}
/** {@inheritDoc} */
public void rollback() throws SQLException
{
autoCommit = false;
}
/** {@inheritDoc} */
public void close() throws SQLException
{
isClosed = true;
}
/** {@inheritDoc} */
public boolean isClosed() throws SQLException
{
return isClosed;
}
/** {@inheritDoc} */
public DatabaseMetaData getMetaData() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void setReadOnly(boolean readOnly) throws SQLException
{
}
/** {@inheritDoc} */
public boolean isReadOnly() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public void setCatalog(String catalog) throws SQLException
{
}
/** {@inheritDoc} */
public String getCatalog() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void setTransactionIsolation(int level) throws SQLException
{
this.isolation = level;
}
/** {@inheritDoc} */
public int getTransactionIsolation() throws SQLException
{
return isolation;
}
/** {@inheritDoc} */
public SQLWarning getWarnings() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void clearWarnings() throws SQLException
{
autoCommit = false;
}
/** {@inheritDoc} */
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
{
return new StubPreparedStatement();
}
/** {@inheritDoc} */
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Map<String, Class<?>> getTypeMap() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void setTypeMap(Map<String, Class<?>> map) throws SQLException
{
}
/** {@inheritDoc} */
public void setHoldability(int holdability) throws SQLException
{
}
/** {@inheritDoc} */
public int getHoldability() throws SQLException
{
return (int) foo;
}
/** {@inheritDoc} */
public Savepoint setSavepoint() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Savepoint setSavepoint(String name) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void rollback(Savepoint savepoint) throws SQLException
{
}
/** {@inheritDoc} */
public void releaseSavepoint(Savepoint savepoint) throws SQLException
{
}
/** {@inheritDoc} */
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
{
return new StubPreparedStatement();
}
/** {@inheritDoc} */
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
{
return new StubPreparedStatement();
}
/** {@inheritDoc} */
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
{
return new StubPreparedStatement();
}
/** {@inheritDoc} */
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
{
return new StubPreparedStatement();
}
/** {@inheritDoc} */
public Clob createClob() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Blob createBlob() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public NClob createNClob() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public SQLXML createSQLXML() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public boolean isValid(int timeout) throws SQLException
{
if (throwRandomExceptions && ThreadLocalRandom.current().nextInt(100) == 9) {
throw new RuntimeException("isValidThrowsException=true");
}
return true;
}
/** {@inheritDoc} */
public void setClientInfo(String name, String value) throws SQLClientInfoException
{
}
/** {@inheritDoc} */
public void setClientInfo(Properties properties) throws SQLClientInfoException
{
}
/** {@inheritDoc} */
public String getClientInfo(String name) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Properties getClientInfo() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Array createArrayOf(String typeName, Object[] elements) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Struct createStruct(String typeName, Object[] attributes) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void setSchema(String schema) throws SQLException
{
}
/** {@inheritDoc} */
public String getSchema() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void abort(Executor executor) throws SQLException
{
}
/** {@inheritDoc} */
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException
{
}
/** {@inheritDoc} */
public int getNetworkTimeout() throws SQLException
{
return 0;
}
}
================================================
FILE: src/main/java/com/zaxxer/hikari/benchmark/stubs/StubDataSource.java
================================================
/*
* Copyright (C) 2014 Brett Wooldridge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zaxxer.hikari.benchmark.stubs;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLTransientConnectionException;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import javax.sql.DataSource;
/**
*
* @author Brett Wooldridge
*/
public class StubDataSource implements DataSource
{
private long connectionDelay;
public void setConnectionDelay(long millis)
{
this.connectionDelay = millis;
}
/** {@inheritDoc} */
public PrintWriter getLogWriter() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void setLogWriter(PrintWriter out) throws SQLException
{
}
/** {@inheritDoc} */
public void setLoginTimeout(int seconds) throws SQLException
{
}
/** {@inheritDoc} */
public int getLoginTimeout() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public Logger getParentLogger() throws SQLFeatureNotSupportedException
{
return null;
}
/** {@inheritDoc} */
public <T> T unwrap(Class<T> iface) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public boolean isWrapperFor(Class<?> iface) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public Connection getConnection() throws SQLException
{
if (connectionDelay > 0) {
try {
TimeUnit.MILLISECONDS.sleep(connectionDelay);
}
catch (InterruptedException e) {
throw new SQLTransientConnectionException();
}
}
return new StubConnection();
}
/** {@inheritDoc} */
public Connection getConnection(String username, String password) throws SQLException
{
return getConnection();
}
}
================================================
FILE: src/main/java/com/zaxxer/hikari/benchmark/stubs/StubDriver.java
================================================
/*
* Copyright (C) 2014 Brett Wooldridge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zaxxer.hikari.benchmark.stubs;
import static java.lang.System.nanoTime;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties;
import java.util.logging.Logger;
import com.zaxxer.hikari.util.UtilityElf;
/**
* @author Brett Wooldridge
*/
public class StubDriver implements Driver
{
private static final Driver driver;
private static long connectionDelay;
static {
driver = new StubDriver();
try {
DriverManager.registerDriver(driver);
}
catch (SQLException e) {
e.printStackTrace();
}
}
public static void setConnectDelayMs(final long delay)
{
connectionDelay = delay; //MILLISECONDS.toNanos(delay);
}
/** {@inheritDoc} */
public Connection connect(String url, Properties info) throws SQLException
{
if (connectionDelay > 0) {
// final long start = nanoTime();
// do {
// // spin
// } while (nanoTime() - start < connectionDelayNs);
UtilityElf.quietlySleep(connectionDelay);
}
return new StubConnection();
}
/** {@inheritDoc} */
public boolean acceptsURL(String url) throws SQLException
{
return true;
}
/** {@inheritDoc} */
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public int getMajorVersion()
{
return 0;
}
/** {@inheritDoc} */
public int getMinorVersion()
{
return 0;
}
/** {@inheritDoc} */
public boolean jdbcCompliant()
{
return true;
}
/** {@inheritDoc} */
public Logger getParentLogger() throws SQLFeatureNotSupportedException
{
return null;
}
}
================================================
FILE: src/main/java/com/zaxxer/hikari/benchmark/stubs/StubPreparedStatement.java
================================================
/*
* Copyright (C) 2014 Brett Wooldridge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zaxxer.hikari.benchmark.stubs;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.Date;
import java.sql.NClob;
import java.sql.ParameterMetaData;
import java.sql.PreparedStatement;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Calendar;
/**
*
* @author Brett Wooldridge
*/
public class StubPreparedStatement extends StubStatement implements PreparedStatement
{
/** {@inheritDoc} */
public ResultSet executeQuery(String sql) throws SQLException
{
return new StubResultSet();
}
/** {@inheritDoc} */
public int executeUpdate(String sql) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public int getMaxFieldSize() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public void setMaxFieldSize(int max) throws SQLException
{
}
/** {@inheritDoc} */
public int getMaxRows() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public void setMaxRows(int max) throws SQLException
{
}
/** {@inheritDoc} */
public void setEscapeProcessing(boolean enable) throws SQLException
{
}
/** {@inheritDoc} */
public int getQueryTimeout() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public void setQueryTimeout(int seconds) throws SQLException
{
}
/** {@inheritDoc} */
public void cancel() throws SQLException
{
}
/** {@inheritDoc} */
public SQLWarning getWarnings() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void clearWarnings() throws SQLException
{
}
/** {@inheritDoc} */
public void setCursorName(String name) throws SQLException
{
}
/** {@inheritDoc} */
public boolean execute(String sql) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public ResultSet getResultSet() throws SQLException
{
return new StubResultSet();
}
/** {@inheritDoc} */
public int getUpdateCount() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public boolean getMoreResults() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public void setFetchDirection(int direction) throws SQLException
{
}
/** {@inheritDoc} */
public int getFetchDirection() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public void setFetchSize(int rows) throws SQLException
{
}
/** {@inheritDoc} */
public int getFetchSize() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public int getResultSetConcurrency() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public int getResultSetType() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public void addBatch(String sql) throws SQLException
{
}
/** {@inheritDoc} */
public void clearBatch() throws SQLException
{
}
/** {@inheritDoc} */
public int[] executeBatch() throws SQLException
{
if (count > 10000)
{
return new int[] {1, count, 3};
}
return new int[] {count, count, 3};
}
/** {@inheritDoc} */
public Connection getConnection() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public boolean getMoreResults(int current) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public ResultSet getGeneratedKeys() throws SQLException
{
return new StubResultSet();
}
/** {@inheritDoc} */
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public int executeUpdate(String sql, String[] columnNames) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public boolean execute(String sql, int[] columnIndexes) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public boolean execute(String sql, String[] columnNames) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public int getResultSetHoldability() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public void setPoolable(boolean poolable) throws SQLException
{
}
/** {@inheritDoc} */
public boolean isPoolable() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public void closeOnCompletion() throws SQLException
{
}
/** {@inheritDoc} */
public boolean isCloseOnCompletion() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public ResultSet executeQuery() throws SQLException
{
return new StubResultSet();
}
/** {@inheritDoc} */
public int executeUpdate() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public void setNull(int parameterIndex, int sqlType) throws SQLException
{
}
/** {@inheritDoc} */
public void setBoolean(int parameterIndex, boolean x) throws SQLException
{
}
/** {@inheritDoc} */
public void setByte(int parameterIndex, byte x) throws SQLException
{
}
/** {@inheritDoc} */
public void setShort(int parameterIndex, short x) throws SQLException
{
}
/** {@inheritDoc} */
public void setInt(int parameterIndex, int x) throws SQLException
{
if (count > 0)
{
count += parameterIndex + x;
}
else
{
count += x;
}
}
/** {@inheritDoc} */
public void setLong(int parameterIndex, long x) throws SQLException
{
}
/** {@inheritDoc} */
public void setFloat(int parameterIndex, float x) throws SQLException
{
}
/** {@inheritDoc} */
public void setDouble(int parameterIndex, double x) throws SQLException
{
}
/** {@inheritDoc} */
public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException
{
}
/** {@inheritDoc} */
public void setString(int parameterIndex, String x) throws SQLException
{
}
/** {@inheritDoc} */
public void setBytes(int parameterIndex, byte[] x) throws SQLException
{
}
/** {@inheritDoc} */
public void setDate(int parameterIndex, Date x) throws SQLException
{
}
/** {@inheritDoc} */
public void setTime(int parameterIndex, Time x) throws SQLException
{
}
/** {@inheritDoc} */
public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
{
}
/** {@inheritDoc} */
public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException
{
}
/** {@inheritDoc} */
public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException
{
}
/** {@inheritDoc} */
public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException
{
}
/** {@inheritDoc} */
public void clearParameters() throws SQLException
{
}
/** {@inheritDoc} */
public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException
{
}
/** {@inheritDoc} */
public void setObject(int parameterIndex, Object x) throws SQLException
{
}
/** {@inheritDoc} */
public boolean execute() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public void addBatch() throws SQLException
{
}
/** {@inheritDoc} */
public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException
{
}
/** {@inheritDoc} */
public void setRef(int parameterIndex, Ref x) throws SQLException
{
}
/** {@inheritDoc} */
public void setBlob(int parameterIndex, Blob x) throws SQLException
{
}
/** {@inheritDoc} */
public void setClob(int parameterIndex, Clob x) throws SQLException
{
}
/** {@inheritDoc} */
public void setArray(int parameterIndex, Array x) throws SQLException
{
}
/** {@inheritDoc} */
public ResultSetMetaData getMetaData() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException
{
}
/** {@inheritDoc} */
public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException
{
}
/** {@inheritDoc} */
public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException
{
}
/** {@inheritDoc} */
public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException
{
}
/** {@inheritDoc} */
public void setURL(int parameterIndex, URL x) throws SQLException
{
}
/** {@inheritDoc} */
public ParameterMetaData getParameterMetaData() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void setRowId(int parameterIndex, RowId x) throws SQLException
{
}
/** {@inheritDoc} */
public void setNString(int parameterIndex, String value) throws SQLException
{
}
/** {@inheritDoc} */
public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void setNClob(int parameterIndex, NClob value) throws SQLException
{
}
/** {@inheritDoc} */
public void setClob(int parameterIndex, Reader reader, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException
{
}
/** {@inheritDoc} */
public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException
{
}
/** {@inheritDoc} */
public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException
{
}
/** {@inheritDoc} */
public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException
{
}
/** {@inheritDoc} */
public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException
{
}
/** {@inheritDoc} */
public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException
{
}
/** {@inheritDoc} */
public void setClob(int parameterIndex, Reader reader) throws SQLException
{
}
/** {@inheritDoc} */
public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException
{
}
/** {@inheritDoc} */
public void setNClob(int parameterIndex, Reader reader) throws SQLException
{
}
}
================================================
FILE: src/main/java/com/zaxxer/hikari/benchmark/stubs/StubResultSet.java
================================================
/*
* Copyright (C) 2014 Brett Wooldridge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zaxxer.hikari.benchmark.stubs;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
import java.sql.NClob;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Map;
/**
*
* @author Brett Wooldridge
*/
public class StubResultSet implements ResultSet
{
private int counter;
private boolean closed;
/** {@inheritDoc} */
public <T> T unwrap(Class<T> iface) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public boolean isWrapperFor(Class<?> iface) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public boolean next() throws SQLException
{
return (counter < 10);
}
/** {@inheritDoc} */
public void close() throws SQLException
{
closed = true;
}
/** {@inheritDoc} */
public boolean wasNull() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public String getString(int columnIndex) throws SQLException
{
return "aString";
}
/** {@inheritDoc} */
public boolean getBoolean(int columnIndex) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public byte getByte(int columnIndex) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public short getShort(int columnIndex) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public int getInt(int columnIndex) throws SQLException
{
return ++counter;
}
/** {@inheritDoc} */
public long getLong(int columnIndex) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public float getFloat(int columnIndex) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public double getDouble(int columnIndex) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public byte[] getBytes(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Date getDate(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Time getTime(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Timestamp getTimestamp(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public InputStream getAsciiStream(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public InputStream getUnicodeStream(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public InputStream getBinaryStream(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public String getString(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public boolean getBoolean(String columnLabel) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public byte getByte(String columnLabel) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public short getShort(String columnLabel) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public int getInt(String columnLabel) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public long getLong(String columnLabel) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public float getFloat(String columnLabel) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public double getDouble(String columnLabel) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public byte[] getBytes(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Date getDate(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Time getTime(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Timestamp getTimestamp(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public InputStream getAsciiStream(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public InputStream getUnicodeStream(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public InputStream getBinaryStream(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public SQLWarning getWarnings() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void clearWarnings() throws SQLException
{
}
/** {@inheritDoc} */
public String getCursorName() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public ResultSetMetaData getMetaData() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Object getObject(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Object getObject(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public int findColumn(String columnLabel) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public Reader getCharacterStream(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Reader getCharacterStream(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public BigDecimal getBigDecimal(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public BigDecimal getBigDecimal(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public boolean isBeforeFirst() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public boolean isAfterLast() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public boolean isFirst() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public boolean isLast() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public void beforeFirst() throws SQLException
{
}
/** {@inheritDoc} */
public void afterLast() throws SQLException
{
}
/** {@inheritDoc} */
public boolean first() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public boolean last() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public int getRow() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public boolean absolute(int row) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public boolean relative(int rows) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public boolean previous() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public void setFetchDirection(int direction) throws SQLException
{
}
/** {@inheritDoc} */
public int getFetchDirection() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public void setFetchSize(int rows) throws SQLException
{
}
/** {@inheritDoc} */
public int getFetchSize() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public int getType() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public int getConcurrency() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public boolean rowUpdated() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public boolean rowInserted() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public boolean rowDeleted() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public void updateNull(int columnIndex) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBoolean(int columnIndex, boolean x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateByte(int columnIndex, byte x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateShort(int columnIndex, short x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateInt(int columnIndex, int x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateLong(int columnIndex, long x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateFloat(int columnIndex, float x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateDouble(int columnIndex, double x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateString(int columnIndex, String x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBytes(int columnIndex, byte[] x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateDate(int columnIndex, Date x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateTime(int columnIndex, Time x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException
{
}
/** {@inheritDoc} */
public void updateObject(int columnIndex, Object x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateNull(String columnLabel) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBoolean(String columnLabel, boolean x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateByte(String columnLabel, byte x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateShort(String columnLabel, short x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateInt(String columnLabel, int x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateLong(String columnLabel, long x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateFloat(String columnLabel, float x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateDouble(String columnLabel, double x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateString(String columnLabel, String x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBytes(String columnLabel, byte[] x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateDate(String columnLabel, Date x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateTime(String columnLabel, Time x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException
{
}
/** {@inheritDoc} */
public void updateObject(String columnLabel, Object x) throws SQLException
{
}
/** {@inheritDoc} */
public void insertRow() throws SQLException
{
}
/** {@inheritDoc} */
public void updateRow() throws SQLException
{
}
/** {@inheritDoc} */
public void deleteRow() throws SQLException
{
}
/** {@inheritDoc} */
public void refreshRow() throws SQLException
{
}
/** {@inheritDoc} */
public void cancelRowUpdates() throws SQLException
{
}
/** {@inheritDoc} */
public void moveToInsertRow() throws SQLException
{
}
/** {@inheritDoc} */
public void moveToCurrentRow() throws SQLException
{
}
/** {@inheritDoc} */
public Statement getStatement() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Ref getRef(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Blob getBlob(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Clob getClob(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Array getArray(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Ref getRef(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Blob getBlob(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Clob getClob(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Array getArray(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Date getDate(int columnIndex, Calendar cal) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Date getDate(String columnLabel, Calendar cal) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Time getTime(int columnIndex, Calendar cal) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Time getTime(String columnLabel, Calendar cal) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public URL getURL(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public URL getURL(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void updateRef(int columnIndex, Ref x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateRef(String columnLabel, Ref x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBlob(int columnIndex, Blob x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBlob(String columnLabel, Blob x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateClob(int columnIndex, Clob x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateClob(String columnLabel, Clob x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateArray(int columnIndex, Array x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateArray(String columnLabel, Array x) throws SQLException
{
}
/** {@inheritDoc} */
public RowId getRowId(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public RowId getRowId(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void updateRowId(int columnIndex, RowId x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateRowId(String columnLabel, RowId x) throws SQLException
{
}
/** {@inheritDoc} */
public int getHoldability() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public boolean isClosed() throws SQLException
{
return closed;
}
/** {@inheritDoc} */
public void updateNString(int columnIndex, String nString) throws SQLException
{
}
/** {@inheritDoc} */
public void updateNString(String columnLabel, String nString) throws SQLException
{
}
/** {@inheritDoc} */
public void updateNClob(int columnIndex, NClob nClob) throws SQLException
{
}
/** {@inheritDoc} */
public void updateNClob(String columnLabel, NClob nClob) throws SQLException
{
}
/** {@inheritDoc} */
public NClob getNClob(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public NClob getNClob(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public SQLXML getSQLXML(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public SQLXML getSQLXML(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException
{
}
/** {@inheritDoc} */
public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException
{
}
/** {@inheritDoc} */
public String getNString(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public String getNString(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Reader getNCharacterStream(int columnIndex) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Reader getNCharacterStream(String columnLabel) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateClob(int columnIndex, Reader reader, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateClob(String columnLabel, Reader reader, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException
{
}
/** {@inheritDoc} */
public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException
{
}
/** {@inheritDoc} */
public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateCharacterStream(int columnIndex, Reader x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException
{
}
/** {@inheritDoc} */
public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException
{
}
/** {@inheritDoc} */
public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException
{
}
/** {@inheritDoc} */
public void updateClob(int columnIndex, Reader reader) throws SQLException
{
}
/** {@inheritDoc} */
public void updateClob(String columnLabel, Reader reader) throws SQLException
{
}
/** {@inheritDoc} */
public void updateNClob(int columnIndex, Reader reader) throws SQLException
{
}
/** {@inheritDoc} */
public void updateNClob(String columnLabel, Reader reader) throws SQLException
{
}
/** {@inheritDoc} */
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException
{
return null;
}
/** {@inheritDoc} */
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException
{
return null;
}
}
================================================
FILE: src/main/java/com/zaxxer/hikari/benchmark/stubs/StubStatement.java
================================================
/*
* Copyright (C) 2014 Brett Wooldridge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zaxxer.hikari.benchmark.stubs;
import static java.lang.System.nanoTime;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
import com.zaxxer.hikari.util.UtilityElf;
/**
*
* @author Brett Wooldridge
*/
public class StubStatement implements Statement
{
protected int count;
private boolean closed;
private static long executeDelay;
public static void setExecuteDelayMs(final long delay)
{
executeDelay = delay;
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public <T> T unwrap(Class<T> iface) throws SQLException
{
if (iface.isInstance(this)) {
return (T) this;
}
throw new SQLException("Wrapped connection is not an instance of " + iface);
}
/** {@inheritDoc} */
public boolean isWrapperFor(Class<?> iface) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public ResultSet executeQuery(String sql) throws SQLException
{
if (executeDelay > 0) {
// final long start = nanoTime();
// do {
// // spin
// } while (nanoTime() - start < MILLISECONDS.toNanos(executeDelayMs));
UtilityElf.quietlySleep(executeDelay);
}
return new StubResultSet();
}
/** {@inheritDoc} */
public int executeUpdate(String sql) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public void close() throws SQLException
{
closed = true;
}
/** {@inheritDoc} */
public int getMaxFieldSize() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public void setMaxFieldSize(int max) throws SQLException
{
}
/** {@inheritDoc} */
public int getMaxRows() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public void setMaxRows(int max) throws SQLException
{
}
/** {@inheritDoc} */
public void setEscapeProcessing(boolean enable) throws SQLException
{
}
/** {@inheritDoc} */
public int getQueryTimeout() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public void setQueryTimeout(int seconds) throws SQLException
{
}
/** {@inheritDoc} */
public void cancel() throws SQLException
{
}
/** {@inheritDoc} */
public SQLWarning getWarnings() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public void clearWarnings() throws SQLException
{
}
/** {@inheritDoc} */
public void setCursorName(String name) throws SQLException
{
}
/** {@inheritDoc} */
public boolean execute(String sql) throws SQLException
{
return sql.startsWith("I");
}
/** {@inheritDoc} */
public ResultSet getResultSet() throws SQLException
{
return new StubResultSet();
}
/** {@inheritDoc} */
public int getUpdateCount() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public boolean getMoreResults() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public void setFetchDirection(int direction) throws SQLException
{
}
/** {@inheritDoc} */
public int getFetchDirection() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public void setFetchSize(int rows) throws SQLException
{
}
/** {@inheritDoc} */
public int getFetchSize() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public int getResultSetConcurrency() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public int getResultSetType() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public void addBatch(String sql) throws SQLException
{
}
/** {@inheritDoc} */
public void clearBatch() throws SQLException
{
}
/** {@inheritDoc} */
public int[] executeBatch() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public Connection getConnection() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public boolean getMoreResults(int current) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public ResultSet getGeneratedKeys() throws SQLException
{
return new StubResultSet();
}
/** {@inheritDoc} */
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public int executeUpdate(String sql, String[] columnNames) throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public boolean execute(String sql, int[] columnIndexes) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public boolean execute(String sql, String[] columnNames) throws SQLException
{
return false;
}
/** {@inheritDoc} */
public int getResultSetHoldability() throws SQLException
{
return 0;
}
/** {@inheritDoc} */
public boolean isClosed() throws SQLException
{
return closed;
}
/** {@inheritDoc} */
public void setPoolable(boolean poolable) throws SQLException
{
}
/** {@inheritDoc} */
public boolean isPoolable() throws SQLException
{
return false;
}
/** {@inheritDoc} */
public void closeOnCompletion() throws SQLException
{
}
/** {@inheritDoc} */
public boolean isCloseOnCompletion() throws SQLException
{
return false;
}
public int getCount()
{
return count;
}
}
================================================
FILE: src/main/resources/log4j2-test.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="OFF">
<appenders>
<Console name="Console" target="SYSTEM_ERR">
<PatternLayout pattern="%d{ABSOLUTE} [seq%5sn] [%-26.26t] %-5level %-20c{1} - %msg%n" />
</Console>
</appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console" />
</Root>
</Loggers>
</configuration>
================================================
FILE: src/test/java/com/zaxxer/hikari/benchmark/BandwidthTest.java
================================================
package com.zaxxer.hikari.benchmark;
import static com.zaxxer.hikari.util.ClockSource.currentTime;
import static java.lang.System.out;
import static java.sql.Connection.TRANSACTION_READ_COMMITTED;
import static java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.SECONDS;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;
import java.util.concurrent.Executors;
import javax.sql.DataSource;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.dbcp2.DbcpPoolAccessor;
import org.apache.commons.dbcp2.TomcatPoolAccessor;
import org.apache.tomcat.jdbc.pool.PoolProperties;
import org.apache.tomcat.jdbc.pool.PooledConnection;
import org.apache.tomcat.jdbc.pool.Validator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.vibur.dbcp.ViburDBCPDataSource;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import com.zaxxer.hikari.util.ClockSource;
public class BandwidthTest
{
private static final Logger LOGGER = LoggerFactory.getLogger(BandwidthTest.class);
private static final String jdbcUrl = "jdbc:postgresql://localhost/test";
private static final int MIN_POOL_SIZE = 1;
private static final int MAX_POOL_SIZE = 1;
private DataSource DS;
private String pool;
public static void main(String[] args) throws InterruptedException, SQLException
{
BandwidthTest test = new BandwidthTest();
test.setup(args);
int blackhole = test.start();
LOGGER.debug("Blackhole value {}", blackhole);
}
private void setup(String[] args) throws SQLException
{
pool = args[0];
switch (pool) {
case "hikari":
setupHikari();
break;
case "dbcp2":
setupDbcp2();
break;
case "tomcat":
setupTomcat();
break;
case "vibur":
setupVibur();
break;
default:
throw new IllegalArgumentException("Unknown connection pool specified");
}
try (Connection connection = DS.getConnection()) {
connection.setAutoCommit(true);
try (Statement stmt = connection.createStatement()) {
stmt.execute("DROP TABLE IF EXISTS test; CREATE TABLE test (value VARCHAR(255));");
stmt.executeUpdate("INSERT INTO test (value) VALUES ('this is a test')");
connection.setAutoCommit(false);
}
}
LOGGER.info("Primed connection: {}.", pool);
}
private int start() throws InterruptedException, SQLException
{
try (Scanner scanner = new Scanner(System.in)) {
LOGGER.info("\n[Re]start iptop capture and press enter: sudo iftop -i lo0 -nf \"port 5432 and host localhost\"");
scanner.nextLine();
int blackhole = 0;
long start = currentTime();
for (int i = 0; i < 10_000; i++) {
try (Connection connection = DS.getConnection()) {
// connection.setTransactionIsolation(TRANSACTION_READ_UNCOMMITTED);
// connection.setReadOnly(true);
try (Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM test")) {
if (rs.next()) {
blackhole += rs.getString(1).hashCode();
}
}
// connection.rollback();
}
}
LOGGER.info("Elapsed runtime {}" , ClockSource.elapsedDisplayString(start, currentTime()));
return blackhole;
}
finally {
shutdownPool(DS);
}
}
private void shutdownPool(DataSource ds)
{
if (ds instanceof AutoCloseable) {
try {
((AutoCloseable) ds).close();
}
catch (Exception e) {
}
}
}
private void setupHikari()
{
HikariConfig config = new HikariConfig();
config.setJdbcUrl(jdbcUrl);
config.setUsername("brettw");
config.setPassword("");
config.setMinimumIdle(MIN_POOL_SIZE);
config.setMaximumPoolSize(MAX_POOL_SIZE);
config.setConnectionTimeout(8000);
config.setAutoCommit(false);
config.setReadOnly(false);
config.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
DS = new HikariDataSource(config);
}
private void setupDbcp2()
{
BasicDataSource ds = new DbcpPoolAccessor();
ds.setUrl(jdbcUrl);
ds.setUsername("brettw");
ds.setPassword("");
ds.setInitialSize(MIN_POOL_SIZE);
ds.setMinIdle(MIN_POOL_SIZE);
ds.setMaxIdle(MIN_POOL_SIZE);
ds.setMaxTotal(MAX_POOL_SIZE);
ds.setMaxWaitMillis(8000);
ds.setSoftMinEvictableIdleTimeMillis(MINUTES.toMillis(10));
ds.setTimeBetweenEvictionRunsMillis(SECONDS.toMillis(30));
ds.setDefaultAutoCommit(false);
ds.setDefaultTransactionIsolation(TRANSACTION_READ_COMMITTED);
ds.setDefaultReadOnly(false);
ds.setRollbackOnReturn(true);
ds.setEnableAutoCommitOnReturn(false);
ds.setTestOnBorrow(true);
ds.setCacheState(true);
ds.setFastFailValidation(true);
DS = ds;
}
protected void setupTomcat()
{
PoolProperties props = new PoolProperties();
props.setUrl(jdbcUrl);
props.setUsername("brettw");
props.setPassword("");
props.setInitialSize(MIN_POOL_SIZE);
props.setMinIdle(MIN_POOL_SIZE);
props.setMaxIdle(MAX_POOL_SIZE);
props.setMaxActive(MAX_POOL_SIZE);
props.setMaxWait(8000);
props.setDefaultAutoCommit(false);
props.setDefaultReadOnly(false);
props.setDefaultTransactionIsolation(TRANSACTION_READ_COMMITTED);
props.setRollbackOnReturn(true);
props.setUseDisposableConnectionFacade(true);
props.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
props.setTestOnBorrow(true);
props.setLogAbandoned(true);
props.setSuspectTimeout(120);
props.setValidationInterval(250);
props.setValidator(new Validator() {
@Override
public boolean validate(Connection connection, int validateAction)
{
try {
return (validateAction == PooledConnection.VALIDATE_BORROW ? connection.isValid(0) : true);
}
catch (SQLException e)
{
return false;
}
}
});
DS = new TomcatPoolAccessor(props);
}
private void setupVibur()
{
ViburDBCPDataSource vibur = new ViburDBCPDataSource();
vibur.setJdbcUrl(jdbcUrl);
vibur.setUsername("brettw");
vibur.setPassword("");
vibur.setPoolFair(false);
vibur.setPoolInitialSize(MIN_POOL_SIZE);
vibur.setPoolMaxSize(MAX_POOL_SIZE);
vibur.setConnectionIdleLimitInSeconds(1);
vibur.setUseNetworkTimeout(true);
vibur.setNetworkTimeoutExecutor(Executors.newFixedThreadPool(1));
vibur.setClearSQLWarnings(true);
vibur.setDefaultAutoCommit(false);
vibur.setDefaultReadOnly(false);
vibur.setDefaultTransactionIsolationIntValue(TRANSACTION_READ_COMMITTED);
vibur.setResetDefaultsAfterUse(true);
vibur.setReducerTimeIntervalInSeconds((int) MINUTES.toSeconds(10));
vibur.start();
DS = vibur;
}
}
================================================
FILE: src/test/java/com/zaxxer/hikari/benchmark/DbDownTest.java
================================================
package com.zaxxer.hikari.benchmark;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import javax.sql.DataSource;
import org.apache.commons.dbcp2.BasicDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.vibur.dbcp.ViburDBCPDataSource;
import com.jolbox.bonecp.BoneCPConfig;
import com.jolbox.bonecp.BoneCPDataSource;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
public class DbDownTest
{
private static final String JDBC_URL = "jdbc:mysql://172.16.207.207/test";
private static final Logger LOGGER = LoggerFactory.getLogger(DbDownTest.class);
private static final int MIN_POOL_SIZE = 5;
private int maxPoolSize = MIN_POOL_SIZE;
private DataSource hikariDS;
private DataSource c3p0DS;
private DataSource dbcp2DS;
private DataSource viburDS;
public static void main(String[] args)
{
DbDownTest dbDownTest = new DbDownTest();
dbDownTest.start();
}
private DbDownTest()
{
hikariDS = setupHikari();
viburDS = setupVibur();
c3p0DS = setupC3P0();
dbcp2DS = setupDbcp2();
}
private void start()
{
class MyTask extends TimerTask
{
private DataSource ds;
public ResultSet resultSet;
MyTask(DataSource ds)
{
this.ds = ds;
}
@Override
public void run()
{
try (Connection c = ds.getConnection()) {
LOGGER.info("{} got a connection.", ds.getClass().getSimpleName(), c);
try (Statement stmt = c.createStatement()) {
LOGGER.debug("{} Statement ({})", ds.getClass().getSimpleName(), System.identityHashCode(stmt));
stmt.setQueryTimeout(1);
resultSet = stmt.executeQuery("SELECT id FROM test");
if (resultSet.next()) {
LOGGER.debug("Ran query got {}", resultSet.getInt(1));
}
else {
LOGGER.warn("{} Query executed, got no results.", ds.getClass().getSimpleName());
}
}
catch (SQLException e) {
LOGGER.error("{} Exception executing query, got a bad connection from the pool: {}", ds.getClass().getSimpleName(), e.getMessage());
}
}
catch (Throwable t)
{
LOGGER.error("{} Exception getting connection: {}", ds.getClass().getSimpleName(), t.getMessage());
}
}
}
new Timer(true).schedule(new MyTask(hikariDS), 5000, 2000);
new Timer(true).schedule(new MyTask(viburDS), 5000, 2000);
new Timer(true).schedule(new MyTask(c3p0DS), 5000, 2000);
new Timer(true).schedule(new MyTask(dbcp2DS), 5000, 2000);
try
{
Thread.sleep(TimeUnit.SECONDS.toMillis(300));
}
catch (InterruptedException e)
{
return;
}
}
protected DataSource setupDbcp2()
{
BasicDataSource ds = new BasicDataSource();
ds.setUrl(JDBC_URL);
ds.setUsername("root");
ds.setPassword("");
ds.setInitialSize(MIN_POOL_SIZE);
ds.setMinIdle(MIN_POOL_SIZE);
ds.setMaxIdle(maxPoolSize);
ds.setMaxTotal(maxPoolSize);
ds.setMaxWaitMillis(5000);
ds.setDefaultAutoCommit(false);
ds.setRollbackOnReturn(true);
ds.setEnableAutoCommitOnReturn(false);
ds.setTestOnBorrow(true);
ds.setCacheState(true);
ds.setFastFailValidation(true);
return ds;
}
protected DataSource setupBone()
{
BoneCPConfig config = new BoneCPConfig();
config.setJdbcUrl(JDBC_URL);
config.setUsername("root");
config.setPassword("");
config.setConnectionTimeoutInMs(5000);
config.setAcquireIncrement(1);
config.setAcquireRetryAttempts(3);
config.setAcquireRetryDelayInMs(5000);
config.setMinConnectionsPerPartition(MIN_POOL_SIZE);
config.setMaxConnectionsPerPartition(maxPoolSize);
config.setConnectionTestStatement("SELECT 1");
return new BoneCPDataSource(config);
}
protected DataSource setupHikari()
{
HikariConfig config = new HikariConfig();
config.setJdbcUrl(JDBC_URL);
// config.setDriverClassName("com.mysql.jdbc.Driver");
config.setUsername("root");
config.setConnectionTimeout(5000);
config.setMinimumIdle(MIN_POOL_SIZE);
config.setMaximumPoolSize(maxPoolSize);
config.setInitializationFailTimeout(0L);
config.setConnectionTestQuery("SELECT 1");
return new HikariDataSource(config);
}
protected DataSource setupC3P0()
{
try
{
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setJdbcUrl( JDBC_URL );
cpds.setUser("root");
cpds.setCheckoutTimeout(5000);
cpds.setTestConnectionOnCheckout(true);
cpds.setAcquireIncrement(1);
cpds.setAcquireRetryAttempts(3);
cpds.setAcquireRetryDelay(5000);
cpds.setInitialPoolSize(MIN_POOL_SIZE);
cpds.setMinPoolSize(MIN_POOL_SIZE);
cpds.setMaxPoolSize(maxPoolSize);
cpds.setPreferredTestQuery("SELECT 1");
return cpds;
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
private DataSource setupVibur()
{
ViburDBCPDataSource vibur = new ViburDBCPDataSource();
vibur.setJdbcUrl( JDBC_URL );
vibur.setUsername("root");
vibur.setPassword("");
vibur.setConnectionTimeoutInMs(5000);
vibur.setValidateTimeoutInSeconds(3);
vibur.setLoginTimeoutInSeconds(2);
vibur.setPoolInitialSize(MIN_POOL_SIZE);
vibur.setPoolMaxSize(maxPoolSize);
vibur.setConnectionIdleLimitInSeconds(1);
vibur.setAcquireRetryAttempts(0);
vibur.setReducerTimeIntervalInSeconds(0);
vibur.setUseNetworkTimeout(true);
vibur.setNetworkTimeoutExecutor(Executors.newCachedThreadPool());
vibur.setClearSQLWarnings(true);
vibur.setResetDefaultsAfterUse(true);
vibur.setTestConnectionQuery("isValid"); // this is the default option, can be left commented out
vibur.start();
return vibur;
}
}
================================================
FILE: src/test/java/com/zaxxer/hikari/benchmark/SpikeLoadTest.java
================================================
package com.zaxxer.hikari.benchmark;
import static com.zaxxer.hikari.util.ConcurrentBag.IConcurrentBagEntry.STATE_IN_USE;
import static com.zaxxer.hikari.util.ConcurrentBag.IConcurrentBagEntry.STATE_NOT_IN_USE;
import static com.zaxxer.hikari.util.UtilityElf.quietlySleep;
import static java.lang.Integer.parseInt;
import static java.lang.System.nanoTime;
import static java.lang.Thread.MAX_PRIORITY;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import java.lang.reflect.Field;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.LongAdder;
import java.util.stream.IntStream;
import javax.sql.DataSource;
import com.alibaba.druid.pool.DruidDataSource;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.dbcp2.DbcpPoolAccessor;
import org.apache.commons.dbcp2.TomcatPoolAccessor;
import org.apache.tomcat.jdbc.pool.PoolProperties;
import org.apache.tomcat.jdbc.pool.PooledConnection;
import org.apache.tomcat.jdbc.pool.Validator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.vibur.dbcp.ViburDBCPDataSource;
import org.vibur.dbcp.pool.Hook.CloseConnection;
import org.vibur.dbcp.pool.Hook.GetConnection;
import org.vibur.dbcp.pool.Hook.InitConnection;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import com.zaxxer.hikari.benchmark.stubs.StubDriver;
import com.zaxxer.hikari.benchmark.stubs.StubStatement;
import com.zaxxer.hikari.pool.HikariPool;
import com.zaxxer.hikari.pool.HikariPoolAccessor;
public class SpikeLoadTest
{
private static final Logger LOGGER = LoggerFactory.getLogger(SpikeLoadTest.class);
public static final String jdbcUrl = "jdbc:stub";
private static final int MIN_POOL_SIZE = 5;
private static final int MAX_POOL_SIZE = 50;
private DataSource DS;
private int requestCount;
private String pool;
private DbcpPoolAccessor dbcpPool;
private ViburPoolHooks viburPool;
private HikariPoolAccessor hikariPoolAccessor;
private AtomicInteger threadsRemaining;
private AtomicInteger threadsPending;
private ComboPooledDataSource c3p0;
private TomcatPoolAccessor tomcat;
private DruidDataSource druid;
public static void main(String[] args) throws InterruptedException
{
SpikeLoadTest test = new SpikeLoadTest();
test.setup(args);
test.start(parseInt(args[0]));
}
private void setup(String[] args)
{
try {
Class.forName("com.zaxxer.hikari.benchmark.stubs.StubDriver");
StubDriver driver = (StubDriver) DriverManager.getDriver(jdbcUrl);
LOGGER.info("Using driver ({}): {}", jdbcUrl, driver);
}
catch (Exception e) {
throw new RuntimeException(e);
}
pool = args[1];
IntStream.of(0, 1).forEach( i -> {
switch (pool) {
case "hikari":
setupHikari();
hikariPoolAccessor = new HikariPoolAccessor(getHikariPool(DS));
break;
case "dbcp2":
setupDbcp2();
dbcpPool = (DbcpPoolAccessor) DS;
break;
case "c3p0":
setupC3P0();
c3p0 = (ComboPooledDataSource) DS;
break;
case "tomcat":
setupTomcat();
tomcat = (TomcatPoolAccessor) DS;
break;
case "vibur":
setupVibur();
break;
case "druid":
setupDruid();
break;
default:
throw new IllegalArgumentException("Unknown connection pool specified");
}
if (i == 0) {
try {
LOGGER.info("Warming up pool...");
LOGGER.info("Warmup blackhole {}", warmupPool());
shutdownPool(DS);
}
catch (InterruptedException e) {
}
}
});
quietlySleep(SECONDS.toMillis(2));
this.requestCount = parseInt(args[2]);
}
private void start(int connectDelay) throws InterruptedException
{
List<RequestThread> list = new ArrayList<>();
for (int i = 0; i < requestCount; i++) {
RequestThread rt = new RequestThread();
list.add(rt);
}
StubDriver.setConnectDelayMs(connectDelay);
StubStatement.setExecuteDelayMs(2L);
Timer timer = new Timer(true);
ExecutorService executor = Executors.newFixedThreadPool(50); /*, new ThreadFactory() {
@Override
public Thread newThread(Runnable r)
{
Thread t = new Thread(r);
t.setPriority(Thread.MIN_PRIORITY);
return t;
}
}); */
quietlySleep(SECONDS.toMillis(3));
threadsRemaining = new AtomicInteger(requestCount);
threadsPending = new AtomicInteger(0);
LOGGER.info("SpikeLoadTest starting.");
currentThread().setPriority(MAX_PRIORITY);
timer.schedule(new TimerTask() {
public void run() {
for (int i = 0; i < requestCount; i++) {
final Runnable runner = list.get(i);
executor.execute(runner);
}
}
}, 1);
final long startTime = nanoTime();
List<PoolStatistics> statsList = new ArrayList<>();
PoolStatistics poolStatistics;
do {
poolStatistics = getPoolStatistics(startTime, threadsPending.get());
statsList.add(poolStatistics);
final long spinStart = nanoTime();
do {
// spin
} while (nanoTime() - spinStart < 250_000 /* 0.1ms */);
}
while (threadsRemaining.get() > 0 || poolStatistics.activeConnections > 0);
long endTime = nanoTime();
executor.shutdown();
LOGGER.info("SpikeLoadTest completed in {}ms", MILLISECONDS.convert(endTime - startTime, NANOSECONDS));
dumpStats(statsList, list);
}
private void dumpStats(List<PoolStatistics> statsList, List<RequestThread> list)
{
System.out.println(String.join("\t", "Time", "Total", "Active", "Idle", "Wait"));
for (PoolStatistics stats : statsList) {
System.out.println(stats);
}
System.out.println("\n" + String.join("\t", "Total", "Conn", "Query", "Thread"));
for (RequestThread req : list) {
System.out.println(req);
}
}
private class RequestThread extends TimerTask implements Runnable
{
@SuppressWarnings("unused")
Exception exception;
String name;
long startTime;
long endTime;
long connectTime;
long queryTime;
@Override
public void run()
{
name = currentThread().getName();
threadsPending.incrementAndGet();
startTime = nanoTime();
try (Connection connection = DS.getConnection()) {
connectTime = nanoTime();
threadsPending.decrementAndGet();
try (Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT x FROM faux")) {
queryTime = nanoTime();
}
}
catch (SQLException e) {
exception = e;
}
finally {
endTime = nanoTime();
threadsRemaining.decrementAndGet();
}
}
@Override
public String toString()
{
return String.format("%d\t%d\t%d\t%s",
NANOSECONDS.toMicros(endTime - startTime),
NANOSECONDS.toMicros(connectTime - startTime),
NANOSECONDS.toMicros(queryTime - connectTime),
name);
}
}
private static class PoolStatistics
{
long timestamp = nanoTime();
int activeConnections;
int idleConnections;
int pendingThreads;
int totalConnections;
PoolStatistics(final long baseTime) {
timestamp = nanoTime() - baseTime;
}
@Override
public String toString()
{
return String.format("%d\t%d\t%d\t%d\t%d", NANOSECONDS.toMicros(timestamp), totalConnections, activeConnections, idleConnections, pendingThreads);
}
}
private PoolStatistics getPoolStatistics(final long baseTime, int remaining)
{
PoolStatistics stats = new PoolStatistics(baseTime);
switch (pool) {
case "hikari":
final int[] poolStateCounts = hikariPoolAccessor.getPoolStateCounts();
stats.activeConnections = poolStateCounts[STATE_IN_USE];
stats.idleConnections = poolStateCounts[STATE_NOT_IN_USE];
stats.totalConnections = poolStateCounts[4];
stats.pendingThreads = remaining;
break;
case "dbcp2":
stats.activeConnections = dbcpPool.getNumActive();
stats.idleConnections = dbcpPool.getNumIdle();
stats.totalConnections = dbcpPool.getNumTotal();
stats.pendingThreads = remaining;
break;
case "tomcat":
stats.activeConnections = tomcat.getNumActive();
stats.idleConnections = tomcat.getNumIdle();
stats.totalConnections = tomcat.getNumTotal();
stats.pendingThreads = remaining;
break;
case "c3p0":
try {
stats.activeConnections = c3p0.getNumBusyConnectionsDefaultUser();
stats.idleConnections = c3p0.getNumIdleConnectionsDefaultUser();
stats.totalConnections = c3p0.getNumConnectionsDefaultUser();
stats.pendingThreads = remaining;
}
catch (SQLException e) {
throw new RuntimeException(e);
}
break;
case "vibur":
stats.activeConnections = viburPool.getActive();
stats.idleConnections = viburPool.getIdle();
stats.totalConnections = viburPool.getTotal();
stats.pendingThreads = remaining;
break;
case "druid":
stats.activeConnections = druid.getActiveCount();
stats.idleConnections = druid.getMinIdle();
stats.totalConnections = (int) druid.getCreateCount();
stats.pendingThreads = remaining;
break;
}
return stats;
}
private long warmupPool() throws InterruptedException
{
final LongAdder j = new LongAdder();
ExecutorService executor = Executors.newFixedThreadPool(10);
for (int k = 0; k < 10; k++) {
executor.execute(() -> {
for (int i = 0; i < 100_000; i++) {
try (Connection connection = DS.getConnection();
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT x FROM faux")) {
j.add(resultSet.getInt(i));
}
catch (SQLException e) {
throw new RuntimeException(e);
}
}
});
}
executor.shutdown();
executor.awaitTermination(60, SECONDS);
return j.sum();
}
private void setupDbcp2()
{
BasicDataSource ds = new DbcpPoolAccessor();
ds.setUrl(jdbcUrl);
ds.setUsername("brettw");
ds.setPassword("");
ds.setInitialSize(MIN_POOL_SIZE);
ds.setMinIdle(MIN_POOL_SIZE);
ds.setMaxIdle(MAX_POOL_SIZE);
ds.setMaxTotal(MAX_POOL_SIZE);
ds.setMaxWaitMillis(8000);
ds.setSoftMinEvictableIdleTimeMillis(MINUTES.toMillis(10));
ds.setTimeBetweenEvictionRunsMillis(SECONDS.toMillis(30));
ds.setDefaultAutoCommit(false);
ds.setRollbackOnReturn(true);
ds.setEnableAutoCommitOnReturn(false);
ds.setTestOnBorrow(true);
ds.setCacheState(true);
ds.setFastFailValidation(true);
try {
// forces internal pool creation
ds.getLogWriter();
}
catch (SQLException e) {
throw new RuntimeException(e);
}
DS = ds;
}
private void setupHikari()
{
HikariConfig config = new HikariConfig();
config.setJdbcUrl(jdbcUrl);
config.setUsername("brettw");
config.setPassword("");
config.setMinimumIdle(MIN_POOL_SIZE);
config.setMaximumPoolSize(MAX_POOL_SIZE);
config.setConnectionTimeout(8000);
config.setAutoCommit(false);
DS = new HikariDataSource(config);
}
protected void setupDruid() {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setInitialSize(MIN_POOL_SIZE);
dataSource.setMaxActive(MAX_POOL_SIZE);
dataSource.setMinIdle(MIN_POOL_SIZE);
dataSource.setMaxIdle(MAX_POOL_SIZE);
dataSource.setPoolPreparedStatements(true);
dataSource.setDriverClassName("com.zaxxer.hikari.benchmark.stubs.StubDriver");
dataSource.setUrl(jdbcUrl);
dataSource.setUsername("brettw");
dataSource.setPassword("");
dataSource.setValidationQuery("SELECT 1");
dataSource.setTestOnBorrow(true);
dataSource.setDefaultAutoCommit(false);
dataSource.setMaxWait(8000);
dataSource.setUseUnfairLock(true);
druid = dataSource;
DS = dataSource;
}
protected void setupTomcat()
{
PoolProperties props = new PoolProperties();
props.setUrl(jdbcUrl);
props.setDriverClassName("com.zaxxer.hikari.benchmark.stubs.StubDriver");
props.setUsername("brettw");
props.setPassword("");
props.setInitialSize(MIN_POOL_SIZE);
props.setMinIdle(MIN_POOL_SIZE);
props.setMaxIdle(MAX_POOL_SIZE);
props.setMaxActive(MAX_POOL_SIZE);
props.setMaxWait(8000);
props.setDefaultAutoCommit(false);
props.setRollbackOnReturn(true);
props.setUseDisposableConnectionFacade(true);
props.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState"); //;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
props.setTestOnBorrow(true);
props.setValidationInterval(250);
props.setValidator(new Validator() {
@Override
public boolean validate(Connection connection, int validateAction)
{
try {
return (validateAction == PooledConnection.VALIDATE_BORROW ? connection.isValid(0) : true);
}
catch (SQLException e)
{
return false;
}
}
});
DS = new TomcatPoolAccessor(props);
}
private void setupC3P0()
{
try {
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setJdbcUrl(jdbcUrl);
cpds.setUser("brettw");
cpds.setPassword("");
cpds.setAcquireIncrement(1);
cpds.setInitialPoolSize(MIN_POOL_SIZE);
cpds.setNumHelperThreads(2);
cpds.setMinPoolSize(MIN_POOL_SIZE);
cpds.setMaxPoolSize(MAX_POOL_SIZE);
cpds.setCheckoutTimeout(8000);
cpds.setLoginTimeout(8);
cpds.setTestConnectionOnCheckout(true);
try (Connection connection = cpds.getConnection()) {
// acquire and close to poke the pool into action
}
DS = cpds;
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
private void setupVibur()
{
ViburDBCPDataSource vibur = new ViburDBCPDataSource();
vibur.setJdbcUrl(jdbcUrl);
vibur.setUsername("brettw");
vibur.setPassword("");
vibur.setPoolFair(false);
vibur.setPoolInitialSize(MIN_POOL_SIZE);
vibur.setPoolMaxSize(MAX_POOL_SIZE);
vibur.setDefaultAutoCommit(false);
vibur.setResetDefaultsAfterUse(true);
vibur.setConnectionIdleLimitInSeconds(30);
vibur.setReducerTimeIntervalInSeconds((int) MINUTES.toSeconds(10));
viburPool = new ViburPoolHooks();
vibur.getConnHooks().addOnInit(viburPool.getInitHook());
vibur.getConnHooks().addOnGet(viburPool.getGetHook());
vibur.getConnHooks().addOnClose(viburPool.getCloseHook());
vibur.start();
DS = vibur;
}
private void shutdownPool(DataSource ds)
{
if (ds instanceof AutoCloseable) {
try {
((AutoCloseable) ds).close();
}
catch (Exception e) {
}
}
else if (ds instanceof ComboPooledDataSource) {
((ComboPooledDataSource) ds).close();
}
}
private static HikariPool getHikariPool(DataSource ds)
{
try {
Field field = ds.getClass().getDeclaredField("pool");
field.setAccessible(true);
return (HikariPool) field.get(ds);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
private static class ViburPoolHooks
{
private AtomicInteger created = new AtomicInteger();
private AtomicInteger active = new AtomicInteger();
int getTotal()
{
return created.get();
}
int getActive()
{
return active.get();
}
int getIdle()
{
return created.get() - active.get();
}
InitHook getInitHook()
{
return new InitHook();
}
GetHook getGetHook()
{
return new GetHook();
}
CloseHook getCloseHook()
{
return new CloseHook();
}
private class InitHook implements InitConnection
{
@Override
public void on(Connection rawConnection, long takenNanos) throws SQLException
{
created.incrementAndGet();
}
}
private class GetHook implements GetConnection
{
@Override
public void on(Connection rawConnection, long takenNanos) throws SQLException
{
active.incrementAndGet();
}
}
private class CloseHook implements CloseConnection
{
@Override
public void on(Connection rawConnection, long takenNanos) throws SQLException
{
active.decrementAndGet();
}
}
}
}
================================================
FILE: src/test/java/com/zaxxer/hikari/pool/HikariPoolAccessor.java
================================================
package com.zaxxer.hikari.pool;
public class HikariPoolAccessor
{
private final HikariPool pool;
public HikariPoolAccessor(HikariPool pool)
{
this.pool = pool;
}
public int[] getPoolStateCounts()
{
return pool.getPoolStateCounts();
}
}
================================================
FILE: src/test/java/org/apache/commons/dbcp2/DbcpPoolAccessor.java
================================================
package org.apache.commons.dbcp2;
import java.sql.Connection;
import java.sql.SQLException;
public final class DbcpPoolAccessor extends BasicDataSource
{
public DbcpPoolAccessor()
{
super();
}
@Override
public Connection getConnection() throws SQLException
{
return super.getConnection();
}
public int getNumTotal()
{
return (int) getConnectionPool().getCreatedCount();
}
}
================================================
FILE: src/test/java/org/apache/commons/dbcp2/TomcatPoolAccessor.java
================================================
package org.apache.commons.dbcp2;
import java.sql.Connection;
import java.sql.SQLException;
import org.apache.tomcat.jdbc.pool.DataSource;
import org.apache.tomcat.jdbc.pool.PoolProperties;
public final class TomcatPoolAccessor extends DataSource
{
public TomcatPoolAccessor(PoolProperties props)
{
super(props);
try {
// forces internal pool creation
super.createPool();
}
catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public Connection getConnection() throws SQLException
{
return super.getConnection();
}
public int getNumTotal()
{
return pool.getActive() + pool.getIdle();
}
}
gitextract_jdhmdfc8/
├── .gitignore
├── README.md
├── benchmark.cmd
├── benchmark.sh
├── lib/
│ └── one-datasource.jar
├── pom.xml
├── spiketest.sh
└── src/
├── main/
│ ├── java/
│ │ └── com/
│ │ └── zaxxer/
│ │ └── hikari/
│ │ └── benchmark/
│ │ ├── BenchBase.java
│ │ ├── ConnectionBench.java
│ │ ├── StatementBench.java
│ │ └── stubs/
│ │ ├── StubConnection.java
│ │ ├── StubDataSource.java
│ │ ├── StubDriver.java
│ │ ├── StubPreparedStatement.java
│ │ ├── StubResultSet.java
│ │ └── StubStatement.java
│ └── resources/
│ └── log4j2-test.xml
└── test/
└── java/
├── com/
│ └── zaxxer/
│ └── hikari/
│ ├── benchmark/
│ │ ├── BandwidthTest.java
│ │ ├── DbDownTest.java
│ │ └── SpikeLoadTest.java
│ └── pool/
│ └── HikariPoolAccessor.java
└── org/
└── apache/
└── commons/
└── dbcp2/
├── DbcpPoolAccessor.java
└── TomcatPoolAccessor.java
SYMBOL INDEX (494 symbols across 15 files)
FILE: src/main/java/com/zaxxer/hikari/benchmark/BenchBase.java
class BenchBase (line 49) | @State(Scope.Benchmark)
method setup (line 65) | @Setup(Level.Trial)
method teardown (line 119) | @TearDown(Level.Trial)
method setupDruid (line 155) | protected void setupDruid() {
method setupDruidStat (line 159) | protected void setupDruidStat()
method setupDruidStatMerge (line 171) | protected void setupDruidStatMerge()
method createDruid (line 180) | protected DruidDataSource createDruid()
method setupTomcat (line 201) | protected void setupTomcat()
method setupDbcp (line 238) | protected void setupDbcp()
method setupDbcp2 (line 256) | protected void setupDbcp2()
method setupHikari (line 278) | protected void setupHikari()
method setupC3P0 (line 292) | protected void setupC3P0()
method setupVibur (line 317) | private void setupVibur()
method setupOne (line 340) | private void setupOne()
FILE: src/main/java/com/zaxxer/hikari/benchmark/ConnectionBench.java
class ConnectionBench (line 37) | @Warmup(iterations=3)
method cycleCnnection (line 48) | @Benchmark
FILE: src/main/java/com/zaxxer/hikari/benchmark/StatementBench.java
class StatementBench (line 44) | @State(Scope.Benchmark)
method cycleStatement (line 51) | @Benchmark
class ConnectionState (line 61) | @State(Scope.Thread)
method setup (line 66) | @Setup(Level.Iteration)
method teardown (line 72) | @TearDown(Level.Iteration)
FILE: src/main/java/com/zaxxer/hikari/benchmark/stubs/StubConnection.java
class StubConnection (line 43) | public class StubConnection implements Connection
method unwrap (line 58) | public <T> T unwrap(Class<T> iface) throws SQLException
method isWrapperFor (line 64) | public boolean isWrapperFor(Class<?> iface) throws SQLException
method createStatement (line 70) | public Statement createStatement() throws SQLException
method prepareStatement (line 76) | public PreparedStatement prepareStatement(String sql) throws SQLException
method prepareCall (line 82) | public CallableStatement prepareCall(String sql) throws SQLException
method nativeSQL (line 88) | public String nativeSQL(String sql) throws SQLException
method setAutoCommit (line 94) | public void setAutoCommit(boolean autoCommit) throws SQLException
method getAutoCommit (line 100) | public boolean getAutoCommit() throws SQLException
method commit (line 106) | public void commit() throws SQLException
method rollback (line 112) | public void rollback() throws SQLException
method close (line 118) | public void close() throws SQLException
method isClosed (line 124) | public boolean isClosed() throws SQLException
method getMetaData (line 130) | public DatabaseMetaData getMetaData() throws SQLException
method setReadOnly (line 136) | public void setReadOnly(boolean readOnly) throws SQLException
method isReadOnly (line 141) | public boolean isReadOnly() throws SQLException
method setCatalog (line 147) | public void setCatalog(String catalog) throws SQLException
method getCatalog (line 152) | public String getCatalog() throws SQLException
method setTransactionIsolation (line 158) | public void setTransactionIsolation(int level) throws SQLException
method getTransactionIsolation (line 164) | public int getTransactionIsolation() throws SQLException
method getWarnings (line 170) | public SQLWarning getWarnings() throws SQLException
method clearWarnings (line 176) | public void clearWarnings() throws SQLException
method createStatement (line 182) | public Statement createStatement(int resultSetType, int resultSetConcu...
method prepareStatement (line 188) | public PreparedStatement prepareStatement(String sql, int resultSetTyp...
method prepareCall (line 194) | public CallableStatement prepareCall(String sql, int resultSetType, in...
method getTypeMap (line 200) | public Map<String, Class<?>> getTypeMap() throws SQLException
method setTypeMap (line 206) | public void setTypeMap(Map<String, Class<?>> map) throws SQLException
method setHoldability (line 211) | public void setHoldability(int holdability) throws SQLException
method getHoldability (line 216) | public int getHoldability() throws SQLException
method setSavepoint (line 222) | public Savepoint setSavepoint() throws SQLException
method setSavepoint (line 228) | public Savepoint setSavepoint(String name) throws SQLException
method rollback (line 234) | public void rollback(Savepoint savepoint) throws SQLException
method releaseSavepoint (line 239) | public void releaseSavepoint(Savepoint savepoint) throws SQLException
method createStatement (line 244) | public Statement createStatement(int resultSetType, int resultSetConcu...
method prepareStatement (line 250) | public PreparedStatement prepareStatement(String sql, int resultSetTyp...
method prepareCall (line 256) | public CallableStatement prepareCall(String sql, int resultSetType, in...
method prepareStatement (line 262) | public PreparedStatement prepareStatement(String sql, int autoGenerate...
method prepareStatement (line 268) | public PreparedStatement prepareStatement(String sql, int[] columnInde...
method prepareStatement (line 274) | public PreparedStatement prepareStatement(String sql, String[] columnN...
method createClob (line 280) | public Clob createClob() throws SQLException
method createBlob (line 286) | public Blob createBlob() throws SQLException
method createNClob (line 292) | public NClob createNClob() throws SQLException
method createSQLXML (line 298) | public SQLXML createSQLXML() throws SQLException
method isValid (line 304) | public boolean isValid(int timeout) throws SQLException
method setClientInfo (line 314) | public void setClientInfo(String name, String value) throws SQLClientI...
method setClientInfo (line 319) | public void setClientInfo(Properties properties) throws SQLClientInfoE...
method getClientInfo (line 324) | public String getClientInfo(String name) throws SQLException
method getClientInfo (line 330) | public Properties getClientInfo() throws SQLException
method createArrayOf (line 336) | public Array createArrayOf(String typeName, Object[] elements) throws ...
method createStruct (line 342) | public Struct createStruct(String typeName, Object[] attributes) throw...
method setSchema (line 348) | public void setSchema(String schema) throws SQLException
method getSchema (line 353) | public String getSchema() throws SQLException
method abort (line 359) | public void abort(Executor executor) throws SQLException
method setNetworkTimeout (line 364) | public void setNetworkTimeout(Executor executor, int milliseconds) thr...
method getNetworkTimeout (line 369) | public int getNetworkTimeout() throws SQLException
FILE: src/main/java/com/zaxxer/hikari/benchmark/stubs/StubDataSource.java
class StubDataSource (line 33) | public class StubDataSource implements DataSource
method setConnectionDelay (line 37) | public void setConnectionDelay(long millis)
method getLogWriter (line 43) | public PrintWriter getLogWriter() throws SQLException
method setLogWriter (line 49) | public void setLogWriter(PrintWriter out) throws SQLException
method setLoginTimeout (line 54) | public void setLoginTimeout(int seconds) throws SQLException
method getLoginTimeout (line 59) | public int getLoginTimeout() throws SQLException
method getParentLogger (line 65) | public Logger getParentLogger() throws SQLFeatureNotSupportedException
method unwrap (line 71) | public <T> T unwrap(Class<T> iface) throws SQLException
method isWrapperFor (line 77) | public boolean isWrapperFor(Class<?> iface) throws SQLException
method getConnection (line 83) | public Connection getConnection() throws SQLException
method getConnection (line 98) | public Connection getConnection(String username, String password) thro...
FILE: src/main/java/com/zaxxer/hikari/benchmark/stubs/StubDriver.java
class StubDriver (line 36) | public class StubDriver implements Driver
method setConnectDelayMs (line 51) | public static void setConnectDelayMs(final long delay)
method connect (line 57) | public Connection connect(String url, Properties info) throws SQLExcep...
method acceptsURL (line 71) | public boolean acceptsURL(String url) throws SQLException
method getPropertyInfo (line 77) | public DriverPropertyInfo[] getPropertyInfo(String url, Properties inf...
method getMajorVersion (line 83) | public int getMajorVersion()
method getMinorVersion (line 89) | public int getMinorVersion()
method jdbcCompliant (line 95) | public boolean jdbcCompliant()
method getParentLogger (line 101) | public Logger getParentLogger() throws SQLFeatureNotSupportedException
FILE: src/main/java/com/zaxxer/hikari/benchmark/stubs/StubPreparedStatement.java
class StubPreparedStatement (line 46) | public class StubPreparedStatement extends StubStatement implements Prep...
method executeQuery (line 50) | public ResultSet executeQuery(String sql) throws SQLException
method executeUpdate (line 56) | public int executeUpdate(String sql) throws SQLException
method getMaxFieldSize (line 62) | public int getMaxFieldSize() throws SQLException
method setMaxFieldSize (line 68) | public void setMaxFieldSize(int max) throws SQLException
method getMaxRows (line 73) | public int getMaxRows() throws SQLException
method setMaxRows (line 79) | public void setMaxRows(int max) throws SQLException
method setEscapeProcessing (line 84) | public void setEscapeProcessing(boolean enable) throws SQLException
method getQueryTimeout (line 89) | public int getQueryTimeout() throws SQLException
method setQueryTimeout (line 95) | public void setQueryTimeout(int seconds) throws SQLException
method cancel (line 100) | public void cancel() throws SQLException
method getWarnings (line 105) | public SQLWarning getWarnings() throws SQLException
method clearWarnings (line 111) | public void clearWarnings() throws SQLException
method setCursorName (line 116) | public void setCursorName(String name) throws SQLException
method execute (line 121) | public boolean execute(String sql) throws SQLException
method getResultSet (line 127) | public ResultSet getResultSet() throws SQLException
method getUpdateCount (line 133) | public int getUpdateCount() throws SQLException
method getMoreResults (line 139) | public boolean getMoreResults() throws SQLException
method setFetchDirection (line 145) | public void setFetchDirection(int direction) throws SQLException
method getFetchDirection (line 150) | public int getFetchDirection() throws SQLException
method setFetchSize (line 156) | public void setFetchSize(int rows) throws SQLException
method getFetchSize (line 161) | public int getFetchSize() throws SQLException
method getResultSetConcurrency (line 167) | public int getResultSetConcurrency() throws SQLException
method getResultSetType (line 173) | public int getResultSetType() throws SQLException
method addBatch (line 179) | public void addBatch(String sql) throws SQLException
method clearBatch (line 184) | public void clearBatch() throws SQLException
method executeBatch (line 189) | public int[] executeBatch() throws SQLException
method getConnection (line 200) | public Connection getConnection() throws SQLException
method getMoreResults (line 206) | public boolean getMoreResults(int current) throws SQLException
method getGeneratedKeys (line 212) | public ResultSet getGeneratedKeys() throws SQLException
method executeUpdate (line 218) | public int executeUpdate(String sql, int autoGeneratedKeys) throws SQL...
method executeUpdate (line 224) | public int executeUpdate(String sql, int[] columnIndexes) throws SQLEx...
method executeUpdate (line 230) | public int executeUpdate(String sql, String[] columnNames) throws SQLE...
method execute (line 236) | public boolean execute(String sql, int autoGeneratedKeys) throws SQLEx...
method execute (line 242) | public boolean execute(String sql, int[] columnIndexes) throws SQLExce...
method execute (line 248) | public boolean execute(String sql, String[] columnNames) throws SQLExc...
method getResultSetHoldability (line 254) | public int getResultSetHoldability() throws SQLException
method setPoolable (line 260) | public void setPoolable(boolean poolable) throws SQLException
method isPoolable (line 265) | public boolean isPoolable() throws SQLException
method closeOnCompletion (line 271) | public void closeOnCompletion() throws SQLException
method isCloseOnCompletion (line 276) | public boolean isCloseOnCompletion() throws SQLException
method executeQuery (line 282) | public ResultSet executeQuery() throws SQLException
method executeUpdate (line 288) | public int executeUpdate() throws SQLException
method setNull (line 294) | public void setNull(int parameterIndex, int sqlType) throws SQLException
method setBoolean (line 299) | public void setBoolean(int parameterIndex, boolean x) throws SQLException
method setByte (line 304) | public void setByte(int parameterIndex, byte x) throws SQLException
method setShort (line 309) | public void setShort(int parameterIndex, short x) throws SQLException
method setInt (line 314) | public void setInt(int parameterIndex, int x) throws SQLException
method setLong (line 327) | public void setLong(int parameterIndex, long x) throws SQLException
method setFloat (line 332) | public void setFloat(int parameterIndex, float x) throws SQLException
method setDouble (line 337) | public void setDouble(int parameterIndex, double x) throws SQLException
method setBigDecimal (line 342) | public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQL...
method setString (line 347) | public void setString(int parameterIndex, String x) throws SQLException
method setBytes (line 352) | public void setBytes(int parameterIndex, byte[] x) throws SQLException
method setDate (line 357) | public void setDate(int parameterIndex, Date x) throws SQLException
method setTime (line 362) | public void setTime(int parameterIndex, Time x) throws SQLException
method setTimestamp (line 367) | public void setTimestamp(int parameterIndex, Timestamp x) throws SQLEx...
method setAsciiStream (line 372) | public void setAsciiStream(int parameterIndex, InputStream x, int leng...
method setUnicodeStream (line 377) | public void setUnicodeStream(int parameterIndex, InputStream x, int le...
method setBinaryStream (line 382) | public void setBinaryStream(int parameterIndex, InputStream x, int len...
method clearParameters (line 387) | public void clearParameters() throws SQLException
method setObject (line 392) | public void setObject(int parameterIndex, Object x, int targetSqlType)...
method setObject (line 397) | public void setObject(int parameterIndex, Object x) throws SQLException
method execute (line 402) | public boolean execute() throws SQLException
method addBatch (line 408) | public void addBatch() throws SQLException
method setCharacterStream (line 413) | public void setCharacterStream(int parameterIndex, Reader reader, int ...
method setRef (line 418) | public void setRef(int parameterIndex, Ref x) throws SQLException
method setBlob (line 423) | public void setBlob(int parameterIndex, Blob x) throws SQLException
method setClob (line 428) | public void setClob(int parameterIndex, Clob x) throws SQLException
method setArray (line 433) | public void setArray(int parameterIndex, Array x) throws SQLException
method getMetaData (line 438) | public ResultSetMetaData getMetaData() throws SQLException
method setDate (line 444) | public void setDate(int parameterIndex, Date x, Calendar cal) throws S...
method setTime (line 449) | public void setTime(int parameterIndex, Time x, Calendar cal) throws S...
method setTimestamp (line 454) | public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal...
method setNull (line 459) | public void setNull(int parameterIndex, int sqlType, String typeName) ...
method setURL (line 464) | public void setURL(int parameterIndex, URL x) throws SQLException
method getParameterMetaData (line 469) | public ParameterMetaData getParameterMetaData() throws SQLException
method setRowId (line 475) | public void setRowId(int parameterIndex, RowId x) throws SQLException
method setNString (line 480) | public void setNString(int parameterIndex, String value) throws SQLExc...
method setNCharacterStream (line 485) | public void setNCharacterStream(int parameterIndex, Reader value, long...
method setNClob (line 490) | public void setNClob(int parameterIndex, NClob value) throws SQLException
method setClob (line 495) | public void setClob(int parameterIndex, Reader reader, long length) th...
method setBlob (line 500) | public void setBlob(int parameterIndex, InputStream inputStream, long ...
method setNClob (line 505) | public void setNClob(int parameterIndex, Reader reader, long length) t...
method setSQLXML (line 510) | public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQL...
method setObject (line 515) | public void setObject(int parameterIndex, Object x, int targetSqlType,...
method setAsciiStream (line 520) | public void setAsciiStream(int parameterIndex, InputStream x, long len...
method setBinaryStream (line 525) | public void setBinaryStream(int parameterIndex, InputStream x, long le...
method setCharacterStream (line 530) | public void setCharacterStream(int parameterIndex, Reader reader, long...
method setAsciiStream (line 535) | public void setAsciiStream(int parameterIndex, InputStream x) throws S...
method setBinaryStream (line 540) | public void setBinaryStream(int parameterIndex, InputStream x) throws ...
method setCharacterStream (line 545) | public void setCharacterStream(int parameterIndex, Reader reader) thro...
method setNCharacterStream (line 550) | public void setNCharacterStream(int parameterIndex, Reader value) thro...
method setClob (line 555) | public void setClob(int parameterIndex, Reader reader) throws SQLExcep...
method setBlob (line 560) | public void setBlob(int parameterIndex, InputStream inputStream) throw...
method setNClob (line 565) | public void setNClob(int parameterIndex, Reader reader) throws SQLExce...
FILE: src/main/java/com/zaxxer/hikari/benchmark/stubs/StubResultSet.java
class StubResultSet (line 45) | public class StubResultSet implements ResultSet
method unwrap (line 51) | public <T> T unwrap(Class<T> iface) throws SQLException
method isWrapperFor (line 58) | public boolean isWrapperFor(Class<?> iface) throws SQLException
method next (line 64) | public boolean next() throws SQLException
method close (line 70) | public void close() throws SQLException
method wasNull (line 76) | public boolean wasNull() throws SQLException
method getString (line 82) | public String getString(int columnIndex) throws SQLException
method getBoolean (line 88) | public boolean getBoolean(int columnIndex) throws SQLException
method getByte (line 94) | public byte getByte(int columnIndex) throws SQLException
method getShort (line 100) | public short getShort(int columnIndex) throws SQLException
method getInt (line 106) | public int getInt(int columnIndex) throws SQLException
method getLong (line 112) | public long getLong(int columnIndex) throws SQLException
method getFloat (line 118) | public float getFloat(int columnIndex) throws SQLException
method getDouble (line 124) | public double getDouble(int columnIndex) throws SQLException
method getBigDecimal (line 130) | public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQL...
method getBytes (line 136) | public byte[] getBytes(int columnIndex) throws SQLException
method getDate (line 142) | public Date getDate(int columnIndex) throws SQLException
method getTime (line 148) | public Time getTime(int columnIndex) throws SQLException
method getTimestamp (line 154) | public Timestamp getTimestamp(int columnIndex) throws SQLException
method getAsciiStream (line 160) | public InputStream getAsciiStream(int columnIndex) throws SQLException
method getUnicodeStream (line 166) | public InputStream getUnicodeStream(int columnIndex) throws SQLException
method getBinaryStream (line 172) | public InputStream getBinaryStream(int columnIndex) throws SQLException
method getString (line 178) | public String getString(String columnLabel) throws SQLException
method getBoolean (line 184) | public boolean getBoolean(String columnLabel) throws SQLException
method getByte (line 190) | public byte getByte(String columnLabel) throws SQLException
method getShort (line 196) | public short getShort(String columnLabel) throws SQLException
method getInt (line 202) | public int getInt(String columnLabel) throws SQLException
method getLong (line 208) | public long getLong(String columnLabel) throws SQLException
method getFloat (line 214) | public float getFloat(String columnLabel) throws SQLException
method getDouble (line 220) | public double getDouble(String columnLabel) throws SQLException
method getBigDecimal (line 226) | public BigDecimal getBigDecimal(String columnLabel, int scale) throws ...
method getBytes (line 232) | public byte[] getBytes(String columnLabel) throws SQLException
method getDate (line 238) | public Date getDate(String columnLabel) throws SQLException
method getTime (line 244) | public Time getTime(String columnLabel) throws SQLException
method getTimestamp (line 250) | public Timestamp getTimestamp(String columnLabel) throws SQLException
method getAsciiStream (line 256) | public InputStream getAsciiStream(String columnLabel) throws SQLException
method getUnicodeStream (line 262) | public InputStream getUnicodeStream(String columnLabel) throws SQLExce...
method getBinaryStream (line 268) | public InputStream getBinaryStream(String columnLabel) throws SQLExcep...
method getWarnings (line 274) | public SQLWarning getWarnings() throws SQLException
method clearWarnings (line 280) | public void clearWarnings() throws SQLException
method getCursorName (line 285) | public String getCursorName() throws SQLException
method getMetaData (line 291) | public ResultSetMetaData getMetaData() throws SQLException
method getObject (line 297) | public Object getObject(int columnIndex) throws SQLException
method getObject (line 303) | public Object getObject(String columnLabel) throws SQLException
method findColumn (line 309) | public int findColumn(String columnLabel) throws SQLException
method getCharacterStream (line 315) | public Reader getCharacterStream(int columnIndex) throws SQLException
method getCharacterStream (line 321) | public Reader getCharacterStream(String columnLabel) throws SQLException
method getBigDecimal (line 327) | public BigDecimal getBigDecimal(int columnIndex) throws SQLException
method getBigDecimal (line 333) | public BigDecimal getBigDecimal(String columnLabel) throws SQLException
method isBeforeFirst (line 339) | public boolean isBeforeFirst() throws SQLException
method isAfterLast (line 345) | public boolean isAfterLast() throws SQLException
method isFirst (line 351) | public boolean isFirst() throws SQLException
method isLast (line 357) | public boolean isLast() throws SQLException
method beforeFirst (line 363) | public void beforeFirst() throws SQLException
method afterLast (line 368) | public void afterLast() throws SQLException
method first (line 373) | public boolean first() throws SQLException
method last (line 379) | public boolean last() throws SQLException
method getRow (line 385) | public int getRow() throws SQLException
method absolute (line 391) | public boolean absolute(int row) throws SQLException
method relative (line 397) | public boolean relative(int rows) throws SQLException
method previous (line 403) | public boolean previous() throws SQLException
method setFetchDirection (line 409) | public void setFetchDirection(int direction) throws SQLException
method getFetchDirection (line 414) | public int getFetchDirection() throws SQLException
method setFetchSize (line 420) | public void setFetchSize(int rows) throws SQLException
method getFetchSize (line 425) | public int getFetchSize() throws SQLException
method getType (line 431) | public int getType() throws SQLException
method getConcurrency (line 437) | public int getConcurrency() throws SQLException
method rowUpdated (line 443) | public boolean rowUpdated() throws SQLException
method rowInserted (line 449) | public boolean rowInserted() throws SQLException
method rowDeleted (line 455) | public boolean rowDeleted() throws SQLException
method updateNull (line 461) | public void updateNull(int columnIndex) throws SQLException
method updateBoolean (line 466) | public void updateBoolean(int columnIndex, boolean x) throws SQLException
method updateByte (line 471) | public void updateByte(int columnIndex, byte x) throws SQLException
method updateShort (line 476) | public void updateShort(int columnIndex, short x) throws SQLException
method updateInt (line 481) | public void updateInt(int columnIndex, int x) throws SQLException
method updateLong (line 486) | public void updateLong(int columnIndex, long x) throws SQLException
method updateFloat (line 491) | public void updateFloat(int columnIndex, float x) throws SQLException
method updateDouble (line 496) | public void updateDouble(int columnIndex, double x) throws SQLException
method updateBigDecimal (line 501) | public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQL...
method updateString (line 506) | public void updateString(int columnIndex, String x) throws SQLException
method updateBytes (line 511) | public void updateBytes(int columnIndex, byte[] x) throws SQLException
method updateDate (line 516) | public void updateDate(int columnIndex, Date x) throws SQLException
method updateTime (line 521) | public void updateTime(int columnIndex, Time x) throws SQLException
method updateTimestamp (line 526) | public void updateTimestamp(int columnIndex, Timestamp x) throws SQLEx...
method updateAsciiStream (line 531) | public void updateAsciiStream(int columnIndex, InputStream x, int leng...
method updateBinaryStream (line 536) | public void updateBinaryStream(int columnIndex, InputStream x, int len...
method updateCharacterStream (line 541) | public void updateCharacterStream(int columnIndex, Reader x, int lengt...
method updateObject (line 546) | public void updateObject(int columnIndex, Object x, int scaleOrLength)...
method updateObject (line 551) | public void updateObject(int columnIndex, Object x) throws SQLException
method updateNull (line 556) | public void updateNull(String columnLabel) throws SQLException
method updateBoolean (line 561) | public void updateBoolean(String columnLabel, boolean x) throws SQLExc...
method updateByte (line 566) | public void updateByte(String columnLabel, byte x) throws SQLException
method updateShort (line 571) | public void updateShort(String columnLabel, short x) throws SQLException
method updateInt (line 576) | public void updateInt(String columnLabel, int x) throws SQLException
method updateLong (line 581) | public void updateLong(String columnLabel, long x) throws SQLException
method updateFloat (line 586) | public void updateFloat(String columnLabel, float x) throws SQLException
method updateDouble (line 591) | public void updateDouble(String columnLabel, double x) throws SQLExcep...
method updateBigDecimal (line 596) | public void updateBigDecimal(String columnLabel, BigDecimal x) throws ...
method updateString (line 601) | public void updateString(String columnLabel, String x) throws SQLExcep...
method updateBytes (line 606) | public void updateBytes(String columnLabel, byte[] x) throws SQLException
method updateDate (line 611) | public void updateDate(String columnLabel, Date x) throws SQLException
method updateTime (line 616) | public void updateTime(String columnLabel, Time x) throws SQLException
method updateTimestamp (line 621) | public void updateTimestamp(String columnLabel, Timestamp x) throws SQ...
method updateAsciiStream (line 626) | public void updateAsciiStream(String columnLabel, InputStream x, int l...
method updateBinaryStream (line 631) | public void updateBinaryStream(String columnLabel, InputStream x, int ...
method updateCharacterStream (line 636) | public void updateCharacterStream(String columnLabel, Reader reader, i...
method updateObject (line 641) | public void updateObject(String columnLabel, Object x, int scaleOrLeng...
method updateObject (line 646) | public void updateObject(String columnLabel, Object x) throws SQLExcep...
method insertRow (line 651) | public void insertRow() throws SQLException
method updateRow (line 656) | public void updateRow() throws SQLException
method deleteRow (line 661) | public void deleteRow() throws SQLException
method refreshRow (line 666) | public void refreshRow() throws SQLException
method cancelRowUpdates (line 671) | public void cancelRowUpdates() throws SQLException
method moveToInsertRow (line 676) | public void moveToInsertRow() throws SQLException
method moveToCurrentRow (line 681) | public void moveToCurrentRow() throws SQLException
method getStatement (line 686) | public Statement getStatement() throws SQLException
method getObject (line 692) | public Object getObject(int columnIndex, Map<String, Class<?>> map) th...
method getRef (line 698) | public Ref getRef(int columnIndex) throws SQLException
method getBlob (line 704) | public Blob getBlob(int columnIndex) throws SQLException
method getClob (line 710) | public Clob getClob(int columnIndex) throws SQLException
method getArray (line 716) | public Array getArray(int columnIndex) throws SQLException
method getObject (line 722) | public Object getObject(String columnLabel, Map<String, Class<?>> map)...
method getRef (line 728) | public Ref getRef(String columnLabel) throws SQLException
method getBlob (line 734) | public Blob getBlob(String columnLabel) throws SQLException
method getClob (line 740) | public Clob getClob(String columnLabel) throws SQLException
method getArray (line 746) | public Array getArray(String columnLabel) throws SQLException
method getDate (line 752) | public Date getDate(int columnIndex, Calendar cal) throws SQLException
method getDate (line 758) | public Date getDate(String columnLabel, Calendar cal) throws SQLException
method getTime (line 764) | public Time getTime(int columnIndex, Calendar cal) throws SQLException
method getTime (line 770) | public Time getTime(String columnLabel, Calendar cal) throws SQLException
method getTimestamp (line 776) | public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQ...
method getTimestamp (line 782) | public Timestamp getTimestamp(String columnLabel, Calendar cal) throws...
method getURL (line 788) | public URL getURL(int columnIndex) throws SQLException
method getURL (line 794) | public URL getURL(String columnLabel) throws SQLException
method updateRef (line 800) | public void updateRef(int columnIndex, Ref x) throws SQLException
method updateRef (line 805) | public void updateRef(String columnLabel, Ref x) throws SQLException
method updateBlob (line 810) | public void updateBlob(int columnIndex, Blob x) throws SQLException
method updateBlob (line 815) | public void updateBlob(String columnLabel, Blob x) throws SQLException
method updateClob (line 820) | public void updateClob(int columnIndex, Clob x) throws SQLException
method updateClob (line 825) | public void updateClob(String columnLabel, Clob x) throws SQLException
method updateArray (line 830) | public void updateArray(int columnIndex, Array x) throws SQLException
method updateArray (line 835) | public void updateArray(String columnLabel, Array x) throws SQLException
method getRowId (line 840) | public RowId getRowId(int columnIndex) throws SQLException
method getRowId (line 846) | public RowId getRowId(String columnLabel) throws SQLException
method updateRowId (line 852) | public void updateRowId(int columnIndex, RowId x) throws SQLException
method updateRowId (line 857) | public void updateRowId(String columnLabel, RowId x) throws SQLException
method getHoldability (line 862) | public int getHoldability() throws SQLException
method isClosed (line 868) | public boolean isClosed() throws SQLException
method updateNString (line 874) | public void updateNString(int columnIndex, String nString) throws SQLE...
method updateNString (line 879) | public void updateNString(String columnLabel, String nString) throws S...
method updateNClob (line 884) | public void updateNClob(int columnIndex, NClob nClob) throws SQLException
method updateNClob (line 889) | public void updateNClob(String columnLabel, NClob nClob) throws SQLExc...
method getNClob (line 894) | public NClob getNClob(int columnIndex) throws SQLException
method getNClob (line 900) | public NClob getNClob(String columnLabel) throws SQLException
method getSQLXML (line 906) | public SQLXML getSQLXML(int columnIndex) throws SQLException
method getSQLXML (line 912) | public SQLXML getSQLXML(String columnLabel) throws SQLException
method updateSQLXML (line 918) | public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQL...
method updateSQLXML (line 923) | public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws ...
method getNString (line 928) | public String getNString(int columnIndex) throws SQLException
method getNString (line 934) | public String getNString(String columnLabel) throws SQLException
method getNCharacterStream (line 940) | public Reader getNCharacterStream(int columnIndex) throws SQLException
method getNCharacterStream (line 946) | public Reader getNCharacterStream(String columnLabel) throws SQLException
method updateNCharacterStream (line 952) | public void updateNCharacterStream(int columnIndex, Reader x, long len...
method updateNCharacterStream (line 957) | public void updateNCharacterStream(String columnLabel, Reader reader, ...
method updateAsciiStream (line 962) | public void updateAsciiStream(int columnIndex, InputStream x, long len...
method updateBinaryStream (line 967) | public void updateBinaryStream(int columnIndex, InputStream x, long le...
method updateCharacterStream (line 972) | public void updateCharacterStream(int columnIndex, Reader x, long leng...
method updateAsciiStream (line 977) | public void updateAsciiStream(String columnLabel, InputStream x, long ...
method updateBinaryStream (line 982) | public void updateBinaryStream(String columnLabel, InputStream x, long...
method updateCharacterStream (line 987) | public void updateCharacterStream(String columnLabel, Reader reader, l...
method updateBlob (line 992) | public void updateBlob(int columnIndex, InputStream inputStream, long ...
method updateBlob (line 997) | public void updateBlob(String columnLabel, InputStream inputStream, lo...
method updateClob (line 1002) | public void updateClob(int columnIndex, Reader reader, long length) th...
method updateClob (line 1007) | public void updateClob(String columnLabel, Reader reader, long length)...
method updateNClob (line 1012) | public void updateNClob(int columnIndex, Reader reader, long length) t...
method updateNClob (line 1017) | public void updateNClob(String columnLabel, Reader reader, long length...
method updateNCharacterStream (line 1022) | public void updateNCharacterStream(int columnIndex, Reader x) throws S...
method updateNCharacterStream (line 1027) | public void updateNCharacterStream(String columnLabel, Reader reader) ...
method updateAsciiStream (line 1032) | public void updateAsciiStream(int columnIndex, InputStream x) throws S...
method updateBinaryStream (line 1037) | public void updateBinaryStream(int columnIndex, InputStream x) throws ...
method updateCharacterStream (line 1042) | public void updateCharacterStream(int columnIndex, Reader x) throws SQ...
method updateAsciiStream (line 1047) | public void updateAsciiStream(String columnLabel, InputStream x) throw...
method updateBinaryStream (line 1052) | public void updateBinaryStream(String columnLabel, InputStream x) thro...
method updateCharacterStream (line 1057) | public void updateCharacterStream(String columnLabel, Reader reader) t...
method updateBlob (line 1062) | public void updateBlob(int columnIndex, InputStream inputStream) throw...
method updateBlob (line 1067) | public void updateBlob(String columnLabel, InputStream inputStream) th...
method updateClob (line 1072) | public void updateClob(int columnIndex, Reader reader) throws SQLExcep...
method updateClob (line 1077) | public void updateClob(String columnLabel, Reader reader) throws SQLEx...
method updateNClob (line 1082) | public void updateNClob(int columnIndex, Reader reader) throws SQLExce...
method updateNClob (line 1087) | public void updateNClob(String columnLabel, Reader reader) throws SQLE...
method getObject (line 1092) | public <T> T getObject(int columnIndex, Class<T> type) throws SQLExcep...
method getObject (line 1098) | public <T> T getObject(String columnLabel, Class<T> type) throws SQLEx...
FILE: src/main/java/com/zaxxer/hikari/benchmark/stubs/StubStatement.java
class StubStatement (line 34) | public class StubStatement implements Statement
method setExecuteDelayMs (line 40) | public static void setExecuteDelayMs(final long delay)
method unwrap (line 46) | @SuppressWarnings("unchecked")
method isWrapperFor (line 57) | public boolean isWrapperFor(Class<?> iface) throws SQLException
method executeQuery (line 63) | public ResultSet executeQuery(String sql) throws SQLException
method executeUpdate (line 76) | public int executeUpdate(String sql) throws SQLException
method close (line 82) | public void close() throws SQLException
method getMaxFieldSize (line 88) | public int getMaxFieldSize() throws SQLException
method setMaxFieldSize (line 94) | public void setMaxFieldSize(int max) throws SQLException
method getMaxRows (line 99) | public int getMaxRows() throws SQLException
method setMaxRows (line 105) | public void setMaxRows(int max) throws SQLException
method setEscapeProcessing (line 110) | public void setEscapeProcessing(boolean enable) throws SQLException
method getQueryTimeout (line 115) | public int getQueryTimeout() throws SQLException
method setQueryTimeout (line 121) | public void setQueryTimeout(int seconds) throws SQLException
method cancel (line 126) | public void cancel() throws SQLException
method getWarnings (line 131) | public SQLWarning getWarnings() throws SQLException
method clearWarnings (line 137) | public void clearWarnings() throws SQLException
method setCursorName (line 142) | public void setCursorName(String name) throws SQLException
method execute (line 147) | public boolean execute(String sql) throws SQLException
method getResultSet (line 153) | public ResultSet getResultSet() throws SQLException
method getUpdateCount (line 159) | public int getUpdateCount() throws SQLException
method getMoreResults (line 165) | public boolean getMoreResults() throws SQLException
method setFetchDirection (line 171) | public void setFetchDirection(int direction) throws SQLException
method getFetchDirection (line 176) | public int getFetchDirection() throws SQLException
method setFetchSize (line 182) | public void setFetchSize(int rows) throws SQLException
method getFetchSize (line 187) | public int getFetchSize() throws SQLException
method getResultSetConcurrency (line 193) | public int getResultSetConcurrency() throws SQLException
method getResultSetType (line 199) | public int getResultSetType() throws SQLException
method addBatch (line 205) | public void addBatch(String sql) throws SQLException
method clearBatch (line 210) | public void clearBatch() throws SQLException
method executeBatch (line 215) | public int[] executeBatch() throws SQLException
method getConnection (line 221) | public Connection getConnection() throws SQLException
method getMoreResults (line 227) | public boolean getMoreResults(int current) throws SQLException
method getGeneratedKeys (line 233) | public ResultSet getGeneratedKeys() throws SQLException
method executeUpdate (line 239) | public int executeUpdate(String sql, int autoGeneratedKeys) throws SQL...
method executeUpdate (line 245) | public int executeUpdate(String sql, int[] columnIndexes) throws SQLEx...
method executeUpdate (line 251) | public int executeUpdate(String sql, String[] columnNames) throws SQLE...
method execute (line 257) | public boolean execute(String sql, int autoGeneratedKeys) throws SQLEx...
method execute (line 263) | public boolean execute(String sql, int[] columnIndexes) throws SQLExce...
method execute (line 269) | public boolean execute(String sql, String[] columnNames) throws SQLExc...
method getResultSetHoldability (line 275) | public int getResultSetHoldability() throws SQLException
method isClosed (line 281) | public boolean isClosed() throws SQLException
method setPoolable (line 287) | public void setPoolable(boolean poolable) throws SQLException
method isPoolable (line 292) | public boolean isPoolable() throws SQLException
method closeOnCompletion (line 298) | public void closeOnCompletion() throws SQLException
method isCloseOnCompletion (line 303) | public boolean isCloseOnCompletion() throws SQLException
method getCount (line 308) | public int getCount()
FILE: src/test/java/com/zaxxer/hikari/benchmark/BandwidthTest.java
class BandwidthTest (line 33) | public class BandwidthTest
method main (line 45) | public static void main(String[] args) throws InterruptedException, SQ...
method setup (line 55) | private void setup(String[] args) throws SQLException
method start (line 87) | private int start() throws InterruptedException, SQLException
method shutdownPool (line 118) | private void shutdownPool(DataSource ds)
method setupHikari (line 129) | private void setupHikari()
method setupDbcp2 (line 145) | private void setupDbcp2()
method setupTomcat (line 173) | protected void setupTomcat()
method setupVibur (line 213) | private void setupVibur()
FILE: src/test/java/com/zaxxer/hikari/benchmark/DbDownTest.java
class DbDownTest (line 25) | public class DbDownTest
method main (line 39) | public static void main(String[] args)
method DbDownTest (line 45) | private DbDownTest()
method start (line 53) | private void start()
method setupDbcp2 (line 107) | protected DataSource setupDbcp2()
method setupBone (line 129) | protected DataSource setupBone()
method setupHikari (line 146) | protected DataSource setupHikari()
method setupC3P0 (line 161) | protected DataSource setupC3P0()
method setupVibur (line 186) | private DataSource setupVibur()
FILE: src/test/java/com/zaxxer/hikari/benchmark/SpikeLoadTest.java
class SpikeLoadTest (line 55) | public class SpikeLoadTest
method main (line 86) | public static void main(String[] args) throws InterruptedException
method setup (line 95) | private void setup(String[] args)
method start (line 151) | private void start(int connectDelay) throws InterruptedException
method dumpStats (line 215) | private void dumpStats(List<PoolStatistics> statsList, List<RequestThr...
class RequestThread (line 228) | private class RequestThread extends TimerTask implements Runnable
method run (line 238) | @Override
method toString (line 262) | @Override
class PoolStatistics (line 273) | private static class PoolStatistics
method PoolStatistics (line 281) | PoolStatistics(final long baseTime) {
method toString (line 285) | @Override
method getPoolStatistics (line 292) | private PoolStatistics getPoolStatistics(final long baseTime, int rema...
method warmupPool (line 344) | private long warmupPool() throws InterruptedException
method setupDbcp2 (line 369) | private void setupDbcp2()
method setupHikari (line 402) | private void setupHikari()
method setupDruid (line 416) | protected void setupDruid() {
method setupTomcat (line 439) | protected void setupTomcat()
method setupC3P0 (line 476) | private void setupC3P0()
method setupVibur (line 503) | private void setupVibur()
method shutdownPool (line 529) | private void shutdownPool(DataSource ds)
method getHikariPool (line 543) | private static HikariPool getHikariPool(DataSource ds)
class ViburPoolHooks (line 555) | private static class ViburPoolHooks
method getTotal (line 560) | int getTotal()
method getActive (line 565) | int getActive()
method getIdle (line 570) | int getIdle()
method getInitHook (line 575) | InitHook getInitHook()
method getGetHook (line 580) | GetHook getGetHook()
method getCloseHook (line 585) | CloseHook getCloseHook()
class InitHook (line 590) | private class InitHook implements InitConnection
method on (line 592) | @Override
class GetHook (line 599) | private class GetHook implements GetConnection
method on (line 601) | @Override
class CloseHook (line 608) | private class CloseHook implements CloseConnection
method on (line 610) | @Override
FILE: src/test/java/com/zaxxer/hikari/pool/HikariPoolAccessor.java
class HikariPoolAccessor (line 3) | public class HikariPoolAccessor
method HikariPoolAccessor (line 7) | public HikariPoolAccessor(HikariPool pool)
method getPoolStateCounts (line 12) | public int[] getPoolStateCounts()
FILE: src/test/java/org/apache/commons/dbcp2/DbcpPoolAccessor.java
class DbcpPoolAccessor (line 6) | public final class DbcpPoolAccessor extends BasicDataSource
method DbcpPoolAccessor (line 8) | public DbcpPoolAccessor()
method getConnection (line 13) | @Override
method getNumTotal (line 19) | public int getNumTotal()
FILE: src/test/java/org/apache/commons/dbcp2/TomcatPoolAccessor.java
class TomcatPoolAccessor (line 9) | public final class TomcatPoolAccessor extends DataSource
method TomcatPoolAccessor (line 11) | public TomcatPoolAccessor(PoolProperties props)
method getConnection (line 24) | @Override
method getNumTotal (line 30) | public int getNumTotal()
Condensed preview — 23 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (127K chars).
[
{
"path": ".gitignore",
"chars": 181,
"preview": "target\n.classpath\n.project\n.settings/org.eclipse.core.resources.prefs\n.settings/org.eclipse.jdt.core.prefs\n.settings/org"
},
{
"path": "README.md",
"chars": 4000,
"preview": "[](https://w"
},
{
"path": "benchmark.cmd",
"chars": 794,
"preview": "@echo off\nsetlocal\n\nset JAVA_OPTIONS=-server -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms1096m -Xmx1096m\n\ncall m"
},
{
"path": "benchmark.sh",
"chars": 1451,
"preview": "#!/bin/bash\n\nJAVA_OPTIONS=\"-server -XX:-RestrictContended -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms1096m -Xmx"
},
{
"path": "pom.xml",
"chars": 6222,
"preview": "<!-- Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. \n\tDO NOT ALTER OR REMOVE COPYRIGHT NOT"
},
{
"path": "spiketest.sh",
"chars": 337,
"preview": "#!/bin/bash\n\nJAVA_OPTIONS=\"-server -XX:-RestrictContended -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms1096m -Xmx"
},
{
"path": "src/main/java/com/zaxxer/hikari/benchmark/BenchBase.java",
"chars": 10395,
"preview": "/*\n * Copyright (C) 2014 Brett Wooldridge\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "src/main/java/com/zaxxer/hikari/benchmark/ConnectionBench.java",
"chars": 1818,
"preview": "/*\n * Copyright (C) 2014 Brett Wooldridge\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "src/main/java/com/zaxxer/hikari/benchmark/StatementBench.java",
"chars": 2504,
"preview": "/*\n * Copyright (C) 2014 Brett Wooldridge\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "src/main/java/com/zaxxer/hikari/benchmark/stubs/StubConnection.java",
"chars": 8421,
"preview": "/*\n * Copyright (C) 2014 Brett Wooldridge\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "src/main/java/com/zaxxer/hikari/benchmark/stubs/StubDataSource.java",
"chars": 2445,
"preview": "/*\n * Copyright (C) 2014 Brett Wooldridge\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "src/main/java/com/zaxxer/hikari/benchmark/stubs/StubDriver.java",
"chars": 2557,
"preview": "/*\n * Copyright (C) 2014 Brett Wooldridge\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "src/main/java/com/zaxxer/hikari/benchmark/stubs/StubPreparedStatement.java",
"chars": 12828,
"preview": "/*\n * Copyright (C) 2014 Brett Wooldridge\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "src/main/java/com/zaxxer/hikari/benchmark/stubs/StubResultSet.java",
"chars": 24449,
"preview": "/*\n * Copyright (C) 2014 Brett Wooldridge\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "src/main/java/com/zaxxer/hikari/benchmark/stubs/StubStatement.java",
"chars": 6469,
"preview": "/*\n * Copyright (C) 2014 Brett Wooldridge\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "src/main/resources/log4j2-test.xml",
"chars": 370,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<configuration status=\"OFF\">\n <appenders>\n <Console name=\"Console\" target=\"SY"
},
{
"path": "src/test/java/com/zaxxer/hikari/benchmark/BandwidthTest.java",
"chars": 7555,
"preview": "package com.zaxxer.hikari.benchmark;\n\nimport static com.zaxxer.hikari.util.ClockSource.currentTime;\nimport static java.l"
},
{
"path": "src/test/java/com/zaxxer/hikari/benchmark/DbDownTest.java",
"chars": 6884,
"preview": "package com.zaxxer.hikari.benchmark;\n\nimport java.sql.Connection;\nimport java.sql.ResultSet;\nimport java.sql.SQLExceptio"
},
{
"path": "src/test/java/com/zaxxer/hikari/benchmark/SpikeLoadTest.java",
"chars": 18524,
"preview": "package com.zaxxer.hikari.benchmark;\n\nimport static com.zaxxer.hikari.util.ConcurrentBag.IConcurrentBagEntry.STATE_IN_US"
},
{
"path": "src/test/java/com/zaxxer/hikari/pool/HikariPoolAccessor.java",
"chars": 272,
"preview": "package com.zaxxer.hikari.pool;\n\npublic class HikariPoolAccessor\n{\n private final HikariPool pool;\n\n public HikariPo"
},
{
"path": "src/test/java/org/apache/commons/dbcp2/DbcpPoolAccessor.java",
"chars": 426,
"preview": "package org.apache.commons.dbcp2;\n\nimport java.sql.Connection;\nimport java.sql.SQLException;\n\npublic final class DbcpPoo"
},
{
"path": "src/test/java/org/apache/commons/dbcp2/TomcatPoolAccessor.java",
"chars": 700,
"preview": "package org.apache.commons.dbcp2;\n\nimport java.sql.Connection;\nimport java.sql.SQLException;\n\nimport org.apache.tomcat.j"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the brettwooldridge/HikariCP-benchmark GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 23 files (116.8 KB), approximately 28.6k tokens, and a symbol index with 494 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.