You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by db...@apache.org on 2016/05/02 18:11:59 UTC

[20/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4 driver build scripts migrated to use maven instead of ant

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Statement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Statement.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Statement.java
new file mode 100644
index 0000000..d0daff1
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Statement.java
@@ -0,0 +1,1690 @@
+// @@@ START COPYRIGHT @@@
+//
+// 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.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.lang.ref.WeakReference;
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+import java.sql.BatchUpdateException;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+/**
+ * <p>
+ * JDBC Type 4 TrafT4Statement class.
+ * </p>
+ * <p>
+ * Description: The <code>TrafT4Statement</code> class is an implementation of
+ * the <code>java.sql.Statement</code> interface.
+ * </p>
+ */
+public class TrafT4Statement extends HPT4Handle implements java.sql.Statement {
+	// java.sql.Statement interface Methods
+
+	public void addBatch(String sql) throws SQLException {
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("addBatch");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "addBatch", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("addBatch");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		if (batchCommands_ == null) {
+			batchCommands_ = new ArrayList();
+		}
+
+
+		batchCommands_.add(sql);
+	}
+
+	public void cancel() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "cancel", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("cancel");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+		// Donot clear warning, since the warning may pertain to
+		// previous opertation and it is not yet seen by the application
+		//
+		// We must decide if this statement is currently being processed or
+		// if it has a result set associated with it, and if that
+		// result set is currently active (i.e. we are fetching rows).
+		if ((ist_.t4statement_ != null && ist_.t4statement_.m_processing == true)
+				|| (resultSet_ != null && resultSet_[result_set_offset] != null
+						&& resultSet_[result_set_offset].irs_ != null
+						&& resultSet_[result_set_offset].irs_.t4resultSet_ != null && resultSet_[result_set_offset].irs_.t4resultSet_.m_processing == true))
+			ist_.cancel();
+	}
+
+	public void clearBatch() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "clearBatch", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("clearBatch");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+		batchCommands_.clear();
+	}
+
+	/**
+	 * Closes the statement object. Synchronized to prevent the same resource
+	 * issued free command twice on the server.
+	 * 
+	 * @throws SQLException
+	 */
+	synchronized public void close() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "close", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("close");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		if (isClosed_) {
+			return;
+		}
+
+		try {
+			if (connection_._isClosed() == false) {
+				for (int i = 0; i < num_result_sets_; i++) {
+					if (resultSet_[i] != null) {
+						resultSet_[i].close(false);
+					}
+				}
+				ist_.close();
+			}
+		} finally {
+			isClosed_ = true;
+			connection_.removeElement(pRef_);
+			initResultSets();
+		}
+	}
+
+	void initResultSets() {
+		num_result_sets_ = 1;
+		result_set_offset = 0;
+		resultSet_[result_set_offset] = null;
+	}
+
+	// ------------------------------------------------------------------
+	/**
+	 * This method will execute an operation.
+	 * 
+	 * @return true
+	 * 
+	 * @exception A
+	 *                SQLException is thrown
+	 */
+
+	public boolean execute() throws SQLException {
+		try {
+			ist_.executeDirect(queryTimeout_, this);
+		} catch (SQLException se) {
+			performConnectionErrorChecks(se);
+			throw se;
+		}
+		return true;
+	} // end execute
+
+	// ------------------------------------------------------------------
+
+	public boolean execute(String sql) throws SQLException {
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("execute");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "execute", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("execute");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+		validateExecDirectInvocation(sql);
+		try {
+			ist_.execute(TRANSPORT.SRVR_API_SQLEXECDIRECT, 0, 0, null, queryTimeout_, sql_, this);
+
+			checkSQLWarningAndClose();
+		} catch (SQLException se) {
+			try {
+				if (num_result_sets_ == 1 && resultSet_[result_set_offset] == null)
+					;
+				{
+					internalClose();
+				}
+			} catch (SQLException closeException) {
+				se.setNextException(closeException);
+			}
+			performConnectionErrorChecks(se);
+			throw se;
+		}
+		if (resultSet_[result_set_offset] != null) {
+			return true;
+		} else {
+			return false;
+		}
+	}
+
+	public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, autoGeneratedKeys);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "execute", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, autoGeneratedKeys);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("execute");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+		boolean ret;
+
+		if (autoGeneratedKeys == TrafT4Statement.NO_GENERATED_KEYS) {
+			ret = execute(sql);
+		} else {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+					"auto_generated_keys_not_supported", null);
+		}
+		return ret;
+	}
+
+	public boolean execute(String sql, int[] columnIndexes) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnIndexes);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "execute", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnIndexes);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("execute");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+		boolean ret;
+
+		if (columnIndexes == null) {
+			ret = execute(sql);
+		} else if (columnIndexes.length == 0) {
+			ret = execute(sql);
+		} else {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+					"auto_generated_keys_not_supported", null);
+		}
+		return ret;
+	}
+
+	public boolean execute(String sql, String[] columnNames) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnNames);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "execute", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnNames);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("execute");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+		boolean ret;
+
+		if (columnNames == null) {
+			ret = execute(sql);
+		} else if (columnNames.length == 0) {
+			ret = execute(sql);
+		} else {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+					"auto_generated_keys_not_supported", null);
+		}
+		return ret;
+	}
+
+	public int[] executeBatch() throws SQLException, BatchUpdateException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeBatch", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("executeBatch");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		try {
+			int i = 0;
+			SQLException se;
+
+			validateExecDirectInvocation();
+			if ((batchCommands_ == null) || (batchCommands_.isEmpty())) {
+				return new int[]
+
+				{};
+			}
+
+			batchRowCount_ = new int[batchCommands_.size()];
+			for (i = 0; i < batchCommands_.size(); i++) {
+				String sql = (String) batchCommands_.get(i);
+
+				if (sql == null) {
+					se = HPT4Messages.createSQLException(connection_.props_, this.ist_.ic_.getLocale(),
+							"batch_command_failed", "Invalid SQL String");
+					throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+				}
+
+				sqlStmtType_ = ist_.getSqlStmtType(sql);
+
+				if (sqlStmtType_ == TRANSPORT.TYPE_SELECT) {
+					se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+							"select_in_batch_not_supported", null);
+					throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+				} else if (sqlStmtType_ == TRANSPORT.TYPE_STATS) {
+					se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+							"infostats_invalid_error", null);
+					throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+				} else if (sqlStmtType_ == TRANSPORT.TYPE_CONFIG) {
+					se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+							"config_cmd_invalid_error", null);
+					throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+				}
+				ist_.setTransactionStatus(connection_, sql);
+			}
+
+			Object[] commands = batchCommands_.toArray();
+			int[] batchRowCount = new int[commands.length];
+			String sql;
+			int rowCount = 0;
+
+			try {
+				for (i = 0; i < commands.length; i++) {
+					sql = String.valueOf(commands[i]);
+
+					validateExecDirectInvocation(sql);
+
+					ist_.execute(TRANSPORT.SRVR_API_SQLEXECDIRECT, 0, 0, null, queryTimeout_, sql_, this);
+
+					checkSQLWarningAndClose();
+
+					batchRowCount[i] = batchRowCount_[0]; // the member will
+					// be set by
+					// execute...keep
+					// them in our local
+					// array
+					rowCount += ist_.getRowCount();
+				}
+				// CTS requirement.
+				if (commands.length < 1) {
+					batchRowCount = new int[] {};
+				}
+			} catch (SQLException e) {
+				ist_.setRowCount(rowCount);
+				batchRowCount_ = new int[i];
+				System.arraycopy(batchRowCount, 0, batchRowCount_, 0, i);
+
+				BatchUpdateException be;
+
+				se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+						"batch_command_failed", null);
+				be = new BatchUpdateException(se.getMessage(), se.getSQLState(), batchRowCount_);
+				be.setNextException(e);
+
+				try {
+					if (resultSet_[result_set_offset] == null) {
+						internalClose();
+					}
+				} catch (SQLException closeException) {
+					be.setNextException(closeException);
+				}
+				performConnectionErrorChecks(e);
+
+				throw be;
+			}
+
+			ist_.setRowCount(rowCount);
+			batchRowCount_ = new int[i];
+			System.arraycopy(batchRowCount, 0, batchRowCount_, 0, i);
+			return batchRowCount_;
+		} finally {
+			clearBatch();
+		}
+
+	}
+
+	public ResultSet executeQuery(String sql) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeQuery", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("executeQuery");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		validateExecDirectInvocation(sql);
+		if (sqlStmtType_ != TRANSPORT.TYPE_SELECT && sqlStmtType_ != TRANSPORT.TYPE_STATS) {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "non_select_invalid",
+					null);
+		}
+		try {
+			ist_.execute(TRANSPORT.SRVR_API_SQLEXECDIRECT, 0, 0, null, queryTimeout_, sql_, this);
+
+			checkSQLWarningAndClose();
+		} catch (SQLException se) {
+			try {
+				if (resultSet_[result_set_offset] == null) {
+					internalClose();
+				}
+			} catch (SQLException closeException) {
+				se.setNextException(closeException);
+			}
+			performConnectionErrorChecks(se);
+			throw se;
+		}
+		return resultSet_[result_set_offset];
+	}
+
+	public int executeUpdate(String sql) throws SQLException {
+		long count = executeUpdate64(sql);
+
+		if (count > Integer.MAX_VALUE)
+			this.setSQLWarning(null, "numeric_out_of_range", null);
+
+		return (int) count;
+	}
+
+	public long executeUpdate64(String sql) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeUpdate", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("executeUpdate");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+		validateExecDirectInvocation(sql);
+		// 7708
+		if (sqlStmtType_ == TRANSPORT.TYPE_SELECT && (ist_.stmtIsLock != true)) {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "select_invalid", null);
+		}
+		try {
+			ist_.execute(TRANSPORT.SRVR_API_SQLEXECDIRECT, 0, 0, null, queryTimeout_, sql_, this);
+
+			checkSQLWarningAndClose();
+		} catch (SQLException se) {
+			try {
+				if (resultSet_[result_set_offset] == null) {
+					internalClose();
+				}
+			} catch (SQLException closeException) {
+				se.setNextException(closeException);
+			}
+			performConnectionErrorChecks(se);
+			throw se;
+		}
+		return ist_.getRowCount();
+	}
+
+	public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, autoGeneratedKeys);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeUpdate", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, autoGeneratedKeys);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("executeUpdate");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+		int ret;
+
+		if (autoGeneratedKeys == TrafT4Statement.NO_GENERATED_KEYS) {
+			ret = executeUpdate(sql);
+		} else {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+					"auto_generated_keys_not_supported", null);
+		}
+		return ret;
+	}
+
+	public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnIndexes);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeUpdate", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnIndexes);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("executeUpdate");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+		int ret;
+
+		if (columnIndexes == null) {
+			ret = executeUpdate(sql);
+		} else if (columnIndexes.length == 0) {
+			ret = executeUpdate(sql);
+		} else {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+					"auto_generated_keys_not_supported", null);
+		}
+		return ret;
+	}
+
+	public int executeUpdate(String sql, String[] columnNames) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnNames);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeUpdate", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnNames);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("executeUpdate");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+		int ret;
+
+		if (columnNames == null) {
+			ret = executeUpdate(sql);
+		} else if (columnNames.length == 0) {
+			ret = executeUpdate(sql);
+		} else {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+					"auto_generated_keys_not_supported", null);
+		}
+		return ret;
+	}
+
+	public Connection getConnection() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getConnection", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("getConnection");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+		return connection_;
+	}
+
+	public int getFetchDirection() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getFetchDirection", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("getFetchDirection");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		return fetchDirection_;
+	}
+
+	public int getFetchSize() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getFetchSize", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("getFetchSize");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		return fetchSize_;
+	}
+
+	public ResultSet getGeneratedKeys() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getGeneratedKeys", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("getGeneratedKeys");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+				"auto_generated_keys_not_supported", null);
+	}
+
+	public int getMaxFieldSize() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getMaxFieldSize", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("getMaxFieldSize");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		return maxFieldSize_;
+	}
+
+	public int getMaxRows() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getMaxRows", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("getMaxRows");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		return maxRows_;
+	}
+
+	public boolean getMoreResults() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getMoreResults", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("getMoreResults");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		return getMoreResults(Statement.CLOSE_CURRENT_RESULT);
+	}
+
+	public boolean getMoreResults(int current) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, current);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getMoreResults", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, current);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("getMoreResults");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		switch (current) {
+		case Statement.CLOSE_ALL_RESULTS:
+			for (int i = 0; i <= result_set_offset; i++) {
+				if (resultSet_[i] != null) {
+					resultSet_[i].close();
+				}
+			}
+			break;
+		case Statement.KEEP_CURRENT_RESULT:
+			break;
+		case Statement.CLOSE_CURRENT_RESULT: // this is the default action
+		default:
+			if (resultSet_[result_set_offset] != null) {
+				resultSet_[result_set_offset].close();
+			}
+			break;
+		}
+		ist_.setRowCount(-1);
+		if (result_set_offset < num_result_sets_ - 1) {
+			result_set_offset++;
+			return true;
+		}
+		return false;
+	}
+
+	public int getQueryTimeout() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getQueryTimeout", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("getQueryTimeout");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		return queryTimeout_;
+	}
+
+	public ResultSet getResultSet() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getResultSet", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("getResultSet");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		return resultSet_[result_set_offset];
+	}
+
+	public int getResultSetConcurrency() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getResultSetConcurrency", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("getResultSetConcurrency");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		return resultSetConcurrency_;
+	}
+
+	public int getResultSetHoldability() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getResultSetHoldability", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("getResultSetHoldability");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		return resultSetHoldability_;
+	}
+
+	public int getResultSetType() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getResultSetType", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("getResultSetType");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		return resultSetType_;
+	}
+
+	public int getUpdateCount() throws SQLException {
+		long count = getUpdateCount64();
+
+		if (count > Integer.MAX_VALUE)
+			this.setSQLWarning(null, "numeric_out_of_range", null);
+
+		return (int) count;
+	}
+
+	public long getUpdateCount64() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getUpdateCount", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("getUpdateCount");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		if (ist_ == null) {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+					"invalid_statement_handle", null);
+		}
+
+		// Spec wants -1 when the resultset is current and no more rows.
+		long count = ist_.getRowCount();
+		if ((count == 0) && resultSet_ != null && resultSet_[result_set_offset] != null) {
+			count = -1;
+		}
+
+		return count;
+	}
+
+	// ------------------------------------------------------------------
+	/**
+	 * This method will get the operation ID for this statement. -1 is returned
+	 * if the operation ID has not been set.
+	 * 
+	 * @retrun The operation ID or -1 if the operation ID has not been set.
+	 * 
+	 * @exception A
+	 *                SQLException is thrown
+	 */
+	public short getOperationID() throws SQLException {
+		return operationID_;
+	} // end getOperationID
+
+	// ------------------------------------------------------------------
+	/**
+	 * This method will get the operation buffer for this statement. Null is
+	 * returned if the operation buffer has not been set.
+	 * 
+	 * @retrun The operation buffer or null if the operation ID has not been
+	 *         set.
+	 * 
+	 * @exception A
+	 *                SQLException is thrown
+	 */
+	public byte[] getOperationBuffer() throws SQLException {
+		// System.out.println("in getOperation");
+		return operationBuffer_;
+	}
+
+	// ------------------------------------------------------------------
+	/**
+	 * This method will get the operation reply buffer for this statement. Null
+	 * is returned if the operation reply buffer has not been set.
+	 * 
+	 * @retrun The operation reply buffer or null.
+	 * 
+	 * @exception A
+	 *                SQLException is thrown
+	 */
+	public byte[] getOperationReplyBuffer() throws SQLException {
+		// System.out.println("in getOperationReplyBuffer");
+		return operationReply_;
+	}
+
+	// ------------------------------------------------------------------
+
+	public void setCursorName(String name) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, name);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setCursorName", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, name);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("setCursorName");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+		// TODO: May need to check the Statement STATE
+		cursorName_ = name;
+	}
+
+	public void setEscapeProcessing(boolean enable) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, enable);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setEscapeProcessing", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, enable);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("setEscapeProcessing");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		escapeProcess_ = enable;
+
+	}
+
+	public void setFetchDirection(int direction) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, direction);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setFetchDirection", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, direction);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("setFetchDirection");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		switch (direction) {
+		case ResultSet.FETCH_FORWARD:
+			fetchDirection_ = direction;
+			break;
+		case ResultSet.FETCH_REVERSE:
+		case ResultSet.FETCH_UNKNOWN:
+			fetchDirection_ = ResultSet.FETCH_FORWARD;
+			break;
+		default:
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+					"invalid_fetch_direction", null);
+		}
+	}
+
+	public void setFetchSize(int rows) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rows);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setFetchSize", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rows);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("setFetchSize");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		if (rows < 0) {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_fetch_size",
+					null);
+		} else if (rows == 0) {
+			fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
+		} else {
+			fetchSize_ = rows;
+		}
+	}
+
+	public void setMaxFieldSize(int max) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, max);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setMaxFieldSize", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, max);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("setMaxFieldSize");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		if (max < 0) {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+					"invalid_maxFieldSize_value", null);
+		}
+		maxFieldSize_ = max;
+	}
+
+	public void setMaxRows(int max) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, max);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setMaxRows", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, max);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("setMaxRows");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		if (max < 0) {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_maxRows_value",
+					null);
+		}
+		maxRows_ = max;
+	}
+
+	public void setQueryTimeout(int seconds) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, seconds);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setQueryTimeout", "", p);
+		}
+		if (connection_.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, seconds);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("setQueryTimeout");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection_.props_.getLogWriter().println(temp);
+		}
+
+		//HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "setQueryTimeout()");
+		
+		if (seconds < 0) {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+					"invalid_queryTimeout_value", null);
+		}
+		queryTimeout_ = seconds;
+	}
+
+	// ------------------------------------------------------------------
+	/**
+	 * This method will set the operation ID for this statement.
+	 * 
+	 * @param opID
+	 *            the operation ID to associate with this statement.
+	 * 
+	 * @exception A
+	 *                SQLException is thrown
+	 */
+	public void setOperationID(short opID) throws SQLException {
+		operationID_ = opID;
+	} // end setOperationID
+
+	// ------------------------------------------------------------------
+	/**
+	 * This method will set the operation buffer for this statement.
+	 * 
+	 * @param The
+	 *            operation buffer.
+	 * 
+	 * @exception A
+	 *                SQLException is thrown
+	 */
+	public void setOperationBuffer(byte[] opBuffer) throws SQLException {
+		operationBuffer_ = opBuffer;
+	}
+
+
+	void validateExecDirectInvocation(String sql) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+			connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "validateExecDirectInvocation", "", p);
+		}
+
+		validateExecDirectInvocation();
+		sqlStmtType_ = ist_.getSqlStmtType(sql);
+		ist_.setTransactionStatus(connection_, sql);
+                sql_ = sql;
+
+	}
+
+	void validateExecDirectInvocation() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "validateExecDirectInvocation", "", p);
+		}
+		ist_.setRowCount(-1);
+		clearWarnings();
+		if (isClosed_) {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_statement",
+					null);
+		}
+		try {
+			// connection_.getServerHandle().isConnectionOpen();
+			connection_.isConnectionOpen();
+
+			// close the previous resultset, if any
+			for (int i = 0; i < num_result_sets_; i++) {
+				if (resultSet_[i] != null) {
+					resultSet_[i].close();
+				}
+			}
+		} catch (SQLException se) {
+			performConnectionErrorChecks(se);
+			throw se;
+		}
+	}
+	
+	// This functions ensure that Database Resources are cleaned up,
+	// but leave the java Statement object
+	// intact.
+	void internalClose() throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "internalClose", "", p);
+		}
+		if (connection_._isClosed() == false) {
+			ist_.close();
+		}
+	}
+
+	private void setResultSet(HPT4Desc[] outputDesc) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, outputDesc);
+			connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "setResultSet", "", p);
+		}
+		initResultSets();
+		if (outputDesc != null) {
+			resultSet_[result_set_offset] = new TrafT4ResultSet(this, outputDesc);
+		} else {
+			resultSet_[result_set_offset] = null;
+		}
+	}
+
+	public void setTransactionToJoin(byte[] txid) throws SQLException {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, txid);
+			connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "setTransactionToJoin", "", p);
+		}
+
+		this.transactionToJoin = txid;
+	}
+
+	void setMultipleResultSets(int num_result_sets, HPT4Desc[][] output_descriptors, String[] stmt_labels,
+			String[] proxySyntax) throws SQLException {
+		if (num_result_sets < 1)
+			return;
+
+		resultSet_ = new TrafT4ResultSet[num_result_sets];
+		num_result_sets_ = num_result_sets;
+		for (int i = 0; i < num_result_sets; i++) {
+			HPT4Desc[] desc = output_descriptors[i];
+			if (desc == null) {
+				resultSet_[i] = null;
+			} else {
+				resultSet_[i] = new TrafT4ResultSet(this, desc, stmt_labels[i], true);
+				resultSet_[i].proxySyntax_ = proxySyntax[i];
+			}
+		}
+	}
+
+	// ----------------------------------------------------------------------------------
+	void setExecute2Outputs(byte[] values, short rowsAffected, boolean endOfData, String[] proxySyntax, HPT4Desc[] desc)
+			throws SQLException {
+		num_result_sets_ = 1;
+		result_set_offset = 0;
+
+		// if NO DATA FOUND is returned from the server, desc = null but
+		// we still want to save our descriptors from PREPARE
+		if (desc != null)
+			outputDesc_ = desc;
+
+		resultSet_ = new TrafT4ResultSet[num_result_sets_];
+
+		if (outputDesc_ != null) {
+			resultSet_[result_set_offset] = new TrafT4ResultSet(this, outputDesc_);
+			resultSet_[result_set_offset].proxySyntax_ = proxySyntax[result_set_offset];
+
+			if (rowsAffected == 0) {
+				if (endOfData == true) {
+					resultSet_[result_set_offset].setFetchOutputs(new Row[0], 0, true);
+				}
+			} else {
+				 if(resultSet_[result_set_offset].keepRawBuffer_ == true)
+			          resultSet_[result_set_offset].rawBuffer_ = values;
+				 
+				resultSet_[result_set_offset].irs_.setExecute2FetchOutputs(resultSet_[result_set_offset], 1, true,
+						values);
+			}
+		} else {
+			resultSet_[result_set_offset] = null;
+		}
+	}
+
+	// Constructors with access specifier as "default"
+	TrafT4Statement() {
+		if (T4Properties.t4GlobalLogger.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(null);
+			T4Properties.t4GlobalLogger.logp(Level.FINE, "TrafT4Statement", "<init>", "", p);
+		}
+		resultSet_ = new TrafT4ResultSet[1];
+		initResultSets();
+	}
+
+	/*
+	 * * For closing statements using label.
+	 */
+	TrafT4Statement(TrafT4Connection connection, String stmtLabel) throws SQLException {
+		if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, stmtLabel);
+			connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>", "", p);
+		}
+		if (connection.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("Note, this constructor was called before the previous constructor");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection.props_.getLogWriter().println(temp);
+		}
+		int hashcode;
+
+		connection_ = connection;
+		operationID_ = -1;
+
+		resultSetType_ = ResultSet.TYPE_FORWARD_ONLY;
+		resultSetConcurrency_ = ResultSet.CONCUR_READ_ONLY;
+		resultSetHoldability_ = TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT;
+		queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
+
+		stmtLabel_ = stmtLabel;
+		fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
+		maxRows_ = 0;
+		fetchDirection_ = ResultSet.FETCH_FORWARD;
+		pRef_ = new WeakReference(this, connection_.refStmtQ_);
+		ist_ = new InterfaceStatement(this);
+		connection_.addElement(pRef_, stmtLabel_);
+
+		resultSet_ = new TrafT4ResultSet[1];
+		initResultSets();
+	}
+
+	TrafT4Statement(TrafT4Connection connection) throws SQLException {
+		this(connection, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT);
+		if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection);
+			connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>",
+					"Note, this constructor was called before the previous constructor", p);
+		}
+		if (connection.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("<init>");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection.props_.getLogWriter().println(temp);
+		}
+		resultSet_ = new TrafT4ResultSet[1];
+		roundingMode_ = connection_.props_.getRoundingMode();
+		initResultSets();
+	}
+
+	TrafT4Statement(TrafT4Connection connection, int resultSetType, int resultSetConcurrency) throws SQLException {
+		this(connection, resultSetType, resultSetConcurrency, TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT);
+		if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+					resultSetConcurrency);
+			connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>",
+					"Note, this constructor was called before the previous constructor", p);
+		}
+		if (connection.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+					resultSetConcurrency);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("<init>");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection.props_.getLogWriter().println(temp);
+		}
+		resultSet_ = new TrafT4ResultSet[1];
+		roundingMode_ = connection_.props_.getRoundingMode();
+		initResultSets();
+	}
+	TrafT4Statement(TrafT4Connection connection, int resultSetType, int resultSetConcurrency, int resultSetHoldability,
+			String stmtLabel) throws SQLException {
+		if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+					resultSetConcurrency, resultSetHoldability);
+			connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>", "", p);
+		}
+		if (connection.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+					resultSetConcurrency, resultSetHoldability);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("<init>");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection.props_.getLogWriter().println(temp);
+		}
+		int hashcode;
+
+		connection_ = connection;
+		operationID_ = -1;
+
+		if (resultSetType != ResultSet.TYPE_FORWARD_ONLY && resultSetType != ResultSet.TYPE_SCROLL_INSENSITIVE
+				&& resultSetType != ResultSet.TYPE_SCROLL_SENSITIVE) {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+					"invalid_resultset_type", null);
+		}
+
+		if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) {
+			resultSetType_ = ResultSet.TYPE_SCROLL_INSENSITIVE;
+			connection_.setSQLWarning(null, "scrollResultSetChanged", null);
+			//setSQLWarning(null, "scrollResultSetChanged", null);
+		} else {
+			resultSetType_ = resultSetType;
+		}
+		if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY && resultSetConcurrency != ResultSet.CONCUR_UPDATABLE) {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+					"invalid_resultset_concurrency", null);
+		}
+
+		if ((resultSetHoldability != 0) && (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT)
+				&& (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
+				throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_holdability",
+					null);
+		}
+
+		resultSetConcurrency_ = resultSetConcurrency;
+		resultSetHoldability_ = resultSetHoldability;
+		queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
+
+		stmtLabel_ = stmtLabel;
+		fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
+		maxRows_ = 0;
+		fetchDirection_ = ResultSet.FETCH_FORWARD;
+
+		connection_.gcStmts();
+		pRef_ = new WeakReference(this, connection_.refStmtQ_);
+		ist_ = new InterfaceStatement(this);
+		connection_.addElement(pRef_, stmtLabel_);
+		roundingMode_ = connection_.props_.getRoundingMode();
+
+		resultSet_ = new TrafT4ResultSet[1];
+	}
+
+	TrafT4Statement(TrafT4Connection connection, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
+			throws SQLException {
+		if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+					resultSetConcurrency, resultSetHoldability);
+			connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>", "", p);
+		}
+		if (connection.props_.getLogWriter() != null) {
+			LogRecord lr = new LogRecord(Level.FINE, "");
+			Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+					resultSetConcurrency, resultSetHoldability);
+			lr.setParameters(p);
+			lr.setSourceClassName("TrafT4Statement");
+			lr.setSourceMethodName("<init>");
+			T4LogFormatter lf = new T4LogFormatter();
+			String temp = lf.format(lr);
+			connection.props_.getLogWriter().println(temp);
+		}
+		int hashcode;
+
+		connection_ = connection;
+		operationID_ = -1;
+
+		if (resultSetType != ResultSet.TYPE_FORWARD_ONLY && resultSetType != ResultSet.TYPE_SCROLL_INSENSITIVE
+				&& resultSetType != ResultSet.TYPE_SCROLL_SENSITIVE) {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+					"invalid_resultset_type", null);
+		}
+
+		if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) {
+			resultSetType_ = ResultSet.TYPE_SCROLL_INSENSITIVE;
+			connection_.setSQLWarning(null, "scrollResultSetChanged", null);
+			//setSQLWarning(null, "scrollResultSetChanged", null);
+		} else {
+			resultSetType_ = resultSetType;
+		}
+		if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY && resultSetConcurrency != ResultSet.CONCUR_UPDATABLE) {
+			throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+					"invalid_resultset_concurrency", null);
+		}
+
+		if ((resultSetHoldability != 0) && (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT)
+				&& (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
+				throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_holdability",
+					null);
+		}
+
+		resultSetConcurrency_ = resultSetConcurrency;
+		resultSetHoldability_ = resultSetHoldability;
+		queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
+
+		stmtLabel_ = generateStmtLabel();
+		fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
+		maxRows_ = 0;
+		fetchDirection_ = ResultSet.FETCH_FORWARD;
+
+		connection_.gcStmts();
+		pRef_ = new WeakReference(this, connection_.refStmtQ_);
+		ist_ = new InterfaceStatement(this);
+		connection_.addElement(pRef_, stmtLabel_);
+
+		resultSet_ = new TrafT4ResultSet[1];
+		roundingMode_ = connection_.props_.getRoundingMode();
+		initResultSets();
+	}
+
+	//max length for a label is 32 characters.
+	String generateStmtLabel() {
+		String id = String.valueOf(this.connection_.ic_.getSequenceNumber());
+		if(id.length() > 24) {
+			id = id.substring(id.length()-24);
+		}
+	
+		return "SQL_CUR_" + id;
+	}
+	
+	// Database statement are not deallocated when there is a
+	// SQLWarning or SQLException or when a resultSet is produced
+	void checkSQLWarningAndClose() {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+			connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "checkSQLWarningAndClose", "", p);
+		}
+		if (sqlWarning_ != null) {
+			if (resultSet_[result_set_offset] == null) {
+				try {
+					internalClose();
+				} catch (SQLException closeException1) {
+				}
+			}
+		}
+	}
+
+	public void setRoundingMode(int roundingMode) {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, roundingMode);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setRoundingMode", "", p);
+		}
+		roundingMode_ = Utility.getRoundingMode(roundingMode);
+	}
+
+	public void setRoundingMode(String roundingMode) {
+		if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+			Object p[] = T4LoggingUtilities.makeParams(connection_.props_, roundingMode);
+			connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setRoundingMode", "", p);
+		}
+		roundingMode_ = Utility.getRoundingMode(roundingMode);
+	}
+
+	void closeErroredConnection(HPT4Exception sme) {
+		connection_.closeErroredConnection(sme);
+	}
+
+	/**
+	 * Use this method to retrieve the statement-label name that was used when
+	 * creating the statement through the Trafodion connectivity service. You can
+	 * subsequently use the name retrieved as the cursor name when invoking
+	 * INFOSTATS to gather resource statistics through either the
+	 * <code>executeQuery(String sql)</code> or
+	 * <code>execute(String sql)</code> methods.
+	 */
+	public String getStatementLabel() {
+		return new String(stmtLabel_);
+	}
+
+	/**
+	 * Returns the raw SQL associated with the statement
+	 * 
+	 * @return the SQL text
+	 */
+	public String getSQL() {
+		return this.sql_;
+	}
+
+	/**
+	 * Returns the MXCS statement handle
+	 * 
+	 * @return the MXCS statement handle
+	 */
+	public int getStmtHandle() {
+		return this.ist_.stmtHandle_;
+	}
+
+	// static fields
+	public static final int NO_GENERATED_KEYS = 2;
+	// Fields
+	TrafT4Connection connection_;
+	int resultSetType_;
+	int resultSetConcurrency_;
+	String sql_;
+	int queryTimeout_;
+	int maxRows_;
+	int maxFieldSize_;
+	int fetchSize_;
+	int fetchDirection_;
+	boolean escapeProcess_;
+	String cursorName_ = "";
+	TrafT4ResultSet[] resultSet_; // Added for SPJ RS - SB 11/21/2005
+	int num_result_sets_; // Added for SPJ RS - SB 11/21/2005
+	int result_set_offset; // Added for SPJ RS - SB 11/21/2005
+	String stmtLabel_;
+	short sqlStmtType_;
+	boolean isClosed_;
+	ArrayList batchCommands_;
+	int[] batchRowCount_;
+	WeakReference pRef_;
+	int resultSetHoldability_;
+	InterfaceStatement ist_;
+
+	int inputParamsLength_;
+	int outputParamsLength_;
+	int inputDescLength_;
+	int outputDescLength_;
+
+	int inputParamCount_;
+	int outputParamCount_;
+
+	int roundingMode_ = BigDecimal.ROUND_HALF_EVEN;
+
+	HPT4Desc[] inputDesc_, outputDesc_;
+
+	short operationID_;
+	byte[] operationBuffer_;
+	byte[] operationReply_;
+
+	boolean usingRawRowset_;
+	ByteBuffer rowwiseRowsetBuffer_;
+
+	byte[] transactionToJoin;
+	
+	int _lastCount = -1;
+
+	/**
+	 * @return the inputParamsLength_
+	 */
+	public int getInputParamsLength_() {
+		return inputParamsLength_;
+	}
+
+	/**
+	 * @return the outputParamsLength_
+	 */
+	public int getOutputParamsLength_() {
+		return outputParamsLength_;
+	}
+
+	public Object unwrap(Class iface) throws SQLException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public boolean isWrapperFor(Class iface) throws SQLException {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	public boolean isClosed() throws SQLException {
+		// TODO Auto-generated method stub
+                return isClosed_;
+	}
+
+	public void setPoolable(boolean poolable) throws SQLException {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public boolean isPoolable() throws SQLException {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	public void closeOnCompletion() throws SQLException {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public boolean isCloseOnCompletion() throws SQLException {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/USER_DESC_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/USER_DESC_def.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/USER_DESC_def.java
new file mode 100644
index 0000000..d67aa96
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/USER_DESC_def.java
@@ -0,0 +1,61 @@
+// @@@ START COPYRIGHT @@@
+//
+// 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.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class USER_DESC_def {
+	int userDescType;
+	byte[] userSid;
+	String domainName;
+	String userName;
+	byte[] password;
+
+	byte[] domainNameBytes;
+	byte[] userNameBytes;
+
+	int sizeOf(InterfaceConnection ic) throws CharacterCodingException, UnsupportedCharsetException {
+		int size = 0;
+
+		domainNameBytes = ic.encodeString(domainName, 1);
+		userNameBytes = ic.encodeString(userName, 1);
+
+		size += TRANSPORT.size_int; // descType
+
+		size += TRANSPORT.size_bytes(userSid);
+		size += TRANSPORT.size_bytes(domainNameBytes);
+		size += TRANSPORT.size_bytes(userNameBytes);
+		size += TRANSPORT.size_bytes(password);
+
+		return size;
+	}
+
+	void insertIntoByteArray(LogicalByteArray buf) {
+		buf.insertInt(userDescType);
+
+		buf.insertString(userSid);
+		buf.insertString(domainNameBytes);
+		buf.insertString(userNameBytes);
+		buf.insertString(password);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Utility.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Utility.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Utility.java
new file mode 100644
index 0000000..a3224d7
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Utility.java
@@ -0,0 +1,636 @@
+// @@@ START COPYRIGHT @@@
+//
+// 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.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.sql.DataTruncation;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ * This class contains a variety of methods for doing all sorts of things. 
+ * @version 1.0
+ */
+
+class Utility {
+
+	private static final byte key[] = Utility.UnicodeToAscii("ci4mg04-3;" + "b,hl;y'd1q" + "x8ngp93nGp" + "oOp4HlD7vm"
+			+ ">o(fHoPdkd" + "khp1`gl0hg" + "qERIFdlIFl" + "w48fgljksg" + "3oi5980rfd" + "4t8u9dfvkl");
+
+	// -------------------------------------------------------------
+	/**
+	 * This method will translate a double byte Unicode string into a single
+	 * byte ASCII array.
+	 * 
+	 * @param original
+	 *            the original string
+	 * 
+	 * @return a byte array containing the translated string
+	 * 
+	 * @exception An
+	 *                UnsupportedEncodingException is thrown
+	 */
+	static byte[] UnicodeToAscii(String original) {
+		try {
+			byte[] utf8Bytes = original.getBytes("UTF8");
+			return utf8Bytes;
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+		}
+		return null;
+	} // end UnicodeToAscii
+
+	// -------------------------------------------------------------
+	/**
+	 * This method will encrypt a byte buffer according to the encryption
+	 * algorithm used by the ODBC server.
+	 * 
+	 * @param original
+	 *            the original string
+	 * 
+	 * @return a byte array containing the translated string
+	 * 
+	 */
+	static boolean Encryption(byte inBuffer[], byte outBuffer[], int inLength) {
+		// Use simple encryption/decryption
+
+		if (outBuffer != inBuffer) {
+			System.arraycopy(outBuffer, 0, inBuffer, 0, inLength);
+		} // end if
+
+		for (int i = 0; i < inLength; ++i) {
+			int j = i % 100;
+			outBuffer[i] ^= key[j];
+		}
+
+		return true;
+	} // end Encryption
+
+	// -------------------------------------------------------------
+	/**
+	 * This method will check a float value according to the MAX_FLOAT and
+	 * MIN_FLOAT values in the Java language.
+	 * 
+	 * @param the
+	 *            original double value to check
+	 * @Locale the Locale to print the error message in
+	 * 
+	 * @return none
+	 * 
+	 */
+	static void checkFloatBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+		double indbl = inbd.doubleValue();
+		// double abdbl = inbd.abs().doubleValue(); Need to do MIN check as well
+		if (indbl > (double) Float.MAX_VALUE) {
+			throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", inbd.toString());
+		}
+	} // end checkFloatBoundary
+
+	// -------------------------------------------------------------
+	/**
+	 * This method will check a double value according to the MAX_VALUE and
+	 * MIN_VALUE values in the Double class.
+	 * 
+	 * @param the
+	 *            original double value to check
+	 * @Locale the Locale to print the error message in
+	 * 
+	 * @return none
+	 * 
+	 */
+	static void checkDoubleBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+		BigDecimal maxbd = new BigDecimal(Double.MAX_VALUE);
+		// need to check min as well
+		// BigDecimal minbd = new BigDecimal(Double.MIN_VALUE);
+		if ((inbd.compareTo(maxbd) > 0)) {
+			throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", inbd.toString());
+		}
+
+	} // end checkDoubleBoundary
+
+	// -------------------------------------------------------------
+	/**
+	 * This method will check a Integer value according to the
+	 * Interger.MAX_VALUE and Integer.MIN_VALUE values.
+	 * 
+	 * @param the
+	 *            original long value to check
+	 * @Locale the Locale to print the error message in
+	 * 
+	 * @return none
+	 * 
+	 */
+	static void checkIntegerBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+		long inlong = inbd.longValue();
+		if ((inlong > Integer.MAX_VALUE) || (inlong < Integer.MIN_VALUE)) {
+			throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
+		}
+	} // end checkIntegerBoundary
+
+	// -------------------------------------------------------------
+	/**
+	 * This method will check a Long value according to the Long.MAX_VALUE*2 and
+	 * 0 values.
+	 * 
+	 * @param the
+	 *            original BigDecimal value to check
+	 * @Locale the Locale to print the error message in
+	 * 
+	 * @return none
+	 * 
+	 */
+	static void checkSignedLongBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+		long inlong = inbd.longValue();
+		BigDecimal maxbd = new BigDecimal(Long.MAX_VALUE);
+		maxbd = maxbd.add(maxbd);
+		if ((inlong < 0) || (inbd.compareTo(maxbd) > 0)) {
+			throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
+		}
+	} // end checkIntegerBoundary
+
+	// -------------------------------------------------------------
+	/**
+	 * This method will check a unsigned Short value according to the
+	 * Short.MAX_VALUE*2 and 0 values.
+	 * 
+	 * @param the
+	 *            original BigDecimal value to check
+	 * @Locale the Locale to print the error message in
+	 * 
+	 * @return none
+	 * 
+	 */
+	static void checkSignedShortBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+		long inlong = inbd.longValue();
+		long maxushort = (Short.MAX_VALUE * 2) + 1;
+		if ((inlong < 0) || (inlong > maxushort)) {
+			throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
+		}
+	} // end checkIntegerBoundary
+
+	// -------------------------------------------------------------
+	/**
+	 * This method will check a unsigned Int value according to the
+	 * Integer.MAX_VALUE*2 and 0 values.
+	 * 
+	 * @param the
+	 *            original BigDecimal value to check
+	 * @Locale the Locale to print the error message in
+	 * 
+	 * @return none
+	 * 
+	 */
+	static void checkUnsignedIntegerBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+		long inlong = inbd.longValue();
+		long maxuint = ((long) Integer.MAX_VALUE * 2L) + 1L;
+		if ((inlong < 0) || (inlong > maxuint)) {
+			throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
+		}
+	} // end checkIntegerBoundary
+
+	// -------------------------------------------------------------
+	/**
+	 * This method will check a Tinyint value according to the Byte.MAX_VALUE
+	 * and Byte.MIN_VALUE values.
+	 * 
+	 * @param the
+	 *            original long value to check
+	 * @Locale the Locale to print the error message in
+	 * 
+	 * @return none
+	 * 
+	 */
+	static void checkTinyintBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+		long inlong = inbd.longValue();
+		if ((inlong > Byte.MAX_VALUE) || (inlong < Byte.MIN_VALUE)) {
+			throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
+		}
+	} // end checkTinyintBoundary
+
+	// -------------------------------------------------------------
+	/**
+	 * This method will check a Short value according to the Short.MAX_VALUE and
+	 * Short.MIN_VALUE values.
+	 * 
+	 * @param the
+	 *            original long value to check
+	 * @Locale the Locale to print the error message in
+	 * 
+	 * @return none
+	 * 
+	 */
+	static void checkShortBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+		long inlong = inbd.longValue();
+		if ((inlong > Short.MAX_VALUE) || (inlong < Short.MIN_VALUE)) {
+			throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
+		}
+	} // end checkShortBoundary
+
+	// -------------------------------------------------------------
+	/**
+	 * This method will extract the BigDecimal value.
+	 * 
+	 * @param the
+	 *            Locale to print the error message in
+	 * @param the
+	 *            original object value to extract
+	 * 
+	 * @return constructed BigDecimal value
+	 * 
+	 */
+	static BigDecimal getBigDecimalValue(Locale locale, Object paramValue) throws SQLException {
+		BigDecimal tmpbd;
+
+		if (paramValue instanceof Long) {
+			tmpbd = BigDecimal.valueOf(((Long) paramValue).longValue());
+		} else if (paramValue instanceof Integer) {
+			tmpbd = BigDecimal.valueOf(((Integer) paramValue).longValue());
+		} else if (paramValue instanceof BigDecimal) {
+			tmpbd = (BigDecimal) paramValue;
+		} else if (paramValue instanceof String) {
+			String sVal = (String) paramValue;
+			if (sVal.equals("true") == true) {
+				sVal = "1";
+			} else if (sVal.equals("false") == true) {
+				sVal = "0";
+			}
+			tmpbd = new BigDecimal(sVal);
+		} else if (paramValue instanceof Float) {
+			tmpbd = new BigDecimal(paramValue.toString());
+		} else if (paramValue instanceof Double) {
+			tmpbd = new BigDecimal(((Double) paramValue).toString());
+		} else if (paramValue instanceof Boolean) {
+			tmpbd = BigDecimal.valueOf(((((Boolean) paramValue).booleanValue() == true) ? 1 : 0));
+		} else if (paramValue instanceof Byte) {
+			tmpbd = BigDecimal.valueOf(((Byte) paramValue).longValue());
+		} else if (paramValue instanceof Short) {
+			tmpbd = BigDecimal.valueOf(((Short) paramValue).longValue());
+		} else if (paramValue instanceof Integer) {
+			tmpbd = BigDecimal.valueOf(((Integer) paramValue).longValue());
+			// For LOB Support SB: 10/25/2004
+			/*
+			 * else if (paramValue instanceof DataWrapper) tmpbd =
+			 * BigDecimal.valueOf(((DataWrapper)paramValue).longValue);
+			 */
+		} else {
+			throw HPT4Messages.createSQLException(null, locale, "object_type_not_supported", paramValue);
+		}
+		return tmpbd;
+	} // end getBigDecimalValue
+
+	// -------------------------------------------------------------
+	/**
+	 * This method will check a Decimal value according to the precision in the
+	 * Database table.
+	 * 
+	 * @param the
+	 *            original BigDecimal value to check
+	 * @param the
+	 *            Locale to print the error message in
+	 * 
+	 * @return none
+	 * 
+	 */
+	static void checkDecimalBoundary(Locale locale, BigDecimal inbd, int precision) throws SQLException {
+		if (precision > 0) {
+			BigDecimal maxbd = new BigDecimal(Math.pow(10, precision));
+			BigDecimal minbd = maxbd.negate();
+			if ((inbd.compareTo(maxbd) >= 0) || (inbd.compareTo(minbd) < 0)) {
+				throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", inbd.toString());
+			}
+		}
+	} // end checkBigDecimalBoundary
+	//---------------------------------------------------------------
+	/*code change starts
+	 *  MR Description:  Warnings not  being displayed  when numeric overflow occurs
+	 */
+
+	/**
+	 * This method will check a scale value with the column in the
+	 * Database table.
+	 * 
+	 * @param the
+	 *             BigDecimal value to check
+	 * @param the
+	 *            scale to check with the BigDecimal's scale
+	 * 
+	 * @return none
+	 * 
+	 */
+	static void checkScale(BigDecimal tmpbd, int scale) throws SQLException
+	{
+		if (tmpbd.scale() > scale)
+			if (!((tmpbd.scale() == 1) && (tmpbd.toString().endsWith("0"))))
+			{
+				try
+				{
+					Object[] messageArguments = new Object[1];
+					messageArguments[0] = new String("A numeric overflow occurred during an arithmetic computation " +
+							"or data conversion.");
+					throw HPT4Messages.createSQLWarning(null, "8411", messageArguments);
+				}
+				catch (SQLWarning e)
+				{
+					e.printStackTrace();
+				}
+			}
+	}
+
+	//code change ends
+
+	// Fix_LeadingZero - AM 08/07/2006
+	private static int getExtraLen(String s) {
+		int extra = 0;
+
+		// count the trailing zero
+		int inx = s.indexOf(".");
+		if (inx != -1) {
+			int len = s.length();
+			for (int i = len - 1; i > inx; i--) {
+				char ch = s.charAt(i);
+				if (ch != '0') {
+					break;
+				}
+				extra++;
+			}
+		}
+		// count for leading zero
+		if (s.startsWith("0.") || s.startsWith("-0.")) {
+			extra++;
+		}
+
+		return extra;
+	}
+
+	// -------------------------------------------------------------
+	/**
+	 * This method will check a Decimal value according to the precision in the
+	 * Database table.
+	 * 
+	 * @param the
+	 *            original BigDecimal value to check
+	 * @param the
+	 *            Locale to print the error message in
+	 * 
+	 * @return none
+	 * 
+	 */
+	static void checkDecimalTruncation(int parameterIndex, Locale locale, BigDecimal inbd, int precision, int scale)
+			throws SQLException {
+		if (precision <= 0)
+			return;
+
+		int expectedLen = precision;
+
+		if (scale > 0)
+			expectedLen = precision + 1;
+
+		if (inbd.signum() == -1)
+			expectedLen++;
+		int actualLen = 0;
+
+		// Fix_LeadingZero - AM 08/07/2006
+		expectedLen += getExtraLen(inbd.toString());
+		/*
+		 * if( (actualLen = inbd.toString().length()) > expectedLen ){
+		 * //System.out.println("Length of " + inbd.toString() + " is greater
+		 * than " + precision); throw new DataTruncation(parameterIndex, true,
+		 * false, actualLen, expectedLen); }
+		 */
+		actualLen = inbd.toString().length();
+		if (precision > 0) {
+			BigDecimal maxbd = new BigDecimal(Math.pow(10, precision - scale));
+			BigDecimal minbd = maxbd.negate();
+			if ((inbd.compareTo(maxbd) >= 0) || (inbd.compareTo(minbd) < 0)) {
+				// System.out.println("Max = " + maxbd.toString() + "\nMin = " +
+				// minbd + "\nInputted Val: " + inbd.toString());
+				// throw new DataTruncation(parameterIndex, true, false,
+				// actualLen, expectedLen);
+				throw new SQLException("*** ERROR[29188] Numeric value " + inbd.doubleValue() + " is out of range [" + minbd.doubleValue() + ", " + maxbd.doubleValue() + "]; Parameter index: " + (parameterIndex) +". ["+new SimpleDateFormat("yyyy-MM-dd HH:mm:s").format(new Date())+"]", "22003", -8411);
+			}
+		}
+	} // end checkDecimalTruncation
+
+	// -------------------------------------------------------------
+	/**
+	 * This method will check a Long value according to the Long.MAX_VALUE and
+	 * Long.MIN_VALUE values.
+	 * 
+	 * @param the
+	 *            original long value to check
+	 * @param the
+	 *            Locale to print the error message in
+	 * 
+	 * @return none
+	 * 
+	 */
+	static void checkLongBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+		if ((inbd.compareTo(long_maxbd) > 0) || (inbd.compareTo(long_minbd) < 0)) {
+			throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", inbd.toString());
+		}
+	} // end checkBigDecimalBoundary
+
+	// -------------------------------------------------------------
+	/**
+	 * This method will check a Double and long value are the same.
+	 * 
+	 * @param the
+	 *            original double value to check
+	 * @param the
+	 *            original long value to check
+	 * @param the
+	 *            Locale to print the error message in
+	 * 
+	 * @return none
+	 * 
+	 */
+	static void checkLongTruncation(int parameterindex, BigDecimal inbd) throws SQLException {
+		long inlong = inbd.longValue();
+		double indbl = inbd.doubleValue();
+
+		if ((double) inlong != indbl) {
+			int sizeLong = String.valueOf(inlong).length();
+			int sizeDbl = String.valueOf(indbl).length();
+			// throw new DataTruncation(parameterindex, true, false,
+			// sizeLong, sizeDbl);
+
+			DataTruncation dt = new DataTruncation(parameterindex, true, false, sizeLong, sizeDbl);
+			dt.setNextException(new SQLException("DataTruncation", "22003", -8411));
+			throw dt;
+		}
+	} // end checkLongTruncation
+
+	/**
+	 * This method sets the round mode behaviour for the driver. Accepted values
+	 * are: static int ROUND_CEILING Rounding mode to round towards positive
+	 * infinity. static int ROUND_DOWN Rounding mode to round towards zero.
+	 * static int ROUND_FLOOR Rounding mode to round towards negative infinity.
+	 * static int ROUND_HALF_DOWN Rounding mode to round towards "nearest
+	 * neighbor" unless both neighbors are equidistant, in which case round
+	 * down. static int ROUND_HALF_EVEN Rounding mode to round towards the
+	 * "nearest neighbor" unless both neighbors are equidistant, in which case,
+	 * round towards the even neighbor. static int ROUND_HALF_UP Rounding mode
+	 * to round towards "nearest neighbor" unless both neighbors are
+	 * equidistant, in which case round up. static int ROUND_UNNECESSARY
+	 * Rounding mode to assert that the requested operation has an exact result,
+	 * hence no rounding is necessary. static int ROUND_UP Rounding mode to
+	 * round away from zero. The default behaviour is to do ROUND_DOWN.
+	 * 
+	 * @param ref
+	 *            roundMode
+	 */
+	static int getRoundingMode(String roundMode) {
+		int op_roundMode = BigDecimal.ROUND_DOWN;
+		if (roundMode == null) {
+			op_roundMode = BigDecimal.ROUND_DOWN;
+		} else if (roundMode.equals("ROUND_CEILING")) {
+			op_roundMode = BigDecimal.ROUND_CEILING;
+		} else if (roundMode.equals("ROUND_DOWN")) {
+			op_roundMode = BigDecimal.ROUND_DOWN;
+		} else if (roundMode.equals("ROUND_FLOOR")) {
+			op_roundMode = BigDecimal.ROUND_FLOOR;
+		} else if (roundMode.equals("ROUND_HALF_UP")) {
+			op_roundMode = BigDecimal.ROUND_HALF_UP;
+		} else if (roundMode.equals("ROUND_UNNECESSARY")) {
+			op_roundMode = BigDecimal.ROUND_UNNECESSARY;
+		} else if (roundMode.equals("ROUND_HALF_EVEN")) {
+			op_roundMode = BigDecimal.ROUND_HALF_EVEN;
+		} else if (roundMode.equals("ROUND_HALF_DOWN")) {
+			op_roundMode = BigDecimal.ROUND_HALF_DOWN;
+		} else if (roundMode.equals("ROUND_UP")) {
+			op_roundMode = BigDecimal.ROUND_UP;
+		} else {
+			try {
+				op_roundMode = getRoundingMode(Integer.parseInt(roundMode));
+			} catch (Exception ex) {
+				op_roundMode = BigDecimal.ROUND_DOWN;
+			}
+
+		}
+		return op_roundMode;
+	}
+
+	/**
+	 * This method sets the round mode behaviour for the driver. Accepted values
+	 * are: static int ROUND_CEILING Rounding mode to round towards positive
+	 * infinity. static int ROUND_DOWN Rounding mode to round towards zero.
+	 * static int ROUND_FLOOR Rounding mode to round towards negative infinity.
+	 * static int ROUND_HALF_DOWN Rounding mode to round towards "nearest
+	 * neighbor" unless both neighbors are equidistant, in which case round
+	 * down. static int ROUND_HALF_EVEN Rounding mode to round towards the
+	 * "nearest neighbor" unless both neighbors are equidistant, in which case,
+	 * round towards the even neighbor. static int ROUND_HALF_UP Rounding mode
+	 * to round towards "nearest neighbor" unless both neighbors are
+	 * equidistant, in which case round up. static int ROUND_UNNECESSARY
+	 * Rounding mode to assert that the requested operation has an exact result,
+	 * hence no rounding is necessary. static int ROUND_UP Rounding mode to
+	 * round away from zero. The default behaviour is to do ROUND_DOWN.
+	 * 
+	 * @param ref
+	 *            roundMode
+	 */
+	static int getRoundingMode(int roundMode) {
+		if ((roundMode == BigDecimal.ROUND_CEILING) || (roundMode == BigDecimal.ROUND_DOWN)
+				|| (roundMode == BigDecimal.ROUND_UP) || (roundMode == BigDecimal.ROUND_FLOOR)
+				|| (roundMode == BigDecimal.ROUND_HALF_UP) || (roundMode == BigDecimal.ROUND_UNNECESSARY)
+				|| (roundMode == BigDecimal.ROUND_HALF_EVEN) || (roundMode == BigDecimal.ROUND_HALF_DOWN)) {
+			return roundMode;
+		} else {
+			return BigDecimal.ROUND_DOWN;
+		}
+	}
+
+	static BigDecimal setScale(BigDecimal tmpbd, int scale, int roundingMode) throws SQLException {
+		try {
+			if (scale > -1) {
+				tmpbd = tmpbd.setScale(scale, roundingMode);
+			}
+		} catch (ArithmeticException aex) {
+			throw new SQLException(aex.getMessage());
+		}
+		return tmpbd;
+	}
+
+	static final BigDecimal long_maxbd = BigDecimal.valueOf(Long.MAX_VALUE);
+	static final BigDecimal long_minbd = BigDecimal.valueOf(Long.MIN_VALUE);
+
+    static private final char DEFAULT_TRIM_WHITESPACE = ' ';
+
+    static public String trimRight(final String string)
+    {
+        return trimRight(string, DEFAULT_TRIM_WHITESPACE);
+    }
+
+    static public String trimRight(final String string, final char trimChar)
+    {
+        final int lastChar = string.length() - 1;
+        int i;
+
+        for (i = lastChar; i >= 0 && string.charAt(i) == trimChar; i--) {
+            /* Decrement i until it is equal to the first char that does not
+             * match the trimChar given. */
+        }
+        
+        if (i < lastChar) {
+            // the +1 is so we include the char at i
+            return string.substring(0, i+1);
+        } else {
+            return string;
+        }
+    }
+    static public String trimLeft(String string)
+    {
+        return trimLeft( string, DEFAULT_TRIM_WHITESPACE );
+    }
+
+    static public String trimLeft(final String string, final char trimChar)
+    {
+        final int stringLength = string.length();
+        int i;
+        
+        for (i = 0; i < stringLength && string.charAt(i) == trimChar; i++) {
+            /* increment i until it is at the location of the first char that
+             * does not match the trimChar given. */
+        }
+
+        if (i == 0) {
+            return string;
+        } else {
+            return string.substring(i);
+        }
+    }
+    static public String trimRightZeros(String x) {
+    	byte[] input = x.getBytes();
+    	int i = input.length;
+   	
+		while (i-- > 0 && input[i] == 0) {}
+	
+		byte[] output = new byte[i+1];
+		System.arraycopy(input, 0, output, 0, i+1);
+		return new String(output);
+    }
+
+} // end class Utility