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

--no commit message

--no commit message
上级 78e7ad72
@echo off
if exist bin/org/h2/build/Build.class goto buildOK
if not exist bin mkdir bin
javac -sourcepath src/tools -d bin src/tools/org/h2/build/*.java
:buildOK
java -cp "bin;target;%JAVA_HOME%/lib/tools.jar" org.h2.build.Build %1
\ No newline at end of file
...@@ -44,20 +44,8 @@ ...@@ -44,20 +44,8 @@
</delete> </delete>
</target> </target>
<target name="compileResources" depends="clean"> <target name="compile" depends="switchSourceAuto, resources, downloadServletJar, downloadLuceneJar">
<javac executable="${javac}" srcdir="src/main" destdir="bin" debug="true" includes="org/h2/util/Resources.java"/> <javac executable="${javac}" destdir="bin" debug="true" debuglevel="lines,source" >
<java classname="org.h2.util.Resources" classpath="bin"/>
<delete>
<fileset dir="bin" includes="org/h2/util/ResourceData.class"/>
</delete>
<javac executable="${javac}" srcdir="bin" destdir="bin" debug="true" includes="org/h2/util/ResourceData.java"/>
<delete>
<fileset dir="bin" includes="org/h2/util/ResourceData.java"/>
</delete>
</target>
<target name="compile" depends="compileResources, switchSourceAuto, downloadServletJar, downloadLuceneJar">
<javac executable="${javac}" destdir="bin" debug="true">
<classpath location="ext/servlet-api-2.4.jar" /> <classpath location="ext/servlet-api-2.4.jar" />
<classpath location="ext/lucene-core-2.2.0.jar" /> <classpath location="ext/lucene-core-2.2.0.jar" />
<src path="src/main"/> <src path="src/main"/>
...@@ -65,13 +53,9 @@ ...@@ -65,13 +53,9 @@
<src path="src/tools"/> <src path="src/tools"/>
</javac> </javac>
<copy todir="bin" overwrite="true"> <copy todir="bin" overwrite="true">
<fileset dir="src/main" includes="META-INF/**/*"/> <fileset dir="src/main" includes="META-INF/services/*"/>
<fileset dir="src/main" includes="**/*.png"/>
<fileset dir="src/main" includes="**/*.sql"/>
<fileset dir="src/installer" includes="*.bat"/> <fileset dir="src/installer" includes="*.bat"/>
<fileset dir="src/test" includes="**/*.txt"/> <fileset dir="src/test" excludes="**/*.java,**/package.html"/>
<fileset dir="src/test" includes="**/*.sql"/>
<fileset dir="src/test" includes="**/*.properties"/>
</copy> </copy>
</target> </target>
...@@ -82,7 +66,7 @@ ...@@ -82,7 +66,7 @@
<java classname="org.h2.test.coverage.Coverage" classpath="." dir="bin" fork="true"> <java classname="org.h2.test.coverage.Coverage" classpath="." dir="bin" fork="true">
<arg line="-r org/h2"/> <arg line="-r org/h2"/>
</java> </java>
<javac executable="${javac}" srcdir="bin" destdir="bin" debug="true" includes="org/h2/**"/> <javac executable="${javac}" srcdir="bin" destdir="bin" debug="true" debuglevel="lines,source" includes="org/h2/**"/>
</target> </target>
<target name="docs" depends="clean, javadoc, compile"> <target name="docs" depends="clean, javadoc, compile">
...@@ -132,8 +116,8 @@ ...@@ -132,8 +116,8 @@
</jar> </jar>
</target> </target>
<target name="jarClient" depends="compileResources, manifest"> <target name="jarClient" depends="resources, manifest">
<javac executable="${javac}" srcdir="src/main" destdir="bin" debug="true"> <javac executable="${javac}" srcdir="src/main" destdir="bin" debug="true" debuglevel="lines,source">
<include name="org/h2/*" /> <include name="org/h2/*" />
<include name="org/h2/jdbc/**" /> <include name="org/h2/jdbc/**" />
<include name="org/h2/jdbcx/**" /> <include name="org/h2/jdbcx/**" />
...@@ -144,7 +128,7 @@ ...@@ -144,7 +128,7 @@
</jar> </jar>
</target> </target>
<target name="jarDb" depends="compileResources, manifest"> <target name="jarDb" depends="resources, manifest">
<javac executable="${javac}" srcdir="src/main" destdir="bin" debug="false"> <javac executable="${javac}" srcdir="src/main" destdir="bin" debug="false">
<include name="org/h2/*" /> <include name="org/h2/*" />
<include name="org/h2/engine/**" /> <include name="org/h2/engine/**" />
...@@ -158,9 +142,9 @@ ...@@ -158,9 +142,9 @@
</target> </target>
<target name="javadoc"> <target name="javadoc">
<javac executable="${javac}" srcdir="src/main" destdir="bin" debug="true" includes="org/h2/util/StringUtils.java"/> <javac executable="${javac}" srcdir="src/main" destdir="bin" debug="true" debuglevel="lines,source" includes="org/h2/util/StringUtils.java"/>
<javac executable="${javac}" srcdir="src/test" destdir="bin" debug="true" includes="org/h2/test/bnf/*.java"/> <javac executable="${javac}" srcdir="src/test" destdir="bin" debug="true" debuglevel="lines,source" includes="org/h2/test/bnf/*.java"/>
<javac executable="${javac}" srcdir="src/tools" destdir="bin" debug="true" includes="org/h2/build/doclet/*.java"/> <javac executable="${javac}" srcdir="src/tools" destdir="bin" debug="true" debuglevel="lines,source" includes="org/h2/build/doclet/*.java"/>
<mkdir dir="docs/javadoc"/> <mkdir dir="docs/javadoc"/>
<javadoc <javadoc
sourcepath="src/main" sourcepath="src/main"
...@@ -240,8 +224,16 @@ ...@@ -240,8 +224,16 @@
</exec> </exec>
</target> </target>
<target name="resources" depends="clean">
<mkdir dir="bin/org/h2/util"/>
<zip destfile="bin/org/h2/util/data.zip"
basedir="src/main"
compress="false"
excludes="**/*.java,**/package.html,**/java.sql.Driver" />
</target>
<target name="switchSourcePrepare" depends="clean"> <target name="switchSourcePrepare" depends="clean">
<javac executable="${javac}" srcdir="src/tools" destdir="bin" debug="true" includes="org/h2/build/code/SwitchSource.java"/> <javac executable="${javac}" srcdir="src/tools" destdir="bin" debug="true" debuglevel="lines,source" includes="org/h2/build/code/SwitchSource.java"/>
</target> </target>
<target name="switchSourceAndroid" depends="switchSourcePrepare"> <target name="switchSourceAndroid" depends="switchSourcePrepare">
......
...@@ -76,6 +76,10 @@ After installing, you should get the following directory structure: ...@@ -76,6 +76,10 @@ After installing, you should get the following directory structure:
<td>docs/javadoc</td> <td>docs/javadoc</td>
<td>Javadoc files</td> <td>Javadoc files</td>
</tr> </tr>
<tr>
<td>ext</td>
<td>External dependencies (downloaded when building)</td>
</tr>
<tr> <tr>
<td>service</td> <td>service</td>
<td>Tools to run the database as a Windows Service</td> <td>Tools to run the database as a Windows Service</td>
......
...@@ -12,7 +12,7 @@ Initial Developer: H2 Group ...@@ -12,7 +12,7 @@ Initial Developer: H2 Group
<script type="text/javascript" src="search.js"></script> <script type="text/javascript" src="search.js"></script>
<script type="text/javascript" src="navigation.js"></script> <script type="text/javascript" src="navigation.js"></script>
</head> </head>
<body style="margin: 10px 0px 0px 0px;" onload="frameMe('menu');"> <body style="margin: 10px 0px 0px 4px;" onload="frameMe('menu');">
<div class="menu"> <div class="menu">
<img border="0" src="images/h2-logo.png" alt="H2 Logo" onclick="document.location='main.html'" /> <img border="0" src="images/h2-logo.png" alt="H2 Logo" onclick="document.location='main.html'" />
......
...@@ -413,13 +413,16 @@ SELECT * FROM CSVREAD('test.csv'); ...@@ -413,13 +413,16 @@ SELECT * FROM CSVREAD('test.csv');
The CSV tool can be used in a Java application even when not using a database at all. The CSV tool can be used in a Java application even when not using a database at all.
Example: Example:
<pre> <pre>
import org.h2.tools.Csv;
import org.h2.tools.SimpleResultSet;
...
SimpleResultSet rs = new SimpleResultSet(); SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("NAME", Types.VARCHAR, 255, 0); rs.addColumn("NAME", Types.VARCHAR, 255, 0);
rs.addColumn("EMAIL", Types.VARCHAR, 255, 0); rs.addColumn("EMAIL", Types.VARCHAR, 255, 0);
rs.addColumn("PHONE", Types.VARCHAR, 255, 0); rs.addColumn("PHONE", Types.VARCHAR, 255, 0);
rs.addRow(new String[]{"Bob Meier", "bob.meier@abcde.abc", "+41123456789"}); rs.addRow(new String[] { "Bob Meier", "bob.meier@abcde.abc", "+41123456789" });
rs.addRow(new String[]{"John Jones", "john.jones@abcde.abc", "+41976543210"}); rs.addRow(new String[] { "John Jones", "john.jones@abcde.abc", "+41976543210" });
Csv.write("test.csv", rs, null); Csv.getInstance().write("data/test.csv", rs, null);
</pre> </pre>
</p> </p>
...@@ -428,11 +431,13 @@ Csv.write("test.csv", rs, null); ...@@ -428,11 +431,13 @@ Csv.write("test.csv", rs, null);
It is possible to read a CSV file without opening a database. It is possible to read a CSV file without opening a database.
Example: Example:
<pre> <pre>
ResultSet rs = Csv.read("test.csv", null, null); import org.h2.tools.Csv;
...
ResultSet rs = Csv.getInstance().read("data/test.csv", null, null);
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
while(rs.next()) { while (rs.next()) {
for(int i=0; i&lt;meta.getColumnCount(); i++) { for (int i = 0; i &lt; meta.getColumnCount(); i++) {
System.out.println(meta.getColumnLabel(i+1) + ": " + rs.getString(i+1)); System.out.println(meta.getColumnLabel(i + 1) + ": " + rs.getString(i + 1));
} }
System.out.println(); System.out.println();
} }
......
Manifest-Version: 1.0
Implementation-Title: H2 Database Engine
Implementation-URL: http://www.h2database.com
Implementation-Version: ${version}
Build-Jdk: ${buildJdk}
Created-By: ${createdBy}
${mainClassTag}
...@@ -150,6 +150,7 @@ public class BackupCommand extends Prepared { ...@@ -150,6 +150,7 @@ public class BackupCommand extends Prepared {
} }
return f; return f;
} }
public boolean needRecompile() { public boolean needRecompile() {
return false; return false;
} }
......
...@@ -88,6 +88,8 @@ public class Constants { ...@@ -88,6 +88,8 @@ public class Constants {
public static final int VERSION_MAJOR = 1; public static final int VERSION_MAJOR = 1;
public static final int VERSION_MINOR = 0; public static final int VERSION_MINOR = 0;
public static final String VERSION = VERSION_MAJOR + "." + VERSION_MINOR + "." + BUILD_ID;
public static final int FILE_BLOCK_SIZE = 16; public static final int FILE_BLOCK_SIZE = 16;
public static final String MAGIC_FILE_HEADER_TEXT = "-- H2 0.5/T -- ".substring(0, FILE_BLOCK_SIZE - 1) + "\n"; public static final String MAGIC_FILE_HEADER_TEXT = "-- H2 0.5/T -- ".substring(0, FILE_BLOCK_SIZE - 1) + "\n";
public static final String MAGIC_FILE_HEADER = "-- H2 0.5/B -- ".substring(0, FILE_BLOCK_SIZE - 1) + "\n"; public static final String MAGIC_FILE_HEADER = "-- H2 0.5/B -- ".substring(0, FILE_BLOCK_SIZE - 1) + "\n";
...@@ -95,8 +97,8 @@ public class Constants { ...@@ -95,8 +97,8 @@ public class Constants {
public static final int VERSION_JDBC_MAJOR = 3; public static final int VERSION_JDBC_MAJOR = 3;
public static final int VERSION_JDBC_MINOR = 0; public static final int VERSION_JDBC_MINOR = 0;
public static String getVersion() { public static String getFullVersion() {
return VERSION_MAJOR + "." + VERSION_MINOR + "." + BUILD_ID + " (" + BUILD + ")"; return VERSION+ " (" + BUILD + ")";
} }
public static final int DEFAULT_SERVER_PORT = 9092; // this is also in the docs public static final int DEFAULT_SERVER_PORT = 9092; // this is also in the docs
......
...@@ -65,7 +65,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -65,7 +65,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
*/ */
public String getDatabaseProductVersion() { public String getDatabaseProductVersion() {
debugCodeCall("getDatabaseProductVersion"); debugCodeCall("getDatabaseProductVersion");
return Constants.getVersion(); return Constants.getFullVersion();
} }
/** /**
...@@ -86,7 +86,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -86,7 +86,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
*/ */
public String getDriverVersion() { public String getDriverVersion() {
debugCodeCall("getDriverVersion"); debugCodeCall("getDriverVersion");
return Constants.getVersion(); return Constants.getFullVersion();
} }
/** /**
......
...@@ -216,7 +216,7 @@ public class TraceObject { ...@@ -216,7 +216,7 @@ public class TraceObject {
buff.append(i + 1); buff.append(i + 1);
buff.append(": "); buff.append(": ");
ParameterInterface p = (ParameterInterface) params.get(i); ParameterInterface p = (ParameterInterface) params.get(i);
if (p == null) { if (p == null || p.getParamValue() == null) {
buff.append("unset"); buff.append("unset");
} else { } else {
buff.append(p.getParamValue().getSQL()); buff.append(p.getParamValue().getSQL());
......
...@@ -262,7 +262,7 @@ public class PgServer implements Service { ...@@ -262,7 +262,7 @@ public class PgServer implements Service {
} }
public static String getVersion() { public static String getVersion() {
return "PostgreSQL 8.1.4 server protocol using H2 " + Constants.getVersion(); return "PostgreSQL 8.1.4 server protocol using H2 " + Constants.getFullVersion();
} }
public static Timestamp getStartTime() { public static Timestamp getStartTime() {
......
...@@ -32,9 +32,11 @@ import java.util.HashSet; ...@@ -32,9 +32,11 @@ import java.util.HashSet;
import org.h2.constant.SysProperties; import org.h2.constant.SysProperties;
import org.h2.engine.ConnectionInfo; import org.h2.engine.ConnectionInfo;
import org.h2.jdbc.JdbcConnection; import org.h2.jdbc.JdbcConnection;
import org.h2.message.Message;
import org.h2.util.IOUtils; 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.Resources;
import org.h2.util.ScriptReader; import org.h2.util.ScriptReader;
/** /**
...@@ -605,7 +607,11 @@ public class PgServerThread implements Runnable { ...@@ -605,7 +607,11 @@ public class PgServerThread implements Runnable {
} }
} }
} }
r = new InputStreamReader(PgServerThread.class.getResourceAsStream("pg_catalog.sql")); try {
r = new InputStreamReader(new ByteArrayInputStream(Resources.get("/org/h2/server/pg/pg_catalog.sql")));
} catch (IOException e) {
throw Message.convertIOException(e, "Can not read pg_catalog resource");
}
ScriptReader reader = new ScriptReader(new BufferedReader(r)); ScriptReader reader = new ScriptReader(new BufferedReader(r));
while (true) { while (true) {
String sql = reader.readStatement(); String sql = reader.readStatement();
......
...@@ -1033,7 +1033,7 @@ class WebThread extends Thread implements DatabaseEventListener { ...@@ -1033,7 +1033,7 @@ class WebThread extends Thread implements DatabaseEventListener {
writer.println("<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\" /></head>"); writer.println("<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\" /></head>");
writer.println("<body><h2>Opening Database</h2>URL: " + PageParser.escapeHtml(url) + "<br />"); writer.println("<body><h2>Opening Database</h2>URL: " + PageParser.escapeHtml(url) + "<br />");
writer.println("User: " + PageParser.escapeHtml(user) + "<br />"); writer.println("User: " + PageParser.escapeHtml(user) + "<br />");
writer.println("Version: " + Constants.getVersion() + "<br /><br />"); writer.println("Version: " + Constants.getFullVersion() + "<br /><br />");
writer.flush(); writer.flush();
log("Start..."); log("Start...");
} }
...@@ -1168,7 +1168,7 @@ class WebThread extends Thread implements DatabaseEventListener { ...@@ -1168,7 +1168,7 @@ class WebThread extends Thread implements DatabaseEventListener {
result = getStackTrace(0, t, false); result = getStackTrace(0, t, false);
} }
} else { } else {
result = "Executing Java code is not allowed, use command line parameters -webScript true"; result = "Executing Java code is not allowed, use command line parameter -webScript";
} }
} else if ("@AUTOCOMMIT TRUE".equals(sql)) { } else if ("@AUTOCOMMIT TRUE".equals(sql)) {
conn.setAutoCommit(true); conn.setAutoCommit(true);
...@@ -1266,28 +1266,10 @@ class WebThread extends Thread implements DatabaseEventListener { ...@@ -1266,28 +1266,10 @@ class WebThread extends Thread implements DatabaseEventListener {
out.println(importCode); out.println(importCode);
out.println("public class Java { public static Object run() throws Throwable {" + code + "}}"); out.println("public class Java { public static Object run() throws Throwable {" + code + "}}");
out.close(); out.close();
Process p = Runtime.getRuntime().exec("javac Java.java"); Class javacClass = Class.forName("com.sun.tools.javac.Main");
InputStream processIn = p.getInputStream(); Method compile = javacClass.getMethod("compile", new Class[] { String[].class });
InputStream processErrorIn = p.getErrorStream(); Object javac = javacClass.newInstance();
StringBuffer buff = new StringBuffer(); compile.invoke(javac, new Object[] { new String[]{"Java.java"}});
while (true) {
int c = processIn.read();
if (c == -1) {
break;
}
buff.append((char) c);
}
while (true) {
int c = processErrorIn.read();
if (c == -1) {
break;
}
buff.append((char) c);
}
String error = buff.toString().trim();
if (error.length() > 0) {
throw new Exception("Error compiling: " + error);
}
byte[] data = new byte[(int) classFile.length()]; byte[] data = new byte[(int) classFile.length()];
DataInputStream in = new DataInputStream(new FileInputStream(classFile)); DataInputStream in = new DataInputStream(new FileInputStream(classFile));
in.readFully(data); in.readFully(data);
......
...@@ -696,7 +696,7 @@ public class MetaTable extends Table { ...@@ -696,7 +696,7 @@ public class MetaTable extends Table {
add(rows, new String[]{"info.BUILD_ID", "" + Constants.BUILD_ID}); add(rows, new String[]{"info.BUILD_ID", "" + Constants.BUILD_ID});
add(rows, new String[]{"info.VERSION_MAJOR", "" + Constants.VERSION_MAJOR}); add(rows, new String[]{"info.VERSION_MAJOR", "" + Constants.VERSION_MAJOR});
add(rows, new String[]{"info.VERSION_MINOR", "" + Constants.VERSION_MINOR}); add(rows, new String[]{"info.VERSION_MINOR", "" + Constants.VERSION_MINOR});
add(rows, new String[]{"info.VERSION", "" + Constants.getVersion()}); add(rows, new String[]{"info.VERSION", "" + Constants.getFullVersion()});
if (session.getUser().getAdmin()) { if (session.getUser().getAdmin()) {
String[] settings = new String[]{ String[] settings = new String[]{
"java.runtime.version", "java.runtime.version",
......
...@@ -28,10 +28,9 @@ import java.awt.event.MouseEvent; ...@@ -28,10 +28,9 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import org.h2.util.IOUtils; import org.h2.util.Resources;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
//## AWT end ## //## AWT end ##
import java.sql.SQLException; import java.sql.SQLException;
...@@ -142,13 +141,12 @@ ShutdownHandler { ...@@ -142,13 +141,12 @@ ShutdownHandler {
} }
private Image loadImage(String name) throws IOException { private Image loadImage(String name) throws IOException {
InputStream in = Console.class.getResourceAsStream(name); byte[] imageData = Resources.get(name);
if (in != null) { if (imageData == null) {
byte[] imageData = IOUtils.readBytesAndClose(in, -1);
return Toolkit.getDefaultToolkit().createImage(imageData);
}
return null; return null;
} }
return Toolkit.getDefaultToolkit().createImage(imageData);
}
/** /**
* INTERNAL * INTERNAL
......
...@@ -113,7 +113,7 @@ public class Shell { ...@@ -113,7 +113,7 @@ public class Shell {
private void promptLoop() { private void promptLoop() {
out.println(); out.println();
out.println("Welcome to H2 Shell " + Constants.getVersion()); out.println("Welcome to H2 Shell " + Constants.getFullVersion());
out.println("Exit with Ctrl+C"); out.println("Exit with Ctrl+C");
if (conn != null) { if (conn != null) {
showHelp(); showHelp();
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
package org.h2.util; package org.h2.util;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileWriter; import java.io.FileWriter;
...@@ -13,6 +14,8 @@ import java.io.IOException; ...@@ -13,6 +14,8 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.HashMap; import java.util.HashMap;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
/** /**
* This class is responsible to read resources and generate the * This class is responsible to read resources and generate the
...@@ -23,8 +26,40 @@ public class Resources { ...@@ -23,8 +26,40 @@ public class Resources {
private static final HashMap FILES = new HashMap(); private static final HashMap FILES = new HashMap();
static { static {
if (!loadFromZip()) {
ResourceData.load(); ResourceData.load();
} }
}
private static boolean loadFromZip() {
InputStream in = Resources.class.getResourceAsStream("data.zip");
if (in == null) {
return false;
}
ZipInputStream zipIn = new ZipInputStream(in);
try {
while (true) {
ZipEntry entry = zipIn.getNextEntry();
if (entry == null) {
break;
}
String entryName = entry.getName();
if (!entryName.startsWith("/")) {
entryName = "/" + entryName;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOUtils.copy(zipIn, out);
zipIn.closeEntry();
FILES.put(entryName, out.toByteArray());
}
zipIn.close();
} catch (IOException e) {
// if this happens we have a real problem
e.printStackTrace();
}
return true;
}
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String inDir = args.length > 0 ? args[0] : null; String inDir = args.length > 0 ? args[0] : null;
......
...@@ -17,6 +17,7 @@ import org.h2.tools.SimpleResultSet; ...@@ -17,6 +17,7 @@ import org.h2.tools.SimpleResultSet;
* This sample application shows how to use the CSV tool * This sample application shows how to use the CSV tool
* to write CSV (comma separated values) files, and * to write CSV (comma separated values) files, and
* how to use the tool to read such files. * how to use the tool to read such files.
* See also the section CSV (Comma Separated Values) Support in the Tutorial.
*/ */
public class CsvSample { public class CsvSample {
......
...@@ -159,6 +159,42 @@ java org.h2.test.TestAll timer ...@@ -159,6 +159,42 @@ java org.h2.test.TestAll timer
/* /*
build.sh
run.sh
jdbc:h2:zip:source.zip!/source
The database is read only [90097-69] 90097/90097 (Help)
org.h2.jdbc.JdbcSQLException: The database is read only [90097-69]
at org.h2.message.Message.getSQLException(Message.java:91)
at org.h2.message.Message.getSQLException(Message.java:95)
at org.h2.message.Message.getSQLException(Message.java:73)
at org.h2.message.Message.getSQLException(Message.java:116)
at org.h2.engine.Database.checkWritingAllowed(Database.java:1401)
at org.h2.log.LogSystem.add(LogSystem.java:410)
at org.h2.store.DiskFile.addRecord(DiskFile.java:867)
at org.h2.store.Storage.addRecord(Storage.java:141)
at org.h2.index.ScanIndex.add(ScanIndex.java:115)
at org.h2.table.TableData.addRow(TableData.java:97)
at org.h2.engine.Database.addMeta(Database.java:685)
at org.h2.engine.Database.addDatabaseObject(Database.java:759)
at org.h2.engine.Database.setMasterUser(Database.java:1364)
at org.h2.engine.Engine.openSession(Engine.java:63)
at org.h2.engine.Engine.getSession(Engine.java:104)
at org.h2.engine.Session.createSession(Session.java:203)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:976)
timebomb should interrupt all threads
Thread[] list = new Thread[1000];
Thread.currentThread().getThreadGroup().enumerate(list);
for (int i = 0; i < list.length; i++) {
Thread t = list[i];
if (t != null && t != Thread.currentThread()) {
System.out.println("interrupting " + t.toString());
t.interrupt();
test case for out of memory (try to corrupt the database using out of memory)
Caused by: java.lang.Error: read len -1170950400 Caused by: java.lang.Error: read len -1170950400
at org.h2.message.Message.getInternalError(Message.java:128) at org.h2.message.Message.getInternalError(Message.java:128)
at org.h2.store.FileStore.readFully(FileStore.java:210) at org.h2.store.FileStore.readFully(FileStore.java:210)
...@@ -233,9 +269,19 @@ Add where required // TODO: change in version 1.1 ...@@ -233,9 +269,19 @@ Add where required // TODO: change in version 1.1
http://www.w3schools.com/sql/ http://www.w3schools.com/sql/
History: History:
The servlet and lucene jar files are now automatically downloaded in the build. The servlet and lucene jar files are now automatically downloaded when building.
The code switch tool has been replaced by a simpler tool called The code switch tool has been replaced by a simpler tool called
SwitchSource that just uses find and replace. SwitchSource that just uses find and replace.
Started to write a Ant replacement ('JAnt') that uses pure Java
build definitions. Advantages: ability to debug the build, extensible,
flexible, no XML, a bit faster. Future plan: support creating custom h2
distributions (for embedded use). Maybe create a new project 'Jant'
or 'Javen' if other people are interested.
The jar file is now about 10% smaller because the variable debugging info
is no longer included. The source file and line number debugging info
is still included. If required, the jar file size of the full version can
be further reduced to about 720 KB using 'build jarSmall' or even
more by removing unneeded components.
Roadmap: Roadmap:
......
/*
* Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
* (license2)
* Initial Developer: H2 Group
*/
package org.h2.build;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.h2.build.code.SwitchSource;
/**
* The implementation of the pure Java build.
*/
public class Build extends BuildBase {
public static void main(String[] args) {
new Build().run(args);
}
public void all() {
jarSmall();
javadoc();
docs();
}
public void docs() {
copy("docs", getFiles("src/docsrc/index.html"), "src/docsrc");
java("org.h2.build.code.CheckJavadoc", null);
java("org.h2.build.code.CheckTextFiles", null);
java("org.h2.build.doc.GenerateDoc", null);
java("org.h2.build.i18n.PrepareTranslation", null);
java("org.h2.build.i18n.PrepareTranslation", null);
java("org.h2.build.indexer.Indexer", null);
java("org.h2.build.doc.MergeDocs", null);
java("org.h2.build.doc.WebSite", null);
java("org.h2.build.doc.LinkChecker", null);
java("org.h2.build.doc.XMLChecker", null);
java("org.h2.build.doc.SpellChecker", null);
}
public void javadoc() {
delete("docs");
mkdir("docs/javadoc");
javadoc(new String[] { "-sourcepath", "src/main", "org.h2.jdbc", "org.h2.jdbcx",
"org.h2.tools", "org.h2.api", "org.h2.constant",
"-doclet", "org.h2.build.doclet.Doclet" });
copy("docs/javadoc", getFiles("src/docsrc/javadoc"), "src/docsrc/javadoc");
}
public void resources() {
List files = getFiles("src/main");
files = filterFiles(files, false, "*.java");
files = filterFiles(files, false, "*/package.html");
files = filterFiles(files, false, "*/java.sql.Driver");
zip("target/org/h2/util/data.zip", "src/main", files, true, false);
}
private void manifest(String mainClassName) {
String manifest = new String(readFile(new File("src/main/META-INF/MANIFEST.MF")));
String version = getStaticField("org.h2.engine.Constants", "VERSION");
manifest = replaceAll(manifest, "${version}", version);
manifest = replaceAll(manifest, "${buildJdk}", getJavaSpecVersion());
String createdBy = System.getProperty("java.runtime.version") + " (" + System.getProperty("java.vm.vendor")
+ ")";
manifest = replaceAll(manifest, "${createdBy}", createdBy);
String mainClassTag = manifest == null ? "" : "Main-Class: " + mainClassName;
manifest = replaceAll(manifest, "${mainClassTag}", mainClassTag);
writeFile(new File("target/META-INF/MANIFEST.MF"), manifest.getBytes());
}
public void jar() {
compile();
manifest("org.h2.tools.Console");
List files = getFiles("target");
files = filterFiles(files, false, "target/org/h2/dev/*");
files = filterFiles(files, false, "target/org/h2/build/*");
files = filterFiles(files, false, "target/org/h2/samples/*");
files = filterFiles(files, false, "target/org/h2/test/*");
files = filterFiles(files, false, "*.bat");
files = filterFiles(files, false, "*.txt");
jar("target/h2.jar", "target", files);
}
public void jarSmall() {
compile(false);
List files = getFiles("target");
files = filterFiles(files, false, "target/org/h2/dev/*");
files = filterFiles(files, false, "target/org/h2/build/*");
files = filterFiles(files, false, "target/org/h2/samples/*");
files = filterFiles(files, false, "target/org/h2/test/*");
files = filterFiles(files, false, "*.bat");
files = filterFiles(files, false, "*.txt");
files = filterFiles(files, false, "target/META-INF/*");
zip("target/h2classes.zip", "target", files, true, true);
manifest("org.h2.tools.Console\nClass-Path: h2classes.zip");
files = getFiles("target/h2classes.zip");
files.addAll(getFiles("target/META-INF"));
jar("target/h2small.jar", "target", files);
}
public void download() {
download("ext/servlet-api-2.4.jar",
"http://repo1.maven.org/maven2/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar",
"3fc542fe8bb8164e8d3e840fe7403bc0518053c0");
download("ext/lucene-core-2.2.0.jar",
"http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/2.2.0/lucene-core-2.2.0.jar",
"47b6eee2e17bd68911e7045896a1c09de0b2dda8");
}
public void compile() {
compile(true);
}
private void compile(boolean debugInfo) {
try {
SwitchSource.main(new String[] { "-dir", "src", "-auto" });
} catch (IOException e) {
throw new Error(e);
}
clean();
resources();
download();
String classpath = "target" + File.pathSeparatorChar + "ext/servlet-api-2.4.jar" + File.pathSeparatorChar
+ "ext/lucene-core-2.2.0.jar" + File.pathSeparator + System.getProperty("java.home")
+ "/../lib/tools.jar";
List files = getFiles("src/main");
if (debugInfo) {
javac(new String[] { "-d", "target", "-sourcepath", "src/main", "-classpath", classpath }, files);
} else {
javac(new String[] { "-g:none", "-d", "target", "-sourcepath", "src/main", "-classpath", classpath }, files);
}
files = getFiles("src/test");
files.addAll(getFiles("src/tools"));
javac(new String[] { "-d", "target", "-sourcepath", "src/test" + File.pathSeparator + "src/tools",
"-classpath", classpath }, files);
files = getFiles("src/main/META-INF/services");
copy("target", files, "src/main");
files = getFiles("src/installer");
files = filterFiles(files, true, "*.bat");
copy("target", files, "src/installer");
files = getFiles("src/test");
files = filterFiles(files, false, "*.java");
files = filterFiles(files, false, "*/package.html");
copy("target", files, "src/test");
}
public void clean() {
delete("target");
delete("docs");
mkdir("target");
mkdir("docs");
}
public void test() {
}
}
差异被折叠。
...@@ -21,9 +21,10 @@ public class CheckTextFiles { ...@@ -21,9 +21,10 @@ public class CheckTextFiles {
new CheckTextFiles().run(); new CheckTextFiles().run();
} }
String[] suffixCheck = new String[] { "html", "jsp", "js", "css", "bat", "nsi", "java", "txt", "properties", "sql", String[] suffixCheck = new String[] { "html", "jsp", "js", "css", "bat", "nsi",
"xml", "csv", "Driver" }; "java", "txt", "properties", "sql", "xml", "csv", "Driver" };
String[] suffixIgnore = new String[] { "gif", "png", "odg", "ico", "sxd", "layout", "res", "win", "jar", "task", "svg" }; String[] suffixIgnore = new String[] { "gif", "png", "odg", "ico", "sxd",
"layout", "res", "win", "jar", "task", "svg", "MF" };
boolean failOnError; boolean failOnError;
boolean allowTab, allowCR = true, allowTrailingSpaces = true; boolean allowTab, allowCR = true, allowTrailingSpaces = true;
int spacesPerTab = 4; int spacesPerTab = 4;
......
...@@ -33,7 +33,7 @@ public class SpellChecker { ...@@ -33,7 +33,7 @@ public class SpellChecker {
private boolean printDictionary = false; private boolean printDictionary = false;
private boolean addToDictionary; private boolean addToDictionary;
private static final String[] SUFFIX = new String[] { "html", "java", "sql", "txt", "xml", "jsp", "css", "bat", private static final String[] SUFFIX = new String[] { "html", "java", "sql", "txt", "xml", "jsp", "css", "bat",
"csv", "xml", "js", "Driver", "properties", "task", "" }; "csv", "xml", "js", "Driver", "properties", "task", "MF", "" };
private static final String[] IGNORE = new String[] { "dev", "nsi", "gif", "png", "odg", "ico", "sxd", "zip", private static final String[] IGNORE = new String[] { "dev", "nsi", "gif", "png", "odg", "ico", "sxd", "zip",
"bz2", "rc", "layout", "res", "dll", "jar", "svg" }; "bz2", "rc", "layout", "res", "dll", "jar", "svg" };
private static final String PREFIX_IGNORE = "abc"; private static final String PREFIX_IGNORE = "abc";
......
...@@ -64,7 +64,7 @@ classes classification classloader classloaders classpath clause clazz clean ...@@ -64,7 +64,7 @@ classes classification classloader classloaders classpath clause clazz clean
cleaned cleaner clear cleared clearing clearly clears cleartext click clicked cleaned cleaner clear cleared clearing clearly clears cleartext click clicked
clicking client clients clientside clob clock clone close closed closely closer clicking client clients clientside clob clock clone close closed closely closer
closes closing clubs cluster clustered clustering cmd cmu cnt coalesce code closes closing clubs cluster clustered clustering cmd cmu cnt coalesce code
codebase codebook coded codehaus codes codist coffee col coldrick coll codebase codebook coded codehaus codes codeswitch codist coffee col coldrick coll
collaborative collapse collateral collation collations collator collators collect collaborative collapse collateral collation collations collator collators collect
collected collecting collection collections collector colon color cols colspan collected collecting collection collections collector colon color cols colspan
column columnlist columns com combination combinations combinatorics combine column columnlist columns com combination combinations combinatorics combine
...@@ -490,4 +490,6 @@ hider ikvmc invert recycle filtering lesser recycled assertion runner teradata ...@@ -490,4 +490,6 @@ hider ikvmc invert recycle filtering lesser recycled assertion runner teradata
christian lgpl elapsed ncr disposed heureuse tera years retrieves unlocked christian lgpl elapsed ncr disposed heureuse tera years retrieves unlocked
selecting vista everywhere locations zones fragment svg thought constructors selecting vista everywhere locations zones fragment svg thought constructors
doubles validating matched established accu accum stats resetting parallel doubles validating matched established accu accum stats resetting parallel
delays guess downloaded jars delays guess downloaded jars advantages interrupt javen sourcepath unneeded
\ No newline at end of file compressibility ext crc enumerate components mkdir jant downloading mismatch
timebomb
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>
Javadoc package documentation
</title></head><body style="font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;">
The pure Java build system and implementation.
</body></html>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论