From: <mro...@us...> - 2012-11-05 15:58:06
|
Revision: 57313 http://firebird.svn.sourceforge.net/firebird/?rev=57313&view=rev Author: mrotteveel Date: 2012-11-05 15:57:56 +0000 (Mon, 05 Nov 2012) Log Message: ----------- Cleanup IscStmtHandle implementations and usage (step towards using interfaces wherever possible) Modified Paths: -------------- client-java/trunk/src/main/org/firebirdsql/gds/IscStmtHandle.java client-java/trunk/src/main/org/firebirdsql/gds/impl/AbstractIscStmtHandle.java client-java/trunk/src/main/org/firebirdsql/gds/impl/AbstractIscTrHandle.java client-java/trunk/src/main/org/firebirdsql/gds/impl/GDSHelper.java client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/BaseGDSImpl.java client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/isc_blob_handle_impl.java client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/isc_stmt_handle_impl.java client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/isc_tr_handle_impl.java client-java/trunk/src/main/org/firebirdsql/gds/impl/wire/AbstractJavaGDSImpl.java client-java/trunk/src/main/org/firebirdsql/gds/impl/wire/isc_blob_handle_impl.java client-java/trunk/src/main/org/firebirdsql/gds/impl/wire/isc_stmt_handle_impl.java client-java/trunk/src/main/org/firebirdsql/gds/impl/wire/isc_tr_handle_impl.java client-java/trunk/src/test/org/firebirdsql/gds/impl/jni/TestNgds.java Modified: client-java/trunk/src/main/org/firebirdsql/gds/IscStmtHandle.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/gds/IscStmtHandle.java 2012-11-05 08:20:57 UTC (rev 57312) +++ client-java/trunk/src/main/org/firebirdsql/gds/IscStmtHandle.java 2012-11-05 15:57:56 UTC (rev 57313) @@ -29,7 +29,6 @@ * Portions created by Alejandro Alberola are Copyright (C) 2001 * Boix i Oltra, S.L. All Rights Reserved. */ - package org.firebirdsql.gds; /** @@ -55,14 +54,52 @@ int TYPE_ROLLBACK = ISCConstants.isc_info_sql_stmt_rollback; int TYPE_SELECT_FOR_UPDATE = ISCConstants.isc_info_sql_stmt_select_for_upd; int TYPE_SET_GENERATOR = ISCConstants.isc_info_sql_stmt_set_generator; + + /** + * Get the {@link IscDbHandle} associated with this statement + * + * @return Instance of {@link IscDbHandle} + */ + IscDbHandle getRsr_rdb(); + + /** + * Sets the {@link IscDbHandle} associated with this statement + * @param value Instance of {@link IscDbHandle} + */ + void setRsr_rdb(IscDbHandle value); + + /** + * Add warning to this statement + * + * @param warning Warning to add + */ + void addWarning(GDSException warning); /** + * @return The statement text + */ + String getStatementText(); + + /** + * @param statement The statement text + */ + void setStatementText(String statement); + + /** * Get the input data structure that contains data that is put into * the statement. * * @return The input data structure */ XSQLDA getInSqlda(); + + /** + * Sets the input data structure that contains data that is put into + * the statement. + * + * @param xsqlda The input data structure + */ + void setInSqlda(XSQLDA xsqlda); /** * Get the output data structure that contains data that is retrieved @@ -71,16 +108,15 @@ * @return The output data structure */ XSQLDA getOutSqlda(); - + /** - * Retrieve whether all rows have been fetched of the rows selected - * by executing this statement. + * Sets the output data structure that contains data that is retrieved + * from the statement. * - * @return <code>true</code> if all rows have been fetched, - * <code>false</code> otherwise + * @param xsqlda The output data structure */ - boolean isAllRowsFetched(); - + void setOutSqlda(XSQLDA xsqlda); + /** * Get the execution plan from the statement. * @@ -90,6 +126,24 @@ String getExecutionPlan(); /** + * Sets the execution plan from the statement. + * + * @param plan execution plan or <code>null</code> if the execution plan was + * not fetched from the server. + */ + void setExecutionPlan(String plan); + + /** + * @return The Firebird server id for this statement + */ + int getRsrId(); + + /** + * @param value The Firebird server id for this statement + */ + void setRsrId(int value); + + /** * Get the statement type. * * @return one of the constants defined in this interface or {@link #TYPE_UNKNOWN} @@ -97,4 +151,189 @@ */ int getStatementType(); + /** + * Sets the statement type + * @param statementType one of the constants defined in this interface or {@link #TYPE_UNKNOWN} + * when no statement type was received from the server. + */ + void setStatementType(int statementType); + + // TODO: Move rows / size related methods to separate interface + + /** + * Retrieve whether all rows have been fetched of the rows selected + * by executing this statement. + * + * @return <code>true</code> if all rows have been fetched, + * <code>false</code> otherwise + */ + boolean isAllRowsFetched(); + + /** + * Set whether all rows have been fetched. + * + * @param value <code>true</code> if all rows have been fetched, <code>false</code> otherwise + */ + void setAllRowsFetched(boolean value); + + /** + * Get the number of rows contained in this statement. + * + * @return The rowcount for this statement + */ + int size(); + + /** + * Ensure capacity for specified number of rows. + * + * @param maxSize Capacity for rows to be created/reserved + */ + void ensureCapacity(int maxSize); + + /** + * Remove all rows contained by this statement. This method differs from + * {@link #clearRows} in that it effectively clears all rows from this + * statement. + * + * @see #clearRows + */ + void removeRows(); + + /** + * Clear all rows that have been fetched for this statement. This + * method differs from {@link #removeRows} in that it only affects rows + * that have already been fetched. + * + * @see #removeRows + */ + void clearRows(); + + /** + * Get the rows retrieved by executing this statement. + * + * @return Array of rows retrieved + */ + byte[][][] getRows(); + + /** + * Adds row to collection of fetched rows + * + * @param row Row to add + */ + void addRow(byte[][] row); + + // TODO Consider moving count methods to separate interface + + /** + * Get the number of rows that were deleted by executing this statement. + * + * @return The number of deleted rows + */ + int getDeleteCount(); + + /** + * Sets the number of rows that were deleted by executing this statement. + * + * @param deleteCount The number of deleted rows + */ + void setDeleteCount(int deleteCount); + + /** + * Get the number of rows that were inserted by executing this statement. + * + * @return The number of inserted rows + */ + int getInsertCount(); + + /** + * Sets the number of rows that were inserted by executing this statement. + * + * @param insertCount The number of inserted rows + */ + void setInsertCount(int insertCount); + + /** + * Get the number of rows that were updated by executing this statement. + * + * @return The number of updated rows + */ + int getUpdateCount(); + + /** + * Sets the number of rows that were updated by executing this statement. + * + * @param updateCount The number of updated rows + */ + void setUpdateCount(int updateCount); + + /** + * Get the number of rows that were selected by executing this statement. + * + * @return The number of selected rows + */ + int getSelectCount(); + + /** + * Get the number of rows that were selected by executing this statement. + * + * @param selectCount The number of selected rows + */ + void setSelectCount(int selectCount); + + /** + * Register statement for the transaction. This method is used within + * the <code>GDS.iscDsqlExecXXX</code> methods to keep a reference on + * current transaction in which statement is executed. + * + * @param trHandle instance of {@link IscTrHandle}. + */ + void registerTransaction(IscTrHandle trHandle); + + /** + * Get current transaction in which statement is currently executed. + * + * @return instance of {@link IscTrHandle} or <code>null</code> + * if statement is not assigned to a transaction. + */ + IscTrHandle getTransaction(); + + /** + * Unregister statement from the transaction. + */ + void unregisterTransaction(); + + /** + * Retrieve whether this statement has an open <code>ResultSet</code>. + * + * @return <code>true</code> if this statement has an open + * <code>ResultSet</code>, false otherwise + */ + boolean hasOpenResultSet(); + + /** + * Notifies this statement that there are open resultsets. + */ + void notifyOpenResultSet(); + + /** + * Retrieve whether this statement has singleton result set. + * + * @return <code>true</code> if result set has singleton result set. + */ + boolean isSingletonResult(); + + /** + * Sets whether this statement has singleton result set. + * + * @param value <code>true</code> if result set has singleton result set. + */ + void setSingletonResult(boolean value); + + /** + * Retrieve whether or not this statement is valid. + * + * @return <code>true</code> if this is a valid statement, + * <code>false</code> otherwise + */ + boolean isValid(); } Modified: client-java/trunk/src/main/org/firebirdsql/gds/impl/AbstractIscStmtHandle.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/gds/impl/AbstractIscStmtHandle.java 2012-11-05 08:20:57 UTC (rev 57312) +++ client-java/trunk/src/main/org/firebirdsql/gds/impl/AbstractIscStmtHandle.java 2012-11-05 15:57:56 UTC (rev 57313) @@ -1,141 +1,72 @@ /* - * Public Firebird Java API. + * Firebird Open Source J2ee connector - jdbc driver * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Distributable under LGPL license. + * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * LGPL License for more details. + * + * This file was created by members of the firebird development team. + * All individual contributions remain the Copyright (C) of those + * individuals. Contributors to this file are either listed here or + * can be obtained from a CVS history command. + * + * All rights reserved. */ +/* + * The Original Code is the Firebird Java GDS implementation. + * + * The Initial Developer of the Original Code is Alejandro Alberola. + * Portions created by Alejandro Alberola are Copyright (C) 2001 + * Boix i Oltra, S.L. All Rights Reserved. + */ package org.firebirdsql.gds.impl; -import org.firebirdsql.gds.ISCConstants; +import org.firebirdsql.gds.GDSException; +import org.firebirdsql.gds.IscDbHandle; import org.firebirdsql.gds.IscStmtHandle; +import org.firebirdsql.gds.IscTrHandle; +import org.firebirdsql.gds.XSQLDA; +import org.firebirdsql.logging.Logger; +import org.firebirdsql.logging.LoggerFactory; - /** * Abstract implementation of the {@link org.firebirdsql.gds.IscStmtHandle} * interface. */ public abstract class AbstractIscStmtHandle implements IscStmtHandle { + private static final Logger log = LoggerFactory.getLogger(AbstractIscStmtHandle.class, false); + private String executionPlan; - private int statementType = TYPE_UNKNOWN; - public String statement; - - /** - * Clear all rows that have been fetched for this statement. This - * method differs from {@link #removeRows} in that it only affects rows - * that have already been fetched. - * - * @see #removeRows - */ - public abstract void clearRows(); - - /** - * Get the number of rows that were deleted by executing this statement. - * - * @return The number of deleted rows - */ - public abstract int getDeleteCount(); - - /** - * Get the number of rows that were inserted by executing this statement. - * - * @return The number of inserted rows - */ - public abstract int getInsertCount(); - - /** - * Get the rows retrieved by executing this statement. - * - * @return Array of rows retrieved - */ - public abstract byte[][][] getRows(); - - /** - * Get the number of rows that were updated by executing this statement. - * - * @return The number of updated rows - */ - public abstract int getUpdateCount(); + private int statementType = IscStmtHandle.TYPE_UNKNOWN; + private String statement; + private int insertCount; + private int updateCount; + private int deleteCount; + private int selectCount; + private XSQLDA in_sqlda = null; + private XSQLDA out_sqlda = null; + private int rsr_id; + private byte[][][] rows; + private int size; + private boolean allRowsFetched = false; + private boolean isSingletonResult = false; + private boolean hasOpenResultSet = false; + private IscTrHandle trHandle; + private IscDbHandle rsr_rdb; - /** - * Retrieve whether this statement has an open <code>ResultSet</code>. - * - * @return <code>true</code> if this statement has an open - * <code>ResultSet</code>, false otherwise - */ - public abstract boolean hasOpenResultSet(); + public String getStatementText() { + return statement; + } - /** - * Retrieve whether this statement has singleton result set. - * - * @return <code>true</code> if result set has singleton result set. - */ - public abstract boolean isSingletonResult(); + public void setStatementText(String statement) { + this.statement = statement; + } - /** - * Retrieve whether or not this statement is valid. - * - * @return <code>true</code> if this is a valid statement, - * <code>false</code> otherwise - */ - public abstract boolean isValid(); - - /** - * Get the number of rows contained in this statement. - * - * @return The rowcount for this statement - */ - public abstract int size(); - - /** - * Remove all rows contained by this statement. This method differs from - * {@link #clearRows} in that it effectively clears all rows from this - * statement. - * - * @see #clearRows - */ - public abstract void removeRows(); - - /** - * Register statement for the transaction. This method is used within - * the <code>GDS.iscDsqlExecXXX</code> methods to keep a reference on - * current transaction in which statement is executed. - * - * @param trHandle instance of {@link AbstractIscTrHandle}. - */ - public abstract void registerTransaction(AbstractIscTrHandle trHandle); - - /** - * Get current transaction in which statement is currently executed. - * - * @return instance of {@link AbstractIscTrHandle} or <code>null</code> - * if statement is not assigned to a transaction. - */ - public abstract AbstractIscTrHandle getTransaction(); - - /** - * Unregister statement from the transaction. - */ - public abstract void unregisterTransaction(); - public String getExecutionPlan() { return executionPlan; } @@ -144,11 +75,6 @@ this.executionPlan = plan; } - /** - * Get type of the statement. - * - * @return value from the {@link ISCConstants} class. - */ public int getStatementType() { return statementType; } @@ -157,4 +83,180 @@ this.statementType = statementType; } + public void setInsertCount(int value) { + insertCount = value; + } + + public int getInsertCount() { + return insertCount; + } + + public void setUpdateCount(int value) { + updateCount = value; + } + + public int getUpdateCount() { + return updateCount; + } + + public void setDeleteCount(int value) { + deleteCount = value; + } + + public int getDeleteCount() { + return deleteCount; + } + + public void setSelectCount(int value) { + selectCount = value; + } + + public int getSelectCount() { + return selectCount; + } + + public XSQLDA getInSqlda() { + return in_sqlda; + } + + public XSQLDA getOutSqlda() { + return out_sqlda; + } + + public void setInSqlda(XSQLDA xsqlda) { + in_sqlda = xsqlda; + } + + public void setOutSqlda(XSQLDA xsqlda) { + out_sqlda = xsqlda; + } + + public void ensureCapacity(int maxSize) { + if (rows == null || rows.length < maxSize) + rows = new byte[maxSize][][]; + size = 0; + } + + public void clearRows() { + size = 0; + if (rows != null) + rows = null; + allRowsFetched = false; + hasOpenResultSet = false; + } + + public boolean isAllRowsFetched() { + return allRowsFetched; + } + + public void setAllRowsFetched(boolean value) { + allRowsFetched = value; + } + + public boolean isSingletonResult() { + return isSingletonResult; + } + + public void setSingletonResult(boolean value) { + isSingletonResult = value; + } + + public int getRsrId() { + return rsr_id; + } + + public void setRsrId(int value) { + rsr_id = value; + } + + public boolean hasOpenResultSet() { + return hasOpenResultSet; + } + + public void notifyOpenResultSet() { + hasOpenResultSet = true; + } + + public int size() { + return size; + } + + public byte[][][] getRows() { + // TODO Return rows up to size? + return rows; + } + + public void removeRows() { + rows = null; + size = 0; + } + + public void addRow(byte[][] row) { + rows[size++] = row; + } + + public IscTrHandle getTransaction() { + return trHandle; + } + + public void registerTransaction(IscTrHandle trHandle) { + this.trHandle = trHandle; + } + + public void unregisterTransaction() { + this.trHandle = null; + } + + public void addWarning(GDSException warning) { + // TODO: Store warnings on statement level? (currently only used from JNI-code) + rsr_rdb.addWarning(warning); + } + + public IscDbHandle getRsr_rdb() { + return rsr_rdb; + } + + public void setRsr_rdb(IscDbHandle value) { + rsr_rdb = value; + } + + public boolean isValid() { + return rsr_rdb != null && rsr_rdb.isValid(); + } + + /** + * Helper method to print the bytes of a row using hex representation. + * @param row Row to print + */ + public static void printRow(byte[][] row) { + StringBuilder sb = new StringBuilder(); + sb.append('\t'); + + if (row == null) + sb.append("null"); + else { + for (int i = 0; i < row.length; i++) { + + if (row[i] == null) + sb.append("null"); + else { + for (int j = 0; j < row[i].length; j++) { + String hexValue = Integer.toHexString(row[i][j] & 0xff); + if (hexValue.length() == 1) + sb.append(0); + + sb.append(hexValue); + if (j < row[i].length - 1) + sb.append(' '); + } + } + + if (i < row.length - 1) + sb.append(", "); + } + } + + if (log != null) + log.debug(sb.toString()); + } } Modified: client-java/trunk/src/main/org/firebirdsql/gds/impl/AbstractIscTrHandle.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/gds/impl/AbstractIscTrHandle.java 2012-11-05 08:20:57 UTC (rev 57312) +++ client-java/trunk/src/main/org/firebirdsql/gds/impl/AbstractIscTrHandle.java 2012-11-05 15:57:56 UTC (rev 57313) @@ -24,9 +24,17 @@ */ package org.firebirdsql.gds.impl; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +import org.firebirdsql.gds.IscBlobHandle; +import org.firebirdsql.gds.IscStmtHandle; import org.firebirdsql.gds.IscTrHandle; - /** * Abstract implementation of the {@link org.firebirdsql.gds.IscTrHandle} * interface. @@ -40,12 +48,24 @@ public final static int TRANSACTIONROLLINGBACK = 6; public final static int TRANSACTIONSTARTED = 2; public final static int TRANSACTIONSTARTING = 1; + + private final List<IscBlobHandle> blobs = Collections.synchronizedList(new LinkedList<IscBlobHandle>()); + private final Set<IscStmtHandle> stmts = Collections.synchronizedSet(new HashSet<IscStmtHandle>()); /** * Clear all the saved result sets from this handle. */ - public abstract void forgetResultSets(); - + public void forgetResultSets() { + synchronized(stmts) { + for (Iterator<IscStmtHandle> iter = stmts.iterator(); iter.hasNext();) { + AbstractIscStmtHandle stmt = (AbstractIscStmtHandle) iter.next(); + stmt.clearRows(); + } + + stmts.clear(); + } + } + /** * Get the current state of the transaction to which this handle is * pointing. The state is equal to one of the <code>TRANSACTION*</code> @@ -56,6 +76,14 @@ */ public abstract int getState(); + public void addBlob(IscBlobHandle blob) { + blobs.add(blob); + } + + public void removeBlob(IscBlobHandle blob) { + blobs.remove(blob); + } + /** * Register a statement within the transaction to which this handle points. * This method allows automated cleanup of the rows fetched within a @@ -63,12 +91,16 @@ * * @param fbStatement Handle to the statement to be registered. */ - public abstract void registerStatementWithTransaction(AbstractIscStmtHandle fbStatement); + public void registerStatementWithTransaction(IscStmtHandle stmt) { + stmts.add(stmt); + } /** * Unregister a statement from the transaction in which it was registered. * * @param fbStatement Handle to the statement to be unregistered. */ - public abstract void unregisterStatementFromTransaction(AbstractIscStmtHandle fbStatement); + public void unregisterStatementFromTransaction(IscStmtHandle stmt) { + stmts.remove(stmt); + } } Modified: client-java/trunk/src/main/org/firebirdsql/gds/impl/GDSHelper.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/gds/impl/GDSHelper.java 2012-11-05 08:20:57 UTC (rev 57312) +++ client-java/trunk/src/main/org/firebirdsql/gds/impl/GDSHelper.java 2012-11-05 15:57:56 UTC (rev 57313) @@ -196,7 +196,7 @@ if (describeBind) gds.iscDsqlDescribeBind(stmt, ISCConstants.SQLDA_VERSION1); - stmt.statement = sql; + stmt.setStatementText(sql); } catch(GDSException ex) { notifyListeners(ex); @@ -220,7 +220,7 @@ try { if (log != null && log.isDebugEnabled()) - log.debug("Executing " + stmt.statement); + log.debug("Executing " + stmt.getStatementText()); // System.out.println("Executing " + stmt.statement); Modified: client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/BaseGDSImpl.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/BaseGDSImpl.java 2012-11-05 08:20:57 UTC (rev 57312) +++ client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/BaseGDSImpl.java 2012-11-05 15:57:56 UTC (rev 57313) @@ -26,6 +26,7 @@ import org.firebirdsql.gds.*; import org.firebirdsql.gds.impl.AbstractGDS; import org.firebirdsql.gds.impl.AbstractIscDbHandle; +import org.firebirdsql.gds.impl.AbstractIscStmtHandle; import org.firebirdsql.gds.impl.AbstractIscTrHandle; import org.firebirdsql.gds.impl.DatabaseParameterBufferExtension; import org.firebirdsql.gds.impl.GDSType; @@ -34,7 +35,7 @@ public abstract class BaseGDSImpl extends AbstractGDS { - // TODO Synchronization seems to be inconsistent: sometimes on dbhandle, sometimes on this (and soemtimes on blobhandle) + // TODO Synchronization seems to be inconsistent: sometimes on dbhandle, sometimes on this (and sometimes on blobhandle) // TODO Checking for validity of dbhandle is inconsistent (sometimes only null check, sometimes also .isValid()) private static Logger log = LoggerFactory.getLogger(BaseGDSImpl.class, @@ -50,12 +51,11 @@ ISCConstants.isc_info_base_level, ISCConstants.isc_info_end }; - private static byte[] stmtInfo = new byte[] { ISCConstants.isc_info_sql_records, ISCConstants.isc_info_sql_stmt_type, ISCConstants.isc_info_end}; - private static int INFO_SIZE = 128; + private static final int INFO_SIZE = 128; public int isc_api_handle; @@ -115,8 +115,9 @@ public void iscAttachDatabase(String file_name, IscDbHandle db_handle, DatabaseParameterBuffer databaseParameterBuffer) throws GDSException { - if (db_handle == null) { throw new GDSException( - ISCConstants.isc_bad_db_handle); } + if (db_handle == null) { + throw new GDSException(ISCConstants.isc_bad_db_handle); + } final byte[] dpbBytes; final String filenameCharset; @@ -166,10 +167,13 @@ public void iscCloseBlob(IscBlobHandle blob_handle) throws GDSException { isc_blob_handle_impl blob = (isc_blob_handle_impl) blob_handle; IscDbHandle db = blob.getDb(); - if (db == null) { throw new GDSException(ISCConstants.isc_bad_db_handle); } - isc_tr_handle_impl tr = blob.getTr(); - if (tr == null) { throw new GDSException( - ISCConstants.isc_bad_trans_handle); } + if (db == null) { + throw new GDSException(ISCConstants.isc_bad_db_handle); + } + AbstractIscTrHandle tr = blob.getTr(); + if (tr == null) { + throw new GDSException(ISCConstants.isc_bad_trans_handle); + } synchronized (db) { native_isc_close_blob(blob_handle); @@ -182,8 +186,9 @@ // --------------------------------------------------------------------------------------------- public void iscCommitRetaining(IscTrHandle tr_handle) throws GDSException { isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - if (tr == null) { throw new GDSException( - ISCConstants.isc_bad_trans_handle); } + if (tr == null) { + throw new GDSException(ISCConstants.isc_bad_trans_handle); + } IscDbHandle db = tr.getDbHandle(); if (db == null || !db.isValid()) @@ -191,8 +196,9 @@ synchronized (db) { if (tr.getState() != AbstractIscTrHandle.TRANSACTIONSTARTED - && tr.getState() != AbstractIscTrHandle.TRANSACTIONPREPARED) { throw new GDSException( - ISCConstants.isc_tra_state); } + && tr.getState() != AbstractIscTrHandle.TRANSACTIONPREPARED) { + throw new GDSException(ISCConstants.isc_tra_state); + } tr.setState(AbstractIscTrHandle.TRANSACTIONCOMMITTING); @@ -215,8 +221,9 @@ synchronized (db) { if (tr.getState() != AbstractIscTrHandle.TRANSACTIONSTARTED - && tr.getState() != AbstractIscTrHandle.TRANSACTIONPREPARED) { throw new GDSException( - ISCConstants.isc_tra_state); } + && tr.getState() != AbstractIscTrHandle.TRANSACTIONPREPARED) { + throw new GDSException(ISCConstants.isc_tra_state); + } tr.setState(AbstractIscTrHandle.TRANSACTIONCOMMITTING); @@ -234,14 +241,18 @@ IscBlobHandle blob_handle, BlobParameterBuffer blobParameterBuffer) throws GDSException { AbstractIscDbHandle db = (AbstractIscDbHandle) db_handle; - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; + AbstractIscTrHandle tr = (AbstractIscTrHandle) tr_handle; isc_blob_handle_impl blob = (isc_blob_handle_impl) blob_handle; - if (db == null) { throw new GDSException(ISCConstants.isc_bad_db_handle); } - if (tr == null) { throw new GDSException( - ISCConstants.isc_bad_trans_handle); } - if (blob == null) { throw new GDSException( - ISCConstants.isc_bad_segstr_handle); } + if (db == null) { + throw new GDSException(ISCConstants.isc_bad_db_handle); + } + if (tr == null) { + throw new GDSException(ISCConstants.isc_bad_trans_handle); + } + if (blob == null) { + throw new GDSException(ISCConstants.isc_bad_segstr_handle); + } final byte[] bpb = blobParameterBuffer == null ? null : ((BlobParameterBufferImp) blobParameterBuffer) @@ -288,8 +299,7 @@ throw new GDSException(ISCConstants.isc_bad_dpb_content); } - native_isc_create_database(urlData, db_handle, - dpbBytes); + native_isc_create_database(urlData, db_handle, dpbBytes); } } @@ -326,8 +336,9 @@ // isc_drop_database // --------------------------------------------------------------------------------------------- public void iscDropDatabase(IscDbHandle db_handle) throws GDSException { - if (db_handle == null) { throw new GDSException( - ISCConstants.isc_bad_db_handle); } + if (db_handle == null) { + throw new GDSException(ISCConstants.isc_bad_db_handle); + } synchronized (this) { native_isc_drop_database(db_handle); @@ -338,39 +349,35 @@ // --------------------------------------------------------------------------------------------- public void iscDsqlAllocateStatement(IscDbHandle db_handle, IscStmtHandle stmt_handle) throws GDSException { - isc_stmt_handle_impl stmt = (isc_stmt_handle_impl) stmt_handle; - if (db_handle == null) { throw new GDSException( - ISCConstants.isc_bad_db_handle); } + if (db_handle == null) { + throw new GDSException(ISCConstants.isc_bad_db_handle); + } - if (stmt_handle == null) { throw new GDSException( - ISCConstants.isc_bad_req_handle); } + if (stmt_handle == null) { + throw new GDSException(ISCConstants.isc_bad_req_handle); + } synchronized (db_handle) { native_isc_dsql_allocate_statement(db_handle, stmt_handle); - stmt.setRsr_rdb((AbstractIscDbHandle) db_handle); - stmt.setAllRowsFetched(false); + stmt_handle.setRsr_rdb(db_handle); + stmt_handle.setAllRowsFetched(false); } } // isc_dsql_describe // --------------------------------------------------------------------------------------------- - public XSQLDA iscDsqlDescribe(IscStmtHandle stmt_handle, int da_version) - throws GDSException { - isc_stmt_handle_impl stmt = (isc_stmt_handle_impl) stmt_handle; + public XSQLDA iscDsqlDescribe(IscStmtHandle stmt_handle, int da_version) throws GDSException { - if (stmt == null) { throw new GDSException( - ISCConstants.isc_bad_req_handle); } + if (stmt_handle == null) { + throw new GDSException(ISCConstants.isc_bad_req_handle); + } - synchronized (stmt.getRsr_rdb()) { + synchronized (stmt_handle.getRsr_rdb()) { + stmt_handle.setInSqlda(native_isc_dsql_describe(stmt_handle, da_version)); + // TODO setInSqlda here ?? - stmt.setInSqlda(native_isc_dsql_describe(stmt_handle, da_version)); /* - * @todo - * setInSqlda - * here ?? - */ - return stmt_handle.getInSqlda(); } } @@ -379,11 +386,9 @@ // --------------------------------------------------------------------------------------------- public XSQLDA iscDsqlDescribeBind(IscStmtHandle stmt_handle, int da_version) throws GDSException { - isc_stmt_handle_impl stmt = (isc_stmt_handle_impl) stmt_handle; - synchronized (stmt.getRsr_rdb()) { - stmt.setInSqlda(native_isc_dsql_describe_bind(stmt_handle, - da_version)); + synchronized (stmt_handle.getRsr_rdb()) { + stmt_handle.setInSqlda(native_isc_dsql_describe_bind(stmt_handle, da_version)); return stmt_handle.getInSqlda(); } @@ -403,6 +408,7 @@ public void iscDsqlExecImmed2(IscDbHandle db_handle, IscTrHandle tr_handle, String statement, int dialect, XSQLDA in_xsqlda, XSQLDA out_xsqlda) throws GDSException { + // TODO Suspicious use of NONE here iscDsqlExecImmed2(db_handle, tr_handle, statement, "NONE", dialect, in_xsqlda, out_xsqlda); } @@ -438,26 +444,25 @@ public void iscDsqlExecute2(IscTrHandle tr_handle, IscStmtHandle stmt_handle, int da_version, XSQLDA in_xsqlda, XSQLDA out_xsqlda) throws GDSException { - isc_stmt_handle_impl stmt = (isc_stmt_handle_impl) stmt_handle; - synchronized (stmt.getRsr_rdb()) { + synchronized (stmt_handle.getRsr_rdb()) { native_isc_dsql_execute2(tr_handle, stmt_handle, da_version, - in_xsqlda, out_xsqlda); /* @todo Fetch Statements */ + in_xsqlda, out_xsqlda); /* TODO Fetch Statements */ - if (stmt.getOutSqlda() != null) stmt.notifyOpenResultSet(); + if (stmt_handle.getOutSqlda() != null) stmt_handle.notifyOpenResultSet(); if (out_xsqlda != null) { // this would be an Execute procedure - stmt.ensureCapacity(1); - readSQLData(out_xsqlda, stmt); - stmt.setAllRowsFetched(true); - stmt.setSingletonResult(true); + stmt_handle.ensureCapacity(1); + readSQLData(out_xsqlda, stmt_handle); + stmt_handle.setAllRowsFetched(true); + stmt_handle.setSingletonResult(true); } else { - stmt.setAllRowsFetched(false); - stmt.setSingletonResult(false); + stmt_handle.setAllRowsFetched(false); + stmt_handle.setSingletonResult(false); } - stmt.registerTransaction((AbstractIscTrHandle)tr_handle); + stmt_handle.registerTransaction(tr_handle); } } @@ -503,26 +508,26 @@ throw new GDSException(ISCConstants.isc_dsql_sqlda_err); } - isc_stmt_handle_impl stmt = (isc_stmt_handle_impl) stmt_handle; - IscDbHandle db = stmt.getRsr_rdb(); + IscDbHandle db = stmt_handle.getRsr_rdb(); synchronized (db) { // Apply fetchSize // Fetch next batch of rows - stmt.ensureCapacity(fetchSize); + stmt_handle.ensureCapacity(fetchSize); for (int i = 0; i < fetchSize; i++) { + // TODO Repeating fetchSize times, but also passing fetchSize into fetch call? try { boolean isRowPresent = native_isc_dsql_fetch(stmt_handle, da_version, xsqlda, fetchSize); if (isRowPresent) { - readSQLData(xsqlda, stmt); + readSQLData(xsqlda, stmt_handle); } else { - stmt.setAllRowsFetched(true); + stmt_handle.setAllRowsFetched(true); return; } } finally { - stmt.notifyOpenResultSet(); + stmt_handle.notifyOpenResultSet(); } } } @@ -535,29 +540,28 @@ if (stmt_handle == null) { throw new GDSException(ISCConstants.isc_bad_req_handle); } - isc_stmt_handle_impl stmt = (isc_stmt_handle_impl) stmt_handle; - IscDbHandle db = stmt.getRsr_rdb(); + IscDbHandle db = stmt_handle.getRsr_rdb(); synchronized (db) { // Does not seem to be possible or necessary to close // an execute procedure statement. - if (stmt.isSingletonResult() && option == ISCConstants.DSQL_close) { return; } + if (stmt_handle.isSingletonResult() && option == ISCConstants.DSQL_close) { return; } if (option == ISCConstants.DSQL_drop) { - stmt.setInSqlda(null); - stmt.setOutSqlda(null); - stmt.setRsr_rdb(null); + stmt_handle.setInSqlda(null); + stmt_handle.setOutSqlda(null); + stmt_handle.setRsr_rdb(null); } native_isc_dsql_free_statement(stmt_handle, option); // clear association with transaction try { - AbstractIscTrHandle tr = stmt.getTransaction(); + AbstractIscTrHandle tr = (AbstractIscTrHandle)stmt_handle.getTransaction(); if (tr != null) - tr.unregisterStatementFromTransaction(stmt); + tr.unregisterStatementFromTransaction(stmt_handle); } finally { - stmt.unregisterTransaction(); + stmt_handle.unregisterTransaction(); } } @@ -575,17 +579,15 @@ if (stmt_handle == null) { throw new GDSException(ISCConstants.isc_bad_req_handle); } - isc_stmt_handle_impl stmt = (isc_stmt_handle_impl) stmt_handle; - IscDbHandle db = stmt.getRsr_rdb(); + + synchronized (stmt_handle.getRsr_rdb()) { + stmt_handle.setInSqlda(null); + stmt_handle.setOutSqlda(null); - synchronized (db) { - stmt.setInSqlda(null); - stmt.setOutSqlda(null); - - stmt.setOutSqlda(native_isc_dsql_prepare(tr_handle, stmt_handle, + stmt_handle.setOutSqlda(native_isc_dsql_prepare(tr_handle, stmt_handle, getZeroTerminatedArray(statement), dialect)); - getStatementType(stmt); + getStatementType(stmt_handle); return stmt_handle.getOutSqlda(); } @@ -598,7 +600,7 @@ * * @throws GDSException if error occured. */ - private void getStatementType(isc_stmt_handle_impl stmt) throws GDSException { + private void getStatementType(IscStmtHandle stmt) throws GDSException { final byte [] REQUEST = new byte [] { ISCConstants.isc_info_sql_stmt_type, ISCConstants.isc_info_end }; @@ -661,8 +663,7 @@ throw new GDSException(ISCConstants.isc_bad_req_handle); } - isc_stmt_handle_impl stmt = (isc_stmt_handle_impl) stmt_handle; - IscDbHandle db = stmt.getRsr_rdb(); + IscDbHandle db = stmt_handle.getRsr_rdb(); synchronized (db) { native_isc_dsql_set_cursor_name(stmt_handle, cursor_name, type); @@ -673,18 +674,11 @@ // --------------------------------------------------------------------------------------------- public byte[] iscDsqlSqlInfo(IscStmtHandle stmt_handle, byte[] items, int buffer_length) throws GDSException { - synchronized (((isc_stmt_handle_impl) stmt_handle).getRsr_rdb()) { + synchronized (((AbstractIscStmtHandle) stmt_handle).getRsr_rdb()) { return native_isc_dsql_sql_info(stmt_handle, items, buffer_length); } } - // isc_expand_dpb - // --------------------------------------------------------------------------------------------- - public byte[] iscExpandDpb(byte[] dpb, int dpb_length, int param, - Object[] params) throws GDSException { - return dpb; - } - // isc_get_segment // --------------------------------------------------------------------------------------------- public byte[] iscGetSegment(IscBlobHandle blob, int maxread) @@ -700,14 +694,18 @@ IscBlobHandle blob_handle, BlobParameterBuffer blobParameterBuffer) throws GDSException { AbstractIscDbHandle db = (AbstractIscDbHandle) db_handle; - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; + AbstractIscTrHandle tr = (AbstractIscTrHandle) tr_handle; isc_blob_handle_impl blob = (isc_blob_handle_impl) blob_handle; - if (db == null) { throw new GDSException(ISCConstants.isc_bad_db_handle); } - if (tr == null) { throw new GDSException( - ISCConstants.isc_bad_trans_handle); } - if (blob == null) { throw new GDSException( - ISCConstants.isc_bad_segstr_handle); } + if (db == null) { + throw new GDSException(ISCConstants.isc_bad_db_handle); + } + if (tr == null) { + throw new GDSException(ISCConstants.isc_bad_trans_handle); + } + if (blob == null) { + throw new GDSException(ISCConstants.isc_bad_segstr_handle); + } final byte[] bpb = blobParameterBuffer == null ? null : ((BlobParameterBufferImp) blobParameterBuffer) @@ -727,11 +725,11 @@ public void iscPrepareTransaction(IscTrHandle tr_handle) throws GDSException { isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - if (tr == null) { throw new GDSException( - ISCConstants.isc_bad_trans_handle); } - AbstractIscDbHandle db = (AbstractIscDbHandle) tr.getDbHandle(); - - synchronized (db) { + if (tr == null) { + throw new GDSException(ISCConstants.isc_bad_trans_handle); + } + + synchronized (tr.getDbHandle()) { if (tr.getState() != AbstractIscTrHandle.TRANSACTIONSTARTED) { throw new GDSException( ISCConstants.isc_tra_state); } tr.setState(AbstractIscTrHandle.TRANSACTIONPREPARING); @@ -747,13 +745,15 @@ public void iscPrepareTransaction2(IscTrHandle tr_handle, byte[] bytes) throws GDSException { isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - if (tr == null) { throw new GDSException( - ISCConstants.isc_bad_trans_handle); } - IscDbHandle db = tr.getDbHandle(); - - synchronized (db) { - if (tr.getState() != AbstractIscTrHandle.TRANSACTIONSTARTED) { throw new GDSException( - ISCConstants.isc_tra_state); } + if (tr == null) { + throw new GDSException(ISCConstants.isc_bad_trans_handle); + } + + synchronized (tr.getDbHandle()) { + if (tr.getState() != AbstractIscTrHandle.TRANSACTIONSTARTED) { + throw new GDSException(ISCConstants.isc_tra_state); + } + tr.setState(AbstractIscTrHandle.TRANSACTIONPREPARING); native_isc_prepare_transaction2(tr_handle, bytes); @@ -791,7 +791,7 @@ tr.setState(AbstractIscTrHandle.TRANSACTIONSTARTING); native_isc_reconnect_transaction(db_handle, tr_handle, buffer); - tr.setDbHandle((AbstractIscDbHandle) db_handle); + tr.setDbHandle(db_handle); tr.setState(AbstractIscTrHandle.TRANSACTIONSTARTED); } @@ -801,8 +801,9 @@ // --------------------------------------------------------------------------------------------- public void iscRollbackRetaining(IscTrHandle tr_handle) throws GDSException { isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - if (tr == null) { throw new GDSException( - ISCConstants.isc_bad_trans_handle); } + if (tr == null) { + throw new GDSException(ISCConstants.isc_bad_trans_handle); + } IscDbHandle db = tr.getDbHandle(); if (db == null || !db.isValid()) throw new GDSException(ISCConstants.isc_bad_db_handle); @@ -824,8 +825,9 @@ public void iscRollbackTransaction(IscTrHandle tr_handle) throws GDSException { isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - if (tr == null) { throw new GDSException( - ISCConstants.isc_bad_trans_handle); } + if (tr == null) { + throw new GDSException(ISCConstants.isc_bad_trans_handle); + } IscDbHandle db = tr.getDbHandle(); if (db == null || !db.isValid()) throw new GDSException(ISCConstants.isc_bad_db_handle); @@ -843,7 +845,6 @@ } } - public byte [] iscTransactionInformation(IscTrHandle trHandle, byte [] requestBuffer, int bufferLen) throws GDSException { synchronized (trHandle) { @@ -876,8 +877,7 @@ } } - public void iscServiceDetach(IscSvcHandle serviceHandle) - throws GDSException { + public void iscServiceDetach(IscSvcHandle serviceHandle) throws GDSException { synchronized (serviceHandle) { if (serviceHandle.isNotValid()) throw new GDSException("serviceHandle is not attached."); @@ -928,13 +928,15 @@ IscDbHandle db_handle, TransactionParameterBuffer tpb) throws GDSException { isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - IscDbHandle db = db_handle; TransactionParameterBufferImpl tpbImpl = (TransactionParameterBufferImpl) tpb; - if (tr == null) { throw new GDSException( - ISCConstants.isc_bad_trans_handle); } + if (tr == null) { + throw new GDSException(ISCConstants.isc_bad_trans_handle); + } - if (db == null) { throw new GDSException(ISCConstants.isc_bad_db_handle); } + if (db_handle == null) { + throw new GDSException(ISCConstants.isc_bad_db_handle); + } synchronized (db_handle) { if (tr.getState() != AbstractIscTrHandle.NOTRANSACTION) @@ -942,14 +944,10 @@ tr.setState(AbstractIscTrHandle.TRANSACTIONSTARTING); - // final byte[] arg = new byte[tpb.length + 1]; - // arg[0] = 3; - // System.arraycopy(tpb, 0, arg, 1, tpb.length); - byte[] arg = tpbImpl.getBytesForNativeCode(); native_isc_start_transaction(tr_handle, db_handle, arg); - tr.setDbHandle((AbstractIscDbHandle) db_handle); + tr.setDbHandle(db_handle); tr.setState(AbstractIscTrHandle.TRANSACTIONSTARTED); } @@ -1130,6 +1128,7 @@ */ private void parseAttachDatabaseInfo(byte[] info, IscDbHandle handle) throws GDSException { + // TODO Duplicate of method in wire.AbstractJavaGDSImpl? boolean debug = log != null && log.isDebugEnabled(); if (debug) log.debug("parseDatabaseInfo: first 2 bytes are " @@ -1207,7 +1206,7 @@ } } - public void readSQLData(XSQLDA xsqlda, isc_stmt_handle_impl stmt) { + public void readSQLData(XSQLDA xsqlda, IscStmtHandle stmt) { // This only works if not (port->port_flags & PORT_symmetric) int numCols = xsqlda.sqld; byte[][] row = new byte[numCols][]; @@ -1245,13 +1244,13 @@ } public void getSqlCounts(IscStmtHandle stmt_handle) throws GDSException { - isc_stmt_handle_impl stmt = (isc_stmt_handle_impl) stmt_handle; - byte[] buffer = iscDsqlSqlInfo(stmt, /* stmtInfo.length, */stmtInfo, INFO_SIZE); + // TODO duplicate of method in wire.AbstractJavaGDSImpl? + byte[] buffer = iscDsqlSqlInfo(stmt_handle, stmtInfo, INFO_SIZE); - stmt.setInsertCount(0); - stmt.setUpdateCount(0); - stmt.setDeleteCount(0); - stmt.setSelectCount(0); + stmt_handle.setInsertCount(0); + stmt_handle.setUpdateCount(0); + stmt_handle.setDeleteCount(0); + stmt_handle.setSelectCount(0); int pos = 0; int length; @@ -1268,19 +1267,19 @@ pos += 2; switch (t) { case ISCConstants.isc_info_req_insert_count: - stmt.setInsertCount(iscVaxInteger(buffer, pos, + stmt_handle.setInsertCount(iscVaxInteger(buffer, pos, l)); break; case ISCConstants.isc_info_req_update_count: - stmt.setUpdateCount(iscVaxInteger(buffer, pos, + stmt_handle.setUpdateCount(iscVaxInteger(buffer, pos, l)); break; case ISCConstants.isc_info_req_delete_count: - stmt.setDeleteCount(iscVaxInteger(buffer, pos, + stmt_handle.setDeleteCount(iscVaxInteger(buffer, pos, l)); break; case ISCConstants.isc_info_req_select_count: - stmt.setSelectCount(iscVaxInteger(buffer, pos, + stmt_handle.setSelectCount(iscVaxInteger(buffer, pos, l)); break; default: @@ -1290,7 +1289,7 @@ } break; case ISCConstants.isc_info_sql_stmt_type: - stmt.setStatementType(iscVaxInteger(buffer, pos, length)); + stmt_handle.setStatementType(iscVaxInteger(buffer, pos, length)); pos += length; break; default: @@ -1363,7 +1362,9 @@ public void fbCancelOperation(IscDbHandle dbHandle, int kind) throws GDSException { - if (dbHandle == null) { throw new GDSException(ISCConstants.isc_bad_db_handle); } + if (dbHandle == null) { + throw new GDSException(ISCConstants.isc_bad_db_handle); + } synchronized (this) { native_fb_cancel_operation(dbHandle, kind); Modified: client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/isc_blob_handle_impl.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/isc_blob_handle_impl.java 2012-11-05 08:20:57 UTC (rev 57312) +++ client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/isc_blob_handle_impl.java 2012-11-05 15:57:56 UTC (rev 57313) @@ -21,6 +21,7 @@ import org.firebirdsql.gds.*; import org.firebirdsql.gds.impl.AbstractIscDbHandle; +import org.firebirdsql.gds.impl.AbstractIscTrHandle; /** * Describe class <code>isc_blob_handle_impl</code> here. @@ -32,7 +33,7 @@ private AbstractIscDbHandle db; - private isc_tr_handle_impl tr; + private AbstractIscTrHandle tr; private int rbl_id; @@ -47,11 +48,11 @@ db.addWarning(warning); } - public isc_tr_handle_impl getTr() { + public AbstractIscTrHandle getTr() { return tr; } - public void setTr(isc_tr_handle_impl value) { + public void setTr(AbstractIscTrHandle value) { tr = value; } Modified: client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/isc_stmt_handle_impl.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/isc_stmt_handle_impl.java 2012-11-05 08:20:57 UTC (rev 57312) +++ client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/isc_stmt_handle_impl.java 2012-11-05 15:57:56 UTC (rev 57313) @@ -16,21 +16,9 @@ * * All rights reserved. */ -/* - * The Original Code is the Firebird Java GDS implementation. - * - * The Initial Developer of the Original Code is Alejandro Alberola. - * Portions created by Alejandro Alberola are Copyright (C) 2001 - * Boix i Oltra, S.L. All Rights Reserved. - */ - package org.firebirdsql.gds.impl.jni; -import org.firebirdsql.gds.XSQLDA; -import org.firebirdsql.gds.GDSException; -import org.firebirdsql.gds.impl.AbstractIscDbHandle; import org.firebirdsql.gds.impl.AbstractIscStmtHandle; -import org.firebirdsql.gds.impl.AbstractIscTrHandle; /** * Describe class <code>isc_stmt_handle_impl</code> here. @@ -40,182 +28,4 @@ * @version 1.0 */ public final class isc_stmt_handle_impl extends AbstractIscStmtHandle { - private int rsr_id; - private int rsr_id_ptr = 0; - - private AbstractIscDbHandle rsr_rdb; - private XSQLDA in_sqlda = null; - private XSQLDA out_sqlda = null; - private byte[][][] rows; - private int size; - private boolean allRowsFetched = false; - private boolean isSingletonResult = false; - private boolean hasOpenResultSet = false; - - private int statementType; - private int insertCount; - private int updateCount; - private int deleteCount; - private int selectCount; //???? - - private AbstractIscTrHandle trHandle; - - public void addWarning(GDSException warning) { - rsr_rdb.addWarning(warning); - } - - public isc_stmt_handle_impl() { - } - - public XSQLDA getInSqlda() { - return in_sqlda; - } - - public XSQLDA getOutSqlda() { - return out_sqlda; - } - - public void setInSqlda(XSQLDA xsqlda) { - in_sqlda = xsqlda; - } - - public void setOutSqlda(XSQLDA xsqlda) { - out_sqlda = xsqlda; - } - - public void ensureCapacity(int maxSize) { - if (rows== null || rows.length<maxSize) - rows = new byte[maxSize][][]; - size=0; - } - - public void clearRows() { - size = 0; - if (rows != null) - rows = null; - allRowsFetched = false; - hasOpenResultSet = false; - } - - public void setStatementType(int value) { - statementType = value; - } - - public int getStatementType() { - return statementType; - } - - public void setInsertCount(int value) { - insertCount = value; - } - - public int getInsertCount() { - return insertCount; - } - - public void setUpdateCount(int value) { - updateCount = value; - } - - public int getUpdateCount() { - return updateCount; - } - - public void setDeleteCount(int value) { - deleteCount = value; - } - - public int getDeleteCount() { - return deleteCount; - } - - public void setSelectCount(int value) { - selectCount = value; - } - - public int getSelectCount() { - return selectCount; - } - - public boolean isAllRowsFetched() { - return allRowsFetched; - } - - public void setAllRowsFetched(boolean value) { - allRowsFetched = value; - } - - public boolean isSingletonResult() { - return isSingletonResult; - } - - public void setSingletonResult(boolean value) { - isSingletonResult = value; - } - - public int getRsrId() { - return rsr_id; - } - - public void setRsrId(int value) { - rsr_id = value; - } - - public int getRsr_id_ptr() { - return rsr_id_ptr; - } - - public void setRsr_id_ptr(int rsr_id_ptr,int value) { - setRsrId(value); - this.rsr_id_ptr = rsr_id_ptr; - } - - public AbstractIscDbHandle getRsr_rdb() { - return rsr_rdb; - } - - public void setRsr_rdb(AbstractIscDbHandle value) { - rsr_rdb = value; - } - - public boolean isValid() { - return rsr_rdb != null && rsr_rdb.isValid(); - } - - public boolean hasOpenResultSet() { - return hasOpenResultSet; - } - - void notifyOpenResultSet() { - hasOpenResultSet = true; - } - - public int size() { - return size; - } - - public byte[][][] getRows() { - return rows; - } - - public void removeRows() { - rows = null; - size = 0; - } - - public void addRow(byte[][] row) { - rows[size++] = row; - } - - public AbstractIscTrHandle getTransaction() { - return trHandle; - } - - public void registerTransaction(AbstractIscTrHandle trHandle) { - this.trHandle = trHandle; - } - - public void unregisterTransaction() { - this.trHandle = null; - } } Modified: client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/isc_tr_handle_impl.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/isc_tr_handle_impl.java 2012-11-05 08:20:57 UTC (rev 57312) +++ client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/isc_tr_handle_impl.java 2012-11-05 15:57:56 UTC (rev 57313) @@ -27,16 +27,8 @@ import org.firebirdsql.gds.IscDbHandle; import org.firebirdsql.gds.GDSException; -import org.firebirdsql.gds.impl.AbstractIscDbHandle; -import org.firebirdsql.gds.impl.AbstractIscStmtHandle; import org.firebirdsql.gds.impl.AbstractIscTrHandle; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; /** * Describe class <code>is... [truncated message content] |