提交 e807600e authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 958e48d2
...@@ -26,8 +26,8 @@ public class Bnf { ...@@ -26,8 +26,8 @@ public class Bnf {
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;
private Random random; private final Random random = new Random();
private HashMap ruleMap = new HashMap(); private final HashMap ruleMap = new HashMap();
private String syntax; private String syntax;
private String currentToken; private String currentToken;
private String[] tokens; private String[] tokens;
...@@ -54,7 +54,6 @@ public class Bnf { ...@@ -54,7 +54,6 @@ public class Bnf {
} }
Bnf() { Bnf() {
this.random = new Random();
random.setSeed(1); random.setSeed(1);
} }
...@@ -170,8 +169,7 @@ public class Bnf { ...@@ -170,8 +169,7 @@ public class Bnf {
private Rule parseRule() { private Rule parseRule() {
read(); read();
Rule r= parseOr(); return parseOr();
return r;
} }
private Rule parseOr() { private Rule parseOr() {
......
...@@ -86,7 +86,7 @@ public class RuleElement implements Rule { ...@@ -86,7 +86,7 @@ public class RuleElement implements Rule {
String up = StringUtils.toUpperEnglish(query); String up = StringUtils.toUpperEnglish(query);
if(up.startsWith(name)) { if(up.startsWith(name)) {
query = query.substring(name.length()); query = query.substring(name.length());
while(!name.equals("_") && query.length()>0 && Character.isWhitespace(query.charAt(0))) { while(!"_".equals(name) && query.length()>0 && Character.isWhitespace(query.charAt(0))) {
query = query.substring(1); query = query.substring(1);
} }
return query; return query;
......
...@@ -18,7 +18,7 @@ public class RuleFixed implements Rule { ...@@ -18,7 +18,7 @@ public class RuleFixed implements Rule {
public static final int ANY_WORD = 7; public static final int ANY_WORD = 7;
public static final int HEX_START = 10, CONCAT = 11, AZ_ = 12, AF = 13, DIGIT = 14; public static final int HEX_START = 10, CONCAT = 11, AZ_ = 12, AF = 13, DIGIT = 14;
private int type; private final int type;
public RuleFixed(int type) { public RuleFixed(int type) {
this.type = type; this.type = type;
...@@ -212,14 +212,14 @@ public class RuleFixed implements Rule { ...@@ -212,14 +212,14 @@ public class RuleFixed implements Rule {
case HEX_START: case HEX_START:
if(query.length() == 0) { if(query.length() == 0) {
sentence.add("0x", "0x", Sentence.KEYWORD); sentence.add("0x", "0x", Sentence.KEYWORD);
} else if(query.equals("0")) { } else if("0".equals(query)) {
sentence.add("0x", "x", Sentence.KEYWORD); sentence.add("0x", "x", Sentence.KEYWORD);
} }
break; break;
case CONCAT: case CONCAT:
if(query.length() == 0) { if(query.length() == 0) {
sentence.add("||", "||", Sentence.KEYWORD); sentence.add("||", "||", Sentence.KEYWORD);
} else if(query.equals("|")) { } else if("|".equals(query)) {
sentence.add("||", "|", Sentence.KEYWORD); sentence.add("||", "|", Sentence.KEYWORD);
} }
break; break;
......
...@@ -61,13 +61,12 @@ public abstract class Command implements CommandInterface { ...@@ -61,13 +61,12 @@ public abstract class Command implements CommandInterface {
public LocalResult executeQueryLocal(int maxrows) throws SQLException { public LocalResult executeQueryLocal(int maxrows) throws SQLException {
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
Database database = session.getDatabase(); Database database = session.getDatabase();
Object sync = Constants.MULTI_THREADED_KERNEL ? (Object)session : (Object)database; Object sync = Constants.multiThreadedKernel ? (Object)session : (Object)database;
synchronized (sync) { synchronized (sync) {
try { try {
database.checkPowerOff(); database.checkPowerOff();
session.setCurrentCommand(this); session.setCurrentCommand(this);
LocalResult result = query(maxrows); return query(maxrows);
return result;
} catch(Throwable e) { } catch(Throwable e) {
SQLException s = Message.convert(e); SQLException s = Message.convert(e);
database.exceptionThrown(s, sql); database.exceptionThrown(s, sql);
...@@ -95,7 +94,7 @@ public abstract class Command implements CommandInterface { ...@@ -95,7 +94,7 @@ public abstract class Command implements CommandInterface {
session.commit(true); session.commit(true);
} else if (session.getAutoCommit()) { } else if (session.getAutoCommit()) {
session.commit(false); session.commit(false);
} else if (Constants.MULTI_THREADED_KERNEL) { } else if (Constants.multiThreadedKernel) {
Database db = session.getDatabase(); Database db = session.getDatabase();
if (db != null && db.getLockMode() == Constants.LOCK_MODE_READ_COMMITTED) { if (db != null && db.getLockMode() == Constants.LOCK_MODE_READ_COMMITTED) {
session.unlockReadLocks(); session.unlockReadLocks();
...@@ -112,14 +111,13 @@ public abstract class Command implements CommandInterface { ...@@ -112,14 +111,13 @@ public abstract class Command implements CommandInterface {
public int executeUpdate() throws SQLException { public int executeUpdate() throws SQLException {
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
Database database = session.getDatabase(); Database database = session.getDatabase();
Object sync = Constants.MULTI_THREADED_KERNEL ? (Object)session : (Object)database; Object sync = Constants.multiThreadedKernel ? (Object)session : (Object)database;
synchronized (sync) { synchronized (sync) {
int rollback = session.getLogId(); int rollback = session.getLogId();
session.setCurrentCommand(this); session.setCurrentCommand(this);
try { try {
database.checkPowerOff(); database.checkPowerOff();
int result = update(); return update();
return result;
} catch (SQLException e) { } catch (SQLException e) {
database.exceptionThrown(e, sql); database.exceptionThrown(e, sql);
database.checkPowerOff(); database.checkPowerOff();
......
...@@ -186,8 +186,7 @@ public class Parser { ...@@ -186,8 +186,7 @@ public class Parser {
public Prepared parseOnly(String sql) throws SQLException { public Prepared parseOnly(String sql) throws SQLException {
try { try {
Prepared p = parse(sql); return parse(sql);
return p;
} catch(Exception e) { } catch(Exception e) {
throw Message.convert(e); throw Message.convert(e);
} }
...@@ -489,8 +488,7 @@ public class Parser { ...@@ -489,8 +488,7 @@ public class Parser {
readIf("SCRIPT"); readIf("SCRIPT");
} }
} }
TransactionCommand command = new TransactionCommand(session, type); return new TransactionCommand(session, type);
return command;
} }
private TransactionCommand parseRollback() throws SQLException { private TransactionCommand parseRollback() throws SQLException {
...@@ -623,8 +621,7 @@ public class Parser { ...@@ -623,8 +621,7 @@ public class Parser {
alias = readAliasIdentifier(); alias = readAliasIdentifier();
} }
} }
TableFilter filter = new TableFilter(session, table, alias, rightsChecked, currentSelect); return new TableFilter(session, table, alias, rightsChecked, currentSelect);
return filter;
} }
private Delete parseDelete() throws SQLException { private Delete parseDelete() throws SQLException {
...@@ -694,8 +691,7 @@ public class Parser { ...@@ -694,8 +691,7 @@ public class Parser {
buff.append("UPPER(TOPIC) LIKE "); buff.append("UPPER(TOPIC) LIKE ");
buff.append(StringUtils.quoteStringSQL("%"+s+"%")); buff.append(StringUtils.quoteStringSQL("%"+s+"%"));
} }
Prepared command = session.prepare(buff.toString()); return session.prepare(buff.toString());
return command;
} }
private Merge parseMerge() throws SQLException { private Merge parseMerge() throws SQLException {
...@@ -817,7 +813,7 @@ public class Parser { ...@@ -817,7 +813,7 @@ public class Parser {
} }
table = new FunctionTable(mainSchema, session, (FunctionCall)func); table = new FunctionTable(mainSchema, session, (FunctionCall)func);
} }
} else if(tableName.equals("DUAL")) { } else if("DUAL".equals(tableName)) {
table = new RangeTable(mainSchema, 1, 1); table = new RangeTable(mainSchema, 1, 1);
} else { } else {
table = readTableOrView(tableName); table = readTableOrView(tableName);
...@@ -832,8 +828,7 @@ public class Parser { ...@@ -832,8 +828,7 @@ public class Parser {
alias = readAliasIdentifier(); alias = readAliasIdentifier();
} }
} }
TableFilter filter = new TableFilter(session, table, alias, rightsChecked, currentSelect); return new TableFilter(session, table, alias, rightsChecked, currentSelect);
return filter;
} }
private Prepared parseTruncate() throws SQLException { private Prepared parseTruncate() throws SQLException {
...@@ -2683,31 +2678,31 @@ public class Parser { ...@@ -2683,31 +2678,31 @@ public class Parser {
} else if(s.length()==2) { } else if(s.length()==2) {
switch (c0) { switch (c0) {
case ':': case ':':
if(s.equals("::")) { if("::".equals(s)) {
return KEYWORD; return KEYWORD;
} }
break; break;
case '>': case '>':
if(s.equals(">=")) { if(">=".equals(s)) {
return BIGGER_EQUAL; return BIGGER_EQUAL;
} }
break; break;
case '<': case '<':
if (s.equals("<=")) { if ("<=".equals(s)) {
return SMALLER_EQUAL; return SMALLER_EQUAL;
} else if (s.equals("<>")) { } else if ("<>".equals(s)) {
return NOT_EQUAL; return NOT_EQUAL;
} }
break; break;
case '!': case '!':
if (s.equals("!=")) { if ("!=".equals(s)) {
return NOT_EQUAL; return NOT_EQUAL;
} else if(s.equals("!~")) { } else if("!~".equals(s)) {
return KEYWORD; return KEYWORD;
} }
break; break;
case '|': case '|':
if(s.equals("||")) { if("||".equals(s)) {
return STRING_CONCAT; return STRING_CONCAT;
} }
break; break;
...@@ -2746,16 +2741,16 @@ public class Parser { ...@@ -2746,16 +2741,16 @@ public class Parser {
case 'D': case 'D':
return getKeywordOrIdentifier(s, "DISTINCT", KEYWORD); return getKeywordOrIdentifier(s, "DISTINCT", KEYWORD);
case 'E': case 'E':
if(s.equals("EXCEPT")) { if("EXCEPT".equals(s)) {
return KEYWORD; return KEYWORD;
} }
return getKeywordOrIdentifier(s, "EXISTS", KEYWORD); return getKeywordOrIdentifier(s, "EXISTS", KEYWORD);
case 'F': case 'F':
if(s.equals("FROM")) { if("FROM".equals(s)) {
return KEYWORD; return KEYWORD;
} else if(s.equals("FOR")) { } else if("FOR".equals(s)) {
return KEYWORD; return KEYWORD;
} else if(s.equals("FULL")) { } else if("FULL".equals(s)) {
return KEYWORD; return KEYWORD;
} }
return getKeywordOrIdentifier(s, "FALSE", FALSE); return getKeywordOrIdentifier(s, "FALSE", FALSE);
...@@ -2764,33 +2759,33 @@ public class Parser { ...@@ -2764,33 +2759,33 @@ public class Parser {
case 'H': case 'H':
return getKeywordOrIdentifier(s, "HAVING", KEYWORD); return getKeywordOrIdentifier(s, "HAVING", KEYWORD);
case 'I': case 'I':
if (s.equals("INNER")) { if ("INNER".equals(s)) {
return KEYWORD; return KEYWORD;
} else if(s.equals("INTERSECT")) { } else if("INTERSECT".equals(s)) {
return KEYWORD; return KEYWORD;
} }
return getKeywordOrIdentifier(s, "IS", KEYWORD); return getKeywordOrIdentifier(s, "IS", KEYWORD);
case 'J': case 'J':
return getKeywordOrIdentifier(s, "JOIN", KEYWORD); return getKeywordOrIdentifier(s, "JOIN", KEYWORD);
case 'L': case 'L':
if (s.equals("LIMIT")) { if ("LIMIT".equals(s)) {
return KEYWORD; return KEYWORD;
} }
return getKeywordOrIdentifier(s, "LIKE", KEYWORD); return getKeywordOrIdentifier(s, "LIKE", KEYWORD);
case 'M': case 'M':
if(s.equals("MINUS")) { if("MINUS".equals(s)) {
return KEYWORD; return KEYWORD;
} }
break; break;
case 'N': case 'N':
if(s.equals("NOT")) { if("NOT".equals(s)) {
return KEYWORD; return KEYWORD;
} else if(s.equals("NATURAL")) { } else if("NATURAL".equals(s)) {
return KEYWORD; return KEYWORD;
} }
return getKeywordOrIdentifier(s, "NULL", NULL); return getKeywordOrIdentifier(s, "NULL", NULL);
case 'O': case 'O':
if (s.equals("ON")) { if ("ON".equals(s)) {
return KEYWORD; return KEYWORD;
} }
return getKeywordOrIdentifier(s, "ORDER", KEYWORD); return getKeywordOrIdentifier(s, "ORDER", KEYWORD);
...@@ -2808,7 +2803,7 @@ public class Parser { ...@@ -2808,7 +2803,7 @@ public class Parser {
} }
return getKeywordOrIdentifier(s, "SELECT", KEYWORD); return getKeywordOrIdentifier(s, "SELECT", KEYWORD);
case 'T': case 'T':
if(s.equals("TODAY")) { if("TODAY".equals(s)) {
return CURRENT_DATE; return CURRENT_DATE;
} }
return getKeywordOrIdentifier(s, "TRUE", TRUE); return getKeywordOrIdentifier(s, "TRUE", TRUE);
......
...@@ -37,7 +37,6 @@ public class AlterTableAddConstraint extends SchemaCommand { ...@@ -37,7 +37,6 @@ public class AlterTableAddConstraint extends SchemaCommand {
private int type; private int type;
private String constraintName; private String constraintName;
private String tableName; private String tableName;
private Table table;
private String[] columnNames; private String[] columnNames;
private int deleteAction; private int deleteAction;
private int updateAction; private int updateAction;
...@@ -62,7 +61,7 @@ public class AlterTableAddConstraint extends SchemaCommand { ...@@ -62,7 +61,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
public int update() throws SQLException { public int update() throws SQLException {
session.commit(true); session.commit(true);
Database db = session.getDatabase(); Database db = session.getDatabase();
table = getSchema().getTableOrView(session, tableName); Table table = getSchema().getTableOrView(session, tableName);
if(getSchema().findConstraint(constraintName)!=null) { if(getSchema().findConstraint(constraintName)!=null) {
throw Message.getSQLException(Message.CONSTRAINT_ALREADY_EXISTS_1, throw Message.getSQLException(Message.CONSTRAINT_ALREADY_EXISTS_1,
constraintName); constraintName);
......
...@@ -34,7 +34,6 @@ public class CreateTable extends SchemaCommand { ...@@ -34,7 +34,6 @@ public class CreateTable extends SchemaCommand {
private boolean ifNotExists; private boolean ifNotExists;
private boolean persistent = true; private boolean persistent = true;
private boolean hashPrimaryKey; private boolean hashPrimaryKey;
private ObjectArray sequences;
private boolean temporary; private boolean temporary;
private boolean globalTemporary; private boolean globalTemporary;
private boolean onCommitDrop; private boolean onCommitDrop;
...@@ -107,7 +106,7 @@ public class CreateTable extends SchemaCommand { ...@@ -107,7 +106,7 @@ public class CreateTable extends SchemaCommand {
} }
} }
} }
sequences = new ObjectArray(); ObjectArray sequences = new ObjectArray();
for(int i=0; i<columns.size(); i++) { for(int i=0; i<columns.size(); i++) {
Column c = (Column) columns.get(i); Column c = (Column) columns.get(i);
if(c.getAutoIncrement()) { if(c.getAutoIncrement()) {
......
...@@ -59,7 +59,7 @@ public abstract class ScriptBase extends Prepared implements DataHandler { ...@@ -59,7 +59,7 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
if(fileName == null || fileName.trim().length() == 0) { if(fileName == null || fileName.trim().length() == 0) {
fileName = "script.sql"; fileName = "script.sql";
} }
this.fileName = Constants.SCRIPT_DIRECTORY + fileName; this.fileName = Constants.scriptDirectory + fileName;
} }
public boolean isTransactional() { public boolean isTransactional() {
......
...@@ -169,7 +169,7 @@ public class Set extends Prepared { ...@@ -169,7 +169,7 @@ public class Set extends Prepared {
} }
case SetTypes.MULTI_THREADED: { case SetTypes.MULTI_THREADED: {
session.getUser().checkAdmin(); session.getUser().checkAdmin();
Constants.MULTI_THREADED_KERNEL = (getIntValue() == 1); Constants.multiThreadedKernel = (getIntValue() == 1);
break; break;
} }
case SetTypes.DB_CLOSE_DELAY: { case SetTypes.DB_CLOSE_DELAY: {
......
...@@ -22,9 +22,9 @@ public class CompressDeflate implements Compressor { ...@@ -22,9 +22,9 @@ public class CompressDeflate implements Compressor {
StringTokenizer tokenizer = new StringTokenizer(options); StringTokenizer tokenizer = new StringTokenizer(options);
while(tokenizer.hasMoreElements()) { while(tokenizer.hasMoreElements()) {
String option = tokenizer.nextToken(); String option = tokenizer.nextToken();
if(option.equals("level") || option.equals("l")) { if("level".equals(option) || "l".equals(option)) {
level = Integer.parseInt(tokenizer.nextToken()); level = Integer.parseInt(tokenizer.nextToken());
} else if(option.equals("strategy") || option.equals("s")) { } else if("strategy".equals(option) || "s".equals(option)) {
strategy = Integer.parseInt(tokenizer.nextToken()); strategy = Integer.parseInt(tokenizer.nextToken());
} }
} }
......
...@@ -75,7 +75,7 @@ public class ConnectionInfo { ...@@ -75,7 +75,7 @@ public class ConnectionInfo {
} }
private void parseName() { private void parseName() {
if(name.equals(".")) { if(".".equals(name)) {
name = "mem:"; name = "mem:";
} }
if(name.startsWith("tcp:")) { if(name.startsWith("tcp:")) {
...@@ -87,7 +87,7 @@ public class ConnectionInfo { ...@@ -87,7 +87,7 @@ public class ConnectionInfo {
name = name.substring("ssl:".length()); name = name.substring("ssl:".length());
} else if(name.startsWith("mem:")) { } else if(name.startsWith("mem:")) {
persistent = false; persistent = false;
if(name.equals("mem:")) { if("mem:".equals(name)) {
unnamed = true; unnamed = true;
} }
} else if(name.startsWith("file:")) { } else if(name.startsWith("file:")) {
......
...@@ -77,7 +77,6 @@ public class Constants { ...@@ -77,7 +77,6 @@ public class Constants {
public static final String MAGIC_FILE_HEADER_TEXT = "-- H2 0.5/T -- ".substring(0, FILE_BLOCK_SIZE-1) + "\n"; public static final String MAGIC_FILE_HEADER_TEXT = "-- H2 0.5/T -- ".substring(0, FILE_BLOCK_SIZE-1) + "\n";
public static final String MAGIC_FILE_HEADER = "-- H2 0.5/B -- ".substring(0, FILE_BLOCK_SIZE-1) + "\n"; public static final String MAGIC_FILE_HEADER = "-- H2 0.5/B -- ".substring(0, FILE_BLOCK_SIZE-1) + "\n";
public static final int TCP_DRIVER_VERSION = 4; public static final int TCP_DRIVER_VERSION = 4;
public static final int VERSION_JDBC_MAJOR = 3; public static final int VERSION_JDBC_MAJOR = 3;
public static final int VERSION_JDBC_MINOR = 0; public static final int VERSION_JDBC_MINOR = 0;
...@@ -88,22 +87,14 @@ public class Constants { ...@@ -88,22 +87,14 @@ public class Constants {
public static final int NULL_SORT_LOW = 1, NULL_SORT_HIGH = 2; public static final int NULL_SORT_LOW = 1, NULL_SORT_HIGH = 2;
public static final int NULL_SORT_START = 3, NULL_SORT_END = 4; public static final int NULL_SORT_START = 3, NULL_SORT_END = 4;
public static final int NULL_SORT_DEFAULT = NULL_SORT_LOW; public static final int NULL_SORT_DEFAULT = NULL_SORT_LOW;
public static final int DEFAULT_SERVER_PORT = 9092; // this is also in the docs public static final int DEFAULT_SERVER_PORT = 9092; // this is also in the docs
public static final String START_URL = "jdbc:h2:"; public static final String START_URL = "jdbc:h2:";
public static final String URL_FORMAT = START_URL + "{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]"; public static final String URL_FORMAT = START_URL + "{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]";
public static final String PRODUCT_NAME = "H2"; public static final String PRODUCT_NAME = "H2";
public static final String DRIVER_NAME = "H2 JDBC Driver"; public static final String DRIVER_NAME = "H2 JDBC Driver";
public static final int IO_BUFFER_SIZE = 4 * 1024; public static final int IO_BUFFER_SIZE = 4 * 1024;
public static final int IO_BUFFER_SIZE_COMPRESS = 128 * 1024; public static final int IO_BUFFER_SIZE_COMPRESS = 128 * 1024;
public static final int DEFAULT_CACHE_SIZE_LINEAR_INDEX = 64 * 1024; public static final int DEFAULT_CACHE_SIZE_LINEAR_INDEX = 64 * 1024;
public static final String SUFFIX_DB_FILE = ".db"; public static final String SUFFIX_DB_FILE = ".db";
public static final String SUFFIX_DATA_FILE = ".data.db"; public static final String SUFFIX_DATA_FILE = ".data.db";
public static final String SUFFIX_LOG_FILE = ".log.db"; public static final String SUFFIX_LOG_FILE = ".log.db";
...@@ -115,59 +106,40 @@ public class Constants { ...@@ -115,59 +106,40 @@ public class Constants {
public static final String SUFFIX_LOB_FILE = ".lob.db"; public static final String SUFFIX_LOB_FILE = ".lob.db";
public static final String SUFFIX_TRACE_START_FILE = ".start"; public static final String SUFFIX_TRACE_START_FILE = ".start";
public static final String SUFFIX_LOBS_DIRECTORY = ".lobs.db"; public static final String SUFFIX_LOBS_DIRECTORY = ".lobs.db";
public static final String UTF8 = "UTF8"; public static final String UTF8 = "UTF8";
public static final int DEFAULT_TABLE_TYPE = 0; public static final int DEFAULT_TABLE_TYPE = 0;
public static final int DEFAULT_MAX_LENGTH_INPLACE_LOB = 128; public static final int DEFAULT_MAX_LENGTH_INPLACE_LOB = 128;
public static final int DEFAULT_MAX_LENGTH_CLIENTSIDE_LOB = 65536; public static final int DEFAULT_MAX_LENGTH_CLIENTSIDE_LOB = 65536;
public static final int SALT_LEN = 8; public static final int SALT_LEN = 8;
public static final int DEFAULT_DATA_PAGE_SIZE = 512; public static final int DEFAULT_DATA_PAGE_SIZE = 512;
public static final String PRIMARY_KEY_PREFIX = "PRIMARY_KEY_"; public static final String PRIMARY_KEY_PREFIX = "PRIMARY_KEY_";
public static final int LOCK_SLEEP = 1000; public static final int LOCK_SLEEP = 1000;
// TODO for testing, the lock timeout is smaller than for interactive use cases // TODO for testing, the lock timeout is smaller than for interactive use cases
// public static final int INITIAL_LOCK_TIMEOUT = 60 * 1000; // public static final int INITIAL_LOCK_TIMEOUT = 60 * 1000;
public static final int INITIAL_LOCK_TIMEOUT = 1000; public static final int INITIAL_LOCK_TIMEOUT = 1000;
public static final char DEFAULT_ESCAPE_CHAR = '\\'; public static final char DEFAULT_ESCAPE_CHAR = '\\';
public static final int DEFAULT_HTTP_PORT = 8082; // also in the docs public static final int DEFAULT_HTTP_PORT = 8082; // also in the docs
public static final boolean DEFAULT_HTTP_SSL = false; public static final boolean DEFAULT_HTTP_SSL = false;
public static final boolean DEFAULT_HTTP_ALLOW_OTHERS = false; public static final boolean DEFAULT_HTTP_ALLOW_OTHERS = false;
public static final int DEFAULT_FTP_PORT = 8021; public static final int DEFAULT_FTP_PORT = 8021;
public static final int DEFAULT_MAX_MEMORY_ROWS = 10000; public static final int DEFAULT_MAX_MEMORY_ROWS = 10000;
public static final int DEFAULT_WRITE_DELAY = 500; public static final int DEFAULT_WRITE_DELAY = 500;
public static final String SERVER_PROPERTIES_TITLE = "H2 Server Properties"; public static final String SERVER_PROPERTIES_TITLE = "H2 Server Properties";
public static final String SERVER_PROPERTIES_FILE = ".h2.server.properties"; public static final String SERVER_PROPERTIES_FILE = ".h2.server.properties";
public static final long LONG_QUERY_LIMIT_MS = 100; public static final long LONG_QUERY_LIMIT_MS = 100;
public static final String PUBLIC_ROLE_NAME = "PUBLIC"; public static final String PUBLIC_ROLE_NAME = "PUBLIC";
public static final String TEMP_TABLE_PREFIX = "TEMP_TABLE_"; public static final String TEMP_TABLE_PREFIX = "TEMP_TABLE_";
public static final int BIG_DECIMAL_SCALE_MAX = 100000; public static final int BIG_DECIMAL_SCALE_MAX = 100000;
public static final String SCHEMA_MAIN = "PUBLIC"; public static final String SCHEMA_MAIN = "PUBLIC";
public static final String SCHEMA_INFORMATION = "INFORMATION_SCHEMA"; public static final String SCHEMA_INFORMATION = "INFORMATION_SCHEMA";
public static final String DBA_NAME = "DBA"; public static final String DBA_NAME = "DBA";
public static final String CHARACTER_SET_NAME = "Unicode"; public static final String CHARACTER_SET_NAME = "Unicode";
public static final String CLUSTERING_DISABLED = "''"; public static final String CLUSTERING_DISABLED = "''";
public static final int LOCK_MODE_OFF = 0; public static final int LOCK_MODE_OFF = 0;
public static final int LOCK_MODE_TABLE = 1; public static final int LOCK_MODE_TABLE = 1;
public static final int LOCK_MODE_TABLE_GC = 2; public static final int LOCK_MODE_TABLE_GC = 2;
public static final int LOCK_MODE_READ_COMMITTED = 3; public static final int LOCK_MODE_READ_COMMITTED = 3;
public static final int SELECTIVITY_DISTINCT_COUNT = 10000; public static final int SELECTIVITY_DISTINCT_COUNT = 10000;
public static final int SELECTIVITY_DEFAULT = 50; public static final int SELECTIVITY_DEFAULT = 50;
public static final int SELECTIVITY_ANALYZE_SAMPLE_ROWS = 10000; public static final int SELECTIVITY_ANALYZE_SAMPLE_ROWS = 10000;
...@@ -177,52 +149,44 @@ public class Constants { ...@@ -177,52 +149,44 @@ public class Constants {
public static final int COST_ROW_OFFSET = 1000; public static final int COST_ROW_OFFSET = 1000;
public static final long FLUSH_INDEX_DELAY = 0; public static final long FLUSH_INDEX_DELAY = 0;
public static final int THROTTLE_DELAY = 50; public static final int THROTTLE_DELAY = 50;
public static final String MANAGEMENT_DB_PREFIX = "management_db_"; public static final String MANAGEMENT_DB_PREFIX = "management_db_";
public static final String MANAGEMENT_DB_USER = "sa"; public static final String MANAGEMENT_DB_USER = "sa";
public static final boolean SERIALIZE_JAVA_OBJECTS = true; public static final boolean SERIALIZE_JAVA_OBJECTS = true;
public static final long DEFAULT_MAX_LOG_SIZE = 32 * 1024 * 1024; public static final long DEFAULT_MAX_LOG_SIZE = 32 * 1024 * 1024;
public static final long LOG_SIZE_DIVIDER = 10; public static final long LOG_SIZE_DIVIDER = 10;
public static final int ALLOW_LITERALS_NONE = 0; public static final int ALLOW_LITERALS_NONE = 0;
public static final int ALLOW_LITERALS_NUMBERS = 1; public static final int ALLOW_LITERALS_NUMBERS = 1;
public static final int ALLOW_LITERALS_ALL = 2; public static final int ALLOW_LITERALS_ALL = 2;
public static final int DEFAULT_ALLOW_LITERALS = ALLOW_LITERALS_ALL; public static final int DEFAULT_ALLOW_LITERALS = ALLOW_LITERALS_ALL;
public static final boolean AUTO_CONVERT_LOB_TO_FILES = true; public static final boolean AUTO_CONVERT_LOB_TO_FILES = true;
public static final boolean ALLOW_EMPTY_BTREE_PAGES = true; public static final boolean ALLOW_EMPTY_BTREE_PAGES = true;
public static final String CONN_URL_INTERNAL = "jdbc:default:connection"; public static final String CONN_URL_INTERNAL = "jdbc:default:connection";
public static final String CONN_URL_COLUMNLIST = "jdbc:columnlist:connection"; public static final String CONN_URL_COLUMNLIST = "jdbc:columnlist:connection";
public static final int VIEW_INDEX_CACHE_SIZE = 64; public static final int VIEW_INDEX_CACHE_SIZE = 64;
public static final int VIEW_COST_CACHE_MAX_AGE = 10000; // 10 seconds public static final int VIEW_COST_CACHE_MAX_AGE = 10000; // 10 seconds
public static final int MAX_PARAMETER_INDEX = 100000; public static final int MAX_PARAMETER_INDEX = 100000;
public static boolean runFinalize = getBooleanSetting("h2.runFinalize", true);
public static String scriptDirectory = getStringSetting("h2.scriptDirectory", "");
private static String baseDir = getStringSetting("h2.baseDir", null);
public static boolean multiThreadedKernel = getBooleanSetting("h2.multiThreadedKernel", false);
public static boolean lobCloseBetweenReads = getBooleanSetting("h2.lobCloseBetweenReads", false);
// TODO: also remove DataHandler.allocateObjectId, createTempFile when setting this to true and removing it
public static final boolean LOB_FILES_IN_DIRECTORIES = getBooleanSetting("h2.lobFilesInDirectories", false);
public static final int LOB_FILES_PER_DIRECTORY = getIntSetting("h2.lobFilesPerDirectory", 256);
// TODO need to refactor & test the code to enable this (add more tests!) // TODO need to refactor & test the code to enable this (add more tests!)
public static final boolean OPTIMIZE_EVALUATABLE_SUBQUERIES = false; public static final boolean OPTIMIZE_EVALUATABLE_SUBQUERIES = false;
// to slow down dictionary attacks // to slow down dictionary attacks
public static final int ENCRYPTION_KEY_HASH_ITERATIONS = 1024; public static final int ENCRYPTION_KEY_HASH_ITERATIONS = 1024;
public static final String SCRIPT_SQL = "script.sql"; public static final String SCRIPT_SQL = "script.sql";
// for testing only
public static final int CACHE_MIN_RECORDS = 16; public static final int CACHE_MIN_RECORDS = 16;
public static final int MIN_WRITE_DELAY = getIntSetting("h2.minWriteDelay", 5); public static final int MIN_WRITE_DELAY = getIntSetting("h2.minWriteDelay", 5);
public static final boolean CHECK2 = getBooleanSetting("h2.check2", false); public static final boolean CHECK2 = getBooleanSetting("h2.check2", false);
// TODO: also remove DataHandler.allocateObjectId, createTempFile when setting this to true and removing it
public static final boolean LOB_FILES_IN_DIRECTORIES = getBooleanSetting("h2.lobFilesInDirectories", false);
public static final int LOB_FILES_PER_DIRECTORY = getIntSetting("h2.lobFilesPerDirectory", 256);
public static final boolean CHECK = getBooleanSetting("h2.check", true); public static final boolean CHECK = getBooleanSetting("h2.check", true);
public static boolean MULTI_THREADED_KERNEL = getBooleanSetting("h2.multiThreadedKernel", false);
public static boolean RUN_FINALIZE = getBooleanSetting("h2.runFinalize", true);
public static String SCRIPT_DIRECTORY = getStringSetting("h2.scriptDirectory", "");
public static final boolean OPTIMIZE_MIN_MAX = getBooleanSetting("h2.optimizeMinMax", true); public static final boolean OPTIMIZE_MIN_MAX = getBooleanSetting("h2.optimizeMinMax", true);
public static final boolean OPTIMIZE_IN = getBooleanSetting("h2.optimizeIn", true); public static final boolean OPTIMIZE_IN = getBooleanSetting("h2.optimizeIn", true);
public static final int REDO_BUFFER_SIZE = getIntSetting("h2.redoBufferSize", 256 * 1024); public static final int REDO_BUFFER_SIZE = getIntSetting("h2.redoBufferSize", 256 * 1024);
...@@ -239,8 +203,7 @@ public class Constants { ...@@ -239,8 +203,7 @@ public class Constants {
public static final int OBJECT_CACHE_SIZE = getIntSetting("h2.objectCacheSize", 1024); public static final int OBJECT_CACHE_SIZE = getIntSetting("h2.objectCacheSize", 1024);
public static final int OBJECT_CACHE_MAX_PER_ELEMENT_SIZE = getIntSetting("h2.objectCacheMaxPerElementSize", 4096); public static final int OBJECT_CACHE_MAX_PER_ELEMENT_SIZE = getIntSetting("h2.objectCacheMaxPerElementSize", 4096);
public static final String CLIENT_TRACE_DIRECTORY = getStringSetting("h2.clientTraceDirectory", "trace.db/"); public static final String CLIENT_TRACE_DIRECTORY = getStringSetting("h2.clientTraceDirectory", "trace.db/");
public static int MAX_FILE_RETRY = Math.max(1, getIntSetting("h2.maxFileRetry", 16)); public static final int MAX_FILE_RETRY = Math.max(1, getIntSetting("h2.maxFileRetry", 16));
public static boolean LOB_CLOSE_BETWEEN_READS = getBooleanSetting("h2.lobCloseBetweenReads", false);
public static final boolean ALLOW_BIG_DECIMAL_EXTENSIONS = getBooleanSetting("h2.allowBigDecimalExtensions", false); public static final boolean ALLOW_BIG_DECIMAL_EXTENSIONS = getBooleanSetting("h2.allowBigDecimalExtensions", false);
public static final boolean INDEX_LOOKUP_NEW = getBooleanSetting("h2.indexLookupNew", true); public static final boolean INDEX_LOOKUP_NEW = getBooleanSetting("h2.indexLookupNew", true);
public static final boolean TRACE_IO = getBooleanSetting("h2.traceIO", false); public static final boolean TRACE_IO = getBooleanSetting("h2.traceIO", false);
...@@ -248,7 +211,6 @@ public class Constants { ...@@ -248,7 +211,6 @@ public class Constants {
public static final int CACHE_SIZE_DEFAULT = getIntSetting("h2.cacheSizeDefault", 16 * 1024); public static final int CACHE_SIZE_DEFAULT = getIntSetting("h2.cacheSizeDefault", 16 * 1024);
public static final int CACHE_SIZE_INDEX_SHIFT = getIntSetting("h2.cacheSizeIndexShift", 3); public static final int CACHE_SIZE_INDEX_SHIFT = getIntSetting("h2.cacheSizeIndexShift", 3);
public static final int CACHE_SIZE_INDEX_DEFAULT = CACHE_SIZE_DEFAULT >> CACHE_SIZE_INDEX_SHIFT; public static final int CACHE_SIZE_INDEX_DEFAULT = CACHE_SIZE_DEFAULT >> CACHE_SIZE_INDEX_SHIFT;
public static String BASE_DIR = getStringSetting("h2.baseDir", null);
public static final int DEFAULT_MAX_MEMORY_UNDO = getIntSetting("h2.defaultMaxMemoryUndo", 50000); public static final int DEFAULT_MAX_MEMORY_UNDO = getIntSetting("h2.defaultMaxMemoryUndo", 50000);
public static final boolean OPTIMIZE_NOT = getBooleanSetting("h2.optimizeNot", true); public static final boolean OPTIMIZE_NOT = getBooleanSetting("h2.optimizeNot", true);
public static final boolean OPTIMIZE_2_EQUALS = getBooleanSetting("h2.optimizeTwoEquals", true); public static final boolean OPTIMIZE_2_EQUALS = getBooleanSetting("h2.optimizeTwoEquals", true);
...@@ -257,7 +219,11 @@ public class Constants { ...@@ -257,7 +219,11 @@ public class Constants {
if(!dir.endsWith("/")) { if(!dir.endsWith("/")) {
dir += "/"; dir += "/";
} }
BASE_DIR = dir; baseDir = dir;
}
public static String getBaseDir() {
return baseDir;
} }
public static boolean getBooleanSetting(String name, boolean defaultValue) { public static boolean getBooleanSetting(String name, boolean defaultValue) {
......
...@@ -164,7 +164,7 @@ public class Database implements DataHandler { ...@@ -164,7 +164,7 @@ public class Database implements DataHandler {
} }
String log = ci.getProperty(SetTypes.LOG, null); String log = ci.getProperty(SetTypes.LOG, null);
if(log != null) { if(log != null) {
this.logIndexChanges = log.equals("2"); this.logIndexChanges = "2".equals(log);
} }
String ignoreSummary = ci.getProperty("RECOVER", null); String ignoreSummary = ci.getProperty("RECOVER", null);
if(ignoreSummary != null) { if(ignoreSummary != null) {
......
...@@ -102,7 +102,7 @@ public class Session implements SessionInterface { ...@@ -102,7 +102,7 @@ public class Session implements SessionInterface {
} }
protected void finalize() { protected void finalize() {
if(!Constants.RUN_FINALIZE) { if(!Constants.runFinalize) {
return; return;
} }
if(database != null) { if(database != null) {
......
...@@ -276,12 +276,4 @@ public class BtreeLeaf extends BtreePage { ...@@ -276,12 +276,4 @@ public class BtreeLeaf extends BtreePage {
return (SearchRow)pageData.get(0); return (SearchRow)pageData.get(0);
} }
public String print(String indent) throws SQLException {
System.out.println(indent + "leaf:");
for(int i=0; i<pageData.size(); i++) {
System.out.println(indent + " " + getData(i).getValue(1).getString().substring(4150));
}
return getData(0).getValue(1).getString().substring(4150);
}
} }
...@@ -353,25 +353,4 @@ public class BtreeNode extends BtreePage { ...@@ -353,25 +353,4 @@ public class BtreeNode extends BtreePage {
return null; return null;
} }
public String print(String indent) throws SQLException {
System.out.println(indent + "node");
String first = null;
String last = null;
for(int i=0; i<pageChildren.size(); i++) {
String firstNow = index.getPage(pageChildren.get(i)).print(indent + " ");
if(first == null) {
first = firstNow;
}
if(last != null && !last.equals(firstNow)) {
System.out.println("STOP!!! " + last + " firstNow:" + firstNow);
}
if(i<pageData.size()) {
String now = getData(i).getValue(1).getString().substring(4150);
System.out.println(indent + " " + now);
last = now;
}
}
return first;
}
} }
...@@ -86,5 +86,4 @@ public abstract class BtreePage extends Record { ...@@ -86,5 +86,4 @@ public abstract class BtreePage extends Record {
return root; return root;
} }
public abstract String print(String indent) throws SQLException;
} }
...@@ -921,7 +921,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -921,7 +921,7 @@ public class JdbcConnection extends TraceObject implements Connection {
session = new SessionRemote().createSession(ci); session = new SessionRemote().createSession(ci);
} else { } else {
SessionInterface si = (SessionInterface) ClassUtils.loadClass("org.h2.engine.Session").newInstance(); SessionInterface si = (SessionInterface) ClassUtils.loadClass("org.h2.engine.Session").newInstance();
String baseDir = Constants.BASE_DIR; String baseDir = Constants.getBaseDir();
if(baseDir != null) { if(baseDir != null) {
ci.setBaseDir(baseDir); ci.setBaseDir(baseDir);
} }
...@@ -1184,7 +1184,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -1184,7 +1184,7 @@ public class JdbcConnection extends TraceObject implements Connection {
} }
protected void finalize() { protected void finalize() {
if(!Constants.RUN_FINALIZE) { if(!Constants.runFinalize) {
return; return;
} }
if(isInternal) { if(isInternal) {
......
...@@ -238,7 +238,7 @@ public class TraceSystem { ...@@ -238,7 +238,7 @@ public class TraceSystem {
} }
protected void finalize() { protected void finalize() {
if(!Constants.RUN_FINALIZE) { if(!Constants.runFinalize) {
return; return;
} }
close(); close();
......
...@@ -158,7 +158,7 @@ class ResultDiskBuffer { ...@@ -158,7 +158,7 @@ class ResultDiskBuffer {
} }
protected void finalize() { protected void finalize() {
if(!Constants.RUN_FINALIZE) { if(!Constants.runFinalize) {
return; return;
} }
close(); close();
......
...@@ -29,7 +29,7 @@ public class TcpServer implements Service { ...@@ -29,7 +29,7 @@ public class TcpServer implements Service {
public static final int DEFAULT_PORT = 9092; public static final int DEFAULT_PORT = 9092;
public static final int SHUTDOWN_NORMAL = 0; public static final int SHUTDOWN_NORMAL = 0;
public static final int SHUTDOWN_FORCE = 1; public static final int SHUTDOWN_FORCE = 1;
public static boolean LOG_INTERNAL_ERRORS; public static boolean logInternalErrors;
private int port; private int port;
private boolean log; private boolean log;
...@@ -80,19 +80,19 @@ public class TcpServer implements Service { ...@@ -80,19 +80,19 @@ public class TcpServer implements Service {
port = DEFAULT_PORT; port = DEFAULT_PORT;
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
String a = args[i]; String a = args[i];
if (a.equals("-log")) { if ("-log".equals(a)) {
log = Boolean.valueOf(args[++i]).booleanValue(); log = Boolean.valueOf(args[++i]).booleanValue();
} else if (a.equals("-tcpSSL")) { } else if ("-tcpSSL".equals(a)) {
ssl = Boolean.valueOf(args[++i]).booleanValue(); ssl = Boolean.valueOf(args[++i]).booleanValue();
} else if (a.equals("-tcpPort")) { } else if ("-tcpPort".equals(a)) {
port = MathUtils.decodeInt(args[++i]); port = MathUtils.decodeInt(args[++i]);
} else if (a.equals("-tcpPassword")) { } else if ("-tcpPassword".equals(a)) {
managementPassword= args[++i]; managementPassword= args[++i];
} else if (a.equals("-baseDir")) { } else if ("-baseDir".equals(a)) {
baseDir = args[++i]; baseDir = args[++i];
} else if (a.equals("-tcpAllowOthers")) { } else if ("-tcpAllowOthers".equals(a)) {
allowOthers = Boolean.valueOf(args[++i]).booleanValue(); allowOthers = Boolean.valueOf(args[++i]).booleanValue();
} else if (a.equals("-ifExists")) { } else if ("-ifExists".equals(a)) {
ifExists = Boolean.valueOf(args[++i]).booleanValue(); ifExists = Boolean.valueOf(args[++i]).booleanValue();
} }
} }
...@@ -243,7 +243,7 @@ public class TcpServer implements Service { ...@@ -243,7 +243,7 @@ public class TcpServer implements Service {
} }
public void logInternalError(String string) { public void logInternalError(String string) {
if(TcpServer.LOG_INTERNAL_ERRORS) { if(TcpServer.logInternalErrors) {
System.out.println(string); System.out.println(string);
new Error(string).printStackTrace(); new Error(string).printStackTrace();
} }
......
...@@ -59,7 +59,7 @@ public class TcpServerThread implements Runnable { ...@@ -59,7 +59,7 @@ public class TcpServerThread implements Runnable {
String originalURL = transfer.readString(); String originalURL = transfer.readString();
String baseDir = server.getBaseDir(); String baseDir = server.getBaseDir();
if(baseDir == null) { if(baseDir == null) {
baseDir = Constants.BASE_DIR; baseDir = Constants.getBaseDir();
} }
ConnectionInfo ci = new ConnectionInfo(db); ConnectionInfo ci = new ConnectionInfo(db);
if(baseDir != null) { if(baseDir != null) {
......
...@@ -42,15 +42,15 @@ public class PgServer implements Service { ...@@ -42,15 +42,15 @@ public class PgServer implements Service {
port = DEFAULT_PORT; port = DEFAULT_PORT;
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
String a = args[i]; String a = args[i];
if (a.equals("-log")) { if ("-log".equals(a)) {
log = Boolean.valueOf(args[++i]).booleanValue(); log = Boolean.valueOf(args[++i]).booleanValue();
} else if (a.equals("-pgPort")) { } else if ("-pgPort".equals(a)) {
port = MathUtils.decodeInt(args[++i]); port = MathUtils.decodeInt(args[++i]);
} else if (a.equals("-baseDir")) { } else if ("-baseDir".equals(a)) {
baseDir = args[++i]; baseDir = args[++i];
} else if (a.equals("-pgAllowOthers")) { } else if ("-pgAllowOthers".equals(a)) {
allowOthers = Boolean.valueOf(args[++i]).booleanValue(); allowOthers = Boolean.valueOf(args[++i]).booleanValue();
} else if (a.equals("-ifExists")) { } else if ("-ifExists".equals(a)) {
ifExists = Boolean.valueOf(args[++i]).booleanValue(); ifExists = Boolean.valueOf(args[++i]).booleanValue();
} }
} }
......
...@@ -30,6 +30,7 @@ import java.util.Properties; ...@@ -30,6 +30,7 @@ import java.util.Properties;
import org.h2.Driver; import org.h2.Driver;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.ObjectUtils;
import org.h2.util.ScriptReader; import org.h2.util.ScriptReader;
/** /**
...@@ -362,7 +363,7 @@ public class PgServerThread implements Runnable { ...@@ -362,7 +363,7 @@ public class PgServerThread implements Runnable {
} }
private void checkType(int type) { private void checkType(int type) {
if(types.contains(new Integer(type))) { if(types.contains(ObjectUtils.getInteger(type))) {
error("Unsupported type: " + type, null); error("Unsupported type: " + type, null);
} }
} }
...@@ -431,7 +432,7 @@ public class PgServerThread implements Runnable { ...@@ -431,7 +432,7 @@ public class PgServerThread implements Runnable {
} }
private String getEncoding() { private String getEncoding() {
if(clientEncoding.equals("UNICODE")) { if("UNICODE".equals(clientEncoding)) {
return "UTF-8"; return "UTF-8";
} }
return clientEncoding; return clientEncoding;
...@@ -593,7 +594,7 @@ public class PgServerThread implements Runnable { ...@@ -593,7 +594,7 @@ public class PgServerThread implements Runnable {
rs = stat.executeQuery("SELECT OID FROM PG_CATALOG.PG_TYPE"); rs = stat.executeQuery("SELECT OID FROM PG_CATALOG.PG_TYPE");
while(rs.next()) { while(rs.next()) {
types.add(new Integer(rs.getInt(1))); types.add(ObjectUtils.getInteger(rs.getInt(1)));
} }
} }
......
...@@ -23,7 +23,7 @@ public class DbContextRule implements Rule { ...@@ -23,7 +23,7 @@ public class DbContextRule implements Rule {
static final int COLUMN = 0, TABLE = 1, TABLE_ALIAS = 2; static final int COLUMN = 0, TABLE = 1, TABLE_ALIAS = 2;
public static final int NEW_TABLE_ALIAS = 3; public static final int NEW_TABLE_ALIAS = 3;
public static final int COLUMN_ALIAS = 4; public static final int COLUMN_ALIAS = 4;
private static boolean SUGGEST_TABLE_ALIAS; private static final boolean SUGGEST_TABLE_ALIAS = false;
DbContextRule(DbContents contents, int type) { DbContextRule(DbContents contents, int type) {
this.contents = contents; this.contents = contents;
......
...@@ -85,25 +85,25 @@ class WebThread extends Thread { ...@@ -85,25 +85,25 @@ class WebThread extends Thread {
} else { } else {
suffix = ""; suffix = "";
} }
if(suffix.equals("ico")) { if("ico".equals(suffix)) {
mimeType = "image/x-icon"; mimeType = "image/x-icon";
cache=true; cache=true;
} else if(suffix.equals("gif")) { } else if("gif".equals(suffix)) {
mimeType = "image/gif"; mimeType = "image/gif";
cache=true; cache=true;
} else if(suffix.equals("css")) { } else if("css".equals(suffix)) {
cache=true; cache=true;
mimeType = "text/css"; mimeType = "text/css";
} else if(suffix.equals("html") || suffix.equals("do") || suffix.equals("jsp")) { } else if("html".equals(suffix) || "do".equals(suffix) || "jsp".equals(suffix)) {
cache=false; cache=false;
mimeType = "text/html"; mimeType = "text/html";
if (session == null) { if (session == null) {
session = server.createNewSession(hostname); session = server.createNewSession(hostname);
if (!file.equals("notAllowed.jsp")) { if (!"notAllowed.jsp".equals(file)) {
file = "index.do"; file = "index.do";
} }
} }
} else if(suffix.equals("js")) { } else if("js".equals(suffix)) {
cache=true; cache=true;
mimeType = "text/javascript"; mimeType = "text/javascript";
} else { } else {
...@@ -329,33 +329,33 @@ class WebThread extends Thread { ...@@ -329,33 +329,33 @@ class WebThread extends Thread {
String process(String file) { String process(String file) {
server.trace("process " + file); server.trace("process " + file);
while(file.endsWith(".do")) { while(file.endsWith(".do")) {
if(file.equals("login.do")) { if("login.do".equals(file)) {
file = login(); file = login();
} else if(file.equals("index.do")) { } else if("index.do".equals(file)) {
file = index(); file = index();
} else if(file.equals("logout.do")) { } else if("logout.do".equals(file)) {
file = logout(); file = logout();
} else if(file.equals("settingRemove.do")) { } else if("settingRemove.do".equals(file)) {
file = settingRemove(); file = settingRemove();
} else if(file.equals("settingSave.do")) { } else if("settingSave.do".equals(file)) {
file = settingSave(); file = settingSave();
} else if(file.equals("test.do")) { } else if("test.do".equals(file)) {
file = test(); file = test();
} else if(file.equals("query.do")) { } else if("query.do".equals(file)) {
file = query(); file = query();
} else if(file.equals("tables.do")) { } else if("tables.do".equals(file)) {
file = tables(); file = tables();
} else if(file.equals("editResult.do")) { } else if("editResult.do".equals(file)) {
file = editResult(); file = editResult();
} else if(file.equals("getHistory.do")) { } else if("getHistory.do".equals(file)) {
file = getHistory(); file = getHistory();
} else if(file.equals("admin.do")) { } else if("admin.do".equals(file)) {
file = admin(); file = admin();
} else if(file.equals("adminSave.do")) { } else if("adminSave.do".equals(file)) {
file = adminSave(); file = adminSave();
} else if(file.equals("adminShutdown.do")) { } else if("adminShutdown.do".equals(file)) {
file = adminShutdown(); file = adminShutdown();
} else if(file.equals("autoCompleteList.do")) { } else if("autoCompleteList.do".equals(file)) {
file = autoCompleteList(); file = autoCompleteList();
} else { } else {
file = "error.jsp"; file = "error.jsp";
...@@ -425,7 +425,7 @@ class WebThread extends Thread { ...@@ -425,7 +425,7 @@ class WebThread extends Thread {
key = StringUtils.toLowerEnglish(key); key = StringUtils.toLowerEnglish(key);
value = StringUtils.toLowerEnglish(value); value = StringUtils.toLowerEnglish(value);
} }
if(key.equals(value) && !value.equals(".")) { if(key.equals(value) && !".".equals(value)) {
value = space + value; value = space + value;
} }
key = StringUtils.urlEncode(key); key = StringUtils.urlEncode(key);
...@@ -717,7 +717,7 @@ class WebThread extends Thread { ...@@ -717,7 +717,7 @@ class WebThread extends Thread {
treeIndex++; treeIndex++;
buff.append("setNode("+treeIndex+", 2, 2, 'type', '${text.tree.current}: " + PageParser.escapeJavaScript(current)+ "', null);\n"); buff.append("setNode("+treeIndex+", 2, 2, 'type', '${text.tree.current}: " + PageParser.escapeJavaScript(current)+ "', null);\n");
treeIndex++; treeIndex++;
if(!increment.equals("1")) { if(!"1".equals(increment)) {
buff.append("setNode("+treeIndex+", 2, 2, 'type', '${text.tree.increment}: " + PageParser.escapeJavaScript(increment)+ "', null);\n"); buff.append("setNode("+treeIndex+", 2, 2, 'type', '${text.tree.increment}: " + PageParser.escapeJavaScript(increment)+ "', null);\n");
treeIndex++; treeIndex++;
} }
...@@ -841,10 +841,10 @@ class WebThread extends Thread { ...@@ -841,10 +841,10 @@ class WebThread extends Thread {
try { try {
Connection conn = session.getConnection(); Connection conn = session.getConnection();
String result; String result;
if(sql.equals("@AUTOCOMMIT TRUE")) { if("@AUTOCOMMIT TRUE".equals(sql)) {
conn.setAutoCommit(true); conn.setAutoCommit(true);
result = "${text.result.autoCommitOn}"; result = "${text.result.autoCommitOn}";
} else if(sql.equals("@AUTOCOMMIT FALSE")) { } else if("@AUTOCOMMIT FALSE".equals(sql)) {
conn.setAutoCommit(false); conn.setAutoCommit(false);
result = "${text.result.autoCommitOff}"; result = "${text.result.autoCommitOff}";
} else if(sql.startsWith("@TRANSACTION_ISOLATION")) { } else if(sql.startsWith("@TRANSACTION_ISOLATION")) {
...@@ -1175,7 +1175,7 @@ class WebThread extends Thread { ...@@ -1175,7 +1175,7 @@ class WebThread extends Thread {
boolean metadata = false; boolean metadata = false;
boolean generatedKeys = false; boolean generatedKeys = false;
boolean edit = false; boolean edit = false;
if(sql.equals("@CANCEL")) { if("@CANCEL".equals(sql)) {
stat = session.executingStatement; stat = session.executingStatement;
if(stat != null) { if(stat != null) {
stat.cancel(); stat.cancel();
...@@ -1201,7 +1201,7 @@ class WebThread extends Thread { ...@@ -1201,7 +1201,7 @@ class WebThread extends Thread {
edit = true; edit = true;
sql = sql.substring("@EDIT".length()).trim(); sql = sql.substring("@EDIT".length()).trim();
session.put("resultSetSQL", sql); session.put("resultSetSQL", sql);
} else if(sql.equals("@HISTORY")) { } else if("@HISTORY".equals(sql)) {
buff.append(getHistoryString()); buff.append(getHistoryString());
return buff.toString(); return buff.toString();
} }
......
...@@ -67,7 +67,7 @@ public class FileLock { ...@@ -67,7 +67,7 @@ public class FileLock {
} }
protected void finalize() { protected void finalize() {
if (!Constants.RUN_FINALIZE) { if (!Constants.runFinalize) {
return; return;
} }
if(locked) { if(locked) {
......
...@@ -140,7 +140,7 @@ public class FileStoreInputStream extends InputStream { ...@@ -140,7 +140,7 @@ public class FileStoreInputStream extends InputStream {
} }
protected void finalize() { protected void finalize() {
if (!Constants.RUN_FINALIZE) { if (!Constants.runFinalize) {
return; return;
} }
try { try {
......
...@@ -224,7 +224,7 @@ public class Column { ...@@ -224,7 +224,7 @@ public class Column {
if(!autoIncrement) { if(!autoIncrement) {
throw Message.getInternalError(); throw Message.getInternalError();
} }
if(originalSQL.equals("IDENTITY")) { if("IDENTITY".equals(originalSQL)) {
originalSQL = "BIGINT"; originalSQL = "BIGINT";
} }
String sequenceName; String sequenceName;
......
...@@ -695,8 +695,8 @@ public class MetaTable extends Table { ...@@ -695,8 +695,8 @@ public class MetaTable extends Table {
add(rows, new String[]{"h2.check2", "" + Constants.CHECK2}); add(rows, new String[]{"h2.check2", "" + Constants.CHECK2});
add(rows, new String[]{"h2.lobFilesInDirectories", "" + Constants.LOB_FILES_IN_DIRECTORIES}); add(rows, new String[]{"h2.lobFilesInDirectories", "" + Constants.LOB_FILES_IN_DIRECTORIES});
add(rows, new String[]{"h2.lobFilesPerDirectory", "" + Constants.LOB_FILES_PER_DIRECTORY}); add(rows, new String[]{"h2.lobFilesPerDirectory", "" + Constants.LOB_FILES_PER_DIRECTORY});
add(rows, new String[]{"h2.multiThreadedKernel", "" + Constants.MULTI_THREADED_KERNEL}); add(rows, new String[]{"h2.multiThreadedKernel", "" + Constants.multiThreadedKernel});
add(rows, new String[]{"h2.runFinalize", "" + Constants.RUN_FINALIZE}); add(rows, new String[]{"h2.runFinalize", "" + Constants.runFinalize});
add(rows, new String[]{"h2.optimizeMinMax", "" + Constants.OPTIMIZE_MIN_MAX}); add(rows, new String[]{"h2.optimizeMinMax", "" + Constants.OPTIMIZE_MIN_MAX});
add(rows, new String[]{"h2.optimizeIn", "" + Constants.OPTIMIZE_IN}); add(rows, new String[]{"h2.optimizeIn", "" + Constants.OPTIMIZE_IN});
add(rows, new String[]{"h2.redoBufferSize", "" + Constants.REDO_BUFFER_SIZE}); add(rows, new String[]{"h2.redoBufferSize", "" + Constants.REDO_BUFFER_SIZE});
...@@ -713,11 +713,11 @@ public class MetaTable extends Table { ...@@ -713,11 +713,11 @@ public class MetaTable extends Table {
add(rows, new String[]{"h2.objectCacheSize", "" + Constants.OBJECT_CACHE_SIZE}); add(rows, new String[]{"h2.objectCacheSize", "" + Constants.OBJECT_CACHE_SIZE});
add(rows, new String[]{"h2.objectCacheMaxPerElementSize", "" + Constants.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE}); add(rows, new String[]{"h2.objectCacheMaxPerElementSize", "" + Constants.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE});
add(rows, new String[]{"h2.clientTraceDirectory", Constants.CLIENT_TRACE_DIRECTORY}); add(rows, new String[]{"h2.clientTraceDirectory", Constants.CLIENT_TRACE_DIRECTORY});
add(rows, new String[]{"h2.scriptDirectory", Constants.SCRIPT_DIRECTORY}); add(rows, new String[]{"h2.scriptDirectory", Constants.scriptDirectory});
add(rows, new String[]{"h2.maxFileRetry", "" + Constants.MAX_FILE_RETRY}); add(rows, new String[]{"h2.maxFileRetry", "" + Constants.MAX_FILE_RETRY});
add(rows, new String[]{"h2.lobCloseBetweenReads", "" + Constants.LOB_CLOSE_BETWEEN_READS}); add(rows, new String[]{"h2.lobCloseBetweenReads", "" + Constants.lobCloseBetweenReads});
add(rows, new String[]{"h2.allowBigDecimalExtensions", "" + Constants.ALLOW_BIG_DECIMAL_EXTENSIONS}); add(rows, new String[]{"h2.allowBigDecimalExtensions", "" + Constants.ALLOW_BIG_DECIMAL_EXTENSIONS});
add(rows, new String[]{"h2.baseDir", "" + Constants.BASE_DIR}); add(rows, new String[]{"h2.baseDir", "" + Constants.getBaseDir()});
add(rows, new String[]{"h2.defaultMaxMemoryUndo", "" + Constants.DEFAULT_MAX_MEMORY_UNDO}); add(rows, new String[]{"h2.defaultMaxMemoryUndo", "" + Constants.DEFAULT_MAX_MEMORY_UNDO});
break; break;
} }
......
...@@ -297,7 +297,7 @@ public class TableData extends Table implements RecordReader { ...@@ -297,7 +297,7 @@ public class TableData extends Table implements RecordReader {
} }
} else { } else {
if (lockExclusive == null) { if (lockExclusive == null) {
if(lockMode == Constants.LOCK_MODE_READ_COMMITTED && !Constants.MULTI_THREADED_KERNEL) { if(lockMode == Constants.LOCK_MODE_READ_COMMITTED && !Constants.multiThreadedKernel) {
// READ_COMMITTED read locks are acquired but they are released immediately // READ_COMMITTED read locks are acquired but they are released immediately
// when allowing only one thread, no read locks are required // when allowing only one thread, no read locks are required
return; return;
......
...@@ -32,7 +32,7 @@ public class CompressTool { ...@@ -32,7 +32,7 @@ public class CompressTool {
private static CompressTool instance = new CompressTool(); private static CompressTool instance = new CompressTool();
private static byte[] buffer; private static byte[] buffer;
private static int MAX_BUFFER_SIZE = 64 * 1024 * 1024; private static final int MAX_BUFFER_SIZE = 64 * 1024 * 1024;
private static byte[] getBuffer(int min) { private static byte[] getBuffer(int min) {
if(min > MAX_BUFFER_SIZE) { if(min > MAX_BUFFER_SIZE) {
......
...@@ -74,7 +74,7 @@ public class Script { ...@@ -74,7 +74,7 @@ public class Script {
for(; i<args.length; i++) { for(; i<args.length; i++) {
String a = args[i]; String a = args[i];
String upper = StringUtils.toUpperEnglish(a); String upper = StringUtils.toUpperEnglish(a);
if(upper.startsWith("NO") || upper.equals("DROP")) { if(upper.startsWith("NO") || "DROP".equals(upper)) {
buff1.append(' '); buff1.append(' ');
buff1.append(args[i]); buff1.append(args[i]);
} else { } else {
......
...@@ -122,30 +122,30 @@ public class Server implements Runnable { ...@@ -122,30 +122,30 @@ public class Server implements Runnable {
boolean startDefaultServers = true; boolean startDefaultServers = true;
for(int i=0; args != null && i<args.length; i++) { for(int i=0; args != null && i<args.length; i++) {
String a = args[i]; String a = args[i];
if(a.equals("-?") || a.equals("-help")) { if("-?".equals(a) || "-help".equals(a)) {
showUsage(); showUsage();
return EXIT_ERROR; return EXIT_ERROR;
} else if(a.equals("-web")) { } else if("-web".equals(a)) {
startDefaultServers = false; startDefaultServers = false;
webStart = true; webStart = true;
} else if(a.equals("-tcp")) { } else if("-tcp".equals(a)) {
startDefaultServers = false; startDefaultServers = false;
tcpStart = true; tcpStart = true;
} else if(a.equals("-pg")) { } else if("-pg".equals(a)) {
startDefaultServers = false; startDefaultServers = false;
pgStart = true; pgStart = true;
} else if(a.equals("-ftp")) { } else if("-ftp".equals(a)) {
startDefaultServers = false; startDefaultServers = false;
ftpStart = true; ftpStart = true;
} else if(a.equals("-tcpShutdown")) { } else if("-tcpShutdown".equals(a)) {
startDefaultServers = false; startDefaultServers = false;
tcpShutdown = true; tcpShutdown = true;
tcpShutdownServer = args[++i]; tcpShutdownServer = args[++i];
} else if(a.equals("-tcpPassword")) { } else if("-tcpPassword".equals(a)) {
tcpPassword = args[++i]; tcpPassword = args[++i];
} else if(a.equals("-tcpShutdownForce")) { } else if("-tcpShutdownForce".equals(a)) {
tcpShutdownForce = true; tcpShutdownForce = true;
} else if(a.equals("-browser")) { } else if("-browser".equals(a)) {
startDefaultServers = false; startDefaultServers = false;
browserStart = true; browserStart = true;
} }
......
...@@ -31,7 +31,7 @@ public class FileUtils { ...@@ -31,7 +31,7 @@ public class FileUtils {
private static final String MEMORY_PREFIX = "inmemory:"; private static final String MEMORY_PREFIX = "inmemory:";
private static final String MEMORY_PREFIX_2 = "mem:"; private static final String MEMORY_PREFIX_2 = "mem:";
// TODO detection of 'case in sensitive filesystem' could maybe implemented using some other means // TODO detection of 'case in sensitive filesystem' could maybe implemented using some other means
private static final boolean isCaseInsensitiveFileSystem = (File.separatorChar == '\\'); private static final boolean IS_FILE_SYSTEM_CASE_INSENSITIVE = (File.separatorChar == '\\');
public static RandomAccessFile openRandomAccessFile(String fileName, String mode) throws IOException { public static RandomAccessFile openRandomAccessFile(String fileName, String mode) throws IOException {
fileName = translateFileName(fileName); fileName = translateFileName(fileName);
...@@ -82,7 +82,7 @@ public class FileUtils { ...@@ -82,7 +82,7 @@ public class FileUtils {
public static boolean fileStartsWith(String fileName, String prefix) { public static boolean fileStartsWith(String fileName, String prefix) {
fileName = translateFileName(fileName); fileName = translateFileName(fileName);
if(isCaseInsensitiveFileSystem) { if(IS_FILE_SYSTEM_CASE_INSENSITIVE) {
fileName = StringUtils.toUpperEnglish(fileName); fileName = StringUtils.toUpperEnglish(fileName);
prefix = StringUtils.toUpperEnglish(prefix); prefix = StringUtils.toUpperEnglish(prefix);
} }
......
...@@ -7,8 +7,8 @@ package org.h2.util; ...@@ -7,8 +7,8 @@ package org.h2.util;
public class MemoryUtils { public class MemoryUtils {
private static long lastGC; private static long lastGC;
private static int GC_DELAY = 50; private static final int GC_DELAY = 50;
private static int MAX_GC = 8; private static final int MAX_GC = 8;
public static int getMemoryUsed() { public static int getMemoryUsed() {
collectGarbage(); collectGarbage();
......
...@@ -10,7 +10,7 @@ public class ObjectUtils { ...@@ -10,7 +10,7 @@ public class ObjectUtils {
*/ */
//#endif //#endif
//#ifdef JDK14 //#ifdef JDK14
return new Integer(x); return new Integer(x); // NOPMD
//#endif //#endif
} }
...@@ -34,7 +34,7 @@ public class ObjectUtils { ...@@ -34,7 +34,7 @@ public class ObjectUtils {
*/ */
//#endif //#endif
//#ifdef JDK14 //#ifdef JDK14
return new Long(x); return new Long(x); // NOPMD
//#endif //#endif
} }
...@@ -46,7 +46,7 @@ public class ObjectUtils { ...@@ -46,7 +46,7 @@ public class ObjectUtils {
*/ */
//#endif //#endif
//#ifdef JDK14 //#ifdef JDK14
return new Short(x); return new Short(x); // NOPMD
//#endif //#endif
} }
...@@ -58,7 +58,7 @@ public class ObjectUtils { ...@@ -58,7 +58,7 @@ public class ObjectUtils {
*/ */
//#endif //#endif
//#ifdef JDK14 //#ifdef JDK14
return new Byte(x); return new Byte(x); // NOPMD
//#endif //#endif
} }
......
...@@ -96,7 +96,7 @@ public class StringCache { ...@@ -96,7 +96,7 @@ public class StringCache {
} }
} }
// create a new object that is not shared (to avoid out of memory if it is a substring of a big String) // create a new object that is not shared (to avoid out of memory if it is a substring of a big String)
s = new String(s); s = new String(s); // NOPMD
cache[index] = s; cache[index] = s;
return s; return s;
} }
......
...@@ -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;
public class ValueByte extends Value { public class ValueByte extends Value {
public static final int PRECISION = 3; public static final int PRECISION = 3;
...@@ -103,7 +104,7 @@ public class ValueByte extends Value { ...@@ -103,7 +104,7 @@ public class ValueByte extends Value {
} }
public Object getObject() { public Object getObject() {
return new Byte(value); return ObjectUtils.getByte(value);
} }
public void set(PreparedStatement prep, int parameterIndex) throws SQLException { public void set(PreparedStatement prep, int parameterIndex) throws SQLException {
......
...@@ -32,7 +32,7 @@ public class ValueDecimal extends Value { ...@@ -32,7 +32,7 @@ public class ValueDecimal extends Value {
private ValueDecimal(BigDecimal value) { private ValueDecimal(BigDecimal value) {
if (value == null) { if (value == null) {
throw new NullPointerException(); throw new IllegalArgumentException();
} else if(!Constants.ALLOW_BIG_DECIMAL_EXTENSIONS && !value.getClass().equals(BigDecimal.class)) { } else if(!Constants.ALLOW_BIG_DECIMAL_EXTENSIONS && !value.getClass().equals(BigDecimal.class)) {
SQLException e = Message.getSQLException(Message.INVALID_CLASS_2, new String[]{BigDecimal.class.getName(), value.getClass().getName()}, null); SQLException e = Message.getSQLException(Message.INVALID_CLASS_2, new String[]{BigDecimal.class.getName(), value.getClass().getName()}, null);
throw Message.convertToInternal(e); throw Message.convertToInternal(e);
......
...@@ -477,7 +477,7 @@ public class ValueLob extends Value { ...@@ -477,7 +477,7 @@ public class ValueLob extends Value {
return new ByteArrayInputStream(small); return new ByteArrayInputStream(small);
} }
FileStore store = handler.openFile(fileName, "r", true); FileStore store = handler.openFile(fileName, "r", true);
boolean alwaysClose = Constants.LOB_CLOSE_BETWEEN_READS; boolean alwaysClose = Constants.lobCloseBetweenReads;
return new BufferedInputStream(new FileStoreInputStream(store, handler, compression, alwaysClose), Constants.IO_BUFFER_SIZE); return new BufferedInputStream(new FileStoreInputStream(store, handler, compression, alwaysClose), Constants.IO_BUFFER_SIZE);
} }
......
...@@ -648,7 +648,7 @@ SELECT COUNT(*) AS A FROM TEST GROUP BY ID HAVING A>0; ...@@ -648,7 +648,7 @@ SELECT COUNT(*) AS A FROM TEST GROUP BY ID HAVING A>0;
public void beforeTest() throws SQLException { public void beforeTest() throws SQLException {
if(networked) { if(networked) {
TcpServer.LOG_INTERNAL_ERRORS = true; TcpServer.logInternalErrors = true;
String[] args = ssl ? new String[]{"-tcpSSL", "true"} : new String[0]; String[] args = ssl ? new String[]{"-tcpSSL", "true"} : new String[0];
server = Server.createTcpServer(args); server = Server.createTcpServer(args);
try { try {
......
...@@ -87,11 +87,11 @@ public class TestLob extends TestBase { ...@@ -87,11 +87,11 @@ public class TestLob extends TestBase {
conn.createStatement().execute("INSERT INTO TEST VALUES(1, SPACE(10000))"); conn.createStatement().execute("INSERT INTO TEST VALUES(1, SPACE(10000))");
ResultSet rs = conn.createStatement().executeQuery("SELECT DATA FROM TEST"); ResultSet rs = conn.createStatement().executeQuery("SELECT DATA FROM TEST");
rs.next(); rs.next();
Constants.LOB_CLOSE_BETWEEN_READS = true; Constants.lobCloseBetweenReads = true;
Reader in = rs.getCharacterStream(1); Reader in = rs.getCharacterStream(1);
in.read(); in.read();
conn.createStatement().execute("DELETE FROM TEST"); conn.createStatement().execute("DELETE FROM TEST");
Constants.LOB_CLOSE_BETWEEN_READS = false; Constants.lobCloseBetweenReads = false;
conn.createStatement().execute("INSERT INTO TEST VALUES(1, SPACE(10000))"); conn.createStatement().execute("INSERT INTO TEST VALUES(1, SPACE(10000))");
rs = conn.createStatement().executeQuery("SELECT DATA FROM TEST"); rs = conn.createStatement().executeQuery("SELECT DATA FROM TEST");
rs.next(); rs.next();
......
...@@ -95,7 +95,7 @@ public class TestPowerOff extends TestBase { ...@@ -95,7 +95,7 @@ public class TestPowerOff extends TestBase {
} }
deleteDb(dir, dbName); deleteDb(dir, dbName);
Random random = new Random(1); Random random = new Random(1);
Constants.RUN_FINALIZE = false; Constants.runFinalize = false;
int repeat = getSize(1, 20); int repeat = getSize(1, 20);
for(int i=0; i<repeat; i++) { for(int i=0; i<repeat; i++) {
Connection conn = getConnection(url); Connection conn = getConnection(url);
......
...@@ -44,7 +44,7 @@ public class TestManyJdbcObjects extends TestBase { ...@@ -44,7 +44,7 @@ public class TestManyJdbcObjects extends TestBase {
// SERVER_CACHED_OBJECTS = 500: connections = 40 // SERVER_CACHED_OBJECTS = 500: connections = 40
// SERVER_CACHED_OBJECTS = 50: connections = 120 // SERVER_CACHED_OBJECTS = 50: connections = 120
deleteDb("manyObjects"); deleteDb("manyObjects");
Constants.RUN_FINALIZE = false; Constants.runFinalize = false;
int connCount = getSize(4, 40); int connCount = getSize(4, 40);
Connection[] conn = new Connection[connCount]; Connection[] conn = new Connection[connCount];
for(int i=0; i<connCount; i++) { for(int i=0; i<connCount; i++) {
...@@ -62,12 +62,12 @@ public class TestManyJdbcObjects extends TestBase { ...@@ -62,12 +62,12 @@ public class TestManyJdbcObjects extends TestBase {
for(int i=0; i<connCount; i++) { for(int i=0; i<connCount; i++) {
conn[i].close(); conn[i].close();
} }
Constants.RUN_FINALIZE = true; Constants.runFinalize = true;
} }
private void testOneConnectionPrepare() throws Exception { private void testOneConnectionPrepare() throws Exception {
deleteDb("manyObjects"); deleteDb("manyObjects");
Constants.RUN_FINALIZE = false; Constants.runFinalize = false;
Connection conn = getConnection("manyObjects"); Connection conn = getConnection("manyObjects");
PreparedStatement prep; PreparedStatement prep;
Statement stat; Statement stat;
...@@ -98,7 +98,7 @@ public class TestManyJdbcObjects extends TestBase { ...@@ -98,7 +98,7 @@ public class TestManyJdbcObjects extends TestBase {
for(int i=0; i<size; i++) { for(int i=0; i<size; i++) {
prep.executeQuery(); prep.executeQuery();
} }
Constants.RUN_FINALIZE = true; Constants.runFinalize = true;
conn.close(); conn.close();
} }
......
...@@ -139,8 +139,8 @@ public class TestRandomSQL extends TestBase { ...@@ -139,8 +139,8 @@ public class TestRandomSQL extends TestBase {
} }
public void testCase(int i) throws Exception { public void testCase(int i) throws Exception {
String old = Constants.SCRIPT_DIRECTORY; String old = Constants.scriptDirectory;
Constants.SCRIPT_DIRECTORY = "dataScript/"; Constants.scriptDirectory = "dataScript/";
seed = i; seed = i;
printTime("TestRandomSQL " + seed); printTime("TestRandomSQL " + seed);
try { try {
...@@ -149,7 +149,7 @@ public class TestRandomSQL extends TestBase { ...@@ -149,7 +149,7 @@ public class TestRandomSQL extends TestBase {
processException("deleteDb", e); processException("deleteDb", e);
} }
testWithSeed(bnf); testWithSeed(bnf);
Constants.SCRIPT_DIRECTORY = old; Constants.scriptDirectory = old;
} }
public void test() throws Exception { public void test() throws Exception {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论