KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > engine > Constants


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.engine;
6
7 /*
8  * Coding rules:
9  * - boolean CHECK = x > boolean CHECK = Database.CHECK
10  * - Database.CHECK = false (or true for debug build)
11  * - System.out > trace messages
12  *
13  * Release checklist
14  * - Run FindBugs
15  * - Update latest version in build.html: http://mirrors.ibiblio.org/pub/mirrors/maven2/com/h2database/h2/
16  * - ant jarClient, check jar file size
17  * - Compiling with JDK 1.3, 1.4, 1.5 and 1.6
18  *
19  * set path=C:\jdk1.3.1_19\bin;%PATH%
20  * set JAVA_HOME=C:\jdk1.3.1_19\bin
21  * ant codeswitch_jdk16
22  * ant compile
23  *
24  * set path=C:\Programme\Java\jdk1.6.0\bin;%PATH%
25  * set JAVA_HOME=C:\Programme\Java\jdk1.6.0\bin
26  * ant codeswitch_jdk16
27  * ant compile
28  *
29  * ant codeswitch_jdk14
30  *
31  * - Change FAQ (next release planned, known bugs)
32  * - Check version, change build number in Constants.java and build.xml
33  * - Check code coverage
34  * - No " Message.getInternalError" (must be "throw Message.getInternalError")
35  * - ' #ifdef', ' #endif'
36  * - No TODO in the docs
37  * - Run regression test with JDK 1.4 and 1.5
38  * - Change version(s) in performance.html; use latest versions of other databases
39  * - Run 'ant benchmark' (with JDK 1.4 currently)
40  * - Copy the benchmark results and update the performance page and diagram
41  * (remove rows 2*open/close, 2*executed statement)
42  *
43  * - Documentation: if there are new files, add them to MergeDocs
44  * - Documentation: check if all javadoc files are in the index
45  * - ant docs
46  * - PDF (15 min)
47  * - footer
48  * - front page
49  * - tables (optimal size)
50  * - orphan control, page breaks
51  * - table of contents
52  * - Switch off auto-build
53  * - ant all
54  * - Make sure odbc files are the
55  * - Make sure the pdf file is there
56  * - Make sure the build files are removed
57  * - ant zip
58  * - Windows installer (nsis)
59  * - Test
60  * - Test the windows service
61  * - TestSystemExit
62  * - Test with hibernate
63  * - Scan for viruses
64  * - newsletter: prepare, send (always send to BCC!!)
65  * - http://maven.apache.org/guides/mini/guide-ibiblio-upload.html
66  * - Add to freshmeat, http://code.google.com/p/h2database/downloads/list
67  *
68  * @author Thomas
69  */

