use of java.sql.SQLTransientConnectionException in project jdk8u_jdk by JetBrains.
the class SQLTransientConnectionExceptionTests method test12.
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLTransientConnectionException ex = new SQLTransientConnectionException("Exception 1", t1);
SQLTransientConnectionException ex1 = new SQLTransientConnectionException("Exception 2");
SQLTransientConnectionException ex2 = new SQLTransientConnectionException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
use of java.sql.SQLTransientConnectionException in project jdk8u_jdk by JetBrains.
the class SQLTransientConnectionExceptionTests method test8.
/**
* Create SQLTransientConnectionException with null Throwable
*/
@Test
public void test8() {
SQLTransientConnectionException ex = new SQLTransientConnectionException((Throwable) null);
assertTrue(ex.getMessage() == null && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0);
}
use of java.sql.SQLTransientConnectionException in project HikariCP by brettwooldridge.
the class PrometheusMetricsTrackerTest method recordConnectionTimeout.
@Test
public void recordConnectionTimeout() throws Exception {
HikariConfig config = newHikariConfig();
config.setMetricsTrackerFactory(new PrometheusMetricsTrackerFactory());
config.setJdbcUrl("jdbc:h2:mem:");
config.setMaximumPoolSize(2);
config.setConnectionTimeout(250);
String[] labelNames = { POOL_LABEL_NAME };
String[] labelValues = { config.getPoolName() };
try (HikariDataSource hikariDataSource = new HikariDataSource(config)) {
try (Connection connection1 = hikariDataSource.getConnection();
Connection connection2 = hikariDataSource.getConnection()) {
try (Connection connection3 = hikariDataSource.getConnection()) {
} catch (SQLTransientConnectionException ignored) {
}
}
Double total = collectorRegistry.getSampleValue("hikaricp_connection_timeout_total", labelNames, labelValues);
assertThat(total, is(1.0));
}
}
use of java.sql.SQLTransientConnectionException in project jdk8u_jdk by JetBrains.
the class SQLTransientConnectionExceptionTests method test13.
/**
* Create SQLTransientConnectionException and validate it is an instance of
* SQLNonTransientException
*/
@Test
public void test13() {
Exception ex = new SQLTransientConnectionException();
assertTrue(ex instanceof SQLTransientException);
}
use of java.sql.SQLTransientConnectionException in project jdk8u_jdk by JetBrains.
the class SQLTransientConnectionExceptionTests method test1.
/**
* Create SQLTransientConnectionException with no-arg constructor
*/
@Test
public void test1() {
SQLTransientConnectionException ex = new SQLTransientConnectionException();
assertTrue(ex.getMessage() == null && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0);
}
Aggregations