提交 180841cb authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 778946d4
#Fri Nov 09 12:31:47 CET 2007
benchmark.drivers.dir=C\:/data/java
#Mon Nov 19 20:09:20 CET 2007
javac=javac
benchmark.drivers.dir=C\:/data/java
path.servlet.jar=C\:/data/classpath/servlet-api.jar
path.lucene.jar=C\:/data/classpath/lucene-core-2.2.0.jar
version.name.maven=1.0.61
path.lucene.jar=C\:/data/classpath/lucene-core-2.2.0.jar
jdk=1.4
......@@ -50,12 +50,21 @@
<javac executable="${javac}" srcdir="src/tools" destdir="bin" debug="true" includes="org/h2/tools/code/CodeSwitch.java"/>
</target>
<target name="codeswitchAndroid" depends="codeswitchPrepare">
<propertyfile file="ant-build.properties">
<entry key="jdk" value="1.3" />
</propertyfile>
<java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="bin">
<arg line="+JDK13 -JDK14 -JDK16 -AWT ../src/main/org/h2"/>
</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="bin">
<arg line="+JDK13 -JDK14 -JDK16 ../src/main/org/h2"/>
<arg line="+JDK13 -JDK14 -JDK16 +AWT ../src/main/org/h2"/>
</java>
</target>
......@@ -64,7 +73,7 @@
<entry key="jdk" value="1.4" />
</propertyfile>
<java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="bin">
<arg line="-JDK13 +JDK14 -JDK16 ../src/main/org/h2"/>
<arg line="-JDK13 +JDK14 -JDK16 +AWT ../src/main/org/h2"/>
</java>
</target>
......@@ -73,7 +82,7 @@
<entry key="jdk" value="1.6" />
</propertyfile>
<java classname="org.h2.tools.code.CodeSwitch" fork="true" dir="bin">
<arg line="-JDK13 +JDK16 +JDK14 ../src/main/org/h2"/>
<arg line="-JDK13 +JDK14 +JDK16 +AWT ../src/main/org/h2"/>
</java>
</target>
......
......@@ -155,12 +155,8 @@ However, the startup of the GCJ version is faster than when using a VM.
<br /><a name="translate"></a>
<h3>How to Translate this Project?</h3>
<p>
The following files can be translated at the moment:
<pre>
src/main/org/h2/server/web/res/_text_*.properties
src/main/org/h2/res/_messages_*.properties
src/docsrc/text/_docs_*.utf8.txt
</pre>
For more information, see
<a href="build.html#translating">Build/Translating</a>.
</p>
</div></td></tr></table></body></html>
\ No newline at end of file
......@@ -6,16 +6,16 @@ package org.h2.jdbcx;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;
//#ifdef JDK14
import java.io.Serializable;
import javax.naming.NamingException;
import javax.naming.Reference;
import javax.naming.Referenceable;
import javax.naming.StringRefAddr;
//#ifdef JDK14
import javax.sql.ConnectionPoolDataSource;
import javax.sql.DataSource;
import javax.sql.PooledConnection;
......@@ -36,11 +36,11 @@ import org.h2.message.Message;
* A data source for H2 database connections. It is a factory for XAConnection and Connection objects.
* This class is usually registered in a JNDI naming service.
*/
public class JdbcDataSource extends TraceObject implements
public class JdbcDataSource extends TraceObject
//#ifdef JDK14
XADataSource, DataSource, ConnectionPoolDataSource,
implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Referenceable
//#endif
Serializable, Referenceable {
{
private static final long serialVersionUID = 1288136338451857771L;
......@@ -211,6 +211,7 @@ Serializable, Referenceable {
*
* @return the new reference
*/
//#ifdef JDK14
public Reference getReference() throws NamingException {
debugCodeCall("getReference");
String factoryClassName = JdbcDataSourceFactory.class.getName();
......@@ -221,9 +222,14 @@ Serializable, Referenceable {
ref.add(new StringRefAddr("loginTimeout", String.valueOf(loginTimeout)));
return ref;
}
//#endif
/**
*
*/
//#ifdef JDK14
public XAConnection getXAConnection() throws SQLException {
int document;
debugCodeCall("getXAConnection");
int id = getNextId(XA_DATA_SOURCE);
return new JdbcXAConnection(factory, id, url, user, password);
......
......@@ -6,10 +6,12 @@ package org.h2.jdbcx;
import java.util.Hashtable;
//#ifdef JDK14
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.Reference;
import javax.naming.spi.ObjectFactory;
//#endif
import org.h2.constant.SysProperties;
import org.h2.engine.Constants;
......@@ -19,7 +21,11 @@ import org.h2.message.TraceSystem;
/**
* This class is used to create new JdbcDataSource objects.
*/
public class JdbcDataSourceFactory implements ObjectFactory {
public class JdbcDataSourceFactory
//#ifdef JDK14
implements ObjectFactory
//#endif
{
private static TraceSystem traceSystem;
private Trace trace;
......@@ -46,6 +52,7 @@ public class JdbcDataSourceFactory implements ObjectFactory {
* @param environment unused
* @return the new JdbcDataSource, or null if the reference class name is not JdbcDataSource.
*/
//#ifdef JDK14
public synchronized Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception {
trace.debug("getObjectInstance obj=" + obj + " name=" + name + " nameCtx=" + nameCtx + " environment=" + environment);
Reference ref = (Reference) obj;
......@@ -60,6 +67,7 @@ public class JdbcDataSourceFactory implements ObjectFactory {
}
return null;
}
//#endif
TraceSystem getTraceSystem() {
return traceSystem;
......
......@@ -47,13 +47,6 @@ implements Xid
}
}
// private JdbcXid(JdbcDataSourceFactory factory, int id, Xid xid) {
// setTrace(factory.getTrace(), TraceObject.XID, id);
// this.formatId = xid.getFormatId();
// this.branchQualifier = clone(xid.getBranchQualifier());
// this.globalTransactionId = clone(xid.getGlobalTransactionId());
// }
/**
* INTERNAL
*/
......@@ -68,12 +61,6 @@ implements Xid
return buff.toString();
}
// private byte[] clone(byte[] data) {
// byte[] d2 = new byte[data.length];
// System.arraycopy(data, 0, d2, 0, data.length);
// return d2;
// }
/**
* Get the format id.
*
......
......@@ -600,7 +600,7 @@ public class PgServerThread implements Runnable {
}
}
}
r = new InputStreamReader(getClass().getResourceAsStream("pg_catalog.sql"));
r = new InputStreamReader(PgServerThread.class.getResourceAsStream("pg_catalog.sql"));
ScriptReader reader = new ScriptReader(new BufferedReader(r));
while (true) {
String sql = reader.readStatement();
......
......@@ -4,6 +4,7 @@
*/
package org.h2.tools;
//#ifdef AWT
import java.awt.Button;
import java.awt.Dimension;
import java.awt.Font;
......@@ -24,11 +25,12 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import org.h2.util.IOUtils;
import java.io.InputStream;
//#endif
import java.sql.SQLException;
import org.h2.server.ShutdownHandler;
import org.h2.util.IOUtils;
import org.h2.util.StartBrowser;
/**
......@@ -37,11 +39,17 @@ import org.h2.util.StartBrowser;
* Otherwise, a small window opens.
*
*/
public class Console implements ActionListener, MouseListener, ShutdownHandler {
public class Console implements
//#ifdef AWT
ActionListener, MouseListener,
//#endif
ShutdownHandler {
//#ifdef AWT
private Font font;
private Image icon;
private Frame frame;
//#endif
private static final int EXIT_ERROR = 1;
private Server web, tcp, pg;
......@@ -92,10 +100,11 @@ public class Console implements ActionListener, MouseListener, ShutdownHandler {
System.out.println(pg.getStatus());
}
}
//#ifdef AWT
if (!GraphicsEnvironment.isHeadless()) {
font = new Font("Dialog", Font.PLAIN, 11);
try {
InputStream in = getClass().getResourceAsStream("/org/h2/res/h2.png");
InputStream in = Console.class.getResourceAsStream("/org/h2/res/h2.png");
if (in != null) {
byte[] imageData = IOUtils.readBytesAndClose(in, -1);
icon = Toolkit.getDefaultToolkit().createImage(imageData);
......@@ -107,6 +116,8 @@ public class Console implements ActionListener, MouseListener, ShutdownHandler {
e.printStackTrace();
}
}
//#endif
// start browser anyway (even if the server is already running)
// because some people don't look at the output,
// but are wondering why nothing happens
......@@ -137,13 +148,16 @@ public class Console implements ActionListener, MouseListener, ShutdownHandler {
pg.stop();
pg = null;
}
//#ifdef AWT
if (frame != null) {
frame.dispose();
frame = null;
}
//#endif
System.exit(0);
}
//#ifdef AWT
private boolean createTrayIcon() {
try {
// SystemTray.isSupported();
......@@ -261,9 +275,17 @@ public class Console implements ActionListener, MouseListener, ShutdownHandler {
frame.setVisible(true);
}
private void startBrowser() {
if (web != null) {
StartBrowser.openURL(web.getURL());
}
}
//#endif
/**
* INTERNAL
*/
//#ifdef AWT
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if ("exit".equals(command)) {
......@@ -274,44 +296,49 @@ public class Console implements ActionListener, MouseListener, ShutdownHandler {
showWindow(false);
}
}
private void startBrowser() {
if (web != null) {
StartBrowser.openURL(web.getURL());
}
}
//#endif
/**
* INTERNAL
*/
//#ifdef AWT
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
startBrowser();
}
}
//#endif
/**
* INTERNAL
*/
//#ifdef AWT
public void mouseEntered(MouseEvent e) {
}
//#endif
/**
* INTERNAL
*/
//#ifdef AWT
public void mouseExited(MouseEvent e) {
}
//#endif
/**
* INTERNAL
*/
//#ifdef AWT
public void mousePressed(MouseEvent e) {
}
//#endif
/**
* INTERNAL
*/
//#ifdef AWT
public void mouseReleased(MouseEvent e) {
}
//#endif
}
......@@ -86,6 +86,7 @@ public class JdbcUtils {
Class d = ClassUtils.loadClass(driver);
if (java.sql.Driver.class.isAssignableFrom(d)) {
return DriverManager.getConnection(url, prop);
//#ifdef JDK14
} else if (javax.naming.Context.class.isAssignableFrom(d)) {
// JNDI context
try {
......@@ -101,6 +102,7 @@ public class JdbcUtils {
} catch (NamingException e) {
throw Message.convert(e);
}
//#endif
} else {
// Don't know, but maybe it loaded a JDBC Driver
return DriverManager.getConnection(url, prop);
......
......@@ -38,18 +38,6 @@ public class ValueArray extends Value {
return values;
}
public int compareTo(ValueArray other, CompareMode mode) throws SQLException {
for (int i = 0; i < values.length; i++) {
Value v1 = values[i];
Value v2 = other.values[i];
int comp = v1.compareTo(v2, mode);
if (comp != 0) {
return comp;
}
}
return 0;
}
public int getType() {
return Value.ARRAY;
}
......@@ -71,43 +59,23 @@ public class ValueArray extends Value {
return buff.toString();
}
// public String getJavaString() {
// StringBuffer buff = new StringBuffer();
// buff.append('{');
// for (int i = 0; i < values.length; i++) {
// if (i > 0) {
// buff.append(", ");
// }
// buff.append(values[i].getJavaString());
// }
// buff.append('}');
// return buff.toString();
// }
protected int compareSecure(Value o, CompareMode mode) throws SQLException {
ValueArray v = (ValueArray) o;
if (values == v.values) {
return 0;
}
if (values.length != v.values.length) {
return values.length > v.values.length ? 1 : -1;
}
for (int i = 0; i < values.length; i++) {
int l = values.length;
int ol = v.values.length;
int len = Math.min(l, ol);
for (int i = 0; i < len; i++) {
Value v1 = values[i];
Value v2 = v.values[i];
int c;
if (v1 == ValueNull.INSTANCE) {
c = v2 == ValueNull.INSTANCE ? 0 : -1;
} else if (v2 == ValueNull.INSTANCE) {
c = 1;
} else {
c = v1.compareSecure(v2, mode);
}
if (c != 0) {
return c;
int comp = v1.compareTo(v2, mode);
if (comp != 0) {
return comp;
}
}
return 0;
return l > ol ? 1 : l == ol ? 0 : -1;
}
public Object getObject() throws SQLException {
......
......@@ -150,49 +150,11 @@ java org.h2.test.TestAll timer
/*
FAQ, build? translation
History
Now using custom toString() for most JDBC objects and commands.
Nested temporary views (SELECT * FROM (SELECT ...)) with parameters didn't work in some cases. Fixed.
CSV: Using an empty field delimiter didn't work (a workaround was using char(0)). Fixed.
Performance: use BufferedReader, BufferedWriter everywhere where possible (BufferInputStream alone doesn't help)
document Memory-Only databases > In-Memory Databases
By default, when the last connection to a in-memory database is closed, the contents are lost.
This can be disabled by adding this to the database URL: ;DB_CLOSE_DELAY=-1
That means to keep the contents of an in-memory database as long as the virtual machine is alive, use
jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
History:
The default value for h2.emergencySpaceInitial is now 256 KB (to speed up creating encrypted databases)
Eduardo Velasques has translated the H2 Console and the error messages to Brazilian Portuguese. Thanks a lot!
Creating a table from GROUP_CONCAT didn't work if the data was longer than 255 characters
document translation (what files to translate)
Known Problems:
link to history page, bug page
Add a link to the google code bug page
Email: h2@olivercomputing.com
Message:
Very cool project, I sent you a few euros yesterday.
I have a feature suggestion in the way that you sort array columns in ORDER BY. To take a concrete example, given
(0,1)
(0,1,1)
(0,2)
then PostgreSQL would order them as above, but H2 orders them as:
(0,1)
(0,2)
(0,1,1)
i.e. the ordering is evidently applied so that the array length is used in the count. While either way could be arguable, I would argue for the PostgreSQL ordering for two reasons:
- PostgreSQL compatibility itself
- Because, at least for my use case, I am using the arrays to represent XML hierarchy information. The first (PG) way of ordering naturally represents the XML document node order, but the current H2 way does not. Given the variable hierarchy of an XML document, such ordering can be difficult to do efficiently in a relational "shredded" node representation.
So, given that arrays are noted as experimental at this point, I thought I would ask if you could change their ordering scheme to match PostgreSQL's. Alternatively, perhaps a system variable could be used to pre-select the desired ordering. Thanks.
Phil Oliver
Google Android support: use 'ant codeswitchAndroid' to switch the source code to Android.
implement & test: checkpoint commits running transactions
......
......@@ -84,6 +84,7 @@ public class TestCluster extends TestBase {
n1.stop();
// re-create the cluster
DeleteDbFiles.main(new String[] { "-dir", baseDir + "/node2", "-quiet" });
CreateCluster.main(new String[] { "-urlSource", "jdbc:h2:file:" + baseDir + "/node1/test", "-urlTarget",
"jdbc:h2:file:" + baseDir + "/node2/test", "-user", "sa", "-serverlist",
"localhost:9091,localhost:9092" });
......@@ -92,6 +93,8 @@ public class TestCluster extends TestBase {
n2 = org.h2.tools.Server.createTcpServer(
new String[] { "-tcpPort", "9092", "-baseDir", baseDir + "/node2" }).start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9091,localhost:9092/test", "sa", "");
stat = conn.createStatement();
stat.execute("CREATE TABLE BOTH(ID INT)");
n1.stop();
......
--- special grammar and test cases ---------------------------------------------------------------------------------------------
create table test(id int primary key, data array);
> ok
insert into test values(1, (1, 1)), (2, (1, 2)), (3, (1, 1, 1));
> update count: 3
select * from test order by data;
> ID DATA
> -- ---------
> 1 (1, 1)
> 3 (1, 1, 1)
> 2 (1, 2)
> rows (ordered): 3
drop table test;
> ok
CREATE TABLE FOO (A CHAR(10));
> ok
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论