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

--no commit message

--no commit message
上级 496327b2
#Tue Jul 24 08:17:27 CEST 2007 #Sun Jul 29 20:39:45 CEST 2007
javac=javac javac=javac
benchmark.drivers.dir=C\:/data/java benchmark.drivers.dir=C\:/data/java
path.servlet.jar=C\:/data/classpath/servlet-api.jar path.servlet.jar=C\:/data/classpath/servlet-api.jar
......
...@@ -47,15 +47,15 @@ ...@@ -47,15 +47,15 @@
</target> </target>
<target name="codeswitchPrepare"> <target name="codeswitchPrepare">
<javac executable="${javac}" srcdir="src/tools" debug="true" includes="org/h2/tools/code/CodeSwitch.java"/> <javac executable="${javac}" srcdir="src/tools" destdir="bin" debug="true" includes="org/h2/tools/code/CodeSwitch.java"/>
</target> </target>
<target name="codeswitchJdk13" depends="codeswitchPrepare"> <target name="codeswitchJdk13" depends="codeswitchPrepare">
<propertyfile file="ant-build.properties"> <propertyfile file="ant-build.properties">
<entry key="jdk" value="1.3" /> <entry key="jdk" value="1.3" />
</propertyfile> </propertyfile>
<java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="src/tools"> <java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="bin">
<arg line="+JDK13 -JDK14 -JDK16 ../main/org/h2"/> <arg line="+JDK13 -JDK14 -JDK16 ../src/main/org/h2"/>
</java> </java>
</target> </target>
...@@ -63,8 +63,8 @@ ...@@ -63,8 +63,8 @@
<propertyfile file="ant-build.properties"> <propertyfile file="ant-build.properties">
<entry key="jdk" value="1.4" /> <entry key="jdk" value="1.4" />
</propertyfile> </propertyfile>
<java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="src/tools"> <java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="bin">
<arg line="-JDK13 +JDK14 -JDK16 ../main/org/h2"/> <arg line="-JDK13 +JDK14 -JDK16 ../src/main/org/h2"/>
</java> </java>
</target> </target>
...@@ -72,8 +72,8 @@ ...@@ -72,8 +72,8 @@
<propertyfile file="ant-build.properties"> <propertyfile file="ant-build.properties">
<entry key="jdk" value="1.6" /> <entry key="jdk" value="1.6" />
</propertyfile> </propertyfile>
<java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="src/tools"> <java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="bin">
<arg line="-JDK13 +JDK16 +JDK14 ../main/org/h2"/> <arg line="-JDK13 +JDK16 +JDK14 ../src/main/org/h2"/>
</java> </java>
</target> </target>
......
...@@ -67,7 +67,7 @@ The version is currently 1.0.&lt;year&gt;&lt;month&gt;&lt;day&gt;. Example: ...@@ -67,7 +67,7 @@ The version is currently 1.0.&lt;year&gt;&lt;month&gt;&lt;day&gt;. Example:
&lt;dependency&gt; &lt;dependency&gt;
&lt;groupId&gt;com.h2database&lt;/groupId&gt; &lt;groupId&gt;com.h2database&lt;/groupId&gt;
&lt;artifactId&gt;h2&lt;/artifactId&gt; &lt;artifactId&gt;h2&lt;/artifactId&gt;
&lt;version&gt;1.0.20070429&lt;/version&gt; &lt;version&gt;1.0.20070617&lt;/version&gt;
&lt;/dependency&gt; &lt;/dependency&gt;
</pre> </pre>
......
...@@ -826,8 +826,9 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch. ...@@ -826,8 +826,9 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
</li><li>Better support large transactions, large updates / deletes: allow tables without primary key </li><li>Better support large transactions, large updates / deletes: allow tables without primary key
</li><li>Support Oracle RPAD and LPAD(string, n[, pad]) (truncate the end if longer) </li><li>Support Oracle RPAD and LPAD(string, n[, pad]) (truncate the end if longer)
</li><li>Allow editing NULL values in the Console </li><li>Allow editing NULL values in the Console
</li><li>Updatable result sets: DatabaseMetaData.ownUpdatesAreVisible = true. </li><li>Updatable result sets: DatabaseMetaData.ownUpdatesAreVisible = true (for insert, delete, update)
Simple solution: automatically calls 'refresh' when the result was changed. Simple solution: automatically calls 'refresh' when the result was changed.
Compare with other databases.
</li></ul> </li></ul>
<h3>Priority 2</h3> <h3>Priority 2</h3>
...@@ -1083,6 +1084,9 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch. ...@@ -1083,6 +1084,9 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
</li><li>Time based cache writing (one second after writing the log) </li><li>Time based cache writing (one second after writing the log)
</li><li>Write a H2 driver for http://db.apache.org/ddlutils/ </li><li>Write a H2 driver for http://db.apache.org/ddlutils/
</li><li>Index usage for REGEXP LIKE. </li><li>Index usage for REGEXP LIKE.
</li><li>Add a role DBA (like ADMIN).
</li><li>Automatic mode: jdbc:h2:auto: (embedded mode if possible, if not use server mode).
Problem: what to do when server stops while others are connected to it.
</li></ul> </li></ul>
<h3>Not Planned</h3> <h3>Not Planned</h3>
......
...@@ -383,20 +383,20 @@ The recommended way to upgrade from one version of the database engine to the ne ...@@ -383,20 +383,20 @@ The recommended way to upgrade from one version of the database engine to the ne
version is to create a backup of the database (in the form of a SQL script) using the old engine, version is to create a backup of the database (in the form of a SQL script) using the old engine,
and then execute the SQL script using the new engine. and then execute the SQL script using the new engine.
<h3>Backup</h3> <h3>Backup using the Script Tool</h3>
There are different ways to backup a database. For example, it is possible to copy the database files. There are different ways to backup a database. For example, it is possible to copy the database files.
However, this is not recommended while the database is in use. Also, the database files are not human readable However, this is not recommended while the database is in use. Also, the database files are not human readable
and quite large. The recommended way to backup a database is to create a compressed SQL script file. and quite large. The recommended way to backup a database is to create a compressed SQL script file.
This can be done using the backup tool: This can be done using the Script tool:
<pre> <pre>
java org.h2.tools.Backup -url jdbc:h2:~/test -user sa -script test.zip -options compression zip java org.h2.tools.Script -url jdbc:h2:~/test -user sa -script test.zip -options compression zip
</pre> </pre>
It is also possible to use the SQL command SCRIPT to create the backup of the database.
For more information about the options, see the SQL command SCRIPT. For more information about the options, see the SQL command SCRIPT.
The backup can be done remotely, however the file will be created on the server side. The backup can be done remotely, however the file will be created on the server side.
The built in FTP server could be used to retrieve the file from the server. The built in FTP server could be used to retrieve the file from the server.
It is also possible to use the SQL command SCRIPT to create the backup of the database.
<h3>Restore</h3> <h3>Restore from a Script</h3>
To restore a database from a SQL script file, you can use the RunScript tool: To restore a database from a SQL script file, you can use the RunScript tool:
<pre> <pre>
java org.h2.tools.RunScript -url jdbc:h2:~/test -user sa -script test.zip -options compression zip java org.h2.tools.RunScript -url jdbc:h2:~/test -user sa -script test.zip -options compression zip
...@@ -409,6 +409,19 @@ SQL script files may contain references to other script files, in the form of ...@@ -409,6 +409,19 @@ SQL script files may contain references to other script files, in the form of
RUNSCRIPT commands. However, when using the server mode, the references script files RUNSCRIPT commands. However, when using the server mode, the references script files
need to be available on the server side. need to be available on the server side.
<h3>Online Backup</h3>
The BACKUP SQL statement and the Backup tool both create a zip file
with all database files. However, the contents of this file are not human readable.
Other than the SCRIPT statement, the BACKUP statement does not lock the
database objects, and therefore does not block other users. The resulting
backup is transactionally consistent:
<pre>
BACKUP TO 'backup.zip'
</pre>
The Backup tool (org.h2.tools.Backup) can not be used to create a online backup;
the database must not be in use while running this program.
<br /><a name="open_office"></a> <br /><a name="open_office"></a>
<h2>Using OpenOffice Base</h2> <h2>Using OpenOffice Base</h2>
OpenOffice.org Base supports database access over the JDBC API. To connect to a H2 database OpenOffice.org Base supports database access over the JDBC API. To connect to a H2 database
......
...@@ -89,10 +89,6 @@ public class CommandRemote implements CommandInterface { ...@@ -89,10 +89,6 @@ public class CommandRemote implements CommandInterface {
transfer.writeInt(SessionRemote.COMMAND_GET_META_DATA).writeInt(id).writeInt(objectId); transfer.writeInt(SessionRemote.COMMAND_GET_META_DATA).writeInt(id).writeInt(objectId);
session.done(transfer); session.done(transfer);
int columnCount = transfer.readInt(); int columnCount = transfer.readInt();
if(result != null) {
result.close();
result = null;
}
result = new ResultRemote(session, transfer, objectId, columnCount, -1); result = new ResultRemote(session, transfer, objectId, columnCount, -1);
break; break;
} catch(IOException e) { } catch(IOException e) {
......
...@@ -17,11 +17,7 @@ import org.h2.message.TraceSystem; ...@@ -17,11 +17,7 @@ import org.h2.message.TraceSystem;
* - Update latest version in build.html: http://mirrors.ibiblio.org/pub/mirrors/maven2/com/h2database/h2/ * - Update latest version in build.html: http://mirrors.ibiblio.org/pub/mirrors/maven2/com/h2database/h2/
* - ant jarClient, check jar file size * - ant jarClient, check jar file size
* *
* - Compile with JDK 1.3, 1.4, 1.5 and 1.6: * - Compile with JDK 1.4, 1.5 and 1.6:
* set path=C:\jdk1.3.1_19\bin;%PATH%
* set JAVA_HOME=C:\jdk1.3.1_19
* ant codeswitchJdk13
* ant compile
* set path=C:\Programme\Java\jdk1.6.0\bin;%PATH% * set path=C:\Programme\Java\jdk1.6.0\bin;%PATH%
* set JAVA_HOME=C:\Programme\Java\jdk1.6.0 * set JAVA_HOME=C:\Programme\Java\jdk1.6.0
* ant codeswitchJdk16 * ant codeswitchJdk16
......
...@@ -9,7 +9,7 @@ import java.lang.ref.WeakReference; ...@@ -9,7 +9,7 @@ import java.lang.ref.WeakReference;
public class DatabaseCloser extends Thread { public class DatabaseCloser extends Thread {
private final boolean shutdownHook; private final boolean shutdownHook;
private WeakReference databaseRef; private volatile WeakReference databaseRef;
private int delayInMillis; private int delayInMillis;
DatabaseCloser(Database db, int delayInMillis, boolean shutdownHook) { DatabaseCloser(Database db, int delayInMillis, boolean shutdownHook) {
......
...@@ -94,7 +94,7 @@ public class Engine { ...@@ -94,7 +94,7 @@ public class Engine {
break; break;
} }
// we found a database that is currently closing // we found a database that is currently closing
// wait a bit to avoid a busy loop // wait a bit to avoid a busy loop (the method is synchronized)
try { try {
Thread.sleep(1); Thread.sleep(1);
} catch(InterruptedException e) { } catch(InterruptedException e) {
......
...@@ -45,9 +45,7 @@ public class ConditionNot extends Condition { ...@@ -45,9 +45,7 @@ public class ConditionNot extends Condition {
Expression expr = condition.optimize(session); Expression expr = condition.optimize(session);
Expression e2 = expr.getNotIfPossible(session); Expression e2 = expr.getNotIfPossible(session);
if(e2 != null) { if(e2 != null) {
e2 = e2.optimize(session); return e2.optimize(session);
expr = e2;
return e2;
} }
if(expr.isConstant()) { if(expr.isConstant()) {
Value v = expr.getValue(session); Value v = expr.getValue(session);
......
...@@ -29,6 +29,7 @@ import java.util.HashSet; ...@@ -29,6 +29,7 @@ import java.util.HashSet;
import java.util.Properties; import java.util.Properties;
import org.h2.Driver; import org.h2.Driver;
import org.h2.util.IOUtils;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.ObjectUtils; import org.h2.util.ObjectUtils;
import org.h2.util.ScriptReader; import org.h2.util.ScriptReader;
...@@ -325,13 +326,14 @@ public class PgServerThread implements Runnable { ...@@ -325,13 +326,14 @@ public class PgServerThread implements Runnable {
String query = readString(); String query = readString();
ScriptReader reader = new ScriptReader(new StringReader(query)); ScriptReader reader = new ScriptReader(new StringReader(query));
while(true) { while(true) {
Statement stat = null;
try { try {
String s = reader.readStatement(); String s = reader.readStatement();
if(s == null) { if(s == null) {
break; break;
} }
s = getSQL(s); s = getSQL(s);
Statement stat = conn.createStatement(); stat = conn.createStatement();
boolean result = stat.execute(s); boolean result = stat.execute(s);
if(result) { if(result) {
ResultSet rs = stat.getResultSet(); ResultSet rs = stat.getResultSet();
...@@ -346,6 +348,8 @@ public class PgServerThread implements Runnable { ...@@ -346,6 +348,8 @@ public class PgServerThread implements Runnable {
} }
} catch(SQLException e) { } catch(SQLException e) {
sendErrorResponse(e); sendErrorResponse(e);
} finally {
JdbcUtils.closeSilently(stat);
} }
} }
sendReadyForQuery(); sendReadyForQuery();
...@@ -568,33 +572,41 @@ public class PgServerThread implements Runnable { ...@@ -568,33 +572,41 @@ public class PgServerThread implements Runnable {
} }
private void initDb() throws SQLException { private void initDb() throws SQLException {
ResultSet rs = conn.getMetaData().getTables(null, "PG_CATALOG", "PG_VERSION", null); Statement stat = null;
boolean tableFound = rs.next(); ResultSet rs = null;
Statement stat = conn.createStatement(); Reader r = null;
if(tableFound) { try {
rs = stat.executeQuery("SELECT VERION FROM PG_CATALOG.PG_VERSION"); rs = conn.getMetaData().getTables(null, "PG_CATALOG", "PG_VERSION", null);
if(rs.next()) { boolean tableFound = rs.next();
if(rs.getInt(1) == 1) { stat = conn.createStatement();
// already installed if(tableFound) {
return; rs = stat.executeQuery("SELECT VERION FROM PG_CATALOG.PG_VERSION");
if(rs.next()) {
if(rs.getInt(1) == 1) {
// already installed
return;
}
} }
} }
} r = new InputStreamReader(getClass().getResourceAsStream("pg_catalog.sql"));
Reader r = new InputStreamReader(getClass().getResourceAsStream("pg_catalog.sql")); ScriptReader reader = new ScriptReader(new BufferedReader(r));
r = new BufferedReader(r); while(true) {
ScriptReader reader = new ScriptReader(r); String sql = reader.readStatement();
while(true) { if(sql == null) {
String sql = reader.readStatement(); break;
if(sql == null) { }
break; stat.execute(sql);
} }
stat.execute(sql); reader.close();
}
reader.close(); rs = stat.executeQuery("SELECT OID FROM PG_CATALOG.PG_TYPE");
while(rs.next()) {
rs = stat.executeQuery("SELECT OID FROM PG_CATALOG.PG_TYPE"); types.add(ObjectUtils.getInteger(rs.getInt(1)));
while(rs.next()) { }
types.add(ObjectUtils.getInteger(rs.getInt(1))); } finally {
JdbcUtils.closeSilently(stat);
JdbcUtils.closeSilently(rs);
IOUtils.closeSilently(r);
} }
} }
......
...@@ -252,7 +252,7 @@ public class CacheLRU implements Cache { ...@@ -252,7 +252,7 @@ public class CacheLRU implements Cache {
public void setMaxSize(int maxKb) throws SQLException { public void setMaxSize(int maxKb) throws SQLException {
int newSize = maxKb * 1024 / 4; int newSize = maxKb * 1024 / 4;
newSize = newSize < 0 ? 0 : newSize; maxSize = newSize < 0 ? 0 : newSize;
// can not resize, otherwise existing records are lost // can not resize, otherwise existing records are lost
// resize(maxSize); // resize(maxSize);
removeOldIfRequired(); removeOldIfRequired();
......
...@@ -437,7 +437,7 @@ public class DataType { ...@@ -437,7 +437,7 @@ public class DataType {
for(int i=0; i<list.length; i++) { for(int i=0; i<list.length; i++) {
values[i] = DataType.convertToValue(session, list[i], Value.NULL); values[i] = DataType.convertToValue(session, list[i], Value.NULL);
} }
v = array ==null ? (Value)ValueNull.INSTANCE : ValueArray.get(values); v = ValueArray.get(values);
break; break;
} }
default: default:
......
...@@ -94,6 +94,30 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2 ...@@ -94,6 +94,30 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
/* /*
Hi!
Openfire server uses this script to setup a user permissions
on the fresh-installed server. The database is [current] HSQLDB :
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
CREATE USER SA PASSWORD ""
GRANT DBA TO SA
SET SCHEMA PUBLIC
Unfortunately, this does not work (first string has a different semantic)
on the H2...
Wrong user name or password [08004-55]
Could you please correct documentation ?
Tutorial --> Upgrade, Backup, and Restore --> Backup
The documentation states :
java org.h2.tools.Backup -url jdbc:h2:~/test -user sa -script test.zip -options compression zip
The "tools.Backup" has no such options ! Seems you meant "tools.Script"
[root@ftp bin]# java -cp "h2.jar" org.h2.tools.Backup -help
java org.h2.tools.Backup [-file <filename>] [-dir <dir>] [-db <database>] [-quiet]
=
Could you please cross-link this topic with
Features --> Database File Layout --> Backup
=
What is the difference between "SCRIPT" and "BACKUP" statements ?
merge html-ja merge html-ja
rename Performance > Comparison [/Compatibility] rename Performance > Comparison [/Compatibility]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论