此内容没有您所选择的语言版本。

15.2.4. JdbcStringBasedStore Programmatic Configuration


The following is a sample configuration for the JdbcStringBasedStore:

Procedure 15.7. Configure the JdbcStringBasedStore Programmatically

  1. Create a New Configuration Builder

    Use the ConfigurationBuilder to create a new configuration object.
    ConfigurationBuilder builder = new ConfigurationBuilder();
    
    Copy to Clipboard Toggle word wrap
  2. Add JdbcStringBasedStoreConfigurationBuilder

    Add the JdbcStringBasedStore configuration builder to build a specific configuration related to this store.
    ConfigurationBuilder builder = new ConfigurationBuilder();
      builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class)
    
    Copy to Clipboard Toggle word wrap
  3. Set Up Persistence

    fetchPersistentState determines whether or not to fetch the persistent state of a cache and apply it to the local cache store when joining the cluster. If the cache store is shared the fetch persistent state is ignored, as caches access the same cache store. A configuration exception will be thrown when starting the cache service if more than one cache loader has this property set to true. The fetchPersistentState property is false by default.
    ConfigurationBuilder builder = new ConfigurationBuilder();
      builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class)
         .fetchPersistentState(false)
    
    Copy to Clipboard Toggle word wrap
  4. Set Modifications

    ignoreModifications determines whether write methods are pushed to the specific cache loader by allowing write operations to the local file cache loader, but not the shared cache loader. In some cases, transient application data should only reside in a file-based cache loader on the same server as the in-memory cache. For example, this would apply with a further JDBC based cache loader used by all servers in the network. ignoreModifications is false by default.
    ConfigurationBuilder builder = new ConfigurationBuilder();
      builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class)
         .fetchPersistentState(false)
         .ignoreModifications(false)
    
    Copy to Clipboard Toggle word wrap
  5. Configure Purging

    purgeOnStartup specifies whether the cache is purged when initially started.
    ConfigurationBuilder builder = new ConfigurationBuilder();
      builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class)
         .fetchPersistentState(false)
         .ignoreModifications(false)
         .purgeOnStartup(false)
    
    Copy to Clipboard Toggle word wrap
  6. Configure the Table

    1. Set Drop Table On Exit Method

      dropOnExit determines if the table will be created when the cache store is stopped. This is set to false by default.
    2. Set Create Table On Start Method

      createOnStart creates the table when starting the cache store if no table currently exists. This method is true by default.
    3. Set the Table Name Prefix

      tableNamePrefix sets the prefix for the name of the table in which the data will be stored.
    4. idColumnName

      The idColumnName property defines the column where the cache key or bucket ID is stored.
    5. dataColumnName

      The dataColumnName property specifies the column where the cache entry or bucket is stored.
    6. timestampColumnName

      The timestampColumnName element specifies the column where the time stamp of the cache entry or bucket is stored.
    ConfigurationBuilder builder = new ConfigurationBuilder();
      builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class)
         .fetchPersistentState(false)
         .ignoreModifications(false)
         .purgeOnStartup(false)
         .table()
            .dropOnExit(true)
            .createOnStart(true)
            .tableNamePrefix("ISPN_STRING_TABLE")
            .idColumnName("ID_COLUMN").idColumnType("VARCHAR(255)")
            .dataColumnName("DATA_COLUMN").dataColumnType("BINARY")
            .timestampColumnName("TIMESTAMP_COLUMN").timestampColumnType("BIGINT")
    
    Copy to Clipboard Toggle word wrap
  7. The connectionPool Element

    The connectionPool element specifies a connection pool for the JDBC driver using the following parameters:
    1. The connectionUrl parameter specifies the JDBC driver-specific connection URL.
    2. The username parameter contains the username used to connect via the connectionUrl.
    3. The driverClass parameter specifies the class name of the driver used to connect to the database.
    ConfigurationBuilder builder = new ConfigurationBuilder();
      builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class)
         .fetchPersistentState(false)
         .ignoreModifications(false)
         .purgeOnStartup(false)
         .table()
            .dropOnExit(true)
            .createOnStart(true)
            .tableNamePrefix("ISPN_STRING_TABLE")
            .idColumnName("ID_COLUMN").idColumnType("VARCHAR(255)")
            .dataColumnName("DATA_COLUMN").dataColumnType("BINARY")
            .timestampColumnName("TIMESTAMP_COLUMN").timestampColumnType("BIGINT")
         .connectionPool()
            .connectionUrl("jdbc:h2:mem:infinispan_binary_based;DB_CLOSE_DELAY=-1")
            .username("sa")
            .driverClass("org.h2.Driver");
    
    
    Copy to Clipboard Toggle word wrap

Note

Programmatic configurations can only be used with Red Hat JBoss Data Grid Library mode.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat