More code coverage tests.

pull/192/head
Brett Wooldridge 11 years ago
parent b140c9ed68
commit ec91bff331

@ -0,0 +1,96 @@
/*
* Copyright (C) 2013 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;
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.junit.Test;
import com.zaxxer.hikari.pool.PoolBagEntry;
import com.zaxxer.hikari.util.ConcurrentBag;
/**
*
* @author Brett Wooldridge
*/
public class TestConcurrentBag
{
@Test
public void testConcurrentBag() throws InterruptedException
{
ConcurrentBag<PoolBagEntry> bag = new ConcurrentBag<PoolBagEntry>(null);
Assert.assertEquals(0, bag.values(8).size());
PoolBagEntry reserved = new PoolBagEntry(null, 0);
bag.add(reserved);
bag.reserve(reserved); // reserved
PoolBagEntry inuse = new PoolBagEntry(null, 0);
bag.add(inuse);
bag.borrow(2L, TimeUnit.SECONDS); // in use
PoolBagEntry notinuse = new PoolBagEntry(null, 0);
bag.add(notinuse); // not in use
bag.dumpState();
try {
bag.requite(reserved);
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
try {
bag.remove(notinuse);
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
try {
bag.unreserve(notinuse);
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
try {
bag.remove(inuse);
bag.remove(inuse);
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
bag.close();
try {
bag.add(new PoolBagEntry(null, 0));
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
Assert.assertNotNull(notinuse.toString());
}
}

@ -61,12 +61,12 @@ public final class TestElf
} }
} }
public static void setConfigUnitTest() public static void setConfigUnitTest(boolean unitTest)
{ {
try { try {
Field field = HikariConfig.class.getDeclaredField("unitTest"); Field field = HikariConfig.class.getDeclaredField("unitTest");
field.setAccessible(true); field.setAccessible(true);
field.setBoolean(null, true); field.setBoolean(null, unitTest);
} }
catch (Exception e) { catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);

@ -1,3 +1,18 @@
/*
* 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; package com.zaxxer.hikari;
import javax.naming.Context; import javax.naming.Context;
@ -53,6 +68,22 @@ public class TestJNDI
Assert.assertEquals("foo", ds.getUsername()); Assert.assertEquals("foo", ds.getUsername());
} }
@Test
public void testJndiLookup3() throws Exception
{
HikariJNDIFactory jndi = new HikariJNDIFactory();
Reference ref = new Reference("javax.sql.DataSource");
ref.add(new BogusRef("dataSourceJNDI", "java:comp/env/HikariDS"));
try {
jndi.getObjectInstance(ref, null, null, null);
Assert.fail();
}
catch (RuntimeException e) {
Assert.assertTrue(e.getMessage().contains("JNDI context is null"));
}
}
private class BogusContext extends AbstractContext private class BogusContext extends AbstractContext
{ {
@Override @Override

@ -4,12 +4,14 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.concurrent.TimeUnit;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import com.zaxxer.hikari.mocks.StubConnection; import com.zaxxer.hikari.mocks.StubConnection;
import com.zaxxer.hikari.mocks.StubStatement; import com.zaxxer.hikari.mocks.StubStatement;
import com.zaxxer.hikari.util.PoolUtilities;
public class TestProxies public class TestProxies
{ {
@ -88,4 +90,228 @@ public class TestProxies
ds.close(); ds.close();
} }
} }
@Test
public void testStatementExceptions() throws SQLException
{
HikariConfig config = new HikariConfig();
config.setMinimumIdle(0);
config.setMaximumPoolSize(1);
config.setConnectionTimeout(TimeUnit.SECONDS.toMillis(1));
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
HikariDataSource ds = new HikariDataSource(config);
try {
Connection conn = ds.getConnection();
StubConnection stubConnection = conn.unwrap(StubConnection.class);
stubConnection.throwException = true;
try {
conn.createStatement();
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.createStatement(0, 0);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.createStatement(0, 0, 0);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareCall("");
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareCall("", 0, 0);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareCall("", 0, 0, 0);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareStatement("");
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareStatement("", 0);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareStatement("", new int[0]);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareStatement("", new String[0]);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareStatement("", 0, 0);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareStatement("", 0, 0, 0);
Assert.fail();
}
catch (SQLException e) {
// pass
}
}
finally {
ds.close();
}
}
@Test
public void testOtherExceptions() throws SQLException
{
HikariConfig config = new HikariConfig();
config.setMinimumIdle(0);
config.setMaximumPoolSize(1);
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
HikariDataSource ds = new HikariDataSource(config);
try {
Connection conn = ds.getConnection();
StubConnection stubConnection = conn.unwrap(StubConnection.class);
stubConnection.throwException = true;
try {
conn.setTransactionIsolation(Connection.TRANSACTION_NONE);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.isReadOnly();
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.setReadOnly(false);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.setCatalog("");
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.setAutoCommit(false);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.clearWarnings();
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.isValid(0);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.isWrapperFor(getClass());
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.unwrap(getClass());
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.close();
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
Assert.assertFalse(conn.isValid(0));
}
catch (SQLException e) {
Assert.fail();
}
}
finally {
ds.close();
}
}
} }

@ -267,6 +267,21 @@ public class TestValidation
} }
} }
@Test
public void validateInvalidLeakDetection()
{
try {
HikariConfig config = new HikariConfig();
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
config.setLeakDetectionThreshold(1000L);
config.validate();
Assert.assertEquals(0, config.getLeakDetectionThreshold());
}
catch (IllegalArgumentException ise) {
// pass
}
}
@Test @Test
public void validateZeroConnectionTimeout() public void validateZeroConnectionTimeout()
{ {

@ -7,17 +7,25 @@ import java.sql.Statement;
public abstract class StubBaseConnection implements Connection public abstract class StubBaseConnection implements Connection
{ {
/** {@inheritDoc} */ public volatile boolean throwException;
@Override
public Statement createStatement() throws SQLException
{
return new StubStatement(this);
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public PreparedStatement prepareStatement(String sql) throws SQLException public Statement createStatement() throws SQLException
{ {
return new StubPreparedStatement(this); if (throwException) {
} throw new SQLException();
}
return new StubStatement(this);
}
/** {@inheritDoc} */
@Override
public PreparedStatement prepareStatement(String sql) throws SQLException
{
if (throwException) {
throw new SQLException();
}
return new StubPreparedStatement(this);
}
} }

@ -45,380 +45,438 @@ import com.zaxxer.hikari.util.PoolUtilities;
*/ */
public class StubConnection extends StubBaseConnection implements Connection public class StubConnection extends StubBaseConnection implements Connection
{ {
public static final AtomicInteger count = new AtomicInteger(); public static final AtomicInteger count = new AtomicInteger();
public static volatile boolean slowCreate; public static volatile boolean slowCreate;
private static long foo; private static long foo;
private boolean autoCommit; private boolean autoCommit;
private int isolation; private int isolation;
private String catalog; private String catalog;
static static {
{ foo = System.currentTimeMillis();
foo = System.currentTimeMillis(); }
}
public StubConnection() {
public StubConnection() count.incrementAndGet();
{ if (slowCreate) {
count.incrementAndGet(); PoolUtilities.quietlySleep(TimeUnit.SECONDS.toMillis(1));
if (slowCreate) }
{ }
PoolUtilities.quietlySleep(TimeUnit.SECONDS.toMillis(1));
} /** {@inheritDoc} */
} @SuppressWarnings("unchecked")
@Override
/** {@inheritDoc} */ public <T> T unwrap(Class<T> iface) throws SQLException
@SuppressWarnings("unchecked") {
@Override if (throwException) {
public <T> T unwrap(Class<T> iface) throws SQLException throw new SQLException();
{ }
if (iface.isInstance(this)) {
return (T) this; if (iface.isInstance(this)) {
} return (T) this;
}
throw new SQLException("Wrapped connection is not an instance of " + iface);
} throw new SQLException("Wrapped connection is not an instance of " + iface);
}
/** {@inheritDoc} */
@Override /** {@inheritDoc} */
public boolean isWrapperFor(Class<?> iface) throws SQLException @Override
{ public boolean isWrapperFor(Class<?> iface) throws SQLException
return false; {
} if (throwException) {
throw new SQLException();
/** {@inheritDoc} */ }
@Override return false;
public CallableStatement prepareCall(String sql) throws SQLException }
{
return null; /** {@inheritDoc} */
} @Override
public CallableStatement prepareCall(String sql) throws SQLException
/** {@inheritDoc} */ {
@Override if (throwException) {
public String nativeSQL(String sql) throws SQLException throw new SQLException();
{ }
return null; return null;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void setAutoCommit(boolean autoCommit) throws SQLException public String nativeSQL(String sql) throws SQLException
{ {
this.autoCommit = autoCommit; return null;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public boolean getAutoCommit() throws SQLException public void setAutoCommit(boolean autoCommit) throws SQLException
{ {
return autoCommit; if (throwException) {
} throw new SQLException();
}
/** {@inheritDoc} */ this.autoCommit = autoCommit;
@Override }
public void commit() throws SQLException
{ /** {@inheritDoc} */
@Override
} public boolean getAutoCommit() throws SQLException
{
/** {@inheritDoc} */ return autoCommit;
@Override }
public void rollback() throws SQLException
{ /** {@inheritDoc} */
@Override
} public void commit() throws SQLException
{
/** {@inheritDoc} */
@Override }
public void close() throws SQLException
{ /** {@inheritDoc} */
@Override
} public void rollback() throws SQLException
{
/** {@inheritDoc} */
@Override }
public boolean isClosed() throws SQLException
{ /** {@inheritDoc} */
return false; @Override
} public void close() throws SQLException
{
/** {@inheritDoc} */
@Override }
public DatabaseMetaData getMetaData() throws SQLException
{ /** {@inheritDoc} */
return null; @Override
} public boolean isClosed() throws SQLException
{
/** {@inheritDoc} */ if (throwException) {
@Override throw new SQLException();
public void setReadOnly(boolean readOnly) throws SQLException }
{ return false;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public boolean isReadOnly() throws SQLException public DatabaseMetaData getMetaData() throws SQLException
{ {
return false; return null;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void setCatalog(String catalog) throws SQLException public void setReadOnly(boolean readOnly) throws SQLException
{ {
this.catalog = catalog; if (throwException) {
} throw new SQLException();
}
/** {@inheritDoc} */ }
@Override
public String getCatalog() throws SQLException /** {@inheritDoc} */
{ @Override
return catalog; public boolean isReadOnly() throws SQLException
} {
if (throwException) {
/** {@inheritDoc} */ throw new SQLException();
@Override }
public void setTransactionIsolation(int level) throws SQLException return false;
{ }
this.isolation = level;
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public void setCatalog(String catalog) throws SQLException
@Override {
public int getTransactionIsolation() throws SQLException if (throwException) {
{ throw new SQLException();
return isolation; }
} this.catalog = catalog;
}
/** {@inheritDoc} */
@Override /** {@inheritDoc} */
public SQLWarning getWarnings() throws SQLException @Override
{ public String getCatalog() throws SQLException
return null; {
} return catalog;
}
/** {@inheritDoc} */
@Override /** {@inheritDoc} */
public void clearWarnings() throws SQLException @Override
{ public void setTransactionIsolation(int level) throws SQLException
} {
if (throwException) {
/** {@inheritDoc} */ throw new SQLException();
@Override }
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException this.isolation = level;
{ }
return null;
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public int getTransactionIsolation() throws SQLException
@Override {
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException return isolation;
{ }
return new StubPreparedStatement(this);
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public SQLWarning getWarnings() throws SQLException
@Override {
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException return null;
{ }
return null;
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public void clearWarnings() throws SQLException
@Override {
public Map<String, Class<?>> getTypeMap() throws SQLException if (throwException) {
{ throw new SQLException();
return null; }
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void setTypeMap(Map<String, Class<?>> map) throws SQLException public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
{ {
} if (throwException) {
throw new SQLException();
/** {@inheritDoc} */ }
@Override return null;
public void setHoldability(int holdability) throws SQLException }
{
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
@Override {
public int getHoldability() throws SQLException if (throwException) {
{ throw new SQLException();
return (int) foo; }
} return new StubPreparedStatement(this);
}
/** {@inheritDoc} */
@Override /** {@inheritDoc} */
public Savepoint setSavepoint() throws SQLException @Override
{ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
return null; {
} if (throwException) {
throw new SQLException();
/** {@inheritDoc} */ }
@Override return null;
public Savepoint setSavepoint(String name) throws SQLException }
{
return null; /** {@inheritDoc} */
} @Override
public Map<String, Class<?>> getTypeMap() throws SQLException
/** {@inheritDoc} */ {
@Override return null;
public void rollback(Savepoint savepoint) throws SQLException }
{
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public void setTypeMap(Map<String, Class<?>> map) throws SQLException
@Override {
public void releaseSavepoint(Savepoint savepoint) throws SQLException }
{
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public void setHoldability(int holdability) throws SQLException
@Override {
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException }
{
return null; /** {@inheritDoc} */
} @Override
public int getHoldability() throws SQLException
/** {@inheritDoc} */ {
@Override return (int) foo;
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException }
{
return new StubPreparedStatement(this); /** {@inheritDoc} */
} @Override
public Savepoint setSavepoint() throws SQLException
/** {@inheritDoc} */ {
@Override return null;
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException }
{
return null; /** {@inheritDoc} */
} @Override
public Savepoint setSavepoint(String name) throws SQLException
/** {@inheritDoc} */ {
@Override return null;
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException }
{
return new StubPreparedStatement(this); /** {@inheritDoc} */
} @Override
public void rollback(Savepoint savepoint) throws SQLException
/** {@inheritDoc} */ {
@Override }
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
{ /** {@inheritDoc} */
return new StubPreparedStatement(this); @Override
} public void releaseSavepoint(Savepoint savepoint) throws SQLException
{
/** {@inheritDoc} */ }
@Override
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException /** {@inheritDoc} */
{ @Override
return new StubPreparedStatement(this); public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
} {
if (throwException) {
/** {@inheritDoc} */ throw new SQLException();
@Override }
public Clob createClob() throws SQLException return null;
{ }
return null;
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
@Override {
public Blob createBlob() throws SQLException if (throwException) {
{ throw new SQLException();
return null; }
} return new StubPreparedStatement(this);
}
/** {@inheritDoc} */
@Override /** {@inheritDoc} */
public NClob createNClob() throws SQLException @Override
{ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
return null; {
} if (throwException) {
throw new SQLException();
/** {@inheritDoc} */ }
@Override return null;
public SQLXML createSQLXML() throws SQLException }
{
return null; /** {@inheritDoc} */
} @Override
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
/** {@inheritDoc} */ {
@Override if (throwException) {
public boolean isValid(int timeout) throws SQLException throw new SQLException();
{ }
return true; return new StubPreparedStatement(this);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void setClientInfo(String name, String value) throws SQLClientInfoException public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
{ {
} if (throwException) {
throw new SQLException();
/** {@inheritDoc} */ }
@Override return new StubPreparedStatement(this);
public void setClientInfo(Properties properties) throws SQLClientInfoException }
{
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
@Override {
public String getClientInfo(String name) throws SQLException if (throwException) {
{ throw new SQLException();
return null; }
} return new StubPreparedStatement(this);
}
/** {@inheritDoc} */
@Override /** {@inheritDoc} */
public Properties getClientInfo() throws SQLException @Override
{ public Clob createClob() throws SQLException
return null; {
} return null;
}
/** {@inheritDoc} */
@Override /** {@inheritDoc} */
public Array createArrayOf(String typeName, Object[] elements) throws SQLException @Override
{ public Blob createBlob() throws SQLException
return null; {
} return null;
}
/** {@inheritDoc} */
@Override /** {@inheritDoc} */
public Struct createStruct(String typeName, Object[] attributes) throws SQLException @Override
{ public NClob createNClob() throws SQLException
return null; {
} return null;
}
/** {@inheritDoc} */
public void setSchema(String schema) throws SQLException /** {@inheritDoc} */
{ @Override
} public SQLXML createSQLXML() throws SQLException
{
/** {@inheritDoc} */ return null;
public String getSchema() throws SQLException }
{
return null; /** {@inheritDoc} */
} @Override
public boolean isValid(int timeout) throws SQLException
/** {@inheritDoc} */ {
public void abort(Executor executor) throws SQLException if (throwException) {
{ throw new SQLException();
throw new SQLException("Intentianal exception during abort"); }
} return true;
}
/** {@inheritDoc} */
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException /** {@inheritDoc} */
{ @Override
} public void setClientInfo(String name, String value) throws SQLClientInfoException
{
/** {@inheritDoc} */ }
public int getNetworkTimeout() throws SQLException
{ /** {@inheritDoc} */
return 0; @Override
} public void setClientInfo(Properties properties) throws SQLClientInfoException
{
}
/** {@inheritDoc} */
@Override
public String getClientInfo(String name) throws SQLException
{
return null;
}
/** {@inheritDoc} */
@Override
public Properties getClientInfo() throws SQLException
{
return null;
}
/** {@inheritDoc} */
@Override
public Array createArrayOf(String typeName, Object[] elements) throws SQLException
{
return null;
}
/** {@inheritDoc} */
@Override
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
{
throw new SQLException("Intentianal exception during abort");
}
/** {@inheritDoc} */
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException
{
}
/** {@inheritDoc} */
public int getNetworkTimeout() throws SQLException
{
return 0;
}
} }

@ -25,14 +25,9 @@ import java.util.concurrent.TimeUnit;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.impl.SimpleLogger;
import org.slf4j.spi.LocationAwareLogger; import org.slf4j.spi.LocationAwareLogger;
import com.zaxxer.hikari.pool.HikariPool; import com.zaxxer.hikari.pool.HikariPool;
import com.zaxxer.hikari.pool.PoolBagEntry;
import com.zaxxer.hikari.util.ConcurrentBag;
import com.zaxxer.hikari.util.LeakTask; import com.zaxxer.hikari.util.LeakTask;
import com.zaxxer.hikari.util.PoolUtilities; import com.zaxxer.hikari.util.PoolUtilities;
@ -49,7 +44,7 @@ public class MiscTest
config.setMaximumPoolSize(4); config.setMaximumPoolSize(4);
config.setPoolName("test"); config.setPoolName("test");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource"); config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
TestElf.setConfigUnitTest(); TestElf.setConfigUnitTest(true);
final HikariDataSource ds = new HikariDataSource(config); final HikariDataSource ds = new HikariDataSource(config);
try { try {
@ -60,6 +55,7 @@ public class MiscTest
} }
finally finally
{ {
TestElf.setConfigUnitTest(false);
ds.close(); ds.close();
} }
} }
@ -88,70 +84,6 @@ public class MiscTest
} }
} }
@Test
public void testConcurrentBag() throws InterruptedException
{
ConcurrentBag<PoolBagEntry> bag = new ConcurrentBag<PoolBagEntry>(null);
Assert.assertEquals(0, bag.values(8).size());
PoolBagEntry reserved = new PoolBagEntry(null, 0);
bag.add(reserved);
bag.reserve(reserved); // reserved
PoolBagEntry inuse = new PoolBagEntry(null, 0);
bag.add(inuse);
bag.borrow(2L, TimeUnit.SECONDS); // in use
PoolBagEntry notinuse = new PoolBagEntry(null, 0);
bag.add(notinuse); // not in use
bag.dumpState();
try {
bag.requite(reserved);
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
try {
bag.remove(notinuse);
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
try {
bag.unreserve(notinuse);
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
try {
bag.remove(inuse);
bag.remove(inuse);
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
bag.close();
try {
bag.add(new PoolBagEntry(null, 0));
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
Assert.assertNotNull(notinuse.toString());
}
@Test @Test
public void testLeakDetection() throws SQLException public void testLeakDetection() throws SQLException
{ {
@ -165,7 +97,7 @@ public class MiscTest
config.setPoolName("test"); config.setPoolName("test");
config.setLeakDetectionThreshold(TimeUnit.SECONDS.toMillis(1)); config.setLeakDetectionThreshold(TimeUnit.SECONDS.toMillis(1));
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource"); config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
TestElf.setConfigUnitTest(); TestElf.setConfigUnitTest(true);
final HikariDataSource ds = new HikariDataSource(config); final HikariDataSource ds = new HikariDataSource(config);
try { try {
@ -183,6 +115,7 @@ public class MiscTest
} }
finally finally
{ {
TestElf.setConfigUnitTest(false);
ds.close(); ds.close();
} }
} }

@ -0,0 +1,96 @@
/*
* Copyright (C) 2013 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;
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.junit.Test;
import com.zaxxer.hikari.pool.PoolBagEntry;
import com.zaxxer.hikari.util.ConcurrentBag;
/**
*
* @author Brett Wooldridge
*/
public class TestConcurrentBag
{
@Test
public void testConcurrentBag() throws InterruptedException
{
ConcurrentBag<PoolBagEntry> bag = new ConcurrentBag<PoolBagEntry>(null);
Assert.assertEquals(0, bag.values(8).size());
PoolBagEntry reserved = new PoolBagEntry(null, 0);
bag.add(reserved);
bag.reserve(reserved); // reserved
PoolBagEntry inuse = new PoolBagEntry(null, 0);
bag.add(inuse);
bag.borrow(2L, TimeUnit.SECONDS); // in use
PoolBagEntry notinuse = new PoolBagEntry(null, 0);
bag.add(notinuse); // not in use
bag.dumpState();
try {
bag.requite(reserved);
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
try {
bag.remove(notinuse);
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
try {
bag.unreserve(notinuse);
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
try {
bag.remove(inuse);
bag.remove(inuse);
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
bag.close();
try {
bag.add(new PoolBagEntry(null, 0));
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
Assert.assertNotNull(notinuse.toString());
}
}

@ -61,12 +61,12 @@ public final class TestElf
} }
} }
public static void setConfigUnitTest() public static void setConfigUnitTest(boolean unitTest)
{ {
try { try {
Field field = HikariConfig.class.getDeclaredField("unitTest"); Field field = HikariConfig.class.getDeclaredField("unitTest");
field.setAccessible(true); field.setAccessible(true);
field.setBoolean(null, true); field.setBoolean(null, unitTest);
} }
catch (Exception e) { catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);

@ -68,6 +68,22 @@ public class TestJNDI
Assert.assertEquals("foo", ds.getUsername()); Assert.assertEquals("foo", ds.getUsername());
} }
@Test
public void testJndiLookup3() throws Exception
{
HikariJNDIFactory jndi = new HikariJNDIFactory();
Reference ref = new Reference("javax.sql.DataSource");
ref.add(new BogusRef("dataSourceJNDI", "java:comp/env/HikariDS"));
try {
jndi.getObjectInstance(ref, null, null, null);
Assert.fail();
}
catch (RuntimeException e) {
Assert.assertTrue(e.getMessage().contains("JNDI context is null"));
}
}
private class BogusContext extends AbstractContext private class BogusContext extends AbstractContext
{ {
@Override @Override

@ -4,12 +4,14 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.concurrent.TimeUnit;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import com.zaxxer.hikari.mocks.StubConnection; import com.zaxxer.hikari.mocks.StubConnection;
import com.zaxxer.hikari.mocks.StubStatement; import com.zaxxer.hikari.mocks.StubStatement;
import com.zaxxer.hikari.util.PoolUtilities;
public class TestProxies public class TestProxies
{ {
@ -88,4 +90,228 @@ public class TestProxies
ds.close(); ds.close();
} }
} }
@Test
public void testStatementExceptions() throws SQLException
{
HikariConfig config = new HikariConfig();
config.setMinimumIdle(0);
config.setMaximumPoolSize(1);
config.setConnectionTimeout(TimeUnit.SECONDS.toMillis(1));
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
HikariDataSource ds = new HikariDataSource(config);
try {
Connection conn = ds.getConnection();
StubConnection stubConnection = conn.unwrap(StubConnection.class);
stubConnection.throwException = true;
try {
conn.createStatement();
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.createStatement(0, 0);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.createStatement(0, 0, 0);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareCall("");
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareCall("", 0, 0);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareCall("", 0, 0, 0);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareStatement("");
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareStatement("", 0);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareStatement("", new int[0]);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareStatement("", new String[0]);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareStatement("", 0, 0);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.prepareStatement("", 0, 0, 0);
Assert.fail();
}
catch (SQLException e) {
// pass
}
}
finally {
ds.close();
}
}
@Test
public void testOtherExceptions() throws SQLException
{
HikariConfig config = new HikariConfig();
config.setMinimumIdle(0);
config.setMaximumPoolSize(1);
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
HikariDataSource ds = new HikariDataSource(config);
try {
Connection conn = ds.getConnection();
StubConnection stubConnection = conn.unwrap(StubConnection.class);
stubConnection.throwException = true;
try {
conn.setTransactionIsolation(Connection.TRANSACTION_NONE);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.isReadOnly();
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.setReadOnly(false);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.setCatalog("");
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.setAutoCommit(false);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.clearWarnings();
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.isValid(0);
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.isWrapperFor(getClass());
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.unwrap(getClass());
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
conn.close();
Assert.fail();
}
catch (SQLException e) {
// pass
}
try {
Assert.assertFalse(conn.isValid(0));
}
catch (SQLException e) {
Assert.fail();
}
}
finally {
ds.close();
}
}
} }

@ -267,6 +267,21 @@ public class TestValidation
} }
} }
@Test
public void validateInvalidLeakDetection()
{
try {
HikariConfig config = new HikariConfig();
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
config.setLeakDetectionThreshold(1000L);
config.validate();
Assert.assertEquals(0, config.getLeakDetectionThreshold());
}
catch (IllegalArgumentException ise) {
// pass
}
}
@Test @Test
public void validateZeroConnectionTimeout() public void validateZeroConnectionTimeout()
{ {

@ -7,17 +7,25 @@ import java.sql.Statement;
public abstract class StubBaseConnection implements Connection public abstract class StubBaseConnection implements Connection
{ {
/** {@inheritDoc} */ public volatile boolean throwException;
@Override
public Statement createStatement() throws SQLException
{
return new StubStatement(this);
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public PreparedStatement prepareStatement(String sql) throws SQLException public Statement createStatement() throws SQLException
{ {
return new StubPreparedStatement(this); if (throwException) {
} throw new SQLException();
}
return new StubStatement(this);
}
/** {@inheritDoc} */
@Override
public PreparedStatement prepareStatement(String sql) throws SQLException
{
if (throwException) {
throw new SQLException();
}
return new StubPreparedStatement(this);
}
} }

@ -45,380 +45,438 @@ import com.zaxxer.hikari.util.PoolUtilities;
*/ */
public class StubConnection extends StubBaseConnection implements Connection public class StubConnection extends StubBaseConnection implements Connection
{ {
public static final AtomicInteger count = new AtomicInteger(); public static final AtomicInteger count = new AtomicInteger();
public static volatile boolean slowCreate; public static volatile boolean slowCreate;
private static long foo; private static long foo;
private boolean autoCommit; private boolean autoCommit;
private int isolation; private int isolation;
private String catalog; private String catalog;
static static {
{ foo = System.currentTimeMillis();
foo = System.currentTimeMillis(); }
}
public StubConnection() {
public StubConnection() count.incrementAndGet();
{ if (slowCreate) {
count.incrementAndGet(); PoolUtilities.quietlySleep(TimeUnit.SECONDS.toMillis(1));
if (slowCreate) }
{ }
PoolUtilities.quietlySleep(TimeUnit.SECONDS.toMillis(1));
} /** {@inheritDoc} */
} @SuppressWarnings("unchecked")
@Override
/** {@inheritDoc} */ public <T> T unwrap(Class<T> iface) throws SQLException
@SuppressWarnings("unchecked") {
@Override if (throwException) {
public <T> T unwrap(Class<T> iface) throws SQLException throw new SQLException();
{ }
if (iface.isInstance(this)) {
return (T) this; if (iface.isInstance(this)) {
} return (T) this;
}
throw new SQLException("Wrapped connection is not an instance of " + iface);
} throw new SQLException("Wrapped connection is not an instance of " + iface);
}
/** {@inheritDoc} */
@Override /** {@inheritDoc} */
public boolean isWrapperFor(Class<?> iface) throws SQLException @Override
{ public boolean isWrapperFor(Class<?> iface) throws SQLException
return false; {
} if (throwException) {
throw new SQLException();
/** {@inheritDoc} */ }
@Override return false;
public CallableStatement prepareCall(String sql) throws SQLException }
{
return null; /** {@inheritDoc} */
} @Override
public CallableStatement prepareCall(String sql) throws SQLException
/** {@inheritDoc} */ {
@Override if (throwException) {
public String nativeSQL(String sql) throws SQLException throw new SQLException();
{ }
return null; return null;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void setAutoCommit(boolean autoCommit) throws SQLException public String nativeSQL(String sql) throws SQLException
{ {
this.autoCommit = autoCommit; return null;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public boolean getAutoCommit() throws SQLException public void setAutoCommit(boolean autoCommit) throws SQLException
{ {
return autoCommit; if (throwException) {
} throw new SQLException();
}
/** {@inheritDoc} */ this.autoCommit = autoCommit;
@Override }
public void commit() throws SQLException
{ /** {@inheritDoc} */
@Override
} public boolean getAutoCommit() throws SQLException
{
/** {@inheritDoc} */ return autoCommit;
@Override }
public void rollback() throws SQLException
{ /** {@inheritDoc} */
@Override
} public void commit() throws SQLException
{
/** {@inheritDoc} */
@Override }
public void close() throws SQLException
{ /** {@inheritDoc} */
@Override
} public void rollback() throws SQLException
{
/** {@inheritDoc} */
@Override }
public boolean isClosed() throws SQLException
{ /** {@inheritDoc} */
return false; @Override
} public void close() throws SQLException
{
/** {@inheritDoc} */
@Override }
public DatabaseMetaData getMetaData() throws SQLException
{ /** {@inheritDoc} */
return null; @Override
} public boolean isClosed() throws SQLException
{
/** {@inheritDoc} */ if (throwException) {
@Override throw new SQLException();
public void setReadOnly(boolean readOnly) throws SQLException }
{ return false;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public boolean isReadOnly() throws SQLException public DatabaseMetaData getMetaData() throws SQLException
{ {
return false; return null;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void setCatalog(String catalog) throws SQLException public void setReadOnly(boolean readOnly) throws SQLException
{ {
this.catalog = catalog; if (throwException) {
} throw new SQLException();
}
/** {@inheritDoc} */ }
@Override
public String getCatalog() throws SQLException /** {@inheritDoc} */
{ @Override
return catalog; public boolean isReadOnly() throws SQLException
} {
if (throwException) {
/** {@inheritDoc} */ throw new SQLException();
@Override }
public void setTransactionIsolation(int level) throws SQLException return false;
{ }
this.isolation = level;
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public void setCatalog(String catalog) throws SQLException
@Override {
public int getTransactionIsolation() throws SQLException if (throwException) {
{ throw new SQLException();
return isolation; }
} this.catalog = catalog;
}
/** {@inheritDoc} */
@Override /** {@inheritDoc} */
public SQLWarning getWarnings() throws SQLException @Override
{ public String getCatalog() throws SQLException
return null; {
} return catalog;
}
/** {@inheritDoc} */
@Override /** {@inheritDoc} */
public void clearWarnings() throws SQLException @Override
{ public void setTransactionIsolation(int level) throws SQLException
} {
if (throwException) {
/** {@inheritDoc} */ throw new SQLException();
@Override }
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException this.isolation = level;
{ }
return null;
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public int getTransactionIsolation() throws SQLException
@Override {
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException return isolation;
{ }
return new StubPreparedStatement(this);
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public SQLWarning getWarnings() throws SQLException
@Override {
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException return null;
{ }
return null;
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public void clearWarnings() throws SQLException
@Override {
public Map<String, Class<?>> getTypeMap() throws SQLException if (throwException) {
{ throw new SQLException();
return null; }
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void setTypeMap(Map<String, Class<?>> map) throws SQLException public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
{ {
} if (throwException) {
throw new SQLException();
/** {@inheritDoc} */ }
@Override return null;
public void setHoldability(int holdability) throws SQLException }
{
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
@Override {
public int getHoldability() throws SQLException if (throwException) {
{ throw new SQLException();
return (int) foo; }
} return new StubPreparedStatement(this);
}
/** {@inheritDoc} */
@Override /** {@inheritDoc} */
public Savepoint setSavepoint() throws SQLException @Override
{ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
return null; {
} if (throwException) {
throw new SQLException();
/** {@inheritDoc} */ }
@Override return null;
public Savepoint setSavepoint(String name) throws SQLException }
{
return null; /** {@inheritDoc} */
} @Override
public Map<String, Class<?>> getTypeMap() throws SQLException
/** {@inheritDoc} */ {
@Override return null;
public void rollback(Savepoint savepoint) throws SQLException }
{
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public void setTypeMap(Map<String, Class<?>> map) throws SQLException
@Override {
public void releaseSavepoint(Savepoint savepoint) throws SQLException }
{
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public void setHoldability(int holdability) throws SQLException
@Override {
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException }
{
return null; /** {@inheritDoc} */
} @Override
public int getHoldability() throws SQLException
/** {@inheritDoc} */ {
@Override return (int) foo;
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException }
{
return new StubPreparedStatement(this); /** {@inheritDoc} */
} @Override
public Savepoint setSavepoint() throws SQLException
/** {@inheritDoc} */ {
@Override return null;
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException }
{
return null; /** {@inheritDoc} */
} @Override
public Savepoint setSavepoint(String name) throws SQLException
/** {@inheritDoc} */ {
@Override return null;
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException }
{
return new StubPreparedStatement(this); /** {@inheritDoc} */
} @Override
public void rollback(Savepoint savepoint) throws SQLException
/** {@inheritDoc} */ {
@Override }
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
{ /** {@inheritDoc} */
return new StubPreparedStatement(this); @Override
} public void releaseSavepoint(Savepoint savepoint) throws SQLException
{
/** {@inheritDoc} */ }
@Override
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException /** {@inheritDoc} */
{ @Override
return new StubPreparedStatement(this); public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
} {
if (throwException) {
/** {@inheritDoc} */ throw new SQLException();
@Override }
public Clob createClob() throws SQLException return null;
{ }
return null;
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
@Override {
public Blob createBlob() throws SQLException if (throwException) {
{ throw new SQLException();
return null; }
} return new StubPreparedStatement(this);
}
/** {@inheritDoc} */
@Override /** {@inheritDoc} */
public NClob createNClob() throws SQLException @Override
{ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
return null; {
} if (throwException) {
throw new SQLException();
/** {@inheritDoc} */ }
@Override return null;
public SQLXML createSQLXML() throws SQLException }
{
return null; /** {@inheritDoc} */
} @Override
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
/** {@inheritDoc} */ {
@Override if (throwException) {
public boolean isValid(int timeout) throws SQLException throw new SQLException();
{ }
return true; return new StubPreparedStatement(this);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void setClientInfo(String name, String value) throws SQLClientInfoException public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
{ {
} if (throwException) {
throw new SQLException();
/** {@inheritDoc} */ }
@Override return new StubPreparedStatement(this);
public void setClientInfo(Properties properties) throws SQLClientInfoException }
{
} /** {@inheritDoc} */
@Override
/** {@inheritDoc} */ public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
@Override {
public String getClientInfo(String name) throws SQLException if (throwException) {
{ throw new SQLException();
return null; }
} return new StubPreparedStatement(this);
}
/** {@inheritDoc} */
@Override /** {@inheritDoc} */
public Properties getClientInfo() throws SQLException @Override
{ public Clob createClob() throws SQLException
return null; {
} return null;
}
/** {@inheritDoc} */
@Override /** {@inheritDoc} */
public Array createArrayOf(String typeName, Object[] elements) throws SQLException @Override
{ public Blob createBlob() throws SQLException
return null; {
} return null;
}
/** {@inheritDoc} */
@Override /** {@inheritDoc} */
public Struct createStruct(String typeName, Object[] attributes) throws SQLException @Override
{ public NClob createNClob() throws SQLException
return null; {
} return null;
}
/** {@inheritDoc} */
public void setSchema(String schema) throws SQLException /** {@inheritDoc} */
{ @Override
} public SQLXML createSQLXML() throws SQLException
{
/** {@inheritDoc} */ return null;
public String getSchema() throws SQLException }
{
return null; /** {@inheritDoc} */
} @Override
public boolean isValid(int timeout) throws SQLException
/** {@inheritDoc} */ {
public void abort(Executor executor) throws SQLException if (throwException) {
{ throw new SQLException();
throw new SQLException("Intentianal exception during abort"); }
} return true;
}
/** {@inheritDoc} */
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException /** {@inheritDoc} */
{ @Override
} public void setClientInfo(String name, String value) throws SQLClientInfoException
{
/** {@inheritDoc} */ }
public int getNetworkTimeout() throws SQLException
{ /** {@inheritDoc} */
return 0; @Override
} public void setClientInfo(Properties properties) throws SQLClientInfoException
{
}
/** {@inheritDoc} */
@Override
public String getClientInfo(String name) throws SQLException
{
return null;
}
/** {@inheritDoc} */
@Override
public Properties getClientInfo() throws SQLException
{
return null;
}
/** {@inheritDoc} */
@Override
public Array createArrayOf(String typeName, Object[] elements) throws SQLException
{
return null;
}
/** {@inheritDoc} */
@Override
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
{
throw new SQLException("Intentianal exception during abort");
}
/** {@inheritDoc} */
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException
{
}
/** {@inheritDoc} */
public int getNetworkTimeout() throws SQLException
{
return 0;
}
} }

Loading…
Cancel
Save