Get rid of JdbcSQLException while numbers are read from cache
Exception org.h2.jdbc.JdbcSQLException: Hexadecimal string with odd number of characters: "0" is thrown when number with value 0 or string with value "0" is stored in H2Cache and read is performed. The fix modifies implementation so that Java de-serialization is performed even for built-in (e.g. Integer) types. Change-Id: I953487cb75b3712e8825a74613977425873507a1 Signed-off-by: Jacek Centkowski <geminica.programs@gmail.com>
This commit is contained in:
@@ -27,6 +27,7 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.sql.Types;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
@@ -267,7 +268,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void set(PreparedStatement ps, int col, K value) throws SQLException {
|
void set(PreparedStatement ps, int col, K value) throws SQLException {
|
||||||
ps.setObject(col, value);
|
ps.setObject(col, value, Types.JAVA_OBJECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
Funnel<K> funnel() {
|
Funnel<K> funnel() {
|
||||||
@@ -488,7 +489,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
keyType.set(c.put, 1, key);
|
keyType.set(c.put, 1, key);
|
||||||
c.put.setObject(2, holder.value);
|
c.put.setObject(2, holder.value, Types.JAVA_OBJECT);
|
||||||
c.put.setTimestamp(3, new Timestamp(holder.created));
|
c.put.setTimestamp(3, new Timestamp(holder.created));
|
||||||
c.put.setTimestamp(4, new Timestamp(System.currentTimeMillis()));
|
c.put.setTimestamp(4, new Timestamp(System.currentTimeMillis()));
|
||||||
c.put.executeUpdate();
|
c.put.executeUpdate();
|
||||||
|
|||||||
Reference in New Issue
Block a user