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

The H2 JDBC client can now be used in an unsigned Applet. The problem was that…

The H2 JDBC client can now be used in an unsigned Applet. The problem was that System.getProperty throws a SecurityException, which is now ignored.
上级 91fad8b1
......@@ -17,13 +17,30 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>Issue 308: Statement.getGeneratedKeys() now returns an empty result set if no key was generated.
<ul><li>The H2 JDBC client can now be used in an unsigned Applet.
The problem was that System.getProperty throws a SecurityException, which is now ignored.
</li><li>The condition "in(select ...)" did not work correctly if the subquery
could not be converted to a "distinct" query, as in:
"select * from dual where x in (select x from dual group by x order by max(x))".
</li><li>In the last release, the error code for "Wrong user name or password" was still
08004 instead of 28000, which resulted in the wrong error message.
</li><li>In some cases, creating a new table or altering an existing table threw the exception:
Unique index or primary key violation: "PRIMARY KEY ON """".PAGE_INDEX".
</li><li>The Shell tool no longer supports the built-in command "show",
because it is a legal SQL statement for H2 and MySQL.
However, the "describe" command is still supported, and now lists all tables
if called without parameter.
</li><li>The sorted insert mode (as in "insert into ... direct sorted select")
did not work for not-persisted tables in a persisted database.
It threw a ClassCastException.
</li><li>Issue 308: Statement.getGeneratedKeys() now returns an empty result set if no key was generated.
</li><li>The h2small.jar (created with build jarSmall) included the Android API.
This has been removed, shrinking the jar file by 21 KB.
</li><li>When creating a table, the precision must now be at least as large as the scale.
</li><li>Support for Java 1.3 and Java 1.4 has been removed.
</li><li>Improved error message for syntax error: the list of expected tokens was sometimes not set correctly.
</li><li>Files do not grow more than 128 pages. For large databases, 20% was too much.
</li><li>Database file growth can now be limited using the database setting PAGE_STORE_MAX_GROWTH.
Slower growth may slow down operation, but speed up closing database.
</li></ul>
<h2>Version 1.3.154 (2011-04-04)</h2>
......
......@@ -9,6 +9,7 @@ package org.h2.engine;
import java.util.HashMap;
import org.h2.constant.ErrorCode;
import org.h2.message.DbException;
import org.h2.util.Utils;
/**
* The base class for settings.
......@@ -75,7 +76,7 @@ public class SettingsBase {
String sysProperty = buff.toString();
String v = settings.get(key);
if (v == null) {
v = System.getProperty(sysProperty, defaultValue);
v = Utils.getProperty(sysProperty, defaultValue);
settings.put(key, v);
}
return v;
......
......@@ -37,6 +37,7 @@ import org.h2.util.JdbcUtils;
import org.h2.util.New;
import org.h2.util.StatementBuilder;
import org.h2.util.StringUtils;
import org.h2.util.Utils;
/*## LUCENE2 begin ##
import org.apache.lucene.index.IndexModifier;
import org.apache.lucene.search.Hits;
......@@ -60,7 +61,7 @@ public class FullTextLucene extends FullText {
/**
* Whether the text content should be stored in the Lucene index.
*/
protected static final boolean STORE_DOCUMENT_TEXT_IN_INDEX = Boolean.getBoolean("h2.storeDocumentTextInIndex");
protected static final boolean STORE_DOCUMENT_TEXT_IN_INDEX = Utils.getProperty("h2.storeDocumentTextInIndex", false);
private static final HashMap<String, IndexAccess> INDEX_ACCESS = New.hashMap();
private static final String TRIGGER_PREFIX = "FTL_";
......
......@@ -21,6 +21,7 @@ import org.h2.constant.SysProperties;
import org.h2.message.DbException;
import org.h2.util.IOUtils;
import org.h2.util.StringUtils;
import org.h2.util.Utils;
/**
* This file system stores files on disk.
......@@ -166,7 +167,7 @@ public class FileSystemDisk extends FileSystem {
String prefix = new File(name).getName();
File dir;
if (inTempDir) {
dir = new File(System.getProperty("java.io.tmpdir"));
dir = new File(Utils.getProperty("java.io.tmpdir", "."));
} else {
dir = new File(name).getAbsoluteFile().getParentFile();
IOUtils.mkdirs(dir);
......
......@@ -18,7 +18,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import org.h2.command.Command;
import org.h2.constant.SysProperties;
import org.h2.constraint.Constraint;
import org.h2.constraint.ConstraintCheck;
import org.h2.constraint.ConstraintReferential;
......@@ -861,7 +860,7 @@ public class MetaTable extends Table {
"user.country", "user.language", "user.variant", "file.encoding"
};
for (String s : settings) {
add(rows, "property." + s, SysProperties.getStringSetting(s, ""));
add(rows, "property." + s, Utils.getProperty(s, ""));
}
}
add(rows, "EXCLUSIVE", database.getExclusiveSession() == null ? "FALSE" : "TRUE");
......
......@@ -32,7 +32,6 @@ import java.awt.event.WindowListener;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import org.h2.constant.SysProperties;
import org.h2.server.ShutdownHandler;
import org.h2.util.JdbcUtils;
import org.h2.util.Tool;
......@@ -109,7 +108,7 @@ ShutdownHandler {
* @param args the command line arguments
*/
public void runTool(String... args) throws SQLException {
isWindows = SysProperties.getStringSetting("os.name", "").startsWith("Windows");
isWindows = Utils.getProperty("os.name", "").startsWith("Windows");
boolean tcpStart = false, pgStart = false, webStart = false, toolStart = false;
boolean browserStart = false;
boolean startDefaultServers = true;
......
......@@ -488,9 +488,9 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
*/
public static void openBrowser(String url) throws Exception {
try {
String osName = SysProperties.getStringSetting("os.name", "linux").toLowerCase();
String osName = Utils.getProperty("os.name", "linux").toLowerCase();
Runtime rt = Runtime.getRuntime();
String browser = System.getProperty(SysProperties.H2_BROWSER);
String browser = Utils.getProperty(SysProperties.H2_BROWSER, null);
if (browser != null) {
if (browser.startsWith("call:")) {
browser = browser.substring("call:".length());
......
......@@ -115,7 +115,7 @@ public class DbUpgrade {
String script = null;
try {
if (scriptInTempDir) {
new File(System.getProperty("java.io.tmpdir")).mkdirs();
new File(Utils.getProperty("java.io.tmpdir", ".")).mkdirs();
script = File.createTempFile("h2dbmigration", "backup.sql").getAbsolutePath();
} else {
script = name + ".script.sql";
......
......@@ -168,7 +168,7 @@ public class CacheLRU implements Cache {
} else {
// can't remove any record, because the records can not be removed
// hopefully this does not happen frequently, but it can happen
writer.getTrace().info("Cannot remove records, cache size too small? records:" + recordCount + " memory:" + memory);
writer.getTrace().info("cannot remove records, cache size too small? records:" + recordCount + " memory:" + memory);
break;
}
}
......
......@@ -39,7 +39,7 @@ public class SourceCompiler {
*/
HashMap<String, Class<?>> compiled = New.hashMap();
private String compileDir = System.getProperty("java.io.tmpdir");
private String compileDir = Utils.getProperty("java.io.tmpdir", ".");
static {
Class<?> clazz;
......
......@@ -650,4 +650,60 @@ public class Utils {
return clazz;
}
/**
* Get the system property. If the system property is not set, or if a
* security exception occurs, the default value is returned.
*
* @param key the key
* @param defaultValue the default value
* @return the value
*/
public static String getProperty(String key, String defaultValue) {
try {
return System.getProperty(key, defaultValue);
} catch (SecurityException se) {
return defaultValue;
}
}
/**
* Get the system property. If the system property is not set, or if a
* security exception occurs, the default value is returned.
*
* @param key the key
* @param defaultValue the default value
* @return the value
*/
public static int getProperty(String key, int defaultValue) {
String s = getProperty(key, null);
if (s != null) {
try {
return Integer.decode(s).intValue();
} catch (NumberFormatException e) {
// ignore
}
}
return defaultValue;
}
/**
* Get the system property. If the system property is not set, or if a
* security exception occurs, the default value is returned.
*
* @param key the key
* @param defaultValue the default value
* @return the value
*/
public static boolean getProperty(String key, boolean defaultValue) {
String s = getProperty(key, null);
if (s != null) {
try {
return Boolean.valueOf(s).booleanValue();
} catch (NumberFormatException e) {
// ignore
}
}
return defaultValue;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论