70 public class Constants {
71
72     public static final int BUILD_ID = 40;
73     private static final String JavaDoc BUILD = "2007-01-17";
74     public static final int VERSION_MAJOR = 1;
75     public static final int VERSION_MINOR = 0;
76
77     public static final int FILE_BLOCK_SIZE = 16;
78     public static final String JavaDoc MAGIC_FILE_HEADER_TEXT = "-- H2 0.5/T -- ".substring(0, FILE_BLOCK_SIZE-1) + "\n";
79     public static final String JavaDoc MAGIC_FILE_HEADER = "-- H2 0.5/B -- ".substring(0, FILE_BLOCK_SIZE-1) + "\n";
80     public static final int TCP_DRIVER_VERSION = 3;
81
82     public static final int VERSION_JDBC_MAJOR = 3;
83     public static final int VERSION_JDBC_MINOR = 0;
84
85     public static String JavaDoc getVersion() {
86         return VERSION_MAJOR + "." + VERSION_MINOR+ " (" + BUILD + ")";
87     }
88
89     public static final int NULL_SORT_LOW = 1, NULL_SORT_HIGH = 2;
90     public static final int NULL_SORT_START = 3, NULL_SORT_END = 4;
91     public static final int NULL_SORT_DEFAULT = NULL_SORT_LOW;
92
93     public static final int DEFAULT_SERVER_PORT = 9092; // this is also in the docs
94

95     public static final String JavaDoc START_URL = "jdbc:h2:";
96
97     public static final String JavaDoc URL_FORMAT = START_URL + "{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]";
98
99     public static final String JavaDoc PRODUCT_NAME = "H2";
100
101     public static final String JavaDoc DRIVER_NAME = "H2 JDBC Driver";
102
103     public static final int IO_BUFFER_SIZE = 4 * 1024;
104     public static final int IO_BUFFER_SIZE_COMPRESS = 128 * 1024;
105
106     public static final int DEFAULT_CACHE_SIZE = 1 << 16;
107     public static final int CACHE_SIZE_INDEX_SHIFT = 3;
108     public static final int DEFAULT_CACHE_SIZE_INDEX = DEFAULT_CACHE_SIZE >> CACHE_SIZE_INDEX_SHIFT;
109
110     public static final int DEFAULT_CACHE_SIZE_LINEAR_INDEX = 1 << 8;
111
112     public static final String JavaDoc SUFFIX_DATA_FILE = ".data.db";
113     public static final String JavaDoc SUFFIX_LOG_FILE = ".log.db";
114     public static final String JavaDoc SUFFIX_INDEX_FILE = ".index.db";
115     public static final String JavaDoc SUFFIX_HASH_FILE = ".hash.db";
116     public static final String JavaDoc SUFFIX_LOCK_FILE = ".lock.db";
117     public static final String JavaDoc SUFFIX_TEMP_FILE = ".temp.db";
118     public static final String JavaDoc SUFFIX_TRACE_FILE = ".trace.db";
119     public static final String JavaDoc SUFFIX_LOB_FILE = ".lob.db";
120     public static final String JavaDoc SUFFIX_TRACE_START_FILE = ".start";
121     public static final String JavaDoc SUFFIX_SUMMARY_FILE = ".sum.db";
122     public static final String JavaDoc SUFFIX_LOBS_DIRECTORY = ".lobs.db";
123
124     public static final String JavaDoc UTF8 = "UTF8";
125     public static final int DEFAULT_TABLE_TYPE = 0;
126     public static final int DEFAULT_MAX_LENGTH_INPLACE_LOB = 128;
127     public static final int DEFAULT_MAX_LENGTH_CLIENTSIDE_LOB = 65536;
128     public static final int SALT_LEN = 8;
129
130     public static final int DEFAULT_DATA_PAGE_SIZE = 512;
131
132     public static final String JavaDoc PRIMARY_KEY_PREFIX = "PRIMARY_KEY_";
133
134     public static final int LOCK_SLEEP = 1000;
135
136     // TODO for testing, the lock timeout is smaller than for interactive use cases
137
// public static final int INITIAL_LOCK_TIMEOUT = 60 * 1000;
138
public static final int INITIAL_LOCK_TIMEOUT = 1000;
139
140     public static final char DEFAULT_ESCAPE_CHAR = '\\';
141     public static final int DEFAULT_HTTP_PORT = 8082; // also in the docs
142
public static final boolean DEFAULT_HTTP_SSL = false;
143     public static final boolean DEFAULT_HTTP_ALLOW_OTHERS = false;
144     public static final int DEFAULT_FTP_PORT = 8021;
145
146     public static final int DEFAULT_MAX_MEMORY_ROWS = 10000;
147
148     public static final int DEFAULT_MAX_MEMORY_UNDO = Integer.MAX_VALUE;
149
150     public static final int DEFAULT_WRITE_DELAY = 500;
151
152     public static final String JavaDoc SERVER_PROPERTIES_TITLE = "H2 Server Properties";
153
154     public static final String JavaDoc SERVER_PROPERTIES_FILE = ".h2.server.properties";
155
156     public static final long LONG_QUERY_LIMIT_MS = 100;
157
158     public static final String JavaDoc PUBLIC_ROLE_NAME = "PUBLIC";
159
160     public static final String JavaDoc TEMP_TABLE_PREFIX = "TEMP_TABLE_";
161     public static final String JavaDoc TEMP_TABLE_TRANSACTION_PREFIX = "TEMP_TRANS_TABLE_";
162
163     public static final int BIGDECIMAL_SCALE_MAX = 100000;
164
165     public static final String JavaDoc SCHEMA_MAIN = "PUBLIC";
166     public static final String JavaDoc SCHEMA_INFORMATION = "INFORMATION_SCHEMA";
167
168     public static final String JavaDoc DBA_NAME = "DBA";
169
170     public static final String JavaDoc CHARACTER_SET_NAME = "Unicode";
171
172     public static final String JavaDoc CLUSTERING_DISABLED = "''";
173
174     public static final int LOCK_MODE_OFF = 0;
175     public static final int LOCK_MODE_TABLE = 1;
176     public static final int LOCK_MODE_TABLE_GC = 2;
177     public static final int LOCK_MODE_READ_COMMITTED = 3;
178
179     public static final int SELECTIVITY_DISTINCT_COUNT = 10000;
180     public static final int SELECTIVITY_DEFAULT = 50;
181     public static final int SELECTIVITY_ANALYZE_SAMPLE_ROWS = 10000;
182
183     // the cost is calculated on rowcount + this offset, to avoid using the wrong or no index
184
// if the table contains no rows _currently_ (when preparing the statement)
185
public static final int COST_ROW_OFFSET = 1000;
186     public static final long FLUSH_INDEX_DELAY = 0;
187     public static final int THROTTLE_DELAY = 50;
188
189     public static final String JavaDoc MANAGEMENT_DB_PREFIX = "management_db_";
190     public static final String JavaDoc MANAGEMENT_DB_USER = "sa";
191
192     public static final boolean SERIALIZE_JAVA_OBJECTS = true;
193     public static final long DEFAULT_MAX_LOG_SIZE = 32 * 1024 * 1024;
194     public static final long LOG_SIZE_DIVIDER = 10;
195
196     public static final int ALLOW_LITERALS_NONE = 0;
197     public static final int ALLOW_LITERALS_NUMBERS = 1;
198     public static final int ALLOW_LITERALS_ALL = 2;
199
200     public static final int DEFAULT_ALLOW_LITERALS = ALLOW_LITERALS_ALL;
201     public static final boolean AUTO_CONVERT_LOB_TO_FILES = true;
202     public static final boolean ALLOW_EMTPY_BTREE_PAGES = true;
203     public static final String JavaDoc CONN_URL_INTERNAL = "jdbc:default:connection";
204     public static final String JavaDoc CONN_URL_COLUMNLIST = "jdbc:columnlist:connection";
205     
206     public static final int VIEW_COST_CACHE_SIZE = 64;
207     public static final int VIEW_COST_CACHE_MAX_AGE = 10000; // 10 seconds
208
public static final int MAX_PARAMETER_INDEX = 100000;
209     
210     // TODO need to refactor & test the code to enable this (add more tests!)
211
public static final boolean OPTIMIZE_EVALUATABLE_SUBQUERIES = false;
212
213     // to slow down dictionary attacks
214
public static final int ENCRYPTION_KEY_HASH_ITERATIONS = 1024;
215     
216     public static final String JavaDoc SCRIPT_SQL = "script.sql";
217
218     // for testing only
219
public static final int CACHE_MIN_RECORDS = 16;
220     
221     public static final int MIN_WRITE_DELAY = getIntSetting("h2.minWriteDelay", 5);
222
223     
224     public static boolean CHECK = getBooleanSetting("h2.check", true);
225     public static final boolean CHECK2 = getBooleanSetting("h2.check2", false);
226
227     // TODO: also remove DataHandler.allocateObjectId, createTempFile when setting this to true and removing it
228
public static final boolean LOB_FILES_IN_DIRECTORIES = getBooleanSetting("h2.lobFilesInDirectories", false);
229     public static final int LOB_FILES_PER_DIRECTORY = getIntSetting("h2.lobFilesPerDirectory", 256);
230     
231     public static boolean MULTI_THREADED_KERNEL = getBooleanSetting("h2.multiThreadedKernel", false);
232     public static boolean RUN_FINALIZERS = getBooleanSetting("h2.runFinalizers", true);
233
234     public static final boolean OPTIMIZE_MIN_MAX = getBooleanSetting("h2.optimizeMinMax", true);
235     public static final boolean OPTIMIZE_IN = getBooleanSetting("h2.optimizeIn", true);
236     public static final int REDO_BUFFER_SIZE = getIntSetting("h2.redoBufferSize", 256 * 1024);
237     public static final boolean RECOMPILE_ALWAYS = getBooleanSetting("h2.recompileAlways", false);
238     public static final boolean OPTIMIZE_SUBQUERY_CACHE = getBooleanSetting("h2.optimizeSubqueryCache", true);
239     public static final boolean OVERFLOW_EXCEPTIONS = getBooleanSetting("h2.overflowExceptions", true);
240     public static final boolean LOG_ALL_ERRORS = getBooleanSetting("h2.logAllErrors", false);
241     public static final String JavaDoc LOG_ALL_ERRORS_FILE = getStringSetting("h2.logAllErrorsFile", "h2errors.txt");
242     public static final int SERVER_CACHED_OBJECTS = getIntSetting("h2.serverCachedObjects", 64);
243     public static final int SERVER_SMALL_RESULTSET_SIZE = getIntSetting("h2.serverSmallResultSetSize", 100);
244     public static final int EMERGENCY_SPACE_INITIAL = getIntSetting("h2.emergencySpaceInitial", 1 * 1024 * 1024);
245     public static final int EMERGENCY_SPACE_MIN = getIntSetting("h2.emergencySpaceMin", 128 * 1024);
246     public static final boolean OBJECT_CACHE = getBooleanSetting("h2.objectCache", true);
247     public static final int OBJECT_CACHE_SIZE = getIntSetting("h2.objectCacheSize", 1024);
248     public static final int OBJECT_CACHE_MAX_PER_ELEMENT_SIZE = getIntSetting("h2.objectCacheMaxPerElementSize", 4096);
249     public static final String JavaDoc CLIENT_TRACE_DIRECTORY = getStringSetting("h2.clientTraceDirectory", "trace.db/");
250     public static String JavaDoc SCRIPT_DIRECTORY = getStringSetting("h2.scriptDirectory", "");
251
252     public static boolean getBooleanSetting(String JavaDoc name, boolean defaultValue) {
253         String JavaDoc s = System.getProperty(name);
254         if(s != null) {
255             try {
256                 return Boolean.valueOf(s).booleanValue();
257             } catch(NumberFormatException JavaDoc e) {
258             }
259         }
260         return defaultValue;
261     }
262
263     public static String JavaDoc getStringSetting(String JavaDoc name, String JavaDoc defaultValue) {
264         String JavaDoc s = System.getProperty(name);
265         return s == null ? defaultValue : s;
266     }
267
268     public static int getIntSetting(String JavaDoc name, int defaultValue) {
269         String JavaDoc s = System.getProperty(name);
270         if(s != null) {
271             try {
272                 return Integer.decode(s).intValue();
273             } catch(NumberFormatException JavaDoc e) {
274             }
275         }
276         return defaultValue;
277     }
278 }
279
Popular Tags