PostgreSQL
<dependency>
<groupId>one.microstream</groupId>
<artifactId>microstream-afs-sql</artifactId>
<version>05.00.02-MS-GA</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.14</version>
</dependency>
PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setUrl("jdbc:postgresql://localhost:5432/mydb");
dataSource.setUser("postgres");
dataSource.setPassword("secret");
SqlFileSystem fileSystem = SqlFileSystem.New(
SqlConnector.Caching(
SqlProviderPostgres.New(dataSource)
)
);
EmbeddedStorage.start(fileSystem.ensureDirectoryPath("microstream_storage"));
Configuration
When using external configuration PostgreSQL can be set as follows. Please note that you have to define a data source provider.
microstream-storage.properties
storage-filesystem.sql.postgres.data-source-provider=com.sample.MyDataSourceProvider
storage-filesystem.sql.postgres.catalog=mycatalog
storage-filesystem.sql.postgres.schema=myschema
storage-filesystem.sql.postgres.url=jdbc:postgresql://localhost:5432/mydb
storage-filesystem.sql.postgres.user=username
storage-filesystem.sql.postgres.password=secret
MyDataSourceProvider.java
package com.sample;
import one.microstream.afs.sql.types.SqlDataSourceProvider
public class MyDataSourceProvider implements SqlDataSourceProvider
{
public DataSource provideDataSource(Configuration configuration)
{
String url = configuration.get("url");
String user = configuration.get("user");
String password = configuration.get("password");
// TODO: return data source of your choice, e.g. from a connection pool
}
}