Changeset: f0410efd32ae for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f0410efd32ae Modified Files: java/ChangeLog java/src/nl/cwi/monetdb/jdbc/MonetConnection.java java/src/nl/cwi/monetdb/jdbc/MonetDriver.java.in java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatementJavaImpl.java Branch: default Log Message:
Drop the long abandoned Java-based implementation for PreparedStatement diffs (truncated from 444 to 300 lines): diff --git a/java/ChangeLog b/java/ChangeLog --- a/java/ChangeLog +++ b/java/ChangeLog @@ -1,3 +1,7 @@ # ChangeLog file for java # This file is updated with Maddlog +* Mon Apr 11 2011 Fabian Groffen <[email protected]> +- The obsolete Java-based implementation for PreparedStatements (formerly + activated using the java_prepared_statements property) has been dropped + diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java b/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java --- a/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java +++ b/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java @@ -115,9 +115,6 @@ /** Embedded properties */ private static Properties embeddedProps = null; - /** Whether or not to use a Java based PreparedStatement - * implementation */ - private final boolean javaPreparedStatements; /** Whether or not BLOB is mapped to BINARY within the driver */ private final boolean blobIsBinary; @@ -148,7 +145,6 @@ this.database = props.getProperty("database"); this.username = props.getProperty("user"); this.password = props.getProperty("password"); - this.javaPreparedStatements = Boolean.valueOf(props.getProperty("java_prepared_statements")).booleanValue(); String language = props.getProperty("language"); boolean debug = Boolean.valueOf(props.getProperty("debug")).booleanValue(); String hash = props.getProperty("hash"); @@ -683,22 +679,13 @@ throws SQLException { try { - PreparedStatement ret; - if (!javaPreparedStatements) { - // use a server-side PreparedStatement - ret = new MonetPreparedStatement( - this, - resultSetType, - resultSetConcurrency, - resultSetHoldability, - sql - ); - } else { - // use a Java implementation of a PreparedStatement - ret = new MonetPreparedStatementJavaImpl( - this, resultSetType, resultSetConcurrency, sql - ); - } + PreparedStatement ret = new MonetPreparedStatement( + this, + resultSetType, + resultSetConcurrency, + resultSetHoldability, + sql + ); // store it in the map for when we close... statements.put(ret, null); return(ret); diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetDriver.java.in b/java/src/nl/cwi/monetdb/jdbc/MonetDriver.java.in --- a/java/src/nl/cwi/monetdb/jdbc/MonetDriver.java.in +++ b/java/src/nl/cwi/monetdb/jdbc/MonetDriver.java.in @@ -117,7 +117,6 @@ props.put("port", PORT); props.put("debug", "false"); props.put("language", "sql"); // mal, sql, <future> - props.put("java_prepared_statements", "false"); props.putAll(info); info = props; diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatementJavaImpl.java b/java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatementJavaImpl.java deleted file mode 100644 --- a/java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatementJavaImpl.java +++ /dev/null @@ -1,366 +0,0 @@ -/* - * The contents of this file are subject to the MonetDB Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the - * License for the specific language governing rights and limitations - * under the License. - * - * The Original Code is the MonetDB Database System. - * - * The Initial Developer of the Original Code is CWI. - * Portions created by CWI are Copyright (C) 1997-July 2008 CWI. - * Copyright August 2008-2011 MonetDB B.V. - * All Rights Reserved. - */ - -package nl.cwi.monetdb.jdbc; - -import java.sql.*; -import java.util.*; -import java.net.URL; -import java.io.*; -import java.math.*; // BigDecimal, etc. - -/** - * A PreparedStatement suitable for the MonetDB database implemented in - * Java. - * <br /><br /> - * Although this class is deprecated, and has been replaced by an - * implementation that makes use of server side capabilities, this class - * is still provided for users that somehow rely on the behaviours from - * this Java implementation of a PreparedStatement. - * <br /><br /> - * This implementation is purely for enabling applications to use the - * interface PreparedStatement, for it does currently not use a PREPARE - * call on the MonetDB SQL backend. - * <br /><br /> - * Because we have no DBMS support here, we need to fake the lot to make - * it work. We try to spot `?', when not enclosed by single or double - * quotes. The positions of the question marks will later be replaced - * by the appropriate SQL and sent to the server using the underlying - * Statement. - * - * @author Fabian Groffen <[email protected]> - * @version 0.3 - * @deprecated - */ -public class MonetPreparedStatementJavaImpl - extends MonetPreparedStatement -{ - private final String pQuery; - - private final int size; - private final int[] pos; - private final String[] value; - - /** - * Constructor which checks the arguments for validity. This - * constructor is only accessible to classes from the jdbc package. - * - * @param connection the connection that created this Statement - * @param resultSetType type of ResultSet to produce - * @param resultSetConcurrency concurrency of ResultSet to produce - * @throws SQLException if an error occurs during login - * @throws IllegalArgumentException is one of the arguments is null or empty - */ - MonetPreparedStatementJavaImpl( - MonetConnection connection, - int resultSetType, - int resultSetConcurrency, - String prepareQuery) - throws SQLException, IllegalArgumentException - { - super( - connection, - resultSetType, - resultSetConcurrency, - ResultSet.HOLD_CURSORS_OVER_COMMIT - ); - - pQuery = prepareQuery; - - // find qualifying ?'s - List tpos = new ArrayList(); - - boolean inString = false; - boolean inIdentifier = false; - boolean escaped = false; - int len = pQuery.length(); - for (int i = 0; i < len; i++) { - switch(pQuery.charAt(i)) { - case '\\': - escaped = !escaped; - break; - default: - escaped = false; - break; - case '\'': - /** - * We can not be in a string if we are in an identifier. So - * If we find a ' and are not in an identifier, and not in - * a string we can safely assume we will be now in a string. - * If we are in a string already, we should stop being in a - * string if we find a quote which is not prefixed by a \, - * for that would be an escaped quote. However, a nasty - * situation can occur where the string is like 'test \\'. - * As obvious, a test for a \ in front of a ' doesn't hold - * here. Because 'test \\\'' can exist as well, we need to - * know if a quote is prefixed by an escaping slash or not. - */ - if (!inIdentifier) { - if (!inString && !escaped) { - // although it makes no sense to escape a quote - // outside a string, it is escaped, thus not meant - // as quote for us, apparently - inString = true; - } else if (inString && !escaped) { - inString = false; - } - } else { - // reset escaped flag - escaped = false; - } - break; - case '"': - if (!inString) { - if (!inIdentifier && !escaped) { - inIdentifier = true; - } else if (inIdentifier && !escaped) { - inIdentifier = false; - } - } else { - // reset escaped flag - escaped = false; - } - break; - case '-': - if (!escaped && !(inString || inIdentifier) && i + 1 < len && pQuery.charAt(i + 1) == '-') { - int nl = pQuery.indexOf('\n', i + 1); - if (nl == -1) { - // no newline found, so we don't need to skip and - // can stop right away - len = pQuery.length(); - } else { - // skip the comment when scanning for `?' - i = nl; - } - } - escaped = false; - break; - case '?': - if (!escaped && !(inString || inIdentifier) && !escaped) { - // mark this location - tpos.add(new Integer(i)); - } - escaped = false; - break; - } - } - - // initialize the ? container arrays - size = tpos.size(); - pos = new int[size]; - value = new String[size]; - - // fill the position array - for (int i = 0; i < size; i++) { - pos[i] = ((Integer)(tpos.get(i))).intValue(); - } - } - - - //== methods interface PreparedStatement - - /** - * Clears the current parameter values immediately. - * <br /><br /> - * In general, parameter values remain in force for repeated use of a - * statement. Setting a parameter value automatically clears its previous - * value. However, in some cases it is useful to immediately release the - * resources used by the current parameter values; this can be done by - * calling the method clearParameters. - */ - public void clearParameters() { - for (int i = 0; i < pos.length; i++) { - value[i] = null; - } - } - - /** - * Retrieves the number, types and properties of this PreparedStatement - * object's parameters. - * - * @return a ParameterMetaData object that contains information about the - * number, types and properties of this PreparedStatement object's - * parameters - * @throws SQLException if a database access error occurs - */ - public ParameterMetaData getParameterMetaData() throws SQLException { - throw new SQLException("Method currently not supported, sorry!"); - } - - /** - * Sets the value of the designated parameter using the given object. The - * second parameter must be of type Object; therefore, the java.lang - * equivalent objects should be used for built-in types. - * <br /><br /> - * The JDBC specification specifies a standard mapping from Java Object - * types to SQL types. The given argument will be converted to the - * corresponding SQL type before being sent to the database. - * <br /><br /> - * Note that this method may be used to pass datatabase-specific abstract - * data types, by using a driver-specific Java type. If the object is of a - * class implementing the interface SQLData, the JDBC driver should call - * the method SQLData.writeSQL to write it to the SQL data stream. If, on - * the other hand, the object is of a class implementing Ref, Blob, Clob, - * Struct, or Array, the driver should pass it to the database as a value - * of the corresponding SQL type. - * <br /><br /> _______________________________________________ Checkin-list mailing list [email protected] http://mail.monetdb.org/mailman/listinfo/checkin-list
