/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/ package org.apache.tomcat.dbcp.dbcp2;
/** * Result set type; one of {@code ResultSet.TYPE_FORWARD_ONLY}, {@code ResultSet.TYPE_SCROLL_INSENSITIVE}, or * {@code ResultSet.TYPE_SCROLL_SENSITIVE}.
*/ privatefinal Integer resultSetType;
/** * Result set concurrency. A concurrency type; one of {@code ResultSet.CONCUR_READ_ONLY} or * {@code ResultSet.CONCUR_UPDATABLE}.
*/ privatefinal Integer resultSetConcurrency;
/** * Result set holdability. One of the following {@code ResultSet} constants: {@code ResultSet.HOLD_CURSORS_OVER_COMMIT} * or {@code ResultSet.CLOSE_CURSORS_AT_COMMIT}.
*/ privatefinal Integer resultSetHoldability;
/** * A flag indicating whether auto-generated keys should be returned; one of {@code Statement.RETURN_GENERATED_KEYS} or * {@code Statement.NO_GENERATED_KEYS}.
*/ privatefinal Integer autoGeneratedKeys;
/** * An array of column indexes indicating the columns that should be returned from the inserted row or rows.
*/ privatefinalint[] columnIndexes;
/** * An array of column names indicating the columns that should be returned from the inserted row or rows.
*/ privatefinal String[] columnNames;
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @deprecated Use {@link #PStmtKey(String, String, String)}.
*/
@Deprecated public PStmtKey(final String sql) { this(sql, null, StatementType.PREPARED_STATEMENT);
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param resultSetType A result set type; one of {@code ResultSet.TYPE_FORWARD_ONLY}, * {@code ResultSet.TYPE_SCROLL_INSENSITIVE}, or {@code ResultSet.TYPE_SCROLL_SENSITIVE}. * @param resultSetConcurrency A concurrency type; one of {@code ResultSet.CONCUR_READ_ONLY} or * {@code ResultSet.CONCUR_UPDATABLE}. * @deprecated Use {@link #PStmtKey(String, String, String, int, int)}.
*/
@Deprecated public PStmtKey(final String sql, finalint resultSetType, finalint resultSetConcurrency) { this(sql, null, resultSetType, resultSetConcurrency, StatementType.PREPARED_STATEMENT);
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @deprecated Use {@link #PStmtKey(String, String, String)}.
*/
@Deprecated public PStmtKey(final String sql, final String catalog) { this(sql, catalog, StatementType.PREPARED_STATEMENT);
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param autoGeneratedKeys A flag indicating whether auto-generated keys should be returned; one of * {@code Statement.RETURN_GENERATED_KEYS} or {@code Statement.NO_GENERATED_KEYS}. * @deprecated Use {@link #PStmtKey(String, String, String, int)}.
*/
@Deprecated public PStmtKey(final String sql, final String catalog, finalint autoGeneratedKeys) { this(sql, catalog, StatementType.PREPARED_STATEMENT, Integer.valueOf(autoGeneratedKeys));
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param resultSetType A result set type; one of {@code ResultSet.TYPE_FORWARD_ONLY}, * {@code ResultSet.TYPE_SCROLL_INSENSITIVE}, or {@code ResultSet.TYPE_SCROLL_SENSITIVE}. * @param resultSetConcurrency A concurrency type; one of {@code ResultSet.CONCUR_READ_ONLY} or * {@code ResultSet.CONCUR_UPDATABLE}. * @deprecated Use {@link #PStmtKey(String, String, String, int, int)}.
*/
@Deprecated public PStmtKey(final String sql, final String catalog, finalint resultSetType, finalint resultSetConcurrency) { this(sql, catalog, resultSetType, resultSetConcurrency, StatementType.PREPARED_STATEMENT);
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param resultSetType a result set type; one of {@code ResultSet.TYPE_FORWARD_ONLY}, * {@code ResultSet.TYPE_SCROLL_INSENSITIVE}, or {@code ResultSet.TYPE_SCROLL_SENSITIVE}. * @param resultSetConcurrency A concurrency type; one of {@code ResultSet.CONCUR_READ_ONLY} or * {@code ResultSet.CONCUR_UPDATABLE} * @param resultSetHoldability One of the following {@code ResultSet} constants: * {@code ResultSet.HOLD_CURSORS_OVER_COMMIT} or {@code ResultSet.CLOSE_CURSORS_AT_COMMIT}. * @deprecated Use {@link #PStmtKey(String, String, String, int, int, int)}.
*/
@Deprecated public PStmtKey(final String sql, final String catalog, finalint resultSetType, finalint resultSetConcurrency, finalint resultSetHoldability) { this(sql, catalog, resultSetType, resultSetConcurrency, resultSetHoldability, StatementType.PREPARED_STATEMENT);
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param resultSetType a result set type; one of {@code ResultSet.TYPE_FORWARD_ONLY}, * {@code ResultSet.TYPE_SCROLL_INSENSITIVE}, or {@code ResultSet.TYPE_SCROLL_SENSITIVE} * @param resultSetConcurrency A concurrency type; one of {@code ResultSet.CONCUR_READ_ONLY} or * {@code ResultSet.CONCUR_UPDATABLE}. * @param resultSetHoldability One of the following {@code ResultSet} constants: * {@code ResultSet.HOLD_CURSORS_OVER_COMMIT} or {@code ResultSet.CLOSE_CURSORS_AT_COMMIT}. * @param statementType The SQL statement type, prepared or callable. * @deprecated Use {@link #PStmtKey(String, String, String, int, int, int, PoolingConnection.StatementType)}
*/
@Deprecated public PStmtKey(final String sql, final String catalog, finalint resultSetType, finalint resultSetConcurrency, finalint resultSetHoldability, final StatementType statementType) { this(sql, catalog, null, Integer.valueOf(resultSetType), Integer.valueOf(resultSetConcurrency), Integer.valueOf(resultSetHoldability), null, null, null, statementType,
k -> match(statementType, StatementHoldability, CallHoldability));
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param resultSetType A result set type; one of {@code ResultSet.TYPE_FORWARD_ONLY}, * {@code ResultSet.TYPE_SCROLL_INSENSITIVE}, or {@code ResultSet.TYPE_SCROLL_SENSITIVE}. * @param resultSetConcurrency A concurrency type; one of {@code ResultSet.CONCUR_READ_ONLY} or * {@code ResultSet.CONCUR_UPDATABLE}. * @param statementType The SQL statement type, prepared or callable. * @deprecated Use {@link #PStmtKey(String, String, String, int, int, PoolingConnection.StatementType)}.
*/
@Deprecated public PStmtKey(final String sql, final String catalog, finalint resultSetType, finalint resultSetConcurrency, final StatementType statementType) { this(sql, catalog, null, Integer.valueOf(resultSetType), Integer.valueOf(resultSetConcurrency), null, null, null, null, statementType,
k -> match(statementType, StatementConcurrency, CallConcurrency));
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param columnIndexes An array of column indexes indicating the columns that should be returned from the inserted row * or rows. * @deprecated Use {@link #PStmtKey(String, String, String, int[])}.
*/
@Deprecated public PStmtKey(final String sql, final String catalog, finalint[] columnIndexes) { this(sql, catalog, null, null, null, null, null, columnIndexes, null, StatementType.PREPARED_STATEMENT, StatementColumnIndexes);
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param statementType The SQL statement type, prepared or callable. * @deprecated Use {@link #PStmtKey(String, String, String, PoolingConnection.StatementType)}.
*/
@Deprecated public PStmtKey(final String sql, final String catalog, final StatementType statementType) { this(sql, catalog, null, null, null, null, null, null, null, statementType, k -> match(statementType, StatementSQL, CallSQL));
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param statementType The SQL statement type, prepared or callable. * @param autoGeneratedKeys A flag indicating whether auto-generated keys should be returned; one of * {@code Statement.RETURN_GENERATED_KEYS} or {@code Statement.NO_GENERATED_KEYS}. * @deprecated Use {@link #PStmtKey(String, String, String, PoolingConnection.StatementType, Integer)}
*/
@Deprecated public PStmtKey(final String sql, final String catalog, final StatementType statementType, final Integer autoGeneratedKeys) { this(sql, catalog, null, null, null, null, autoGeneratedKeys, null, null, statementType,
k -> match(statementType, StatementAutoGeneratedKeys, CallSQL));
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param schema The schema * @since 2.5.0
*/ public PStmtKey(final String sql, final String catalog, final String schema) { this(sql, catalog, schema, StatementType.PREPARED_STATEMENT);
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param schema The schema * @param autoGeneratedKeys A flag indicating whether auto-generated keys should be returned; one of * {@code Statement.RETURN_GENERATED_KEYS} or {@code Statement.NO_GENERATED_KEYS}. * @since 2.5.0
*/ public PStmtKey(final String sql, final String catalog, final String schema, finalint autoGeneratedKeys) { this(sql, catalog, schema, StatementType.PREPARED_STATEMENT, Integer.valueOf(autoGeneratedKeys));
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param schema The schema * @param resultSetType A result set type; one of {@code ResultSet.TYPE_FORWARD_ONLY}, * {@code ResultSet.TYPE_SCROLL_INSENSITIVE}, or {@code ResultSet.TYPE_SCROLL_SENSITIVE}. * @param resultSetConcurrency A concurrency type; one of {@code ResultSet.CONCUR_READ_ONLY} or * {@code ResultSet.CONCUR_UPDATABLE}.
*/ public PStmtKey(final String sql, final String catalog, final String schema, finalint resultSetType, finalint resultSetConcurrency) { this(sql, catalog, schema, resultSetType, resultSetConcurrency, StatementType.PREPARED_STATEMENT);
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param schema The schema * @param resultSetType a result set type; one of {@code ResultSet.TYPE_FORWARD_ONLY}, * {@code ResultSet.TYPE_SCROLL_INSENSITIVE}, or {@code ResultSet.TYPE_SCROLL_SENSITIVE}. * @param resultSetConcurrency A concurrency type; one of {@code ResultSet.CONCUR_READ_ONLY} or * {@code ResultSet.CONCUR_UPDATABLE} * @param resultSetHoldability One of the following {@code ResultSet} constants: * {@code ResultSet.HOLD_CURSORS_OVER_COMMIT} or {@code ResultSet.CLOSE_CURSORS_AT_COMMIT}. * @since 2.5.0
*/ public PStmtKey(final String sql, final String catalog, final String schema, finalint resultSetType, finalint resultSetConcurrency, finalint resultSetHoldability) { this(sql, catalog, schema, resultSetType, resultSetConcurrency, resultSetHoldability, StatementType.PREPARED_STATEMENT);
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param schema The schema. * @param resultSetType a result set type; one of {@code ResultSet.TYPE_FORWARD_ONLY}, * {@code ResultSet.TYPE_SCROLL_INSENSITIVE}, or {@code ResultSet.TYPE_SCROLL_SENSITIVE} * @param resultSetConcurrency A concurrency type; one of {@code ResultSet.CONCUR_READ_ONLY} or * {@code ResultSet.CONCUR_UPDATABLE}. * @param resultSetHoldability One of the following {@code ResultSet} constants: * {@code ResultSet.HOLD_CURSORS_OVER_COMMIT} or {@code ResultSet.CLOSE_CURSORS_AT_COMMIT}. * @param statementType The SQL statement type, prepared or callable. * @since 2.5.0
*/ public PStmtKey(final String sql, final String catalog, final String schema, finalint resultSetType, finalint resultSetConcurrency, finalint resultSetHoldability, final StatementType statementType) { this(sql, catalog, schema, Integer.valueOf(resultSetType), Integer.valueOf(resultSetConcurrency), Integer.valueOf(resultSetHoldability), null, null, null, statementType,
k -> match(statementType, StatementHoldability, CallHoldability));
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param schema The schema. * @param resultSetType A result set type; one of {@code ResultSet.TYPE_FORWARD_ONLY}, * {@code ResultSet.TYPE_SCROLL_INSENSITIVE}, or {@code ResultSet.TYPE_SCROLL_SENSITIVE}. * @param resultSetConcurrency A concurrency type; one of {@code ResultSet.CONCUR_READ_ONLY} or * {@code ResultSet.CONCUR_UPDATABLE}. * @param statementType The SQL statement type, prepared or callable. * @since 2.5.0
*/ public PStmtKey(final String sql, final String catalog, final String schema, finalint resultSetType, finalint resultSetConcurrency, final StatementType statementType) { this(sql, catalog, schema, Integer.valueOf(resultSetType), Integer.valueOf(resultSetConcurrency), null, null, null, null, statementType,
k -> match(statementType, StatementConcurrency, CallConcurrency));
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param schema The schema. * @param columnIndexes An array of column indexes indicating the columns that should be returned from the inserted row * or rows.
*/ public PStmtKey(final String sql, final String catalog, final String schema, finalint[] columnIndexes) { this(sql, catalog, schema, null, null, null, null, columnIndexes, null, StatementType.PREPARED_STATEMENT, StatementColumnIndexes);
}
private PStmtKey(final String sql, final String catalog, final String schema, final Integer resultSetType, final Integer resultSetConcurrency, final Integer resultSetHoldability, final Integer autoGeneratedKeys, finalint[] columnIndexes, final String[] columnNames, final StatementType statementType, finalFunction<PStmtKey, StatementBuilder> statementBuilder) { this.sql = Objects.requireNonNull(sql, "sql").trim(); this.catalog = catalog; this.schema = schema; this.resultSetType = resultSetType; this.resultSetConcurrency = resultSetConcurrency; this.resultSetHoldability = resultSetHoldability; this.autoGeneratedKeys = autoGeneratedKeys; this.columnIndexes = clone(columnIndexes); this.columnNames = clone(columnNames); this.statementBuilder = Objects.requireNonNull(Objects.requireNonNull(statementBuilder, "statementBuilder").apply(this), "statementBuilder"); this.statementType = statementType;
}
// Root constructor. private PStmtKey(final String sql, final String catalog, final String schema, final Integer resultSetType, final Integer resultSetConcurrency, final Integer resultSetHoldability, final Integer autoGeneratedKeys, finalint[] columnIndexes, final String[] columnNames, final StatementType statementType, final StatementBuilder statementBuilder) { this.sql = sql; this.catalog = catalog; this.schema = schema; this.resultSetType = resultSetType; this.resultSetConcurrency = resultSetConcurrency; this.resultSetHoldability = resultSetHoldability; this.autoGeneratedKeys = autoGeneratedKeys; this.columnIndexes = clone(columnIndexes); this.columnNames = clone(columnNames); this.statementBuilder = Objects.requireNonNull(statementBuilder, "statementBuilder"); this.statementType = statementType;
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param schema The schema. * @param statementType The SQL statement type, prepared or callable. * @since 2.5.0
*/ public PStmtKey(final String sql, final String catalog, final String schema, final StatementType statementType) { this(sql, catalog, schema, null, null, null, null, null, null, statementType, k -> match(statementType, StatementSQL, CallSQL));
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param schema The schema. * @param statementType The SQL statement type, prepared or callable. * @param autoGeneratedKeys A flag indicating whether auto-generated keys should be returned; one of * {@code Statement.RETURN_GENERATED_KEYS} or {@code Statement.NO_GENERATED_KEYS}. * @since 2.5.0
*/ public PStmtKey(final String sql, final String catalog, final String schema, final StatementType statementType, final Integer autoGeneratedKeys) { this(sql, catalog, schema, null, null, null, autoGeneratedKeys, null, null, statementType,
k -> match(statementType, StatementAutoGeneratedKeys, CallSQL));
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param schema The schema. * @param columnNames An array of column names indicating the columns that should be returned from the inserted row or * rows. * @since 2.5.0
*/ public PStmtKey(final String sql, final String catalog, final String schema, final String[] columnNames) { this(sql, catalog, schema, null, null, null, null, null, columnNames, StatementType.PREPARED_STATEMENT, StatementColumnNames);
}
/** * Constructs a key to uniquely identify a prepared statement. * * @param sql The SQL statement. * @param catalog The catalog. * @param columnNames An array of column names indicating the columns that should be returned from the inserted row or * rows. * @deprecated Use {@link #PStmtKey(String, String, String, String[])}.
*/
@Deprecated public PStmtKey(final String sql, final String catalog, final String[] columnNames) { this(sql, catalog, null, null, null, null, null, null, columnNames, StatementType.PREPARED_STATEMENT, StatementColumnNames);
}
/** * Creates a new Statement from the given Connection. * * @param connection The Connection to use to create the statement. * @return The statement. * @throws SQLException Thrown when there is a problem creating the statement.
*/ public Statement createStatement(final Connection connection) throws SQLException { return statementBuilder.createStatement(connection, this);
}
@Override publicboolean equals(final Object obj) { if (this == obj) { returntrue;
} if (obj == null) { returnfalse;
} if (getClass() != obj.getClass()) { returnfalse;
} final PStmtKey other = (PStmtKey) obj; if (!Objects.equals(autoGeneratedKeys, other.autoGeneratedKeys)) { returnfalse;
} if (!Objects.equals(catalog, other.catalog)) { returnfalse;
} if (!Arrays.equals(columnIndexes, other.columnIndexes)) { returnfalse;
} if (!Arrays.equals(columnNames, other.columnNames)) { returnfalse;
} if (!Objects.equals(resultSetConcurrency, other.resultSetConcurrency)) { returnfalse;
} if (!Objects.equals(resultSetHoldability, other.resultSetHoldability)) { returnfalse;
} if (!Objects.equals(resultSetType, other.resultSetType)) { returnfalse;
} if (!Objects.equals(schema, other.schema)) { returnfalse;
} if (!Objects.equals(sql, other.sql)) { returnfalse;
} return statementType == other.statementType;
}
/** * Gets a flag indicating whether auto-generated keys should be returned; one of {@code Statement.RETURN_GENERATED_KEYS} * or {@code Statement.NO_GENERATED_KEYS}. * * @return a flag indicating whether auto-generated keys should be returned.
*/ public Integer getAutoGeneratedKeys() { return autoGeneratedKeys;
}
/** * Gets the catalog. * * @return The catalog.
*/ public String getCatalog() { return catalog;
}
/** * Gets an array of column indexes indicating the columns that should be returned from the inserted row or rows. * * @return An array of column indexes.
*/ publicint[] getColumnIndexes() { return clone(columnIndexes);
}
/** * Gets an array of column names indicating the columns that should be returned from the inserted row or rows. * * @return An array of column names.
*/ public String[] getColumnNames() { return clone(columnNames);
}
/** * Gets the result set concurrency type; one of {@code ResultSet.CONCUR_READ_ONLY} or * {@code ResultSet.CONCUR_UPDATABLE}. * * @return The result set concurrency type.
*/ public Integer getResultSetConcurrency() { return resultSetConcurrency;
}
/** * Gets the result set holdability, one of the following {@code ResultSet} constants: * {@code ResultSet.HOLD_CURSORS_OVER_COMMIT} or {@code ResultSet.CLOSE_CURSORS_AT_COMMIT}. * * @return The result set holdability.
*/ public Integer getResultSetHoldability() { return resultSetHoldability;
}
/** * Gets the result set type, one of {@code ResultSet.TYPE_FORWARD_ONLY}, {@code ResultSet.TYPE_SCROLL_INSENSITIVE}, or * {@code ResultSet.TYPE_SCROLL_SENSITIVE}. * * @return the result set type.
*/ public Integer getResultSetType() { return resultSetType;
}
/** * Gets the schema. * * @return The catalog.
*/ public String getSchema() { return schema;
}
/** * Gets the SQL statement. * * @return the SQL statement.
*/ public String getSql() { return sql;
}
/** * Gets the SQL statement type. * * @return The SQL statement type.
*/ public StatementType getStmtType() { return statementType;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.