1 /* Copyright (c) 2001-2016, The HSQL Development Group 2 * All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * Redistributions of source code must retain the above copyright notice, this 8 * list of conditions and the following disclaimer. 9 * 10 * Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * 14 * Neither the name of the HSQL Development Group nor the names of its 15 * contributors may be used to endorse or promote products derived from this 16 * software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG, 22 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 32 package org.hsqldb.persist; 33 34 import java.util.Enumeration; 35 36 import org.hsqldb.Database; 37 import org.hsqldb.error.Error; 38 import org.hsqldb.error.ErrorCode; 39 import org.hsqldb.lib.HashMap; 40 import org.hsqldb.lib.HashSet; 41 import org.hsqldb.lib.Iterator; 42 import org.hsqldb.lib.Set; 43 import org.hsqldb.lib.StringUtil; 44 45 /** 46 * Manages a .properties file for a database. 47 * 48 * @author Fred Toussi (fredt@users dot sourceforge.net) 49 * @version 2.3.3 50 * @since 1.7.0 51 */ 52 public class HsqlDatabaseProperties extends HsqlProperties { 53 54 private static final String hsqldb_method_class_names = 55 "hsqldb.method_class_names"; 56 public static final String textdb_allow_full_path = 57 "textdb.allow_full_path"; 58 private static HashSet accessibleJavaMethodNames; 59 private static boolean allowFullPath; 60 61 static { 62 try { 63 String prop = System.getProperty(hsqldb_method_class_names); 64 65 if (prop != null) { 66 accessibleJavaMethodNames = new HashSet(); 67 68 String[] names = StringUtil.split(prop, ";"); 69 70 for (int i = 0; i < names.length; i++) { 71 accessibleJavaMethodNames.add(names[i]); 72 } 73 } 74 75 prop = System.getProperty(textdb_allow_full_path); 76 77 if (prop != null) { 78 if (Boolean.valueOf(prop)) { 79 allowFullPath = true; 80 } 81 } 82 } catch (Exception e) {} 83 } 84 85 /** 86 * If the system property "hsqldb.method_class_names" is not set, then 87 * static methods of all available Java classes can be accessed as functions 88 * in HSQLDB. If the property is set, then only the list of semicolon 89 * separated method names becomes accessible. An empty property value means 90 * no class is accessible.<p> 91 * 92 * A property value that ends with .* is treated as a wild card and allows 93 * access to all classe or method names formed by substitution of the 94 * asterisk.<p> 95 * 96 * All methods of java.lang.Math are always accessible. 97 */ supportsJavaMethod(String name)98 public static boolean supportsJavaMethod(String name) { 99 100 if (accessibleJavaMethodNames == null) { 101 return true; 102 } 103 104 if (name.startsWith("java.lang.Math.")) { 105 return true; 106 } 107 108 if (accessibleJavaMethodNames.contains(name)) { 109 return true; 110 } 111 112 Iterator it = accessibleJavaMethodNames.iterator(); 113 114 while (it.hasNext()) { 115 String className = (String) it.next(); 116 int limit = className.lastIndexOf(".*"); 117 118 if (limit < 1) { 119 continue; 120 } 121 122 if (name.startsWith(className.substring(0, limit + 1))) { 123 return true; 124 } 125 } 126 127 return false; 128 } 129 130 // accessibility 131 public static final int SYSTEM_PROPERTY = 0; 132 public static final int FILE_PROPERTY = 1; 133 public static final int SQL_PROPERTY = 2; 134 135 // db files modified 136 public static final int FILES_NOT_MODIFIED = 0; 137 public static final int FILES_MODIFIED = 1; 138 public static final int FILES_MODIFIED_NEW = 2; 139 public static final int FILES_NEW = 3; 140 private static final String MODIFIED_NO = "no"; 141 private static final String MODIFIED_YES = "yes"; 142 private static final String MODIFIED_YES_NEW = "yes-new-files"; 143 private static final String MODIFIED_NO_NEW = "no-new-files"; 144 145 // allowed property metadata 146 private static final HashMap dbMeta = new HashMap(67); 147 private static final HashMap textMeta = new HashMap(17); 148 149 // versions 150 public static final String VERSION_STRING_1_8_0 = "1.8.0"; 151 public static final String THIS_VERSION = "2.3.4"; 152 public static final String THIS_FULL_VERSION = "2.3.4"; 153 public static final String THIS_CACHE_VERSION = "2.0.0"; 154 public static final String PRODUCT_NAME = "HSQL Database Engine"; 155 public static final int MAJOR = 2, 156 MINOR = 3, 157 REVISION = 4; 158 159 /** 160 * system properties supported by HSQLDB 161 */ 162 public static final String system_lockfile_poll_retries_property = 163 "hsqldb.lockfile_poll_retries"; 164 public static final String system_max_char_or_varchar_display_size = 165 "hsqldb.max_char_or_varchar_display_size"; 166 167 // 168 public static final String hsqldb_inc_backup = "hsqldb.inc_backup"; 169 170 // 171 public static final String hsqldb_version = "version"; 172 public static final String hsqldb_readonly = "readonly"; 173 private static final String hsqldb_modified = "modified"; 174 175 // 176 public static final String tx_timestamp = "tx_timestamp"; 177 178 // 179 public static final String hsqldb_cache_version = "hsqldb.cache_version"; 180 181 // 182 public static final String runtime_gc_interval = "runtime.gc_interval"; 183 184 // 185 public static final String url_ifexists = "ifexists"; 186 public static final String url_create = "create"; 187 public static final String url_default_schema = "default_schema"; 188 public static final String url_check_props = "check_props"; 189 public static final String url_get_column_name = "get_column_name"; 190 public static final String url_close_result = "close_result"; 191 public static final String url_allow_empty_batch = "allow_empty_batch"; 192 193 // 194 public static final String url_storage_class_name = "storage_class_name"; 195 public static final String url_fileaccess_class_name = 196 "fileaccess_class_name"; 197 public static final String url_storage_key = "storage_key"; 198 public static final String url_shutdown = "shutdown"; 199 public static final String url_recover = "recover"; 200 public static final String url_tls_wrapper = "tls_wrapper"; 201 202 // 203 public static final String url_crypt_key = "crypt_key"; 204 public static final String url_crypt_type = "crypt_type"; 205 public static final String url_crypt_provider = "crypt_provider"; 206 public static final String url_crypt_lobs = "crypt_lobs"; 207 208 // 209 public static final String hsqldb_tx = "hsqldb.tx"; 210 public static final String hsqldb_tx_level = "hsqldb.tx_level"; 211 public static final String hsqldb_tx_conflict_rollback = 212 "hsqldb.tx_conflict_rollback"; 213 public static final String hsqldb_applog = "hsqldb.applog"; 214 public static final String hsqldb_sqllog = "hsqldb.sqllog"; 215 public static final String hsqldb_lob_file_scale = "hsqldb.lob_file_scale"; 216 public static final String hsqldb_lob_file_compressed = 217 "hsqldb.lob_compressed"; 218 public static final String hsqldb_cache_file_scale = 219 "hsqldb.cache_file_scale"; 220 public static final String hsqldb_cache_free_count = 221 "hsqldb.cache_free_count"; 222 public static final String hsqldb_cache_rows = "hsqldb.cache_rows"; 223 public static final String hsqldb_cache_size = "hsqldb.cache_size"; 224 public static final String hsqldb_default_table_type = 225 "hsqldb.default_table_type"; 226 public static final String hsqldb_defrag_limit = "hsqldb.defrag_limit"; 227 public static final String hsqldb_files_readonly = "files_readonly"; 228 public static final String hsqldb_lock_file = "hsqldb.lock_file"; 229 public static final String hsqldb_log_data = "hsqldb.log_data"; 230 public static final String hsqldb_log_size = "hsqldb.log_size"; 231 public static final String hsqldb_nio_data_file = "hsqldb.nio_data_file"; 232 public static final String hsqldb_nio_max_size = "hsqldb.nio_max_size"; 233 public static final String hsqldb_script_format = "hsqldb.script_format"; 234 public static final String hsqldb_temp_directory = "hsqldb.temp_directory"; 235 public static final String hsqldb_result_max_memory_rows = 236 "hsqldb.result_max_memory_rows"; 237 public static final String hsqldb_write_delay = "hsqldb.write_delay"; 238 public static final String hsqldb_write_delay_millis = 239 "hsqldb.write_delay_millis"; 240 public static final String hsqldb_full_log_replay = 241 "hsqldb.full_log_replay"; 242 public static final String hsqldb_large_data = "hsqldb.large_data"; 243 public static final String hsqldb_files_space = "hsqldb.files_space"; 244 public static final String hsqldb_digest = "hsqldb.digest"; 245 246 // 247 public static final String jdbc_translate_tti_types = 248 "jdbc.translate_tti_types"; 249 250 // 251 public static final String sql_ref_integrity = "sql.ref_integrity"; 252 public static final String sql_compare_in_locale = "sql.compare_in_locale"; 253 public static final String sql_enforce_size = "sql.enforce_size"; 254 public static final String sql_enforce_strict_size = 255 "sql.enforce_strict_size"; // synonym for sql_enforce_size 256 public static final String sql_enforce_refs = "sql.enforce_refs"; 257 public static final String sql_enforce_names = "sql.enforce_names"; 258 public static final String sql_regular_names = "sql.regular_names"; 259 public static final String sql_enforce_types = "sql.enforce_types"; 260 public static final String sql_enforce_tdcd = "sql.enforce_tdc_delete"; 261 public static final String sql_enforce_tdcu = "sql.enforce_tdc_update"; 262 public static final String sql_char_literal = "sql.char_literal"; 263 public static final String sql_concat_nulls = "sql.concat_nulls"; 264 public static final String sql_nulls_first = "sql.nulls_first"; 265 public static final String sql_nulls_order = "sql.nulls_order"; 266 public static final String sql_unique_nulls = "sql.unique_nulls"; 267 public static final String sql_convert_trunc = "sql.convert_trunc"; 268 public static final String sql_avg_scale = "sql.avg_scale"; 269 public static final String sql_double_nan = "sql.double_nan"; 270 public static final String sql_syntax_db2 = "sql.syntax_db2"; 271 public static final String sql_syntax_mss = "sql.syntax_mss"; 272 public static final String sql_syntax_mys = "sql.syntax_mys"; 273 public static final String sql_syntax_ora = "sql.syntax_ora"; 274 public static final String sql_syntax_pgs = "sql.syntax_pgs"; 275 public static final String sql_longvar_is_lob = "sql.longvar_is_lob"; 276 public static final String sql_pad_space = "sql.pad_space"; 277 public static final String sql_ignore_case = "sql.ignore_case"; 278 public static final String sql_live_object = "sql.live_object"; 279 280 // 281 public static final String textdb_cache_scale = "textdb.cache_scale"; 282 public static final String textdb_cache_size_scale = 283 "textdb.cache_size_scale"; 284 public static final String textdb_cache_rows = "textdb.cache_rows"; 285 public static final String textdb_cache_size = "textdb.cache_size"; 286 public static final String textdb_all_quoted = "textdb.all_quoted"; 287 public static final String textdb_encoding = "textdb.encoding"; 288 public static final String textdb_ignore_first = "textdb.ignore_first"; 289 public static final String textdb_quoted = "textdb.quoted"; 290 public static final String textdb_fs = "textdb.fs"; 291 public static final String textdb_vs = "textdb.vs"; 292 public static final String textdb_lvs = "textdb.lvs"; 293 public static final String textdb_qc = "textdb.qc"; 294 295 // 296 public static final String hsqldb_min_reuse = "hsqldb.min_reuse"; 297 298 static { 299 300 // text table defaults textMeta.put(textdb_allow_full_path, HsqlProperties.getMeta(textdb_allow_full_path, SYSTEM_PROPERTY, allowFullPath))301 textMeta.put(textdb_allow_full_path, 302 HsqlProperties.getMeta(textdb_allow_full_path, 303 SYSTEM_PROPERTY, allowFullPath)); textMeta.put(textdb_quoted, HsqlProperties.getMeta(textdb_quoted, SQL_PROPERTY, true))304 textMeta.put(textdb_quoted, 305 HsqlProperties.getMeta(textdb_quoted, SQL_PROPERTY, 306 true)); textMeta.put(textdb_all_quoted, HsqlProperties.getMeta(textdb_all_quoted, SQL_PROPERTY, false))307 textMeta.put(textdb_all_quoted, 308 HsqlProperties.getMeta(textdb_all_quoted, SQL_PROPERTY, 309 false)); textMeta.put(textdb_ignore_first, HsqlProperties.getMeta(textdb_ignore_first, SQL_PROPERTY, false))310 textMeta.put(textdb_ignore_first, 311 HsqlProperties.getMeta(textdb_ignore_first, SQL_PROPERTY, 312 false)); textMeta.put(textdb_fs, HsqlProperties.getMeta(textdb_fs, SQL_PROPERTY, R))313 textMeta.put(textdb_fs, 314 HsqlProperties.getMeta(textdb_fs, SQL_PROPERTY, ",")); textMeta.put(textdb_vs, HsqlProperties.getMeta(textdb_vs, SQL_PROPERTY, null))315 textMeta.put(textdb_vs, 316 HsqlProperties.getMeta(textdb_vs, SQL_PROPERTY, null)); textMeta.put(textdb_lvs, HsqlProperties.getMeta(textdb_lvs, SQL_PROPERTY, null))317 textMeta.put(textdb_lvs, 318 HsqlProperties.getMeta(textdb_lvs, SQL_PROPERTY, null)); textMeta.put(textdb_qc, HsqlProperties.getMeta(textdb_qc, SQL_PROPERTY, R))319 textMeta.put(textdb_qc, 320 HsqlProperties.getMeta(textdb_qc, SQL_PROPERTY, "\"")); textMeta.put(textdb_encoding, HsqlProperties.getMeta(textdb_encoding, SQL_PROPERTY, R))321 textMeta.put(textdb_encoding, 322 HsqlProperties.getMeta(textdb_encoding, SQL_PROPERTY, 323 "ISO-8859-1")); textMeta.put(textdb_cache_scale, HsqlProperties.getMeta(textdb_cache_scale, SQL_PROPERTY, 10, 8, 16))324 textMeta.put(textdb_cache_scale, 325 HsqlProperties.getMeta(textdb_cache_scale, SQL_PROPERTY, 326 10, 8, 16)); textMeta.put(textdb_cache_size_scale, HsqlProperties.getMeta(textdb_cache_size_scale, SQL_PROPERTY, 10, 6, 20))327 textMeta.put(textdb_cache_size_scale, 328 HsqlProperties.getMeta(textdb_cache_size_scale, 329 SQL_PROPERTY, 10, 6, 20)); textMeta.put(textdb_cache_rows, HsqlProperties.getMeta(textdb_cache_rows, SQL_PROPERTY, 1000, 100, 1000000))330 textMeta.put(textdb_cache_rows, 331 HsqlProperties.getMeta(textdb_cache_rows, SQL_PROPERTY, 332 1000, 100, 1000000)); textMeta.put(textdb_cache_size, HsqlProperties.getMeta(textdb_cache_size, SQL_PROPERTY, 100, 10, 1000000))333 textMeta.put(textdb_cache_size, 334 HsqlProperties.getMeta(textdb_cache_size, SQL_PROPERTY, 335 100, 10, 1000000)); 336 dbMeta.putAll(textMeta); 337 338 // string defaults for protected props dbMeta.put(hsqldb_version, HsqlProperties.getMeta(hsqldb_version, FILE_PROPERTY, null))339 dbMeta.put(hsqldb_version, 340 HsqlProperties.getMeta(hsqldb_version, FILE_PROPERTY, 341 null)); dbMeta.put(hsqldb_modified, HsqlProperties.getMeta(hsqldb_modified, FILE_PROPERTY, null))342 dbMeta.put(hsqldb_modified, 343 HsqlProperties.getMeta(hsqldb_modified, FILE_PROPERTY, 344 null)); dbMeta.put(hsqldb_cache_version, HsqlProperties.getMeta(hsqldb_cache_version, FILE_PROPERTY, null))345 dbMeta.put(hsqldb_cache_version, 346 HsqlProperties.getMeta(hsqldb_cache_version, FILE_PROPERTY, 347 null)); 348 349 // boolean defaults for protected props dbMeta.put(hsqldb_readonly, HsqlProperties.getMeta(hsqldb_readonly, FILE_PROPERTY, false))350 dbMeta.put(hsqldb_readonly, 351 HsqlProperties.getMeta(hsqldb_readonly, FILE_PROPERTY, 352 false)); dbMeta.put(hsqldb_files_readonly, HsqlProperties.getMeta(hsqldb_files_readonly, FILE_PROPERTY, false))353 dbMeta.put(hsqldb_files_readonly, 354 HsqlProperties.getMeta(hsqldb_files_readonly, 355 FILE_PROPERTY, false)); 356 357 // string defaults for user defined props dbMeta.put(hsqldb_tx, HsqlProperties.getMeta(hsqldb_tx, SQL_PROPERTY, R))358 dbMeta.put(hsqldb_tx, 359 HsqlProperties.getMeta(hsqldb_tx, SQL_PROPERTY, "LOCKS")); dbMeta.put(hsqldb_tx_level, HsqlProperties.getMeta(hsqldb_tx_level, SQL_PROPERTY, R))360 dbMeta.put(hsqldb_tx_level, 361 HsqlProperties.getMeta(hsqldb_tx_level, SQL_PROPERTY, 362 "READ_COMMITTED")); dbMeta.put(hsqldb_temp_directory, HsqlProperties.getMeta(hsqldb_temp_directory, SQL_PROPERTY, null))363 dbMeta.put(hsqldb_temp_directory, 364 HsqlProperties.getMeta(hsqldb_temp_directory, SQL_PROPERTY, 365 null)); dbMeta.put(hsqldb_default_table_type, HsqlProperties.getMeta(hsqldb_default_table_type, SQL_PROPERTY, R))366 dbMeta.put(hsqldb_default_table_type, 367 HsqlProperties.getMeta(hsqldb_default_table_type, 368 SQL_PROPERTY, "MEMORY")); dbMeta.put(hsqldb_digest, HsqlProperties.getMeta(hsqldb_digest, SQL_PROPERTY, R))369 dbMeta.put(hsqldb_digest, 370 HsqlProperties.getMeta(hsqldb_digest, SQL_PROPERTY, "MD5")); dbMeta.put(sql_live_object, HsqlProperties.getMeta(sql_live_object, SQL_PROPERTY, false))371 dbMeta.put(sql_live_object, 372 HsqlProperties.getMeta(sql_live_object, SQL_PROPERTY, 373 false)); dbMeta.put(tx_timestamp, HsqlProperties.getMeta(tx_timestamp, SYSTEM_PROPERTY))374 dbMeta.put(tx_timestamp, 375 HsqlProperties.getMeta(tx_timestamp, SYSTEM_PROPERTY)); 376 377 // boolean defaults for user defined props dbMeta.put(hsqldb_tx_conflict_rollback, HsqlProperties.getMeta(hsqldb_tx_conflict_rollback, SQL_PROPERTY, true))378 dbMeta.put(hsqldb_tx_conflict_rollback, 379 HsqlProperties.getMeta(hsqldb_tx_conflict_rollback, 380 SQL_PROPERTY, true)); dbMeta.put(jdbc_translate_tti_types, HsqlProperties.getMeta(jdbc_translate_tti_types, SQL_PROPERTY, true))381 dbMeta.put(jdbc_translate_tti_types, 382 HsqlProperties.getMeta(jdbc_translate_tti_types, 383 SQL_PROPERTY, true)); dbMeta.put(hsqldb_inc_backup, HsqlProperties.getMeta(hsqldb_inc_backup, SQL_PROPERTY, true))384 dbMeta.put(hsqldb_inc_backup, 385 HsqlProperties.getMeta(hsqldb_inc_backup, SQL_PROPERTY, 386 true)); dbMeta.put(hsqldb_lock_file, HsqlProperties.getMeta(hsqldb_lock_file, SQL_PROPERTY, true))387 dbMeta.put(hsqldb_lock_file, 388 HsqlProperties.getMeta(hsqldb_lock_file, SQL_PROPERTY, 389 true)); dbMeta.put(hsqldb_log_data, HsqlProperties.getMeta(hsqldb_log_data, SQL_PROPERTY, true))390 dbMeta.put(hsqldb_log_data, 391 HsqlProperties.getMeta(hsqldb_log_data, SQL_PROPERTY, 392 true)); dbMeta.put(hsqldb_nio_data_file, HsqlProperties.getMeta(hsqldb_nio_data_file, SQL_PROPERTY, true))393 dbMeta.put(hsqldb_nio_data_file, 394 HsqlProperties.getMeta(hsqldb_nio_data_file, SQL_PROPERTY, 395 true)); dbMeta.put(hsqldb_full_log_replay, HsqlProperties.getMeta(hsqldb_full_log_replay, SQL_PROPERTY, false))396 dbMeta.put(hsqldb_full_log_replay, 397 HsqlProperties.getMeta(hsqldb_full_log_replay, 398 SQL_PROPERTY, false)); dbMeta.put(sql_ref_integrity, HsqlProperties.getMeta(sql_ref_integrity, SQL_PROPERTY, true))399 dbMeta.put(sql_ref_integrity, 400 HsqlProperties.getMeta(sql_ref_integrity, SQL_PROPERTY, 401 true)); 402 403 // SQL reserved words not allowed as some identifiers dbMeta.put(sql_enforce_names, HsqlProperties.getMeta(sql_enforce_names, SQL_PROPERTY, false))404 dbMeta.put(sql_enforce_names, 405 HsqlProperties.getMeta(sql_enforce_names, SQL_PROPERTY, 406 false)); dbMeta.put(sql_regular_names, HsqlProperties.getMeta(sql_regular_names, SQL_PROPERTY, true))407 dbMeta.put(sql_regular_names, 408 HsqlProperties.getMeta(sql_regular_names, SQL_PROPERTY, 409 true)); dbMeta.put(sql_enforce_refs, HsqlProperties.getMeta(sql_enforce_refs, SQL_PROPERTY, false))410 dbMeta.put(sql_enforce_refs, 411 HsqlProperties.getMeta(sql_enforce_refs, SQL_PROPERTY, 412 false)); 413 414 // char padding to size and exception if data is too long dbMeta.put(sql_enforce_size, HsqlProperties.getMeta(sql_enforce_size, SQL_PROPERTY, true))415 dbMeta.put(sql_enforce_size, 416 HsqlProperties.getMeta(sql_enforce_size, SQL_PROPERTY, 417 true)); dbMeta.put(sql_enforce_types, HsqlProperties.getMeta(sql_enforce_types, SQL_PROPERTY, false))418 dbMeta.put(sql_enforce_types, 419 HsqlProperties.getMeta(sql_enforce_types, SQL_PROPERTY, 420 false)); dbMeta.put(sql_enforce_tdcd, HsqlProperties.getMeta(sql_enforce_tdcd, SQL_PROPERTY, true))421 dbMeta.put(sql_enforce_tdcd, 422 HsqlProperties.getMeta(sql_enforce_tdcd, SQL_PROPERTY, 423 true)); dbMeta.put(sql_enforce_tdcu, HsqlProperties.getMeta(sql_enforce_tdcu, SQL_PROPERTY, true))424 dbMeta.put(sql_enforce_tdcu, 425 HsqlProperties.getMeta(sql_enforce_tdcu, SQL_PROPERTY, 426 true)); dbMeta.put(sql_char_literal, HsqlProperties.getMeta(sql_char_literal, SQL_PROPERTY, true))427 dbMeta.put(sql_char_literal, 428 HsqlProperties.getMeta(sql_char_literal, SQL_PROPERTY, 429 true)); dbMeta.put(sql_concat_nulls, HsqlProperties.getMeta(sql_concat_nulls, SQL_PROPERTY, true))430 dbMeta.put(sql_concat_nulls, 431 HsqlProperties.getMeta(sql_concat_nulls, SQL_PROPERTY, 432 true)); dbMeta.put(sql_nulls_first, HsqlProperties.getMeta(sql_nulls_first, SQL_PROPERTY, true))433 dbMeta.put(sql_nulls_first, 434 HsqlProperties.getMeta(sql_nulls_first, SQL_PROPERTY, 435 true)); dbMeta.put(sql_nulls_order, HsqlProperties.getMeta(sql_nulls_order, SQL_PROPERTY, true))436 dbMeta.put(sql_nulls_order, 437 HsqlProperties.getMeta(sql_nulls_order, SQL_PROPERTY, 438 true)); dbMeta.put(sql_unique_nulls, HsqlProperties.getMeta(sql_unique_nulls, SQL_PROPERTY, true))439 dbMeta.put(sql_unique_nulls, 440 HsqlProperties.getMeta(sql_unique_nulls, SQL_PROPERTY, 441 true)); dbMeta.put(sql_convert_trunc, HsqlProperties.getMeta(sql_convert_trunc, SQL_PROPERTY, true))442 dbMeta.put(sql_convert_trunc, 443 HsqlProperties.getMeta(sql_convert_trunc, SQL_PROPERTY, 444 true)); dbMeta.put(sql_avg_scale, HsqlProperties.getMeta(sql_avg_scale, SQL_PROPERTY, 0, 0, 10))445 dbMeta.put(sql_avg_scale, 446 HsqlProperties.getMeta(sql_avg_scale, SQL_PROPERTY, 0, 0, 447 10)); dbMeta.put(sql_double_nan, HsqlProperties.getMeta(sql_double_nan, SQL_PROPERTY, true))448 dbMeta.put(sql_double_nan, 449 HsqlProperties.getMeta(sql_double_nan, SQL_PROPERTY, true)); dbMeta.put(sql_syntax_db2, HsqlProperties.getMeta(sql_syntax_db2, SQL_PROPERTY, false))450 dbMeta.put(sql_syntax_db2, 451 HsqlProperties.getMeta(sql_syntax_db2, SQL_PROPERTY, 452 false)); dbMeta.put(sql_syntax_mss, HsqlProperties.getMeta(sql_syntax_mss, SQL_PROPERTY, false))453 dbMeta.put(sql_syntax_mss, 454 HsqlProperties.getMeta(sql_syntax_mss, SQL_PROPERTY, 455 false)); dbMeta.put(sql_syntax_mys, HsqlProperties.getMeta(sql_syntax_mys, SQL_PROPERTY, false))456 dbMeta.put(sql_syntax_mys, 457 HsqlProperties.getMeta(sql_syntax_mys, SQL_PROPERTY, 458 false)); dbMeta.put(sql_syntax_ora, HsqlProperties.getMeta(sql_syntax_ora, SQL_PROPERTY, false))459 dbMeta.put(sql_syntax_ora, 460 HsqlProperties.getMeta(sql_syntax_ora, SQL_PROPERTY, 461 false)); dbMeta.put(sql_syntax_pgs, HsqlProperties.getMeta(sql_syntax_pgs, SQL_PROPERTY, false))462 dbMeta.put(sql_syntax_pgs, 463 HsqlProperties.getMeta(sql_syntax_pgs, SQL_PROPERTY, 464 false)); dbMeta.put(sql_compare_in_locale, HsqlProperties.getMeta(sql_compare_in_locale, SQL_PROPERTY, false))465 dbMeta.put(sql_compare_in_locale, 466 HsqlProperties.getMeta(sql_compare_in_locale, SQL_PROPERTY, 467 false)); dbMeta.put(sql_longvar_is_lob, HsqlProperties.getMeta(sql_longvar_is_lob, SQL_PROPERTY, false))468 dbMeta.put(sql_longvar_is_lob, 469 HsqlProperties.getMeta(sql_longvar_is_lob, SQL_PROPERTY, 470 false)); dbMeta.put(sql_pad_space, HsqlProperties.getMeta(sql_pad_space, SQL_PROPERTY, true))471 dbMeta.put(sql_pad_space, 472 HsqlProperties.getMeta(sql_pad_space, SQL_PROPERTY, true)); dbMeta.put(sql_ignore_case, HsqlProperties.getMeta(sql_ignore_case, SQL_PROPERTY, false))473 dbMeta.put(sql_ignore_case, 474 HsqlProperties.getMeta(sql_ignore_case, SQL_PROPERTY, 475 false)); dbMeta.put(hsqldb_write_delay, HsqlProperties.getMeta(hsqldb_write_delay, SQL_PROPERTY, true))476 dbMeta.put(hsqldb_write_delay, 477 HsqlProperties.getMeta(hsqldb_write_delay, SQL_PROPERTY, 478 true)); dbMeta.put(hsqldb_large_data, HsqlProperties.getMeta(hsqldb_large_data, SQL_PROPERTY, false))479 dbMeta.put(hsqldb_large_data, 480 HsqlProperties.getMeta(hsqldb_large_data, SQL_PROPERTY, 481 false)); dbMeta.put(hsqldb_files_space, HsqlProperties.getMeta(hsqldb_files_space, SQL_PROPERTY, 0, new int[] { 0, 1, 2, 4, 8, 16, 32, 64 }))482 dbMeta.put(hsqldb_files_space, 483 HsqlProperties.getMeta(hsqldb_files_space, SQL_PROPERTY, 0, 484 new int[] { 485 0, 1, 2, 4, 8, 16, 32, 64 486 })); 487 488 // integral defaults for user-defined props - sets dbMeta.put(hsqldb_write_delay_millis, HsqlProperties.getMeta(hsqldb_write_delay_millis, SQL_PROPERTY, 500, 0, 10000))489 dbMeta.put(hsqldb_write_delay_millis, 490 HsqlProperties.getMeta(hsqldb_write_delay_millis, 491 SQL_PROPERTY, 500, 0, 10000)); dbMeta.put(hsqldb_applog, HsqlProperties.getMeta(hsqldb_applog, SQL_PROPERTY, 0, 0, 3))492 dbMeta.put(hsqldb_applog, 493 HsqlProperties.getMeta(hsqldb_applog, SQL_PROPERTY, 0, 0, 494 3)); dbMeta.put(hsqldb_sqllog, HsqlProperties.getMeta(hsqldb_sqllog, SQL_PROPERTY, 0, 0, 4))495 dbMeta.put(hsqldb_sqllog, 496 HsqlProperties.getMeta(hsqldb_sqllog, SQL_PROPERTY, 0, 0, 497 4)); dbMeta.put(hsqldb_script_format, HsqlProperties.getMeta(hsqldb_script_format, SQL_PROPERTY, 0, new int[] { 0, 1, 3 }))498 dbMeta.put(hsqldb_script_format, 499 HsqlProperties.getMeta(hsqldb_script_format, SQL_PROPERTY, 500 0, new int[] { 501 0, 1, 3 502 })); dbMeta.put(hsqldb_lob_file_scale, HsqlProperties.getMeta(hsqldb_lob_file_scale, SQL_PROPERTY, 32, new int[] { 1, 2, 4, 8, 16, 32 }))503 dbMeta.put(hsqldb_lob_file_scale, 504 HsqlProperties.getMeta(hsqldb_lob_file_scale, SQL_PROPERTY, 505 32, new int[] { 506 1, 2, 4, 8, 16, 32 507 })); dbMeta.put(hsqldb_lob_file_compressed, HsqlProperties.getMeta(hsqldb_lob_file_compressed, SQL_PROPERTY, false))508 dbMeta.put(hsqldb_lob_file_compressed, 509 HsqlProperties.getMeta(hsqldb_lob_file_compressed, 510 SQL_PROPERTY, false)); 511 512 // this property is normally 8 - or 1 for old databases from early versions dbMeta.put(hsqldb_cache_file_scale, HsqlProperties.getMeta(hsqldb_cache_file_scale, SQL_PROPERTY, 32, new int[] { 1, 8, 16, 32, 64, 128, 256, 512, 1024 }))513 dbMeta.put(hsqldb_cache_file_scale, 514 HsqlProperties.getMeta(hsqldb_cache_file_scale, 515 SQL_PROPERTY, 32, new int[] { 516 1, 8, 16, 32, 64, 128, 256, 512, 1024 517 })); 518 519 // integral defaults for user defined props - ranges dbMeta.put(hsqldb_log_size, HsqlProperties.getMeta(hsqldb_log_size, SQL_PROPERTY, 50, 0, 4 * 1024))520 dbMeta.put(hsqldb_log_size, 521 HsqlProperties.getMeta(hsqldb_log_size, SQL_PROPERTY, 50, 522 0, 4 * 1024)); dbMeta.put(hsqldb_defrag_limit, HsqlProperties.getMeta(hsqldb_defrag_limit, SQL_PROPERTY, 0, 0, 100))523 dbMeta.put(hsqldb_defrag_limit, 524 HsqlProperties.getMeta(hsqldb_defrag_limit, SQL_PROPERTY, 525 0, 0, 100)); dbMeta.put(runtime_gc_interval, HsqlProperties.getMeta(runtime_gc_interval, SQL_PROPERTY, 0, 0, 1000000))526 dbMeta.put(runtime_gc_interval, 527 HsqlProperties.getMeta(runtime_gc_interval, SQL_PROPERTY, 528 0, 0, 1000000)); dbMeta.put(hsqldb_cache_size, HsqlProperties.getMeta(hsqldb_cache_size, SQL_PROPERTY, 10000, 100, 4 * 1024 * 1024))529 dbMeta.put(hsqldb_cache_size, 530 HsqlProperties.getMeta(hsqldb_cache_size, SQL_PROPERTY, 531 10000, 100, 4 * 1024 * 1024)); dbMeta.put(hsqldb_cache_rows, HsqlProperties.getMeta(hsqldb_cache_rows, SQL_PROPERTY, 50000, 100, 4 * 1024 * 1024))532 dbMeta.put(hsqldb_cache_rows, 533 HsqlProperties.getMeta(hsqldb_cache_rows, SQL_PROPERTY, 534 50000, 100, 4 * 1024 * 1024)); dbMeta.put(hsqldb_cache_free_count, HsqlProperties.getMeta(hsqldb_cache_free_count, SQL_PROPERTY, 512, 0, 4096))535 dbMeta.put(hsqldb_cache_free_count, 536 HsqlProperties.getMeta(hsqldb_cache_free_count, 537 SQL_PROPERTY, 512, 0, 4096)); dbMeta.put(hsqldb_result_max_memory_rows, HsqlProperties.getMeta(hsqldb_result_max_memory_rows, SQL_PROPERTY, 0, 0, 4 * 1024 * 1024))538 dbMeta.put(hsqldb_result_max_memory_rows, 539 HsqlProperties.getMeta(hsqldb_result_max_memory_rows, 540 SQL_PROPERTY, 0, 0, 541 4 * 1024 * 1024)); dbMeta.put(hsqldb_nio_max_size, HsqlProperties.getMeta(hsqldb_nio_max_size, SQL_PROPERTY, 256, 64, 262144))542 dbMeta.put(hsqldb_nio_max_size, 543 HsqlProperties.getMeta(hsqldb_nio_max_size, SQL_PROPERTY, 544 256, 64, 262144)); dbMeta.put(hsqldb_min_reuse, HsqlProperties.getMeta(hsqldb_min_reuse, SQL_PROPERTY, 0, 0, 1024 * 1024))545 dbMeta.put(hsqldb_min_reuse, 546 HsqlProperties.getMeta(hsqldb_min_reuse, SQL_PROPERTY, 0, 547 0, 1024 * 1024)); 548 } 549 550 private Database database; 551 HsqlDatabaseProperties(Database db)552 public HsqlDatabaseProperties(Database db) { 553 554 super(dbMeta, db.getPath(), db.logger.getFileAccess(), 555 db.isFilesInJar()); 556 557 database = db; 558 559 setNewDatabaseProperties(); 560 } 561 setNewDatabaseProperties()562 void setNewDatabaseProperties() { 563 564 // version of a new database 565 setProperty(hsqldb_version, THIS_VERSION); 566 setProperty(hsqldb_modified, MODIFIED_NO_NEW); 567 568 // OOo related code 569 if (database.logger.isStoredFileAccess()) { 570 setProperty(hsqldb_cache_rows, 25000); 571 setProperty(hsqldb_cache_size, 6000); 572 setProperty(hsqldb_log_size, 10); 573 setProperty(sql_enforce_size, true); 574 setProperty(hsqldb_nio_data_file, false); 575 setProperty(hsqldb_lock_file, true); 576 setProperty(hsqldb_default_table_type, "cached"); 577 setProperty(jdbc_translate_tti_types, true); 578 } 579 580 // OOo end 581 } 582 583 /** 584 * Creates file with defaults if it didn't exist. 585 * Returns false if file already existed. 586 */ load()587 public boolean load() { 588 589 boolean exists; 590 591 if (!database.getType().isFileBased()) { 592 return true; 593 } 594 595 try { 596 exists = super.load(); 597 } catch (Throwable t) { 598 throw Error.error(t, ErrorCode.FILE_IO_ERROR, 599 ErrorCode.M_LOAD_SAVE_PROPERTIES, new Object[] { 600 t.toString(), fileName 601 }); 602 } 603 604 if (!exists) { 605 return false; 606 } 607 608 filterLoadedProperties(); 609 610 String version = getStringProperty(hsqldb_version); 611 int check = version.substring(0, 5).compareTo(VERSION_STRING_1_8_0); 612 613 // do not open early version databases 614 if (check < 0) { 615 throw Error.error(ErrorCode.WRONG_DATABASE_FILE_VERSION); 616 } 617 618 // do not open databases of 1.8 versions if script format is not compatible 619 if (check == 0) { 620 if (getIntegerProperty(hsqldb_script_format) != 0) { 621 throw Error.error(ErrorCode.WRONG_DATABASE_FILE_VERSION); 622 } 623 } 624 625 check = version.substring(0, 2).compareTo(THIS_VERSION); 626 627 // do not open if the database belongs to a later (future) version (3.x) 628 if (check > 0) { 629 throw Error.error(ErrorCode.WRONG_DATABASE_FILE_VERSION); 630 } 631 632 return true; 633 } 634 save()635 public void save() { 636 637 if (!database.getType().isFileBased() || database.isFilesReadOnly() 638 || database.isFilesInJar()) { 639 return; 640 } 641 642 try { 643 HsqlProperties props = new HsqlProperties(dbMeta, 644 database.getPath(), database.logger.getFileAccess(), false); 645 646 if (getIntegerProperty(hsqldb_script_format) == 3) { 647 props.setProperty(hsqldb_script_format, 3); 648 } 649 650 props.setProperty(hsqldb_version, THIS_VERSION); 651 props.setProperty( 652 tx_timestamp, 653 Long.toString(database.logger.getFilesTimestamp())); 654 655 if (database.logger.isStoredFileAccess()) { 656 if (!database.logger.isNewStoredFileAccess()) { 657 658 // when jar is used with embedded databases in AOO 3.4 and recent(2012) LO this 659 // line can be uncommented to circumvent hard-coded check in OOo code in 660 // drivers/hsqldb/HDriver.cxx 661 // props.setProperty(hsqldb_version, VERSION_STRING_1_8_0); 662 } 663 } 664 665 props.setProperty(hsqldb_modified, getProperty(hsqldb_modified)); 666 props.save(fileName + ".properties" + ".new"); 667 fa.renameElement(fileName + ".properties" + ".new", 668 fileName + ".properties"); 669 } catch (Throwable t) { 670 database.logger.logSevereEvent("save failed", t); 671 672 throw Error.error(t, ErrorCode.FILE_IO_ERROR, 673 ErrorCode.M_LOAD_SAVE_PROPERTIES, new Object[] { 674 t.toString(), fileName 675 }); 676 } 677 } 678 filterLoadedProperties()679 void filterLoadedProperties() { 680 681 String val = stringProps.getProperty(sql_enforce_strict_size); 682 683 if (val != null) { 684 stringProps.setProperty(sql_enforce_size, val); 685 } 686 687 Enumeration en = stringProps.propertyNames(); 688 689 while (en.hasMoreElements()) { 690 String key = (String) en.nextElement(); 691 boolean accept = dbMeta.containsKey(key); 692 693 if (!accept) { 694 stringProps.remove(key); 695 } 696 } 697 } 698 699 /** 700 * overload file database properties with any passed on URL line 701 * do not store password etc 702 */ setURLProperties(HsqlProperties p)703 public void setURLProperties(HsqlProperties p) { 704 705 boolean strict = false; 706 707 if (p == null) { 708 return; 709 } 710 711 String val = p.getProperty(sql_enforce_strict_size); 712 713 if (val != null) { 714 p.setProperty(sql_enforce_size, val); 715 p.removeProperty(sql_enforce_strict_size); 716 } 717 718 strict = p.isPropertyTrue(url_check_props, false); 719 720 for (Enumeration e = p.propertyNames(); e.hasMoreElements(); ) { 721 String propertyName = (String) e.nextElement(); 722 String propertyValue = p.getProperty(propertyName); 723 boolean valid = false; 724 boolean validVal = false; 725 String error = null; 726 Object[] meta = (Object[]) dbMeta.get(propertyName); 727 728 if (meta != null 729 && ((Integer) meta[HsqlProperties.indexType]).intValue() 730 == SQL_PROPERTY) { 731 valid = true; 732 error = HsqlProperties.validateProperty(propertyName, 733 propertyValue, meta); 734 validVal = error == null; 735 } 736 737 if (propertyName.startsWith("sql.") 738 || propertyName.startsWith("hsqldb.") 739 || propertyName.startsWith("textdb.")) { 740 if (strict && !valid) { 741 throw Error.error(ErrorCode.X_42555, propertyName); 742 } 743 744 if (strict && !validVal) { 745 throw Error.error(ErrorCode.X_42556, error); 746 } 747 } 748 } 749 750 for (Enumeration e = p.propertyNames(); e.hasMoreElements(); ) { 751 String propertyName = (String) e.nextElement(); 752 Object[] meta = (Object[]) dbMeta.get(propertyName); 753 754 if (meta != null 755 && ((Integer) meta[HsqlProperties.indexType]).intValue() 756 == SQL_PROPERTY) { 757 setDatabaseProperty(propertyName, p.getProperty(propertyName)); 758 } 759 } 760 } 761 getUserDefinedPropertyData()762 public Set getUserDefinedPropertyData() { 763 764 Set set = new HashSet(); 765 Iterator it = dbMeta.values().iterator(); 766 767 while (it.hasNext()) { 768 Object[] row = (Object[]) it.next(); 769 770 if (((Integer) row[HsqlProperties.indexType]).intValue() 771 == SQL_PROPERTY) { 772 set.add(row); 773 } 774 } 775 776 return set; 777 } 778 isUserDefinedProperty(String key)779 public boolean isUserDefinedProperty(String key) { 780 781 Object[] row = (Object[]) dbMeta.get(key); 782 783 return row != null 784 && ((Integer) row[HsqlProperties.indexType]).intValue() 785 == SQL_PROPERTY; 786 } 787 isBoolean(String key)788 public boolean isBoolean(String key) { 789 790 Object[] row = (Object[]) dbMeta.get(key); 791 792 return row != null && row[HsqlProperties.indexClass].equals("Boolean") 793 && ((Integer) row[HsqlProperties.indexType]).intValue() 794 == SQL_PROPERTY; 795 } 796 isIntegral(String key)797 public boolean isIntegral(String key) { 798 799 Object[] row = (Object[]) dbMeta.get(key); 800 801 return row != null && row[HsqlProperties.indexClass].equals("Integer") 802 && ((Integer) row[HsqlProperties.indexType]).intValue() 803 == SQL_PROPERTY; 804 } 805 isString(String key)806 public boolean isString(String key) { 807 808 Object[] row = (Object[]) dbMeta.get(key); 809 810 return row != null && row[HsqlProperties.indexClass].equals("String") 811 && ((Integer) row[HsqlProperties.indexType]).intValue() 812 == SQL_PROPERTY; 813 } 814 setDatabaseProperty(String key, String value)815 public boolean setDatabaseProperty(String key, String value) { 816 817 Object[] meta = (Object[]) dbMeta.get(key); 818 String error = HsqlProperties.validateProperty(key, value, meta); 819 820 if (error != null) { 821 return false; 822 } 823 824 stringProps.put(key, value); 825 826 return true; 827 } 828 getDefaultWriteDelay()829 public int getDefaultWriteDelay() { 830 831 // OOo related code 832 if (database.logger.isStoredFileAccess()) { 833 return 2000; 834 } 835 836 // OOo end 837 return 500; 838 } 839 setDBModified(int mode)840 public void setDBModified(int mode) { 841 842 String value; 843 844 switch (mode) { 845 846 case FILES_NOT_MODIFIED : 847 value = MODIFIED_NO; 848 break; 849 850 case FILES_MODIFIED : 851 value = MODIFIED_YES; 852 break; 853 854 case FILES_MODIFIED_NEW : 855 value = MODIFIED_YES_NEW; 856 break; 857 858 default : 859 throw Error.runtimeError(ErrorCode.U_S0500, 860 "HsqlDatabaseProperties"); 861 } 862 863 stringProps.put(hsqldb_modified, value); 864 save(); 865 } 866 getDBModified()867 public int getDBModified() { 868 869 String value = getStringProperty(hsqldb_modified); 870 871 if (MODIFIED_YES.equals(value)) { 872 return FILES_MODIFIED; 873 } else if (MODIFIED_YES_NEW.equals(value)) { 874 return FILES_MODIFIED_NEW; 875 } else if (MODIFIED_NO_NEW.equals(value)) { 876 return FILES_NEW; 877 } 878 879 return FILES_NOT_MODIFIED; 880 } 881 882 //----------------------- getProperty(String key)883 public String getProperty(String key) { 884 885 Object[] metaData = (Object[]) dbMeta.get(key); 886 887 if (metaData == null) { 888 throw Error.error(ErrorCode.X_42555, key); 889 } 890 891 return stringProps.getProperty(key); 892 } 893 894 /** for all types of property apart from system props */ getPropertyString(String key)895 public String getPropertyString(String key) { 896 897 Object[] metaData = (Object[]) dbMeta.get(key); 898 899 if (metaData == null) { 900 throw Error.error(ErrorCode.X_42555, key); 901 } 902 903 String prop = stringProps.getProperty(key); 904 boolean isSystem = 905 ((Integer) metaData[HsqlProperties.indexType]).intValue() 906 == SYSTEM_PROPERTY; 907 908 if (prop == null && isSystem) { 909 try { 910 prop = System.getProperty(key); 911 } catch (SecurityException e) {} 912 } 913 914 if (prop == null) { 915 Object value = metaData[HsqlProperties.indexDefaultValue]; 916 917 if (value == null) { 918 return null; 919 } 920 921 return String.valueOf(value); 922 } 923 924 return prop; 925 } 926 isPropertyTrue(String key)927 public boolean isPropertyTrue(String key) { 928 929 Boolean value; 930 Object[] metaData = (Object[]) dbMeta.get(key); 931 932 if (metaData == null) { 933 throw Error.error(ErrorCode.X_42555, key); 934 } 935 936 value = (Boolean) metaData[HsqlProperties.indexDefaultValue]; 937 938 String prop = null; 939 boolean isSystem = 940 ((Integer) metaData[HsqlProperties.indexType]).intValue() 941 == SYSTEM_PROPERTY; 942 943 if (isSystem) { 944 try { 945 prop = System.getProperty(key); 946 } catch (SecurityException e) {} 947 } else { 948 prop = stringProps.getProperty(key); 949 } 950 951 if (prop != null) { 952 value = Boolean.valueOf(prop); 953 } 954 955 return value.booleanValue(); 956 } 957 getStringPropertyDefault(String key)958 public String getStringPropertyDefault(String key) { 959 960 Object[] metaData = (Object[]) dbMeta.get(key); 961 962 if (metaData == null) { 963 throw Error.error(ErrorCode.X_42555, key); 964 } 965 966 return (String) metaData[HsqlProperties.indexDefaultValue]; 967 } 968 getStringProperty(String key)969 public String getStringProperty(String key) { 970 971 String value; 972 Object[] metaData = (Object[]) dbMeta.get(key); 973 974 if (metaData == null) { 975 throw Error.error(ErrorCode.X_42555, key); 976 } 977 978 value = (String) metaData[HsqlProperties.indexDefaultValue]; 979 980 String prop = stringProps.getProperty(key); 981 982 if (prop != null) { 983 value = prop; 984 } 985 986 return value; 987 } 988 getIntegerProperty(String key)989 public int getIntegerProperty(String key) { 990 991 int value; 992 Object[] metaData = (Object[]) dbMeta.get(key); 993 994 if (metaData == null) { 995 throw Error.error(ErrorCode.X_42555, key); 996 } 997 998 value = 999 ((Integer) metaData[HsqlProperties.indexDefaultValue]).intValue(); 1000 1001 String prop = stringProps.getProperty(key); 1002 1003 if (prop != null) { 1004 try { 1005 value = Integer.parseInt(prop); 1006 } catch (NumberFormatException e) {} 1007 } 1008 1009 return value; 1010 } 1011 getPropertiesMetaIterator()1012 public static Iterator getPropertiesMetaIterator() { 1013 return dbMeta.values().iterator(); 1014 } 1015 getClientPropertiesAsString()1016 public String getClientPropertiesAsString() { 1017 1018 if (isPropertyTrue(jdbc_translate_tti_types)) { 1019 StringBuffer sb = new StringBuffer(jdbc_translate_tti_types); 1020 1021 sb.append('=').append(true); 1022 1023 return sb.toString(); 1024 } 1025 1026 return ""; 1027 } 1028 isVersion18()1029 public boolean isVersion18() { 1030 1031 String version = 1032 getProperty(HsqlDatabaseProperties.hsqldb_cache_version, 1033 THIS_VERSION); 1034 1035 return version.substring(0, 4).equals("1.7."); 1036 } 1037 } 1038