提交 7190dd29 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 a3b0faf5
...@@ -104,6 +104,7 @@ public class Driver implements java.sql.Driver { ...@@ -104,6 +104,7 @@ public class Driver implements java.sql.Driver {
* INTERNAL * INTERNAL
*/ */
public static void load() { public static void load() {
// does nothing, but calling it loads the class
} }
} }
...@@ -21,7 +21,7 @@ import org.h2.util.StringUtils; ...@@ -21,7 +21,7 @@ import org.h2.util.StringUtils;
public class Bnf { public class Bnf {
static boolean COMBINE_KEYWORDS; static final boolean COMBINE_KEYWORDS = false;
private static final String SEPARATORS = " [](){}|.,\r\n<>:-+*/=<\">!'"; private static final String SEPARATORS = " [](){}|.,\r\n<>:-+*/=<\">!'";
private static final long MAX_PARSE_TIME = 100; private static final long MAX_PARSE_TIME = 100;
......
...@@ -27,6 +27,7 @@ import org.h2.store.LogSystem; ...@@ -27,6 +27,7 @@ import org.h2.store.LogSystem;
import org.h2.store.UndoLog; import org.h2.store.UndoLog;
import org.h2.store.UndoLogRecord; import org.h2.store.UndoLogRecord;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.util.ObjectUtils;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
import org.h2.value.Value; import org.h2.value.Value;
import org.h2.value.ValueLong; import org.h2.value.ValueLong;
...@@ -377,7 +378,7 @@ public class Session implements SessionInterface { ...@@ -377,7 +378,7 @@ public class Session implements SessionInterface {
if(savepoints == null) { if(savepoints == null) {
savepoints = new HashMap(); savepoints = new HashMap();
} }
savepoints.put(name, new Integer(getLogId())); savepoints.put(name, ObjectUtils.getInteger(getLogId()));
} }
public void rollbackToSavepoint(String name) throws SQLException { public void rollbackToSavepoint(String name) throws SQLException {
......
...@@ -20,6 +20,7 @@ import org.h2.table.Column; ...@@ -20,6 +20,7 @@ import org.h2.table.Column;
import org.h2.table.ColumnResolver; import org.h2.table.ColumnResolver;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.table.TableFilter; import org.h2.table.TableFilter;
import org.h2.util.ObjectUtils;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.value.DataType; import org.h2.value.DataType;
...@@ -87,7 +88,7 @@ public class Aggregate extends Expression { ...@@ -87,7 +88,7 @@ public class Aggregate extends Expression {
} }
private static void addAggregate(String name, int type) { private static void addAggregate(String name, int type) {
aggregates.put(name, new Integer(type)); aggregates.put(name, ObjectUtils.getInteger(type));
} }
public static int getAggregateType(String name) { public static int getAggregateType(String name) {
......
...@@ -31,6 +31,7 @@ import org.h2.table.TableFilter; ...@@ -31,6 +31,7 @@ import org.h2.table.TableFilter;
import org.h2.tools.CompressTool; import org.h2.tools.CompressTool;
import org.h2.tools.Csv; import org.h2.tools.Csv;
import org.h2.tools.SimpleResultSet; import org.h2.tools.SimpleResultSet;
import org.h2.util.ObjectUtils;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
import org.h2.util.MemoryUtils; import org.h2.util.MemoryUtils;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
...@@ -116,20 +117,20 @@ public class Function extends Expression implements FunctionCall { ...@@ -116,20 +117,20 @@ public class Function extends Expression implements FunctionCall {
static { static {
datePart = new HashMap(); datePart = new HashMap();
datePart.put("YY", new Integer(Calendar.YEAR)); datePart.put("YY", ObjectUtils.getInteger(Calendar.YEAR));
datePart.put("YEAR", new Integer(Calendar.YEAR)); datePart.put("YEAR", ObjectUtils.getInteger(Calendar.YEAR));
datePart.put("MM", new Integer(Calendar.MONTH)); datePart.put("MM", ObjectUtils.getInteger(Calendar.MONTH));
datePart.put("MONTH", new Integer(Calendar.MONTH)); datePart.put("MONTH", ObjectUtils.getInteger(Calendar.MONTH));
datePart.put("DD", new Integer(Calendar.DATE)); datePart.put("DD", ObjectUtils.getInteger(Calendar.DATE));
datePart.put("DAY", new Integer(Calendar.DATE)); datePart.put("DAY", ObjectUtils.getInteger(Calendar.DATE));
datePart.put("HH", new Integer(Calendar.HOUR)); datePart.put("HH", ObjectUtils.getInteger(Calendar.HOUR));
datePart.put("HOUR", new Integer(Calendar.HOUR)); datePart.put("HOUR", ObjectUtils.getInteger(Calendar.HOUR));
datePart.put("MI", new Integer(Calendar.MINUTE)); datePart.put("MI", ObjectUtils.getInteger(Calendar.MINUTE));
datePart.put("MINUTE", new Integer(Calendar.MINUTE)); datePart.put("MINUTE", ObjectUtils.getInteger(Calendar.MINUTE));
datePart.put("SS", new Integer(Calendar.SECOND)); datePart.put("SS", ObjectUtils.getInteger(Calendar.SECOND));
datePart.put("SECOND", new Integer(Calendar.SECOND)); datePart.put("SECOND", ObjectUtils.getInteger(Calendar.SECOND));
datePart.put("MS", new Integer(Calendar.MILLISECOND)); datePart.put("MS", ObjectUtils.getInteger(Calendar.MILLISECOND));
datePart.put("MILLISECOND", new Integer(Calendar.MILLISECOND)); datePart.put("MILLISECOND", ObjectUtils.getInteger(Calendar.MILLISECOND));
} }
static { static {
......
...@@ -21,6 +21,7 @@ import java.util.StringTokenizer; ...@@ -21,6 +21,7 @@ import java.util.StringTokenizer;
import org.h2.api.Trigger; import org.h2.api.Trigger;
import org.h2.tools.SimpleResultSet; import org.h2.tools.SimpleResultSet;
import org.h2.util.ByteUtils; import org.h2.util.ByteUtils;
import org.h2.util.ObjectUtils;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.value.DataType; import org.h2.value.DataType;
...@@ -217,7 +218,7 @@ public class FullText implements Trigger { ...@@ -217,7 +218,7 @@ public class FullText implements Trigger {
long id = rs.getLong("ID"); long id = rs.getLong("ID");
word = setting.convertWord(word); word = setting.convertWord(word);
if(word != null) { if(word != null) {
map.put(word, new Long(id)); map.put(word, ObjectUtils.getLong(id));
} }
} }
} }
...@@ -477,7 +478,7 @@ public class FullText implements Trigger { ...@@ -477,7 +478,7 @@ public class FullText implements Trigger {
ResultSet rs = JdbcUtils.getGeneratedKeys(prepInsertWord); ResultSet rs = JdbcUtils.getGeneratedKeys(prepInsertWord);
rs.next(); rs.next();
wordId = rs.getInt(1); wordId = rs.getInt(1);
allWords.put(word, new Integer(wordId)); allWords.put(word, ObjectUtils.getInteger(wordId));
} else { } else {
wordId = wId.intValue(); wordId = wId.intValue();
} }
...@@ -560,7 +561,7 @@ public class FullText implements Trigger { ...@@ -560,7 +561,7 @@ public class FullText implements Trigger {
prepSelectMapByWordId.setInt(1, wId.intValue()); prepSelectMapByWordId.setInt(1, wId.intValue());
ResultSet rs = prepSelectMapByWordId.executeQuery(); ResultSet rs = prepSelectMapByWordId.executeQuery();
while(rs.next()) { while(rs.next()) {
Long rId = new Long(rs.getLong(1)); Long rId = ObjectUtils.getLong(rs.getLong(1));
if(lastRowIds == null || lastRowIds.contains(rId)) { if(lastRowIds == null || lastRowIds.contains(rId)) {
rIds.add(rId); rIds.add(rId);
} }
......
...@@ -12,6 +12,8 @@ import java.sql.Statement; ...@@ -12,6 +12,8 @@ import java.sql.Statement;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import org.h2.util.ObjectUtils;
public class FullTextSettings { public class FullTextSettings {
private static HashMap settings = new HashMap(); private static HashMap settings = new HashMap();
...@@ -34,11 +36,11 @@ public class FullTextSettings { ...@@ -34,11 +36,11 @@ public class FullTextSettings {
} }
IndexInfo getIndexInfo(long indexId) { IndexInfo getIndexInfo(long indexId) {
return (IndexInfo) indexes.get(new Long(indexId)); return (IndexInfo) indexes.get(ObjectUtils.getLong(indexId));
} }
void addIndexInfo(IndexInfo index) { void addIndexInfo(IndexInfo index) {
indexes.put(new Long(index.id), index); indexes.put(ObjectUtils.getLong(index.id), index);
} }
public String convertWord(String word) { public String convertWord(String word) {
......
...@@ -13,6 +13,7 @@ import org.h2.result.SearchRow; ...@@ -13,6 +13,7 @@ import org.h2.result.SearchRow;
import org.h2.table.Column; import org.h2.table.Column;
import org.h2.table.TableData; import org.h2.table.TableData;
import org.h2.util.IntIntHashMap; import org.h2.util.IntIntHashMap;
import org.h2.util.ObjectUtils;
import org.h2.util.ValueHashMap; import org.h2.util.ValueHashMap;
import org.h2.value.Value; import org.h2.value.Value;
import org.h2.value.ValueArray; import org.h2.value.ValueArray;
...@@ -63,7 +64,7 @@ public class HashIndex extends Index { ...@@ -63,7 +64,7 @@ public class HashIndex extends Index {
// TODO index duplicate key for hash indexes: is this allowed? // TODO index duplicate key for hash indexes: is this allowed?
throw getDuplicateKeyException(); throw getDuplicateKeyException();
} }
Integer pos = new Integer(row.getPos()); Integer pos = ObjectUtils.getInteger(row.getPos());
rows.put(getKey(row), pos); rows.put(getKey(row), pos);
} }
rowCount++; rowCount++;
......
...@@ -14,6 +14,7 @@ import org.h2.engine.SessionInterface; ...@@ -14,6 +14,7 @@ import org.h2.engine.SessionInterface;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.message.TraceObject; import org.h2.message.TraceObject;
import org.h2.tools.SimpleResultSet; import org.h2.tools.SimpleResultSet;
import org.h2.util.ObjectUtils;
import org.h2.value.Value; import org.h2.value.Value;
/** /**
...@@ -232,7 +233,7 @@ public class JdbcArray extends TraceObject implements Array { ...@@ -232,7 +233,7 @@ public class JdbcArray extends TraceObject implements Array {
rs.addColumn("VALUE", Types.NULL, 0, 0); rs.addColumn("VALUE", Types.NULL, 0, 0);
for(int i=0; i<array.length; i++) { for(int i=0; i<array.length; i++) {
Object[] row = new Object[2]; Object[] row = new Object[2];
row[0] = new Long(offset + i + 1); row[0] = ObjectUtils.getLong(offset + i + 1);
row[1] = array[i]; row[1] = array[i];
rs.addRow(row); rs.addRow(row);
} }
......
...@@ -23,7 +23,7 @@ public class TraceObject { ...@@ -23,7 +23,7 @@ public class TraceObject {
PARAMETER_META_DATA = 11; PARAMETER_META_DATA = 11;
public static final int DATA_SOURCE = 12, XA_DATA_SOURCE = 13, XID = 14, ARRAY = 15; public static final int DATA_SOURCE = 12, XA_DATA_SOURCE = 13, XID = 14, ARRAY = 15;
private static int LAST = ARRAY + 1; private static final int LAST = ARRAY + 1;
private Trace trace; private Trace trace;
private static final int[] ID = new int[LAST]; private static final int[] ID = new int[LAST];
private static final String[] PREFIX = { private static final String[] PREFIX = {
......
...@@ -25,6 +25,7 @@ import java.util.HashMap; ...@@ -25,6 +25,7 @@ import java.util.HashMap;
import org.h2.engine.ConnectionInfo; import org.h2.engine.ConnectionInfo;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.util.ObjectUtils;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.value.DataType; import org.h2.value.DataType;
...@@ -55,7 +56,7 @@ public class OdbcServerThread implements Runnable { ...@@ -55,7 +56,7 @@ public class OdbcServerThread implements Runnable {
private int addObject(Object o) { private int addObject(Object o) {
int id = nextId++; int id = nextId++;
server.log("addObj "+id+" "+o); server.log("addObj "+id+" "+o);
object.put(new Integer(id), o); object.put(ObjectUtils.getInteger(id), o);
cacheId = id; cacheId = id;
cache = o; cache = o;
return id; return id;
...@@ -66,7 +67,7 @@ public class OdbcServerThread implements Runnable { ...@@ -66,7 +67,7 @@ public class OdbcServerThread implements Runnable {
cacheId = -1; cacheId = -1;
cache = null; cache = null;
} }
object.remove(new Integer(id)); object.remove(ObjectUtils.getInteger(id));
} }
private Object getObject(int id) { private Object getObject(int id) {
...@@ -74,8 +75,8 @@ public class OdbcServerThread implements Runnable { ...@@ -74,8 +75,8 @@ public class OdbcServerThread implements Runnable {
server.log("getObj "+id+" "+cache); server.log("getObj "+id+" "+cache);
return cache; return cache;
} }
server.log("getObj "+id+" "+object.get(new Integer(id))); server.log("getObj "+id+" "+object.get(ObjectUtils.getInteger(id)));
return object.get(new Integer(id)); return object.get(ObjectUtils.getInteger(id));
} }
public void run() { public void run() {
......
...@@ -34,6 +34,7 @@ import java.util.Map.Entry; ...@@ -34,6 +34,7 @@ import java.util.Map.Entry;
import org.h2.bnf.Bnf; import org.h2.bnf.Bnf;
import org.h2.message.TraceSystem; import org.h2.message.TraceSystem;
import org.h2.tools.SimpleResultSet; import org.h2.tools.SimpleResultSet;
import org.h2.util.ObjectUtils;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
import org.h2.util.MemoryUtils; import org.h2.util.MemoryUtils;
...@@ -1261,10 +1262,10 @@ class WebThread extends Thread { ...@@ -1261,10 +1262,10 @@ class WebThread extends Thread {
break; break;
} }
if(sql.substring(idx).startsWith("?/*RND*/")) { if(sql.substring(idx).startsWith("?/*RND*/")) {
params.add(new Integer(1)); params.add(ObjectUtils.getInteger(1));
sql = sql.substring(0, idx) + "?" + sql.substring(idx+"/*RND*/".length()+1); sql = sql.substring(0, idx) + "?" + sql.substring(idx+"/*RND*/".length()+1);
} else { } else {
params.add(new Integer(0)); params.add(ObjectUtils.getInteger(0));
} }
idx++; idx++;
} }
......
...@@ -14,6 +14,7 @@ import org.h2.engine.Database; ...@@ -14,6 +14,7 @@ import org.h2.engine.Database;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.message.Trace; import org.h2.message.Trace;
import org.h2.util.FileUtils; import org.h2.util.FileUtils;
import org.h2.util.ObjectUtils;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/** /**
...@@ -190,7 +191,7 @@ public class LogSystem { ...@@ -190,7 +191,7 @@ public class LogSystem {
for (int i = undo.size() - 1; i >= 0 && sessions.size() > 0; i--) { for (int i = undo.size() - 1; i >= 0 && sessions.size() > 0; i--) {
database.setProgress(DatabaseEventListener.STATE_RECOVER, null, undo.size() - 1 - i, undo.size()); database.setProgress(DatabaseEventListener.STATE_RECOVER, null, undo.size() - 1 - i, undo.size());
LogRecord record = (LogRecord) undo.get(i); LogRecord record = (LogRecord) undo.get(i);
if (sessions.get(new Integer(record.sessionId)) != null) { if (sessions.get(ObjectUtils.getInteger(record.sessionId)) != null) {
// undo only if the session is not yet committed // undo only if the session is not yet committed
record.log.undo(record.logRecordId); record.log.undo(record.logRecordId);
database.getDataFile().flushRedoLog(); database.getDataFile().flushRedoLog();
...@@ -255,7 +256,7 @@ public class LogSystem { ...@@ -255,7 +256,7 @@ public class LogSystem {
} else { } else {
dataFile = true; dataFile = true;
} }
Integer i = new Integer(id); Integer i = ObjectUtils.getInteger(id);
Storage storage = (Storage) storages.get(i); Storage storage = (Storage) storages.get(i);
if (storage == null) { if (storage == null) {
storage = database.getStorage(null, id, dataFile); storage = database.getStorage(null, id, dataFile);
...@@ -265,7 +266,7 @@ public class LogSystem { ...@@ -265,7 +266,7 @@ public class LogSystem {
} }
boolean isSessionCommitted(int sessionId, int logId, int pos) { boolean isSessionCommitted(int sessionId, int logId, int pos) {
Integer key = new Integer(sessionId); Integer key = ObjectUtils.getInteger(sessionId);
SessionState state = (SessionState) sessions.get(key); SessionState state = (SessionState) sessions.get(key);
if (state == null) { if (state == null) {
return true; return true;
...@@ -274,7 +275,7 @@ public class LogSystem { ...@@ -274,7 +275,7 @@ public class LogSystem {
} }
void setLastCommitForSession(int sessionId, int logId, int pos) { void setLastCommitForSession(int sessionId, int logId, int pos) {
Integer key = new Integer(sessionId); Integer key = ObjectUtils.getInteger(sessionId);
SessionState state = (SessionState) sessions.get(key); SessionState state = (SessionState) sessions.get(key);
if (state == null) { if (state == null) {
state = new SessionState(); state = new SessionState();
...@@ -287,7 +288,7 @@ public class LogSystem { ...@@ -287,7 +288,7 @@ public class LogSystem {
} }
void setPreparedCommitForSession(LogFile log, int sessionId, int pos, String transaction, int blocks) { void setPreparedCommitForSession(LogFile log, int sessionId, int pos, String transaction, int blocks) {
Integer key = new Integer(sessionId); Integer key = ObjectUtils.getInteger(sessionId);
SessionState state = (SessionState) sessions.get(key); SessionState state = (SessionState) sessions.get(key);
if (state == null) { if (state == null) {
state = new SessionState(); state = new SessionState();
...@@ -304,7 +305,7 @@ public class LogSystem { ...@@ -304,7 +305,7 @@ public class LogSystem {
} }
void removeSession(int sessionId) { void removeSession(int sessionId) {
sessions.remove(new Integer(sessionId)); sessions.remove(ObjectUtils.getInteger(sessionId));
} }
public void prepareCommit(Session session, String transaction) throws SQLException { public void prepareCommit(Session session, String transaction) throws SQLException {
......
...@@ -38,6 +38,7 @@ import org.h2.store.LogFile; ...@@ -38,6 +38,7 @@ import org.h2.store.LogFile;
import org.h2.util.ByteUtils; import org.h2.util.ByteUtils;
import org.h2.util.FileUtils; import org.h2.util.FileUtils;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
import org.h2.util.ObjectUtils;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
import org.h2.util.RandomUtils; import org.h2.util.RandomUtils;
import org.h2.value.Value; import org.h2.value.Value;
...@@ -701,8 +702,8 @@ public class Recover implements DataHandler { ...@@ -701,8 +702,8 @@ public class Recover implements DataHandler {
writeDataError(writer, "out of memory", s.getBytes(), blockCount); writeDataError(writer, "out of memory", s.getBytes(), blockCount);
continue; continue;
} }
if(!objectIdSet.contains(new Integer(storageId))) { if(!objectIdSet.contains(ObjectUtils.getInteger(storageId))) {
objectIdSet.add(new Integer(storageId)); objectIdSet.add(ObjectUtils.getInteger(storageId));
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append("CREATE TABLE O_" + storageId + "("); sb.append("CREATE TABLE O_" + storageId + "(");
for(int i=0; i<recordLength; i++) { for(int i=0; i<recordLength; i++) {
...@@ -749,7 +750,7 @@ public class Recover implements DataHandler { ...@@ -749,7 +750,7 @@ public class Recover implements DataHandler {
if(end >= 0) { if(end >= 0) {
int start = sql.lastIndexOf(' ', end); int start = sql.lastIndexOf(' ', end);
String name = sql.substring(start, end).trim(); String name = sql.substring(start, end).trim();
tableMap.put(new Integer(meta.getId()), name); tableMap.put(ObjectUtils.getInteger(meta.getId()), name);
} }
} }
} catch(Throwable t) { } catch(Throwable t) {
......
...@@ -22,6 +22,7 @@ import org.h2.engine.Constants; ...@@ -22,6 +22,7 @@ import org.h2.engine.Constants;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.util.ClassUtils; import org.h2.util.ClassUtils;
import org.h2.util.FileUtils; import org.h2.util.FileUtils;
import org.h2.util.ObjectUtils;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.ScriptReader; import org.h2.util.ScriptReader;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
...@@ -183,7 +184,7 @@ public class RunScript { ...@@ -183,7 +184,7 @@ public class RunScript {
execute(conn, threadMap, sql, continueOnError, charsetName); execute(conn, threadMap, sql, continueOnError, charsetName);
} else if (MULTI_THREAD && sql.startsWith("/*")) { } else if (MULTI_THREAD && sql.startsWith("/*")) {
int idx = sql.indexOf(']'); int idx = sql.indexOf(']');
Integer id = new Integer(Integer.parseInt(sql.substring("/*".length(), idx))); Integer id = ObjectUtils.getInteger(Integer.parseInt(sql.substring("/*".length(), idx)));
RunScriptThread thread = (RunScriptThread) threadMap.get(id); RunScriptThread thread = (RunScriptThread) threadMap.get(id);
if (thread == null) { if (thread == null) {
Connection c = DriverManager.getConnection(conn.getMetaData().getURL()); Connection c = DriverManager.getConnection(conn.getMetaData().getURL());
......
package org.h2.util;
public class ObjectUtils {
public static Integer getInteger(int x) {
//#ifdef JDK16
/*
return Integer.valueOf(x);
*/
//#endif
//#ifdef JDK14
return new Integer(x);
//#endif
}
public static Long getLong(long x) {
//#ifdef JDK16
/*
return Long.valueOf(x);
*/
//#endif
//#ifdef JDK14
return new Long(x);
//#endif
}
public static Short getShort(short x) {
//#ifdef JDK16
/*
return Short.valueOf(x);
*/
//#endif
//#ifdef JDK14
return new Short(x);
//#endif
}
public static Byte getByte(byte x) {
//#ifdef JDK16
/*
return Byte.valueOf(x);
*/
//#endif
//#ifdef JDK14
return new Byte(x);
//#endif
}
public static Float getFloat(float x) {
//#ifdef JDK16
/*
return Float.valueOf(x);
*/
//#endif
//#ifdef JDK14
return new Float(x);
//#endif
}
public static Double getDouble(double x) {
//#ifdef JDK16
/*
return Double.valueOf(x);
*/
//#endif
//#ifdef JDK14
return new Double(x);
//#endif
}
}
...@@ -34,7 +34,7 @@ public class SmallMap { ...@@ -34,7 +34,7 @@ public class SmallMap {
if(id > lastId) { if(id > lastId) {
lastId = id; lastId = id;
} }
map.put(new Integer(id), o); map.put(ObjectUtils.getInteger(id), o);
cacheId = id; cacheId = id;
cache = o; cache = o;
return id; return id;
...@@ -45,14 +45,14 @@ public class SmallMap { ...@@ -45,14 +45,14 @@ public class SmallMap {
cacheId = -1; cacheId = -1;
cache = null; cache = null;
} }
map.remove(new Integer(id)); map.remove(ObjectUtils.getInteger(id));
} }
public Object getObject(int id, boolean ifAvailable) throws SQLException { public Object getObject(int id, boolean ifAvailable) throws SQLException {
if (id == cacheId) { if (id == cacheId) {
return cache; return cache;
} }
Object obj = map.get(new Integer(id)); Object obj = map.get(ObjectUtils.getInteger(id));
if(obj == null && !ifAvailable) { if(obj == null && !ifAvailable) {
throw Message.getSQLException(Message.OBJECT_CLOSED); throw Message.getSQLException(Message.OBJECT_CLOSED);
} }
......
...@@ -25,6 +25,7 @@ import org.h2.jdbc.JdbcConnection; ...@@ -25,6 +25,7 @@ import org.h2.jdbc.JdbcConnection;
import org.h2.jdbc.JdbcSQLException; import org.h2.jdbc.JdbcSQLException;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.util.ByteUtils; import org.h2.util.ByteUtils;
import org.h2.util.ObjectUtils;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
...@@ -678,9 +679,9 @@ public class DataType { ...@@ -678,9 +679,9 @@ public class DataType {
} else if(clazz == Short.TYPE) { } else if(clazz == Short.TYPE) {
return new Short((short)0); return new Short((short)0);
} else if(clazz == Integer.TYPE) { } else if(clazz == Integer.TYPE) {
return new Integer(0); return ObjectUtils.getInteger(0);
} else if(clazz == Long.TYPE) { } else if(clazz == Long.TYPE) {
return new Long(0); return ObjectUtils.getLong(0);
} else if(clazz == Float.TYPE) { } else if(clazz == Float.TYPE) {
return new Float(0); return new Float(0);
} else if(clazz == Double.TYPE) { } else if(clazz == Double.TYPE) {
......
...@@ -9,6 +9,7 @@ import java.sql.SQLException; ...@@ -9,6 +9,7 @@ import java.sql.SQLException;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.util.ObjectUtils;
/** /**
* @author Thomas * @author Thomas
...@@ -131,7 +132,7 @@ public class ValueInt extends Value { ...@@ -131,7 +132,7 @@ public class ValueInt extends Value {
} }
public Object getObject() { public Object getObject() {
return new Integer(value); return ObjectUtils.getInteger(value);
} }
public void set(PreparedStatement prep, int parameterIndex) throws SQLException { public void set(PreparedStatement prep, int parameterIndex) throws SQLException {
......
...@@ -10,6 +10,7 @@ import java.sql.SQLException; ...@@ -10,6 +10,7 @@ import java.sql.SQLException;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.util.ObjectUtils;
public class ValueLong extends Value { public class ValueLong extends Value {
...@@ -155,7 +156,7 @@ public class ValueLong extends Value { ...@@ -155,7 +156,7 @@ public class ValueLong extends Value {
} }
public Object getObject() { public Object getObject() {
return new Long(value); return ObjectUtils.getLong(value);
} }
public void set(PreparedStatement prep, int parameterIndex) throws SQLException { public void set(PreparedStatement prep, int parameterIndex) throws SQLException {
......
...@@ -94,6 +94,8 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2 ...@@ -94,6 +94,8 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
/* /*
replace new Byte, Double, Float, Long, Byte, Short with ObjectUtils.get
set read-committed as the default set read-committed as the default
SELECT rolcreaterole, rolcreatedb FROM pg_roles WHERE rolname = current_user; SELECT rolcreaterole, rolcreatedb FROM pg_roles WHERE rolname = current_user;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论