private static void createConnectionConfig(StoreProperties props, JdbcStringBasedStoreConfigurationBuilder storeBuilder) { props.required(props.key(CONNECTION_POOL, CONNECTION_URL)); props.required(props.key(CONNECTION_POOL, DRIVER_CLASS)); storeBuilder.connectionPool() .connectionUrl(props.get(CONNECTION_POOL, CONNECTION_URL)) .driverClass(props.get(CONNECTION_POOL, DRIVER_CLASS)) .username(props.get(CONNECTION_POOL, USERNAME)) .password(props.get(CONNECTION_POOL, PASSWORD)) .create(); } }
public static ConnectionFactoryConfigurationBuilder<?> configureUniqueConnectionFactory(AbstractJdbcStoreConfigurationBuilder<?, ?> store) { switch (dt) { case H2: return store .connectionPool() .driverClass(org.h2.Driver.class) .connectionUrl(String.format("jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1", extractTestName() + userIndex.incrementAndGet())) .username("sa"); case MYSQL: return store .simpleConnection() .driverClass(com.mysql.jdbc.Driver.class) .connectionUrl("jdbc:mysql://localhost/infinispan?user=ispn&password=ispn") .username("ispn") .password("ispn"); default: throw new RuntimeException("Cannot configure connection for database type "+dt); } }
private void parseConnectionPoolAttributes(XMLExtendedStreamReader reader, PooledConnectionFactoryConfigurationBuilder<?> builder) throws XMLStreamException { for (int i = 0; i < reader.getAttributeCount(); i++) { ParseUtils.requireNoNamespaceAttribute(reader, i); String value = replaceProperties(reader.getAttributeValue(i)); Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case CONNECTION_URL: { builder.connectionUrl(value); break; } case DRIVER_CLASS: { builder.driverClass(value); break; } case PASSWORD: { builder.password(value); break; } case USERNAME: { builder.username(value); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); }
builder.username(value); break;
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder cb = TestCacheManagerFactory.getDefaultCacheConfiguration(false); cb.persistence() .addStore(JdbcStringBasedStoreConfigurationBuilder.class) .preload(true) .key2StringMapper(LuceneKey2StringMapper.class) .table() .idColumnName("ID_COLUMN") .idColumnType("VARCHAR(255)") .tableNamePrefix("ISPN_JDBC") .dataColumnName("DATA_COLUMN") .dataColumnType("BLOB") .timestampColumnName("TIMESTAMP_COLUMN") .timestampColumnType("BIGINT") .connectionPool() .driverClass(org.h2.Driver.class) .connectionUrl("jdbc:h2:mem:infinispan;DB_CLOSE_DELAY=0") .username("sa"); return TestCacheManagerFactory.createClusteredCacheManager(cb); }