此内容没有您所选择的语言版本。
15.2.4. JdbcStringBasedStore Programmatic Configuration
The following is a sample configuration for the
JdbcStringBasedStore:
Procedure 15.7. Configure the JdbcStringBasedStore Programmatically
Create a New Configuration Builder
Use theConfigurationBuilderto create a new configuration object.ConfigurationBuilder builder = new ConfigurationBuilder();
ConfigurationBuilder builder = new ConfigurationBuilder();Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add
JdbcStringBasedStoreConfigurationBuilderAdd theJdbcStringBasedStoreconfiguration builder to build a specific configuration related to this store.ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class)
ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Up Persistence
fetchPersistentStatedetermines 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 totrue. ThefetchPersistentStateproperty isfalseby default.ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class) .fetchPersistentState(false)ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class) .fetchPersistentState(false)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Modifications
ignoreModificationsdetermines 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.ignoreModificationsisfalseby default.ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class) .fetchPersistentState(false) .ignoreModifications(false)ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class) .fetchPersistentState(false) .ignoreModifications(false)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Purging
purgeOnStartupspecifies whether the cache is purged when initially started.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Table
Set Drop Table On Exit Method
dropOnExitdetermines if the table will be created when the cache store is stopped. This is set tofalseby default.Set Create Table On Start Method
createOnStartcreates the table when starting the cache store if no table currently exists. This method istrueby default.Set the Table Name Prefix
tableNamePrefixsets the prefix for the name of the table in which the data will be stored.idColumnNameTheidColumnNameproperty defines the column where the cache key or bucket ID is stored.dataColumnNameThedataColumnNameproperty specifies the column where the cache entry or bucket is stored.timestampColumnNameThetimestampColumnNameelement specifies the column where the time stamp of the cache entry or bucket is stored.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The connectionPool Element
TheconnectionPoolelement specifies a connection pool for the JDBC driver using the following parameters:- The
connectionUrlparameter specifies the JDBC driver-specific connection URL. - The
usernameparameter contains the username used to connect via theconnectionUrl. - The
driverClassparameter specifies the class name of the driver used to connect to the database.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Note
Programmatic configurations can only be used with Red Hat JBoss Data Grid Library mode.