提交 778946d4 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 f24001c8
......@@ -20,6 +20,8 @@ Build
Building the Software</a><br />
<a href="#maven2">
Using Maven 2</a><br />
<a href="#translating">
Translating</a><br />
<br /><a name="portability"></a>
<h2>Portability</h2>
......@@ -101,4 +103,20 @@ Afterwards, you can include the database in your Maven 2 project as a dependency
</pre>
</p>
<br /><a name="translating"></a>
<h2>Translating</h2>
<p>
The translation of this software is split into the following parts:
</p>
<ul>
<li>H2 Console: src/main/org/h2/server/web/res/_text_*.properties
</li><li>Error messages: src/main/org/h2/res/_messages_*.properties
</li><li>Web site: src/docsrc/text/_docs_*.utf8.txt
</li></ul>
<p>
The conversion between UTF-8 and Java encoding (using the \u syntax), as well as the HTML entities (&#..;)
is automated by running the tool PropertiesToUTF8. The web site translation is automated as well,
using <code>ant docs</code>.
</p>
</div></td></tr></table></body></html>
......@@ -23,6 +23,8 @@ Features
Connection Modes</a><br />
<a href="#database_url">
Database URL Overview</a><br />
<a href="#memory_only_databases">
Memory-Only Databases</a><br />
<a href="#file_encryption">
Connecting to a Database with File Encryption</a><br />
<a href="#database_file_locking">
......@@ -239,8 +241,6 @@ http://groups.google.com/group/h2-database/web/h2-in-use
</a>
</p>
<br /><a name="connection_modes"></a>
<h2>Connection Modes</h2>
<p>
The following connection modes are supported:
</p>
......@@ -385,7 +385,8 @@ The database name must be at least three characters long (a limitation of File.c
To point to the user home directory, use ~/, as in: jdbc:h2:~/test.
</p>
<h3>Memory-Only Databases</h3>
<br /><a name="memory_only_databases"></a>
<h2>Memory-Only Databases</h2>
<p>
For certain use cases (for example: rapid prototyping, testing, high performance
operations, read-only databases), it may not be required to persist (changes to) the data at all.
......@@ -405,6 +406,11 @@ It is also possible to access a memory-only database remotely
(or from multiple processes in the same machine) using TCP/IP or SSL/TLS.
An example database URL is: <code>jdbc:h2:tcp://localhost/mem:db1</code>
(using private database remotely is also possible).
</p><p>
By default, when the last connection to a in-memory database is closed, the contents are lost.
This can be disabled by adding ;DB_CLOSE_DELAY=-1 to the database URL. 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
</p>
<br /><a name="file_encryption"></a>
......
......@@ -16,6 +16,9 @@ import org.h2.engine.Constants;
import org.h2.message.Trace;
import org.h2.message.TraceSystem;
/**
* This class is used to create new JdbcDataSource objects.
*/
public class JdbcDataSourceFactory implements ObjectFactory {
private static TraceSystem traceSystem;
......@@ -27,13 +30,25 @@ public class JdbcDataSourceFactory implements ObjectFactory {
traceSystem.setLevelFile(SysProperties.DATASOURCE_TRACE_LEVEL);
}
/**
* The public constructor to create new factory objects.
*/
public JdbcDataSourceFactory() {
trace = traceSystem.getTrace("JDBCX");
}
/**
* Creates a new object using the specified location or reference information.
*
* @param obj the reference (this factory only supports objects of type javax.naming.Reference)
* @param name unused
* @param nameCtx unused
* @param environment unused
* @return the new JdbcDataSource, or null if the reference class name is not JdbcDataSource.
*/
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;
Reference ref = (Reference) obj;
if (ref.getClassName().equals(JdbcDataSource.class.getName())) {
JdbcDataSource dataSource = new JdbcDataSource();
dataSource.setURL((String) ref.get("url").getContent());
......
......@@ -30,6 +30,11 @@ import javax.sql.StatementEventListener;
*/
//#endif
/**
* This class provides support for distributed transactions.
* An application developer usually does not use this interface.
* It is used by the transaction manager internally.
*/
public class JdbcXAConnection extends TraceObject
//#ifdef JDK14
implements XAConnection, XAResource, JdbcConnectionListener
......@@ -60,11 +65,20 @@ implements XAConnection, XAResource, JdbcConnectionListener
getConnection();
}
/**
* Get the XAResource object.
*
* @return itself
*/
public XAResource getXAResource() throws SQLException {
debugCodeCall("getXAResource");
return this;
}
/**
* Close the physical connection.
* This method is usually called by the connection pool.
*/
public void close() throws SQLException {
debugCodeCall("close");
try {
......@@ -94,6 +108,12 @@ implements XAConnection, XAResource, JdbcConnectionListener
return conn;
}
/**
* Get a new connection.
* This method is usually called by the connection pool when there are no more connections in the pool.
*
* @return the connection
*/
public Connection getConnection() throws SQLException {
debugCodeCall("getConnection");
if (conn != null) {
......@@ -105,6 +125,11 @@ implements XAConnection, XAResource, JdbcConnectionListener
return conn;
}
/**
* Register a new listener for the connection.
*
* @param listener the event listener
*/
public void addConnectionEventListener(ConnectionEventListener listener) {
debugCode("addConnectionEventListener(listener)");
listeners.add(listener);
......@@ -113,11 +138,19 @@ implements XAConnection, XAResource, JdbcConnectionListener
}
}
/**
* Remove the event listener.
*
* @param listener the event listener
*/
public void removeConnectionEventListener(ConnectionEventListener listener) {
debugCode("removeConnectionEventListener(listener)");
listeners.remove(listener);
}
/**
* INTERNAL
*/
public void fatalErrorOccurred(JdbcConnection conn, SQLException e) throws SQLException {
debugCode("fatalErrorOccurred(conn, e)");
for (int i = 0; i < listeners.size(); i++) {
......@@ -128,6 +161,9 @@ implements XAConnection, XAResource, JdbcConnectionListener
close();
}
/**
* INTERNAL
*/
public void closed(JdbcConnection conn) {
debugCode("closed(conn)");
for (int i = 0; i < listeners.size(); i++) {
......@@ -137,21 +173,46 @@ implements XAConnection, XAResource, JdbcConnectionListener
}
}
/**
* Get the transaction timeout.
*
* @return 0
*/
public int getTransactionTimeout() throws XAException {
debugCodeCall("getTransactionTimeout");
return 0;
}
/**
* Set the transaction timeout.
*
* @param seconds ignored
* @return false
*/
public boolean setTransactionTimeout(int seconds) throws XAException {
debugCodeCall("setTransactionTimeout", seconds);
return false;
}
/**
* Checks if this is the same XAResource.
*
* @param xares the other object
* @return true if this is the same object
*/
public boolean isSameRM(XAResource xares) throws XAException {
debugCode("isSameRM(xares)");
return xares == this;
}
/**
* Get the list of prepared transaction branches.
* This method is called by the transaction manager during recovery.
*
* @param flag TMSTARTRSCAN, TMENDRSCAN, or TMNOFLAGS. If no other flags are set,
* TMNOFLAGS must be used.
* @return zero or more Xid objects
*/
public Xid[] recover(int flag) throws XAException {
debugCodeCall("recover", quoteFlags(flag));
checkOpen();
......@@ -185,6 +246,11 @@ implements XAConnection, XAResource, JdbcConnectionListener
}
}
/**
* Prepare a transaction.
*
* @param xid the transaction id
*/
public int prepare(Xid xid) throws XAException {
debugCode("prepare("+quoteXid(xid)+")");
checkOpen();
......@@ -206,11 +272,21 @@ implements XAConnection, XAResource, JdbcConnectionListener
return XA_OK;
}
/**
* Forget a transaction.
* This method does not have an effect for this database.
*
* @param xid the transaction id
*/
public void forget(Xid xid) throws XAException {
debugCode("forget("+quoteXid(xid)+")");
// TODO
}
/**
* Roll back a transaction.
*
* @param xid the transaction id
*/
public void rollback(Xid xid) throws XAException {
debugCode("rollback("+quoteXid(xid)+")");
try {
......@@ -222,8 +298,15 @@ implements XAConnection, XAResource, JdbcConnectionListener
currentTransaction = null;
}
/**
* End a transaction.
*
* @param xid the transaction id
* @param flags TMSUCCESS, TMFAIL, or TMSUSPEND
*/
public void end(Xid xid, int flags) throws XAException {
debugCode("end("+quoteXid(xid)+", "+quoteFlags(flags)+")");
// TODO transaction end: implement this method
if (flags == TMSUSPEND) {
return;
}
......@@ -285,6 +368,12 @@ implements XAConnection, XAResource, JdbcConnectionListener
return buff.toString();
}
/**
* Start or continue to work on a transaction.
*
* @param xid the transaction id
* @param flags TMNOFLAGS, TMJOIN, or TMRESUME
*/
public void start(Xid xid, int flags) throws XAException {
debugCode("start("+quoteXid(xid)+", "+quoteFlags(flags)+")");
if (flags == TMRESUME) {
......@@ -308,6 +397,12 @@ implements XAConnection, XAResource, JdbcConnectionListener
return new XAException(e.getMessage());
}
/**
* Commit a transaction.
*
* @param xid the transaction id
* @param onePhase use a one-phase protocol if true
*/
public void commit(Xid xid, boolean onePhase) throws XAException {
debugCode("commit("+quoteXid(xid)+", "+onePhase+")");
Statement stat = null;
......
......@@ -16,6 +16,9 @@ import org.h2.message.Message;
import org.h2.message.TraceObject;
import org.h2.util.ByteUtils;
/**
* An object of this class represents a transaction id.
*/
public class JdbcXid extends TraceObject
//#ifdef JDK14
implements Xid
......@@ -51,6 +54,9 @@ implements Xid
// this.globalTransactionId = clone(xid.getGlobalTransactionId());
// }
/**
* INTERNAL
*/
public String getAsString() {
StringBuffer buff = new StringBuffer(PREFIX);
buff.append('_');
......@@ -68,16 +74,31 @@ implements Xid
// return d2;
// }
/**
* Get the format id.
*
* @return the format id
*/
public int getFormatId() {
debugCodeCall("getFormatId");
return formatId;
}
/**
* The transaction branch identifier.
*
* @return the identifier
*/
public byte[] getBranchQualifier() {
debugCodeCall("getBranchQualifier");
return branchQualifier;
}
/**
* The global transaction identifier.
*
* @return the transaction id
*/
public byte[] getGlobalTransactionId() {
debugCodeCall("getGlobalTransactionId");
return globalTransactionId;
......
......@@ -150,6 +150,8 @@ 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.
......@@ -174,6 +176,24 @@ 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
implement & test: checkpoint commits running transactions
start writing javadocs for jdbcx package
......@@ -570,16 +590,16 @@ Features of H2
// mvcc = true;
// db
// new TestScriptSimple().runTest(this);
// new TestScript().runTest(this);
// new TestAutoRecompile().runTest(this);
// new TestBackup().runTest(this);
// new TestBatchUpdates().runTest(this);
// new TestBigDb().runTest(this);
// new TestBigResult().runTest(this);
// new TestCache().runTest(this);
// new TestCases().runTest(this);
// new TestCheckpoint().runTest(this);
new TestScriptSimple().runTest(this);
new TestScript().runTest(this);
new TestAutoRecompile().runTest(this);
new TestBackup().runTest(this);
new TestBatchUpdates().runTest(this);
new TestBigDb().runTest(this);
new TestBigResult().runTest(this);
new TestCache().runTest(this);
new TestCases().runTest(this);
new TestCheckpoint().runTest(this);
new TestCluster().runTest(this);
new TestCompatibility().runTest(this);
new TestCsv().runTest(this);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论