提交 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
benchmark.drivers.dir=C\:/data/java
path.servlet.jar=C\:/data/classpath/servlet-api.jar
......
......@@ -47,15 +47,15 @@
</target>
<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 name="codeswitchJdk13" depends="codeswitchPrepare">
<propertyfile file="ant-build.properties">
<entry key="jdk" value="1.3" />
</propertyfile>
<java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="src/tools">
<arg line="+JDK13 -JDK14 -JDK16 ../main/org/h2"/>
<java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="bin">
<arg line="+JDK13 -JDK14 -JDK16 ../src/main/org/h2"/>
</java>
</target>
......@@ -63,8 +63,8 @@
<propertyfile file="ant-build.properties">
<entry key="jdk" value="1.4" />
</propertyfile>
<java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="src/tools">
<arg line="-JDK13 +JDK14 -JDK16 ../main/org/h2"/>
<java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="bin">
<arg line="-JDK13 +JDK14 -JDK16 ../src/main/org/h2"/>
</java>
</target>
......@@ -72,8 +72,8 @@
<propertyfile file="ant-build.properties">
<entry key="jdk" value="1.6" />
</propertyfile>
<java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="src/tools">
<arg line="-JDK13 +JDK16 +JDK14 ../main/org/h2"/>
<java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="bin">
<arg line="-JDK13 +JDK16 +JDK14 ../src/main/org/h2"/>
</java>
</target>
......
......@@ -67,7 +67,7 @@ The version is currently 1.0.&lt;year&gt;&lt;month&gt;&lt;day&gt;. Example:
&lt;dependency&gt;
&lt;groupId&gt;com.h2database&lt;/groupId&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;
</pre>
......
......@@ -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>Support Oracle RPAD and LPAD(string, n[, pad]) (truncate the end if longer)
</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.
Compare with other databases.
</li></ul>
<h3>Priority 2</h3>
......@@ -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>Write a H2 driver for http://db.apache.org/ddlutils/
</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>
<h3>Not Planned</h3>
......
......@@ -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,
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.
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.
This can be done using the backup tool:
This can be done using the Script tool:
<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>
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.
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.
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:
<pre>
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
RUNSCRIPT commands. However, when using the server mode, the references script files
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>
<h2>Using OpenOffice Base</h2>
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 {
transfer.writeInt(SessionRemote.COMMAND_GET_META_DATA).writeInt(id).writeInt(objectId);
session.done(transfer);
int columnCount = transfer.readInt();
if(result != null) {
result.close();
result = null;
}
result = new ResultRemote(session, transfer, objectId, columnCount, -1);
break;
} catch(IOException e) {
......
......@@ -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/
* - ant jarClient, check jar file size
*
* - Compile with JDK 1.3, 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
* - Compile with JDK 1.4, 1.5 and 1.6:
* set path=C:\Programme\Java\jdk1.6.0\bin;%PATH%
* set JAVA_HOME=C:\Programme\Java\jdk1.6.0
* ant codeswitchJdk16
......
......@@ -9,7 +9,7 @@ import java.lang.ref.WeakReference;
public class DatabaseCloser extends Thread {
private final boolean shutdownHook;
private WeakReference databaseRef;
private volatile WeakReference databaseRef;
private int delayInMillis;
DatabaseCloser(Database db, int delayInMillis, boolean shutdownHook) {
......
......@@ -94,7 +94,7 @@ public class Engine {
break;
}
// 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 {
Thread.sleep(1);
} catch(InterruptedException e) {
......
......@@ -45,9 +45,7 @@ public class ConditionNot extends Condition {
Expression expr = condition.optimize(session);
Expression e2 = expr.getNotIfPossible(session);
if(e2 != null) {
e2 = e2.optimize(session);
expr = e2;
return e2;
return e2.optimize(session);
}
if(expr.isConstant()) {
Value v = expr.getValue(session);
......
......@@ -29,6 +29,7 @@ import java.util.HashSet;
import java.util.Properties;
import org.h2.Driver;
import org.h2.util.IOUtils;
import org.h2.util.JdbcUtils;
import org.h2.util.ObjectUtils;
import org.h2.util.ScriptReader;
......@@ -325,13 +326,14 @@ public class PgServerThread implements Runnable {
String query = readString();
ScriptReader reader = new ScriptReader(new StringReader(query));
while(true) {
Statement stat = null;
try {
String s = reader.readStatement();
if(s == null) {
break;
}
s = getSQL(s);
Statement stat = conn.createStatement();
stat = conn.createStatement();
boolean result = stat.execute(s);
if(result) {
ResultSet rs = stat.getResultSet();
......@@ -346,6 +348,8 @@ public class PgServerThread implements Runnable {
}
} catch(SQLException e) {
sendErrorResponse(e);
} finally {
JdbcUtils.closeSilently(stat);
}
}
sendReadyForQuery();
......@@ -568,33 +572,41 @@ public class PgServerThread implements Runnable {
}
private void initDb() throws SQLException {
ResultSet rs = conn.getMetaData().getTables(null, "PG_CATALOG", "PG_VERSION", null);
boolean tableFound = rs.next();
Statement stat = conn.createStatement();
if(tableFound) {
rs = stat.executeQuery("SELECT VERION FROM PG_CATALOG.PG_VERSION");
if(rs.next()) {
if(rs.getInt(1) == 1) {
// already installed
return;
Statement stat = null;
ResultSet rs = null;
Reader r = null;
try {
rs = conn.getMetaData().getTables(null, "PG_CATALOG", "PG_VERSION", null);
boolean tableFound = rs.next();
stat = conn.createStatement();
if(tableFound) {
rs = stat.executeQuery("SELECT VERION FROM PG_CATALOG.PG_VERSION");
if(rs.next()) {
if(rs.getInt(1) == 1) {
// already installed
return;
}
}
}
}
Reader r = new InputStreamReader(getClass().getResourceAsStream("pg_catalog.sql"));
r = new BufferedReader(r);
ScriptReader reader = new ScriptReader(r);
while(true) {
String sql = reader.readStatement();
if(sql == null) {
break;
r = new InputStreamReader(getClass().getResourceAsStream("pg_catalog.sql"));
ScriptReader reader = new ScriptReader(new BufferedReader(r));
while(true) {
String sql = reader.readStatement();
if(sql == null) {
break;
}
stat.execute(sql);
}
stat.execute(sql);
}
reader.close();
rs = stat.executeQuery("SELECT OID FROM PG_CATALOG.PG_TYPE");
while(rs.next()) {
types.add(ObjectUtils.getInteger(rs.getInt(1)));
reader.close();
rs = stat.executeQuery("SELECT OID FROM PG_CATALOG.PG_TYPE");
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 {
public void setMaxSize(int maxKb) throws SQLException {
int newSize = maxKb * 1024 / 4;
newSize = newSize < 0 ? 0 : newSize;
maxSize = newSize < 0 ? 0 : newSize;
// can not resize, otherwise existing records are lost
// resize(maxSize);
removeOldIfRequired();
......
......@@ -437,7 +437,7 @@ public class DataType {
for(int i=0; i<list.length; i++) {
values[i] = DataType.convertToValue(session, list[i], Value.NULL);
}
v = array ==null ? (Value)ValueNull.INSTANCE : ValueArray.get(values);
v = ValueArray.get(values);
break;
}
default:
......
......@@ -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
rename Performance > Comparison [/Compatibility]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论