use of org.springframework.jdbc.datasource.SingleConnectionDataSource in project spring-boot by spring-projects.
the class DataSourceHealthIndicatorTests method init.
@Before
public void init() {
EmbeddedDatabaseConnection db = EmbeddedDatabaseConnection.HSQL;
this.dataSource = new SingleConnectionDataSource(db.getUrl() + ";shutdown=true", "sa", "", false);
this.dataSource.setDriverClassName(db.getDriverClassName());
}
use of org.springframework.jdbc.datasource.SingleConnectionDataSource in project SimpleFlatMapper by arnaudroger.
the class JdbcTemplateCrudTest method setUp.
@Before
public void setUp() throws SQLException {
Connection dbConnection;
try {
dbConnection = DbHelper.getDbConnection(DbHelper.TargetDB.MYSQL);
dbConnection.createStatement().executeQuery("SELECT 1");
} catch (Exception e) {
dbConnection = DbHelper.getDbConnection(DbHelper.TargetDB.HSQLDB);
}
template = new JdbcTemplate(new SingleConnectionDataSource(dbConnection, true));
}
use of org.springframework.jdbc.datasource.SingleConnectionDataSource in project SimpleFlatMapper by arnaudroger.
the class MappingSqlQueryTest method setUp.
@Before
public void setUp() throws SQLException {
Connection dbConnection = DbHelper.getDbConnection(DbHelper.TargetDB.HSQLDB);
dataSource = new SingleConnectionDataSource(dbConnection, true);
}
use of org.springframework.jdbc.datasource.SingleConnectionDataSource in project ovirt-engine by oVirt.
the class DbConnectionUtilTest method testDBConnectionWithoutConnection.
/**
* Ensures that the checkDBConnection method throws an Exception when connection is not valid
*/
@Test(expected = DataAccessException.class)
@DirtiesContext
public void testDBConnectionWithoutConnection() throws Exception {
try (InputStream is = super.getClass().getResourceAsStream("/test-database.properties")) {
Properties properties = new Properties();
properties.load(is);
ClassLoader.getSystemClassLoader().loadClass(properties.getProperty("database.driver"));
DataSource dataSource = new SingleConnectionDataSource(properties.getProperty("database.url"), // connection
"no-such-username", properties.getProperty("database.password"), true);
final DbEngineDialect dbEngineDialect = DbFacadeLocator.loadDbEngineDialect();
final JdbcTemplate jdbcTemplate = dbEngineDialect.createJdbcTemplate(dataSource);
underTest = new DbConnectionUtil(jdbcTemplate, 666, 777);
underTest.checkDBConnection();
}
}
use of org.springframework.jdbc.datasource.SingleConnectionDataSource in project spring-security by spring-projects.
the class BasicLookupStrategyTestsDbHelper method createDatabase.
public void createDatabase() throws Exception {
// Use a different connection url so the tests can run in parallel
String connectionUrl;
String sqlClassPathResource;
if (!this.withAclClassIdType) {
connectionUrl = "jdbc:hsqldb:mem:lookupstrategytest";
sqlClassPathResource = ACL_SCHEMA_SQL_FILE;
} else {
connectionUrl = "jdbc:hsqldb:mem:lookupstrategytestWithAclClassIdType";
sqlClassPathResource = ACL_SCHEMA_SQL_FILE_WITH_ACL_CLASS_ID;
}
this.dataSource = new SingleConnectionDataSource(connectionUrl, "sa", "", true);
this.dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
this.jdbcTemplate = new JdbcTemplate(this.dataSource);
Resource resource = new ClassPathResource(sqlClassPathResource);
String sql = new String(FileCopyUtils.copyToByteArray(resource.getInputStream()));
this.jdbcTemplate.execute(sql);
}
Aggregations