MySQL
This is an enterprise feature. |
<dependency>
<groupId>one.microstream</groupId>
<artifactId>microstream-enterprise-afs-sql</artifactId>
<version>06.01.00-MS-GA</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.21</version>
</dependency>
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setUrl("jdbc:mysql://host:3306/mydb");
dataSource.setUser("user");
dataSource.setPassword("secret");
SqlFileSystem fileSystem = SqlFileSystem.New(
SqlConnector.Caching(
SqlProviderMySql.New(dataSource)
)
);
EmbeddedStorage.start(fileSystem.ensureDirectoryPath("microstream_storage"));
Configuration
When using external configuration MySQL can be set as follows. Please note that you have to define a data source provider.
microstream-storage.properties
storage-filesystem.sql.mysql.data-source-provider=com.sample.MyDataSourceProvider
storage-filesystem.sql.mysql.catalog=mycatalog
storage-filesystem.sql.mysql.schema=myschema
storage-filesystem.sql.mysql.url=jdbc:mysql://host:3306/mydb
storage-filesystem.sql.mysql.user=username
storage-filesystem.sql.mysql.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
}
}