19.6. JDBC Based Cache Stores
			Red Hat JBoss Data Grid offers several cache stores for use with common data storage formats. JDBC based cache stores are used with any cache store that exposes a JDBC driver. JBoss Data Grid offers the following JDBC based cache stores depending on the key to be persisted:
		
- JdbcBinaryStore.
- JdbcStringBasedStore.
- JdbcMixedStore.
19.6.1. JdbcBinaryStores
Copy linkLink copied to clipboard!
				The 
JdbcBinaryStore supports all key types. It stores all keys with the same hash value (hashCode method on the key) in the same table row/blob. The hash value common to the included keys is set as the primary key for the table row/blob. As a result of this hash value, JdbcBinaryStore offers excellent flexibility but at the cost of concurrency and throughput.
			
				As an example, if three keys (
k1, k2 and k3) have the same hash code, they are stored in the same table row. If three different threads attempt to concurrently update k1, k2 and k3, they must do it sequentially because all three keys share the same row and therefore cannot be simultaneously updated.
			19.6.1.1. JdbcBinaryStore Configuration (Remote Client-Server Mode)
Copy linkLink copied to clipboard!
		The following is a configuration for 
JdbcBinaryStore using Red Hat JBoss Data Grid's Remote Client-Server mode with Passivation enabled:
	
		For details about the elements and parameters used in this sample configuration, see Section 19.3, “Cache Store Configuration Details (Remote Client-Server Mode)”.
	
19.6.1.2. JdbcBinaryStore Configuration (Library Mode)
Copy linkLink copied to clipboard!
		The following is a sample configuration for the 
JdbcBinaryStore:
	
		For details about the elements and parameters used in this sample configuration, see Section 19.2, “Cache Store Configuration Details (Library Mode)”.
	
19.6.2. JdbcStringBasedStores
Copy linkLink copied to clipboard!
				The 
JdbcStringBasedStore stores each entry in its own row in the table, instead of grouping multiple entries into each row, resulting in increased throughput under a concurrent load. It also uses a (pluggable) bijection that maps each key to a String object. The key-to-string-mapper interface defines the bijection.
			
				Red Hat JBoss Data Grid includes a default implementation called 
DefaultTwoWayKey2StringMapper that handles primitive types.
			19.6.2.1. JdbcStringBasedStore Configuration (Remote Client-Server Mode)
Copy linkLink copied to clipboard!
		The following is a sample 
JdbcStringBasedStore for Red Hat JBoss Data Grid's Remote Client-Server mode:
	
		For details about the elements and parameters used in this sample configuration, see Section 19.3, “Cache Store Configuration Details (Remote Client-Server Mode)”.
	
19.6.2.2. JdbcStringBasedStore Configuration (Library Mode)
Copy linkLink copied to clipboard!
		The following is a sample configuration for the 
JdbcStringBasedStore:
	
		For details about the elements and parameters used in this sample configuration, see Section 19.2, “Cache Store Configuration Details (Library Mode)”.
	
19.6.2.3. JdbcStringBasedStore Multiple Node Configuration (Remote Client-Server Mode)
Copy linkLink copied to clipboard!
		The following is a configuration for the 
JdbcStringBasedStore in Red Hat JBoss Data Grid's Remote Client-Server mode. This configuration is used when multiple nodes must be used.
	
		For details about the elements and parameters used in this sample configuration, see Section 19.3, “Cache Store Configuration Details (Remote Client-Server Mode)”.
	
19.6.3. JdbcMixedStores
Copy linkLink copied to clipboard!
				The 
JdbcMixedStore is a hybrid implementation that delegates keys based on their type to either the JdbcBinaryStore or JdbcStringBasedStore.
			19.6.3.1. JdbcMixedStore Configuration (Remote Client-Server Mode)
Copy linkLink copied to clipboard!
		The following is a configuration for a 
JdbcMixedStore for Red Hat JBoss Data Grid's Remote Client-Server mode:
	
		For details about the elements and parameters used in this sample configuration, see Section 19.3, “Cache Store Configuration Details (Remote Client-Server Mode)”.
	
19.6.3.2. JdbcMixedStore Configuration (Library Mode)
Copy linkLink copied to clipboard!
		The following is a sample configuration for the 
JdbcMixedStore:
	
		For details about the elements and parameters used in this sample configuration, see Section 19.2, “Cache Store Configuration Details (Library Mode)”.
	
19.6.4. Cache Store Troubleshooting
Copy linkLink copied to clipboard!
19.6.4.1. IOExceptions with JdbcStringBasedStore
Copy linkLink copied to clipboard!
		An IOException Unsupported protocol version 48 error when using 
JdbcStringBasedStore indicates that your data column type is set to VARCHAR, CLOB or something similar instead of the correct type, BLOB or VARBINARY. Despite its name, JdbcStringBasedStore only requires that the keys are strings while the values can be any data type, so that they can be stored in a binary column.