提交 17c8fe72 authored 作者: Thomas Mueller's avatar Thomas Mueller

Support for Java 1.3 and Java 1.4 has been removed.

上级 2c2262d3
......@@ -6,7 +6,6 @@
*/
package org.h2.fulltext;
//## Java 1.4 begin ##
import java.io.IOException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
......@@ -38,7 +37,6 @@ import org.h2.util.JdbcUtils;
import org.h2.util.New;
import org.h2.util.StatementBuilder;
import org.h2.util.StringUtils;
//## Java 1.4 end ##
/*## LUCENE2 begin ##
import org.apache.lucene.index.IndexModifier;
import org.apache.lucene.search.Hits;
......@@ -64,7 +62,6 @@ public class FullTextLucene extends FullText {
*/
protected static final boolean STORE_DOCUMENT_TEXT_IN_INDEX = Boolean.getBoolean("h2.storeDocumentTextInIndex");
//## Java 1.4 begin ##
private static final HashMap<String, IndexAccess> INDEX_ACCESS = New.hashMap();
private static final String TRIGGER_PREFIX = "FTL_";
private static final String SCHEMA = "FTL";
......@@ -72,7 +69,6 @@ public class FullTextLucene extends FullText {
private static final String LUCENE_FIELD_QUERY = "_QUERY";
private static final String LUCENE_FIELD_MODIFIED = "_modified";
private static final String LUCENE_FIELD_COLUMN_PREFIX = "_";
//## Java 1.4 end ##
/**
* Initializes full text search functionality for this database. This adds
......@@ -96,7 +92,6 @@ public class FullTextLucene extends FullText {
*
* @param conn the connection
*/
//## Java 1.4 begin ##
public static void init(Connection conn) throws SQLException {
Statement stat = conn.createStatement();
stat.execute("CREATE SCHEMA IF NOT EXISTS " + SCHEMA);
......@@ -113,7 +108,6 @@ public class FullTextLucene extends FullText {
throw convertException(e);
}
}
//## Java 1.4 end ##
/**
* Create a new full text index for a table and column list. Each table may
......@@ -124,7 +118,6 @@ public class FullTextLucene extends FullText {
* @param table the table name (case sensitive)
* @param columnList the column list (null for all columns)
*/
//## Java 1.4 begin ##
public static void createIndex(Connection conn, String schema, String table, String columnList) throws SQLException {
init(conn);
PreparedStatement prep = conn.prepareStatement("INSERT INTO " + SCHEMA
......@@ -136,7 +129,6 @@ public class FullTextLucene extends FullText {
createTrigger(conn, schema, table);
indexExistingRows(conn, schema, table);
}
//## Java 1.4 end ##
/**
* Re-creates the full text index for this database. Calling this method is
......@@ -144,7 +136,6 @@ public class FullTextLucene extends FullText {
*
* @param conn the connection
*/
//## Java 1.4 begin ##
public static void reindex(Connection conn) throws SQLException {
init(conn);
removeAllTriggers(conn, TRIGGER_PREFIX);
......@@ -158,21 +149,18 @@ public class FullTextLucene extends FullText {
indexExistingRows(conn, schema, table);
}
}
//## Java 1.4 end ##
/**
* Drops all full text indexes from the database.
*
* @param conn the connection
*/
//## Java 1.4 begin ##
public static void dropAll(Connection conn) throws SQLException {
Statement stat = conn.createStatement();
stat.execute("DROP SCHEMA IF EXISTS " + SCHEMA);
removeAllTriggers(conn, TRIGGER_PREFIX);
removeIndexFiles(conn);
}
//## Java 1.4 end ##
/**
* Searches from the full text index for this database.
......@@ -189,11 +177,9 @@ public class FullTextLucene extends FullText {
* @param offset the offset or 0 for no offset
* @return the result set
*/
//## Java 1.4 begin ##
public static ResultSet search(Connection conn, String text, int limit, int offset) throws SQLException {
return search(conn, text, limit, offset, false);
}
//## Java 1.4 end ##
/**
* Searches from the full text index for this database. The result contains
......@@ -215,7 +201,6 @@ public class FullTextLucene extends FullText {
* @param offset the offset or 0 for no offset
* @return the result set
*/
//## Java 1.4 begin ##
public static ResultSet searchData(Connection conn, String text, int limit, int offset) throws SQLException {
return search(conn, text, limit, offset, true);
}
......@@ -413,7 +398,7 @@ public class FullTextLucene extends FullText {
for (int i = 0; i < limit && i + offset < max; i++) {
Document doc = hits.doc(i + offset);
float score = hits.score(i + offset);
## LUCENE2 end ##*/
## LUCENE2 end ##*/
//## LUCENE3 begin ##
// take a reference as the searcher may change
Searcher searcher = access.searcher;
......@@ -470,18 +455,12 @@ public class FullTextLucene extends FullText {
}
return result;
}
//## Java 1.4 end ##
/**
* Trigger updates the index when a inserting, updating, or deleting a row.
*/
public static class FullTextTrigger
//## Java 1.4 begin ##
implements Trigger
//## Java 1.4 end ##
{
public static class FullTextTrigger implements Trigger {
//## Java 1.4 begin ##
protected String schema;
protected String table;
protected int[] keys;
......@@ -490,12 +469,10 @@ public class FullTextLucene extends FullText {
protected int[] columnTypes;
protected String indexPath;
protected IndexAccess indexAccess;
//## Java 1.4 end ##
/**
* INTERNAL
*/
//## Java 1.4 begin ##
public void init(Connection conn, String schemaName, String triggerName,
String tableName, boolean before, int type) throws SQLException {
this.schema = schemaName;
......@@ -556,12 +533,10 @@ public class FullTextLucene extends FullText {
indexColumns = new int[indexList.size()];
setColumns(indexColumns, indexList, columnList);
}
//## Java 1.4 end ##
/**
* INTERNAL
*/
//## Java 1.4 begin ##
public void fire(Connection conn, Object[] oldRow, Object[] newRow)
throws SQLException {
if (oldRow != null) {
......@@ -580,19 +555,16 @@ public class FullTextLucene extends FullText {
insert(newRow);
}
}
//## Java 1.4 end ##
/**
* INTERNAL
*/
//## Java 1.4 begin ##
public void close() throws SQLException {
if (indexAccess != null) {
removeIndexAccess(indexAccess, indexPath);
indexAccess = null;
}
}
//## Java 1.4 end ##
/**
* INTERNAL
......
......@@ -267,7 +267,7 @@ public class JdbcCallableStatement extends JdbcPreparedStatement implements Call
/**
* Returns the value of the specified column as a BigDecimal.
*
* @deprecated use {@link #getBigDecimal(String)} or {@link #getBigDecimal(int)}
* @deprecated use {@link #getBigDecimal(int)}
*
* @param parameterIndex the parameter index (1, 2, ...)
* @param scale is ignored
......
......@@ -82,9 +82,7 @@ public class JdbcConnection extends TraceObject implements Connection {
private CommandInterface setLockMode, getLockMode;
private CommandInterface setQueryTimeout, getQueryTimeout;
//## Java 1.4 begin ##
private int savepointId;
//## Java 1.4 end ##
private Trace trace;
private boolean isInternal;
private String catalog;
......@@ -890,7 +888,6 @@ public class JdbcConnection extends TraceObject implements Connection {
*
* @return the new savepoint
*/
//## Java 1.4 begin ##
public Savepoint setSavepoint() throws SQLException {
try {
int id = getNextId(TraceObject.SAVEPOINT);
......@@ -907,7 +904,6 @@ public class JdbcConnection extends TraceObject implements Connection {
throw logAndConvert(e);
}
}
//## Java 1.4 end ##
/**
* Creates a new named savepoint.
......@@ -915,7 +911,6 @@ public class JdbcConnection extends TraceObject implements Connection {
* @param name the savepoint name
* @return the new savepoint
*/
//## Java 1.4 begin ##
public Savepoint setSavepoint(String name) throws SQLException {
try {
int id = getNextId(TraceObject.SAVEPOINT);
......@@ -931,14 +926,12 @@ public class JdbcConnection extends TraceObject implements Connection {
throw logAndConvert(e);
}
}
//## Java 1.4 end ##
/**
* Rolls back to a savepoint.
*
* @param savepoint the savepoint
*/
//## Java 1.4 begin ##
public void rollback(Savepoint savepoint) throws SQLException {
try {
JdbcSavepoint sp = convertSavepoint(savepoint);
......@@ -953,14 +946,12 @@ public class JdbcConnection extends TraceObject implements Connection {
throw logAndConvert(e);
}
}
//## Java 1.4 end ##
/**
* Releases a savepoint.
*
* @param savepoint the savepoint to release
*/
//## Java 1.4 begin ##
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
try {
debugCode("releaseSavepoint(savepoint);");
......@@ -977,7 +968,6 @@ public class JdbcConnection extends TraceObject implements Connection {
}
return (JdbcSavepoint) savepoint;
}
//## Java 1.4 end ##
/**
* Creates a prepared statement with the specified result set type,
......@@ -1079,11 +1069,9 @@ public class JdbcConnection extends TraceObject implements Connection {
private static void checkJavaVersion() {
try {
//## Java 1.4 begin ##
// check for existence of this class (avoiding Class . forName)
Class<?> clazz = java.sql.Savepoint.class;
clazz.getClass();
//## Java 1.4 end ##
} catch (NoClassDefFoundError e) {
throw DbException.get(ErrorCode.UNSUPPORTED_JAVA_VERSION);
}
......@@ -1333,12 +1321,10 @@ public class JdbcConnection extends TraceObject implements Connection {
private static void checkHoldability(int resultSetHoldability) {
// TODO compatibility / correctness: DBPool uses
// ResultSet.HOLD_CURSORS_OVER_COMMIT
//## Java 1.4 begin ##
if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT
&& resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) {
throw DbException.getInvalidValueException("resultSetHoldability", resultSetHoldability);
}
//## Java 1.4 end ##
}
/**
......
......@@ -2644,24 +2644,20 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* CLOSE_CURSORS_AT_COMMIT
* @return true if the holdability is ResultSet.CLOSE_CURSORS_AT_COMMIT
*/
//## Java 1.4 begin ##
public boolean supportsResultSetHoldability(int holdability) {
debugCodeCall("supportsResultSetHoldability", holdability);
return holdability == ResultSet.CLOSE_CURSORS_AT_COMMIT;
}
//## Java 1.4 end ##
/**
* Gets the result set holdability.
*
* @return ResultSet.CLOSE_CURSORS_AT_COMMIT
*/
//## Java 1.4 begin ##
public int getResultSetHoldability() {
debugCodeCall("getResultSetHoldability");
return ResultSet.CLOSE_CURSORS_AT_COMMIT;
}
//## Java 1.4 end ##
/**
* Gets the major version of the database.
......@@ -2714,12 +2710,10 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
*
* @return DatabaseMetaData.sqlStateSQL99
*/
//## Java 1.4 begin ##
public int getSQLStateType() {
debugCodeCall("getSQLStateType");
return DatabaseMetaData.sqlStateSQL99;
}
//## Java 1.4 end ##
/**
* Does the database make a copy before updating.
......
......@@ -21,11 +21,7 @@ import org.h2.value.Value;
/**
* Information about the parameters of a prepared statement.
*/
public class JdbcParameterMetaData extends TraceObject
//## Java 1.4 begin ##
implements ParameterMetaData
//## Java 1.4 end ##
{
public class JdbcParameterMetaData extends TraceObject implements ParameterMetaData {
private JdbcPreparedStatement prep;
private int paramCount;
......@@ -60,7 +56,6 @@ implements ParameterMetaData
* @param param the column index (1,2,...)
* @return parameterModeIn
*/
//## Java 1.4 begin ##
public int getParameterMode(int param) throws SQLException {
try {
debugCodeCall("getParameterMode", param);
......@@ -70,7 +65,6 @@ implements ParameterMetaData
throw logAndConvert(e);
}
}
//## Java 1.4 end ##
/**
* Returns the parameter type.
......
......@@ -669,7 +669,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
/**
* [Not supported] This feature is deprecated and not supported.
*
* @deprecated this feature is deprecated.
* @deprecated
*/
public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException {
throw unsupported("unicodeStream");
......@@ -1098,9 +1098,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
e.setNextException(next);
next = e;
}
//## Java 1.4 begin ##
result[i] = Statement.EXECUTE_FAILED;
//## Java 1.4 end ##
error = true;
}
}
......@@ -1248,7 +1246,6 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*
* @return the meta data
*/
//## Java 1.4 begin ##
public ParameterMetaData getParameterMetaData() throws SQLException {
try {
int id = getNextId(TraceObject.PARAMETER_META_DATA);
......@@ -1262,7 +1259,6 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
throw logAndConvert(e);
}
}
//## Java 1.4 end ##
// =============================================================
......
......@@ -696,7 +696,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/**
* Returns the value of the specified column as a BigDecimal.
*
* @deprecated use {@link #getBigDecimal(String)} or {@link #getBigDecimal(int)}
* @deprecated use {@link #getBigDecimal(String)}
*
* @param columnLabel the column label
* @param scale the scale of the returned value
......@@ -722,7 +722,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/**
* Returns the value of the specified column as a BigDecimal.
*
* @deprecated use {@link #getBigDecimal(String)} or {@link #getBigDecimal(int)}
* @deprecated use {@link #getBigDecimal(int)}
*
* @param columnIndex (1,2,...)
* @param scale the scale of the returned value
......
......@@ -48,9 +48,7 @@ public class JdbcSQLException extends SQLException {
this.cause = cause;
this.stackTrace = stackTrace;
buildMessage();
//## Java 1.4 begin ##
initCause(cause);
//## Java 1.4 end ##
}
/**
......@@ -88,11 +86,6 @@ public class JdbcSQLException extends SQLException {
public void printStackTrace(PrintWriter s) {
if (s != null) {
super.printStackTrace(s);
/*## Java 1.3 only begin ##
if (cause != null) {
cause.printStackTrace(s);
}
## Java 1.3 only end ##*/
// getNextException().printStackTrace(s) would be very very slow
// if many exceptions are joined
SQLException next = getNextException();
......@@ -114,11 +107,6 @@ public class JdbcSQLException extends SQLException {
public void printStackTrace(PrintStream s) {
if (s != null) {
super.printStackTrace(s);
/*## Java 1.3 only begin ##
if (cause != null) {
cause.printStackTrace(s);
}
## Java 1.3 only end ##*/
// getNextException().printStackTrace(s) would be very very slow
// if many exceptions are joined
SQLException next = getNextException();
......
......@@ -7,9 +7,7 @@
package org.h2.jdbc;
import java.sql.SQLException;
//## Java 1.4 begin ##
import java.sql.Savepoint;
//## Java 1.4 end ##
import org.h2.constant.ErrorCode;
import org.h2.message.DbException;
......@@ -22,11 +20,7 @@ import org.h2.util.StringUtils;
* rolled back. The tasks that where done before the savepoint are not rolled
* back in this case.
*/
public class JdbcSavepoint extends TraceObject
//## Java 1.4 begin ##
implements Savepoint
//## Java 1.4 end ##
{
public class JdbcSavepoint extends TraceObject implements Savepoint {
private static final String SYSTEM_SAVEPOINT_PREFIX = "SYSTEM_SAVEPOINT_";
......
......@@ -639,9 +639,7 @@ public class JdbcStatement extends TraceObject implements Statement {
e.setNextException(next);
next = e;
}
//## Java 1.4 begin ##
result[i] = Statement.EXECUTE_FAILED;
//## Java 1.4 end ##
error = true;
}
}
......@@ -858,7 +856,6 @@ public class JdbcStatement extends TraceObject implements Statement {
*
* @return the holdability
*/
//## Java 1.4 begin ##
public int getResultSetHoldability() throws SQLException {
try {
debugCodeCall("getResultSetHoldability");
......@@ -868,7 +865,6 @@ public class JdbcStatement extends TraceObject implements Statement {
throw logAndConvert(e);
}
}
//## Java 1.4 end ##
/**
* [Not supported]
......
......@@ -63,11 +63,7 @@ import java.util.logging.Logger;
* In this example the user name and password are serialized as
* well; this may be a security problem in some cases.
*/
public class JdbcDataSource extends TraceObject
//## Java 1.4 begin ##
implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Referenceable
//## Java 1.4 end ##
{
public class JdbcDataSource extends TraceObject implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Referenceable {
private static final long serialVersionUID = 1288136338451857771L;
......@@ -295,7 +291,6 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
*
* @return the new reference
*/
//## Java 1.4 begin ##
public Reference getReference() {
debugCodeCall("getReference");
String factoryClassName = JdbcDataSourceFactory.class.getName();
......@@ -307,20 +302,17 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
ref.add(new StringRefAddr("description", description));
return ref;
}
//## Java 1.4 end ##
/**
* Open a new XA connection using the current URL, user name and password.
*
* @return the connection
*/
//## Java 1.4 begin ##
public XAConnection getXAConnection() throws SQLException {
debugCodeCall("getXAConnection");
int id = getNextId(XA_DATA_SOURCE);
return new JdbcXAConnection(factory, id, getJdbcConnection(userName, StringUtils.cloneCharArray(passwordChars)));
}
//## Java 1.4 end ##
/**
* Open a new XA connection using the current URL and the specified user
......@@ -330,7 +322,6 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
* @param password the password
* @return the connection
*/
//## Java 1.4 begin ##
public XAConnection getXAConnection(String user, String password) throws SQLException {
if (isDebugEnabled()) {
debugCode("getXAConnection("+quote(user)+", \"\");");
......@@ -338,19 +329,16 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
int id = getNextId(XA_DATA_SOURCE);
return new JdbcXAConnection(factory, id, getJdbcConnection(user, convertToCharArray(password)));
}
//## Java 1.4 end ##
/**
* Open a new pooled connection using the current URL, user name and password.
*
* @return the connection
*/
//## Java 1.4 begin ##
public PooledConnection getPooledConnection() throws SQLException {
debugCodeCall("getPooledConnection");
return getXAConnection();
}
//## Java 1.4 end ##
/**
* Open a new pooled connection using the current URL and the specified user
......@@ -360,14 +348,12 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
* @param password the password
* @return the connection
*/
//## Java 1.4 begin ##
public PooledConnection getPooledConnection(String user, String password) throws SQLException {
if (isDebugEnabled()) {
debugCode("getPooledConnection("+quote(user)+", \"\");");
}
return getXAConnection(user, password);
}
//## Java 1.4 end ##
/**
* [Not supported] Return an object of this class if possible.
......
......@@ -8,12 +8,10 @@ package org.h2.jdbcx;
import java.util.Hashtable;
//## Java 1.4 begin ##
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.Reference;
import javax.naming.spi.ObjectFactory;
//## Java 1.4 end ##
import org.h2.constant.SysProperties;
import org.h2.engine.Constants;
......@@ -24,11 +22,7 @@ import org.h2.message.TraceSystem;
* This class is used to create new DataSource objects.
* An application should not use this class directly.
*/
public class JdbcDataSourceFactory
//## Java 1.4 begin ##
implements ObjectFactory
//## Java 1.4 end ##
{
public class JdbcDataSourceFactory implements ObjectFactory {
private static TraceSystem cachedTraceSystem;
private Trace trace;
......@@ -56,7 +50,6 @@ implements ObjectFactory
* @return the new JdbcDataSource, or null if the reference class name is
* not JdbcDataSource.
*/
//## Java 1.4 begin ##
public synchronized Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) {
if (trace.isDebugEnabled()) {
trace.debug("getObjectInstance obj={0} name={1} nameCtx={2} environment={3}", obj, name, nameCtx, environment);
......@@ -76,7 +69,6 @@ implements ObjectFactory
}
return null;
}
//## Java 1.4 end ##
/**
* INTERNAL
......
......@@ -6,7 +6,6 @@
*/
package org.h2.jdbcx;
//## Java 1.4 begin ##
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
......@@ -23,7 +22,6 @@ import org.h2.constant.SysProperties;
import org.h2.jdbc.JdbcConnection;
import org.h2.util.JdbcUtils;
import org.h2.util.New;
//## Java 1.4 end ##
import org.h2.message.DbException;
import org.h2.message.Trace;
......@@ -38,13 +36,8 @@ import javax.sql.StatementEventListener;
* An application developer usually does not use this interface.
* It is used by the transaction manager internally.
*/
public class JdbcXAConnection extends TraceObject
//## Java 1.4 begin ##
implements XAConnection, XAResource
//## Java 1.4 end ##
{
public class JdbcXAConnection extends TraceObject implements XAConnection, XAResource {
//## Java 1.4 begin ##
private JdbcDataSourceFactory factory;
// This connection is kept open as long as the XAConnection is alive
......@@ -64,19 +57,16 @@ implements XAConnection, XAResource
setTrace(factory.getTrace(), TraceObject.XA_DATA_SOURCE, id);
this.physicalConn = physicalConn;
}
//## Java 1.4 end ##
/**
* Get the XAResource object.
*
* @return itself
*/
//## Java 1.4 begin ##
public XAResource getXAResource() {
debugCodeCall("getXAResource");
return this;
}
//## Java 1.4 end ##
/**
* Close the physical connection.
......@@ -84,7 +74,6 @@ implements XAConnection, XAResource
*
* @throws SQLException
*/
//## Java 1.4 begin ##
public void close() throws SQLException {
debugCodeCall("close");
PooledJdbcConnection lastHandle = handleConn;
......@@ -100,7 +89,6 @@ implements XAConnection, XAResource
}
}
}
//## Java 1.4 end ##
/**
* Get a connection that is a handle to the physical connection. This method
......@@ -109,7 +97,6 @@ implements XAConnection, XAResource
*
* @return the connection
*/
//## Java 1.4 begin ##
public Connection getConnection() throws SQLException {
debugCodeCall("getConnection");
PooledJdbcConnection lastHandle = handleConn;
......@@ -119,36 +106,30 @@ implements XAConnection, XAResource
handleConn = new PooledJdbcConnection(physicalConn);
return handleConn;
}
//## Java 1.4 end ##
/**
* Register a new listener for the connection.
*
* @param listener the event listener
*/
//## Java 1.4 begin ##
public void addConnectionEventListener(ConnectionEventListener listener) {
debugCode("addConnectionEventListener(listener);");
listeners.add(listener);
}
//## Java 1.4 end ##
/**
* Remove the event listener.
*
* @param listener the event listener
*/
//## Java 1.4 begin ##
public void removeConnectionEventListener(ConnectionEventListener listener) {
debugCode("removeConnectionEventListener(listener);");
listeners.remove(listener);
}
//## Java 1.4 end ##
/**
* INTERNAL
*/
//## Java 1.4 begin ##
void closedHandle() {
debugCode("closedHandle();");
for (ConnectionEventListener listener : New.arrayList(listeners)) {
......@@ -157,19 +138,16 @@ implements XAConnection, XAResource
}
handleConn = null;
}
//## Java 1.4 end ##
/**
* Get the transaction timeout.
*
* @return 0
*/
//## Java 1.4 begin ##
public int getTransactionTimeout() {
debugCodeCall("getTransactionTimeout");
return 0;
}
//## Java 1.4 end ##
/**
* Set the transaction timeout.
......@@ -177,12 +155,10 @@ implements XAConnection, XAResource
* @param seconds ignored
* @return false
*/
//## Java 1.4 begin ##
public boolean setTransactionTimeout(int seconds) {
debugCodeCall("setTransactionTimeout", seconds);
return false;
}
//## Java 1.4 end ##
/**
* Checks if this is the same XAResource.
......@@ -190,12 +166,10 @@ implements XAConnection, XAResource
* @param xares the other object
* @return true if this is the same object
*/
//## Java 1.4 begin ##
public boolean isSameRM(XAResource xares) {
debugCode("isSameRM(xares);");
return xares == this;
}
//## Java 1.4 end ##
/**
* Get the list of prepared transaction branches.
......@@ -206,7 +180,6 @@ implements XAConnection, XAResource
* @return zero or more Xid objects
* @throws XAException
*/
//## Java 1.4 begin ##
public Xid[] recover(int flag) throws XAException {
debugCodeCall("recover", quoteFlags(flag));
checkOpen();
......@@ -233,7 +206,6 @@ implements XAConnection, XAResource
JdbcUtils.closeSilently(stat);
}
}
//## Java 1.4 end ##
/**
* Prepare a transaction.
......@@ -242,7 +214,6 @@ implements XAConnection, XAResource
* @return XA_OK
* @throws XAException
*/
//## Java 1.4 begin ##
public int prepare(Xid xid) throws XAException {
if (isDebugEnabled()) {
debugCode("prepare("+JdbcXid.toString(xid)+");");
......@@ -262,7 +233,6 @@ implements XAConnection, XAResource
}
return XA_OK;
}
//## Java 1.4 end ##
/**
* Forget a transaction.
......@@ -270,13 +240,11 @@ implements XAConnection, XAResource
*
* @param xid the transaction id
*/
//## Java 1.4 begin ##
public void forget(Xid xid) {
if (isDebugEnabled()) {
debugCode("forget("+JdbcXid.toString(xid)+");");
}
}
//## Java 1.4 end ##
/**
* Roll back a transaction.
......@@ -284,7 +252,6 @@ implements XAConnection, XAResource
* @param xid the transaction id
* @throws XAException
*/
//## Java 1.4 begin ##
public void rollback(Xid xid) throws XAException {
if (isDebugEnabled()) {
debugCode("rollback("+JdbcXid.toString(xid)+");");
......@@ -306,7 +273,6 @@ implements XAConnection, XAResource
}
currentTransaction = null;
}
//## Java 1.4 end ##
/**
* End a transaction.
......@@ -315,7 +281,6 @@ implements XAConnection, XAResource
* @param flags TMSUCCESS, TMFAIL, or TMSUSPEND
* @throws XAException
*/
//## Java 1.4 begin ##
public void end(Xid xid, int flags) throws XAException {
if (isDebugEnabled()) {
debugCode("end("+JdbcXid.toString(xid)+", "+quoteFlags(flags)+");");
......@@ -328,7 +293,6 @@ implements XAConnection, XAResource
throw new XAException(XAException.XAER_OUTSIDE);
}
}
//## Java 1.4 end ##
/**
* Start or continue to work on a transaction.
......@@ -337,7 +301,6 @@ implements XAConnection, XAResource
* @param flags TMNOFLAGS, TMJOIN, or TMRESUME
* @throws XAException
*/
//## Java 1.4 begin ##
public void start(Xid xid, int flags) throws XAException {
if (isDebugEnabled()) {
debugCode("start("+JdbcXid.toString(xid)+", "+quoteFlags(flags)+");");
......@@ -359,7 +322,6 @@ implements XAConnection, XAResource
}
currentTransaction = xid;
}
//## Java 1.4 end ##
/**
* Commit a transaction.
......@@ -368,7 +330,6 @@ implements XAConnection, XAResource
* @param onePhase use a one-phase protocol if true
* @throws XAException
*/
//## Java 1.4 begin ##
public void commit(Xid xid, boolean onePhase) throws XAException {
if (isDebugEnabled()) {
debugCode("commit("+JdbcXid.toString(xid)+", "+onePhase+");");
......@@ -389,7 +350,6 @@ implements XAConnection, XAResource
}
currentTransaction = null;
}
//## Java 1.4 end ##
/**
* [Not supported] Add a statement event listener.
......@@ -416,7 +376,6 @@ implements XAConnection, XAResource
/**
* INTERNAL
*/
//## Java 1.4 begin ##
public String toString() {
return getTraceObjectName() + ": " + physicalConn;
}
......@@ -467,7 +426,6 @@ implements XAConnection, XAResource
throw new XAException(XAException.XAER_RMERR);
}
}
//## Java 1.4 end ##
/**
* A pooled connection.
......
......@@ -16,11 +16,7 @@ import org.h2.util.StringUtils;
/**
* An object of this class represents a transaction id.
*/
public class JdbcXid extends TraceObject
//## Java 1.4 begin ##
implements Xid
//## Java 1.4 end ##
{
public class JdbcXid extends TraceObject implements Xid {
private static final String PREFIX = "XID";
......
......@@ -344,9 +344,7 @@ public class DbException extends RuntimeException {
}
}
IOException io = new IOException(e.toString());
//## Java 1.4 begin ##
io.initCause(e);
//## Java 1.4 end ##
return io;
}
......
......@@ -79,7 +79,6 @@ public class CipherFactory {
*/
public static Socket createSocket(InetAddress address, int port) throws IOException {
Socket socket = null;
//## Java 1.4 begin ##
setKeystore();
SSLSocketFactory f = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket secureSocket = (SSLSocket) f.createSocket();
......@@ -91,7 +90,6 @@ public class CipherFactory {
secureSocket.setEnabledCipherSuites(list);
}
socket = secureSocket;
//## Java 1.4 end ##
return socket;
}
......@@ -106,7 +104,6 @@ public class CipherFactory {
*/
public static ServerSocket createServerSocket(int port, InetAddress bindAddress) throws IOException {
ServerSocket socket = null;
//## Java 1.4 begin ##
setKeystore();
ServerSocketFactory f = SSLServerSocketFactory.getDefault();
SSLServerSocket secureSocket;
......@@ -121,11 +118,9 @@ public class CipherFactory {
secureSocket.setEnabledCipherSuites(list);
}
socket = secureSocket;
//## Java 1.4 end ##
return socket;
}
//## Java 1.4 begin ##
private static byte[] getKeyStoreBytes(KeyStore store, String password) throws IOException {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
try {
......@@ -135,15 +130,13 @@ public class CipherFactory {
}
return bout.toByteArray();
}
//## Java 1.4 end ##
/**
/**
* Get the keystore object using the given password.
*
* @param password the keystore password
* @return the keystore
*/
//## Java 1.4 begin ##
public static KeyStore getKeyStore(String password) throws IOException {
try {
// The following source code can be re-generated
......
......@@ -1123,12 +1123,9 @@ public class WebApp {
}
rs.addRow("conn.getTypeMap", "" + map);
rs.addRow("conn.isReadOnly", "" + conn.isReadOnly());
//## Java 1.4 begin ##
rs.addRow("conn.getHoldability", "" + conn.getHoldability());
//## Java 1.4 end ##
addDatabaseMetaData(rs, meta);
return rs;
//## Java 1.4 begin ##
} else if (isBuiltIn(sql, "@attributes")) {
String[] p = split(sql);
return meta.getAttributes(p[1], p[2], p[3], p[4]);
......@@ -1138,7 +1135,6 @@ public class WebApp {
} else if (isBuiltIn(sql, "@super_types")) {
String[] p = split(sql);
return meta.getSuperTypes(p[1], p[2], p[3]);
//## Java 1.4 end ##
} else if (isBuiltIn(sql, "@prof_stop")) {
if (profiler != null) {
profiler.stopCollecting();
......@@ -1309,9 +1305,7 @@ public class WebApp {
session.addCommand(sql);
if (generatedKeys) {
rs = null;
//## Java 1.4 begin ##
rs = stat.getGeneratedKeys();
//## Java 1.4 end ##
} else {
if (!isResultSet) {
buff.append("${text.result.updateCount}: " + stat.getUpdateCount());
......
......@@ -27,9 +27,7 @@ class FileObjectMemoryData {
private static final byte[] BUFFER = new byte[BLOCK_SIZE * 2];
private static final byte[] COMPRESSED_EMPTY_BLOCK;
//## Java 1.4 begin ##
private static final Cache<CompressItem, CompressItem> COMPRESS_LATER = new Cache<CompressItem, CompressItem>(CACHE_SIZE);
//## Java 1.4 end ##
private String name;
private final boolean compress;
......@@ -49,7 +47,6 @@ class FileObjectMemoryData {
/**
* This small cache compresses the data if an element leaves the cache.
*/
//## Java 1.4 begin ##
static class Cache<K, V> extends LinkedHashMap<K, V> {
private static final long serialVersionUID = 1L;
......@@ -97,7 +94,6 @@ class FileObjectMemoryData {
return false;
}
}
//## Java 1.4 end ##
FileObjectMemoryData(String name, boolean compress) {
this.name = name;
......@@ -107,14 +103,12 @@ class FileObjectMemoryData {
}
private static void compressLater(byte[][] data, int page) {
//## Java 1.4 begin ##
CompressItem c = new CompressItem();
c.data = data;
c.page = page;
synchronized (LZF) {
COMPRESS_LATER.put(c, c);
}
//## Java 1.4 end ##
}
private static void expand(byte[][] data, int page) {
......
......@@ -1683,11 +1683,9 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
*
* @return the holdability
*/
//## Java 1.4 begin ##
public int getHoldability() {
return ResultSet.HOLD_CURSORS_OVER_COMMIT;
}
//## Java 1.4 end ##
/**
* Returns whether this result set has been closed.
......
......@@ -555,12 +555,7 @@ public class DateTimeUtils {
if (locale == null) {
df = new SimpleDateFormat(format);
} else {
//## Java 1.4 begin ##
Locale l = new Locale(locale);
//## Java 1.4 end ##
/*## Java 1.3 only begin ##
Locale l = new Locale(locale, "");
## Java 1.3 only end ##*/
df = new SimpleDateFormat(format, l);
}
if (timeZone != null) {
......
......@@ -146,7 +146,6 @@ public class JdbcUtils {
Class<?> d = Utils.loadUserClass(driver);
if (java.sql.Driver.class.isAssignableFrom(d)) {
return DriverManager.getConnection(url, prop);
//## Java 1.4 begin ##
} else if (javax.naming.Context.class.isAssignableFrom(d)) {
// JNDI context
try {
......@@ -161,9 +160,8 @@ public class JdbcUtils {
} catch (Exception e) {
throw DbException.toSQLException(e);
}
//## Java 1.4 end ##
} else {
// Don't know, but maybe it loaded a JDBC Driver
// don't know, but maybe it loaded a JDBC Driver
return DriverManager.getConnection(url, prop);
}
}
......
......@@ -30,8 +30,6 @@ public class MathUtils {
*/
static volatile boolean seeded;
private static boolean usePrecisionWorkaround;
private static final Random RANDOM = new Random();
/**
......@@ -305,24 +303,6 @@ public class MathUtils {
return (reverseInt((int) (x >>> 32L)) & 0xffffffffL) ^ (((long) reverseInt((int) x)) << 32L);
}
/**
* Compatibility for BigDecimal.precision() which is not available in Java 1.4.
*
* @param x the value
* @return the precision
*/
public static int precision(BigDecimal x) {
if (!usePrecisionWorkaround) {
try {
return x.precision();
} catch (Throwable e) {
// NoSuchMethodError
usePrecisionWorkaround = true;
}
}
return x.unscaledValue().abs().toString().length();
}
/**
* Compare two values. Returns -1 if the first value is smaller, 1 if bigger,
* and 0 if equal.
......
......@@ -187,11 +187,9 @@ public class NetUtils {
*/
public static boolean isLocalAddress(Socket socket) throws UnknownHostException {
InetAddress test = socket.getInetAddress();
//## Java 1.4 begin ##
if (test.isLoopbackAddress()) {
return true;
}
//## Java 1.4 end ##
InetAddress localhost = InetAddress.getLocalHost();
// localhost.getCanonicalHostName() is very very slow
String host = localhost.getHostAddress();
......
......@@ -6,12 +6,7 @@
*/
package org.h2.util;
//## Java 1.4 begin ##
import java.util.LinkedHashMap;
//## Java 1.4 end ##
/*## Java 1.3 only begin ##
import java.util.HashMap;
## Java 1.3 only end ##*/
import java.util.Map;
/**
......@@ -20,14 +15,7 @@ import java.util.Map;
* @param <K> the key
* @param <V> the value
*/
public class SmallLRUCache<K, V>
//## Java 1.4 begin ##
extends LinkedHashMap<K, V>
//## Java 1.4 end ##
/*## Java 1.3 only begin ##
extends HashMap
## Java 1.3 only end ##*/
{
public class SmallLRUCache<K, V> extends LinkedHashMap<K, V> {
private static final long serialVersionUID = 1L;
private int size;
......@@ -53,9 +41,8 @@ extends HashMap
this.size = size;
}
//## Java 1.4 begin ##
protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
return size() > size;
}
//## Java 1.4 end ##
}
......@@ -432,25 +432,12 @@ public class StringUtils {
* @return the encoded string
*/
public static String urlEncode(String s) {
//## Java 1.4 begin ##
try {
return URLEncoder.encode(s, "UTF-8");
} catch (Exception e) {
// UnsupportedEncodingException
throw DbException.convert(e);
}
//## Java 1.4 end ##
/*## Java 1.3 only begin ##
/*
return URLEncoder.encode(s);
*/
//## Java 1.4 end ##
// byte[] utf = utf8Encode(s);
// StringBuilder buff = new StringBuilder(utf.length);
// for(int i=0; i<utf.length; i++) {
//
// buff.append()
// }
}
/**
......
......@@ -143,7 +143,7 @@ public class ValueDecimal extends Value {
public long getPrecision() {
if (precision == 0) {
precision = MathUtils.precision(value);
precision = value.precision();
}
return precision;
}
......@@ -223,7 +223,7 @@ public class ValueDecimal extends Value {
}
public int getMemory() {
return MathUtils.precision(value) + 120;
return value.precision() + 120;
}
}
......@@ -58,33 +58,15 @@ public class SwitchSource {
}
if (version == null) {
// ok
} else if ("1.3".equals(version)) {
enable.add("Java 1.3 only");
disable.add("Java 1.4");
disable.add("Java 1.5");
disable.add("Java 1.6");
disable.add("Java 1.7");
} else if ("1.4".equals(version)) {
disable.add("Java 1.3 only");
enable.add("Java 1.4");
disable.add("Java 1.5");
disable.add("Java 1.6");
disable.add("Java 1.7");
} else if ("1.5".equals(version)) {
disable.add("Java 1.3 only");
enable.add("Java 1.4");
enable.add("Java 1.5");
disable.add("Java 1.6");
disable.add("Java 1.7");
} else if ("1.6".equals(version)) {
disable.add("Java 1.3 only");
enable.add("Java 1.4");
enable.add("Java 1.5");
enable.add("Java 1.6");
disable.add("Java 1.7");
} else if (version.compareTo("1.7") >= 0) {
disable.add("Java 1.3 only");
enable.add("Java 1.4");
enable.add("Java 1.5");
enable.add("Java 1.6");
enable.add("Java 1.7");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论