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:12:04 UTC

[25/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/T4Statement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Statement.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Statement.java
new file mode 100644
index 0000000..c32f3b9
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Statement.java
@@ -0,0 +1,204 @@
+// @@@ 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;
+import java.sql.SQLException;
+
+final class T4Statement extends T4Connection {
+	private int m_queryTimeout;
+	private String m_stmtLabel;
+	private String m_stmtExplainLabel;
+	private static short EXTERNAL_STMT = 0;
+
+	boolean m_processing = false;
+
+	// -----------------------------------------------------------------------------------
+	T4Statement(InterfaceStatement is) throws SQLException {
+		super(is.ic_);
+		m_queryTimeout = is.queryTimeout_;
+		m_stmtLabel = is.stmtLabel_;
+		m_stmtExplainLabel = "";
+
+		if (m_stmtLabel == null) {
+			throwInternalException();
+		}
+	}// end T4Statement
+
+	// -----------------------------------------------------------------------------------
+
+	ExecuteReply Execute(short executeAPI, int sqlAsyncEnable, int inputRowCnt, int maxRowsetSize, int sqlStmtType,
+			int stmtHandle, String sqlString, int sqlStringCharset, String cursorName, int cursorNameCharset,
+			String stmtLabel, int stmtLabelCharset, SQL_DataValue_def inputDataValue, SQLValueList_def inputValueList,
+			byte[] txId, boolean userBuffer) throws SQLException {
+		try {
+			getInputOutput().setTimeout(m_ic.t4props_.getNetworkTimeout());
+
+			LogicalByteArray wbuffer = ExecuteMessage.marshal(this.m_dialogueId, sqlAsyncEnable, this.m_queryTimeout,
+					inputRowCnt, maxRowsetSize, sqlStmtType, stmtHandle, this.EXTERNAL_STMT, sqlString,
+					sqlStringCharset, cursorName, cursorNameCharset, stmtLabel, stmtLabelCharset,
+					this.m_stmtExplainLabel, inputDataValue, inputValueList, txId, userBuffer, this.m_ic);
+
+			LogicalByteArray rbuffer = getReadBuffer(executeAPI, wbuffer);
+
+			ExecuteReply er = new ExecuteReply(rbuffer, m_ic);
+
+			return er;
+		} catch (SQLException e) {
+			throw e;
+		} catch (CharacterCodingException e) {
+			SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale,
+					"translation_of_parameter_failed", "ExecuteMessage", e.getMessage());
+			se.initCause(e);
+			throw se;
+		} catch (UnsupportedCharsetException e) {
+			SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale, "unsupported_encoding", e
+					.getCharsetName());
+			se.initCause(e);
+			throw se;
+		} catch (Exception e) {
+			SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale, "execute_message_error", e
+					.getMessage());
+			se.initCause(e);
+			throw se;
+		}
+	} // end Execute
+
+	// -----------------------------------------------------------------------------------
+	GenericReply ExecuteGeneric(short executeAPI, byte[] messageBuffer) throws SQLException {
+		LogicalByteArray wbuffer = null;
+		LogicalByteArray rbuffer = null;
+		GenericReply gr = null;
+
+		try {
+			getInputOutput().setTimeout(m_ic.t4props_.getNetworkTimeout());
+			wbuffer = GenericMessage.marshal(m_locale, messageBuffer, this.m_ic);
+			rbuffer = getReadBuffer(executeAPI, wbuffer);
+			gr = new GenericReply(m_locale, rbuffer);
+
+			return gr;
+		} catch (SQLException se) {
+			throw se;
+		} catch (Exception e) {
+			SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale, "execute_message_error", e
+					.getMessage());
+
+			se.initCause(e);
+			throw se;
+		}
+	} // end ExecuteGeneric
+
+	// -----------------------------------------------------------------------------------
+	PrepareReply Prepare(int sqlAsyncEnable, short stmtType, int sqlStmtType, String stmtLabel, int stmtLabelCharset,
+			String cursorName, int cursorNameCharset, String moduleName, int moduleNameCharset, long moduleTimestamp,
+			String sqlString, int sqlStringCharset, String stmtOptions, int maxRowsetSize, byte[] txId
+
+	) throws SQLException {
+
+		if (sqlString == null) {
+			throwInternalException();
+		}
+		try {
+			getInputOutput().setTimeout(m_ic.t4props_.getNetworkTimeout());
+
+			LogicalByteArray wbuffer = PrepareMessage.marshal(this.m_dialogueId, sqlAsyncEnable, this.m_queryTimeout,
+					stmtType, sqlStmtType, stmtLabel, stmtLabelCharset, cursorName, cursorNameCharset, moduleName,
+					moduleNameCharset, moduleTimestamp, sqlString, sqlStringCharset, stmtOptions,
+					this.m_stmtExplainLabel, maxRowsetSize, txId, this.m_ic);
+
+			LogicalByteArray rbuffer = getReadBuffer(TRANSPORT.SRVR_API_SQLPREPARE, wbuffer);
+
+			PrepareReply pr = new PrepareReply(rbuffer, m_ic);
+
+			return pr;
+		} catch (SQLException se) {
+			throw se;
+		} catch (CharacterCodingException e) {
+			SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale,
+					"translation_of_parameter_failed", "PrepareMessage", e.getMessage());
+			se.initCause(e);
+			throw se;
+		} catch (UnsupportedCharsetException e) {
+			SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale, "unsupported_encoding", e
+					.getCharsetName());
+			se.initCause(e);
+			throw se;
+		} catch (Exception e) {
+			SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale, "prepare_message_error", e
+					.getMessage());
+
+			se.initCause(e);
+			throw se;
+		}
+	} // end Prepare
+
+	// -----------------------------------------------------------------------------------
+
+	CloseReply Close() throws SQLException {
+		try {
+			LogicalByteArray wbuffer = CloseMessage.marshal(m_dialogueId, m_stmtLabel, InterfaceStatement.SQL_DROP,
+					this.m_ic);
+
+			getInputOutput().setTimeout(m_ic.t4props_.getNetworkTimeout());
+
+			LogicalByteArray rbuffer = getReadBuffer(TRANSPORT.SRVR_API_SQLFREESTMT, wbuffer);
+
+			CloseReply cr = new CloseReply(rbuffer, m_ncsAddress.getIPorName(), m_ic);
+
+			return cr;
+		} catch (SQLException se) {
+			throw se;
+		} catch (CharacterCodingException e) {
+			SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale,
+					"translation_of_parameter_failed", "CloseMessage", e.getMessage());
+			se.initCause(e);
+			throw se;
+		} catch (UnsupportedCharsetException e) {
+			SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale, "unsupported_encoding", e
+					.getCharsetName());
+			se.initCause(e);
+			throw se;
+		} catch (Exception e) {
+			SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale, "close_message_error", e
+					.getMessage());
+
+			se.initCause(e);
+			throw se;
+		}
+	}
+
+	// --------------------------------------------------------------------------------
+	protected LogicalByteArray getReadBuffer(short odbcAPI, LogicalByteArray wbuffer) throws SQLException {
+		LogicalByteArray buf = null;
+
+		try {
+			m_processing = true;
+			buf = super.getReadBuffer(odbcAPI, wbuffer);
+			m_processing = false;
+		} catch (SQLException se) {
+			m_processing = false;
+			throw se;
+		}
+		return buf;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4TimerThread.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4TimerThread.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4TimerThread.java
new file mode 100644
index 0000000..7e81a12
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4TimerThread.java
@@ -0,0 +1,116 @@
+// @@@ 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.util.Hashtable;
+
+/*
+ Swastik: On 2/24/2005 - this class was changed to NOT inherit from the Thread
+ class. The reason is that nothing was dependent on the exact time at
+ which the InputOutput object timed out (for which it was used).
+ Timeout is always polled from this class. As a result - the timeout is
+ is calculated based on current system time.
+
+ Later if some event needs to be triggered at the exact time this Timer
+ timed out - then all the commented fields with the comment of 2/24/05
+ can be uncommented.
+ */
+class T4TimerThread
+// extends Thread
+{
+	// Stores a timer thread using the dialogue id as the key
+	private static Hashtable threadTable;
+	// Stores the idle time out value
+	private long sleepTime_;
+	// Stores when the absolute time at which timeout will/has to occur
+	private long timeoutTime_;
+
+	// Track if the thread timed out
+	// private boolean m_timedOut; // SB:2/24/05
+
+	T4TimerThread(int dialogueId, long time) {
+		if (time < 0) {
+			sleepTime_ = 0;
+		} else {
+			sleepTime_ = time;
+			// Calcluate the absolute time when timeout should occur
+		}
+		timeoutTime_ = System.currentTimeMillis() + sleepTime_;
+		// m_timedOut = false; // SB:2/24/05
+		if (threadTable == null) {
+			threadTable = new Hashtable();
+		}
+		threadTable.put(new Integer(dialogueId), this);
+	}
+
+	public void reset(long slpTime) {
+		// Reset the absolute time when timeout should occur
+		if (slpTime > 0) {
+			timeoutTime_ = slpTime + System.currentTimeMillis();
+		}
+	}
+
+	/*
+	 * // SB:2/24/05 public void run() { try { while (System.currentTimeMillis() <
+	 * timeoutTime_) { //m_timedOut = false; long timeToSleep = timeoutTime_ -
+	 * System.currentTimeMillis(); if (timeToSleep > 0) { sleep(timeToSleep); }
+	 * else { //m_timedOut = true; //sleep(sleepTime_); } //m_timedOut = true; } }
+	 * catch (InterruptedException ie) { return; } }
+	 */
+
+	boolean getTimedOut() {
+		// return m_timedOut; // SB:2/24/05
+		return timeoutTime_ <= System.currentTimeMillis();
+	}
+
+	static T4TimerThread getThread(int dialogueId) {
+		if (dialogueId <= 0) {
+			return null;
+		}
+		if (threadTable == null) {
+			threadTable = new Hashtable();
+		}
+		Object o = threadTable.get(new Integer(dialogueId));
+		if (o == null) {
+			return null;
+		} else {
+			return (T4TimerThread) o;
+		}
+	}
+
+	static void removeThread(int dialogueId) {
+		if (dialogueId <= 0) {
+			return;
+		}
+		if (threadTable == null) {
+			return;
+		}
+		// First check if the thread is active
+		Integer key = new Integer(dialogueId);
+		/*
+		 * // SB:2/24/05 Object o = threadTable.get(key); if (o != null) {
+		 * T4TimerThread t = (T4TimerThread) o; if (t.isAlive()) {
+		 * t.interrupt(); } }
+		 */
+		threadTable.remove(key);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4_Dcs_Cancel.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4_Dcs_Cancel.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4_Dcs_Cancel.java
new file mode 100644
index 0000000..7357535
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4_Dcs_Cancel.java
@@ -0,0 +1,115 @@
+// @@@ 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.sql.SQLException;
+import java.util.Locale;
+
+/*******************************************************************************
+ * 
+ * This class corresponds to the ODBC client driver function
+ * odbcas_ASSvc_StopSrvr_pst_ as taken from odbcas_drvr.cpp.
+ * @version 1.0
+ ******************************************************************************/
+
+class T4_Dcs_Cancel {
+
+	/**
+	 * This method will establish an initial connection to the ODBC association
+	 * server.
+	 * 
+	 * @param locale
+	 *            The locale associated with this operation
+	 * @param dialogueId
+	 *            A dialogue ID
+	 * @param srvrType
+	 *            A server type
+	 * @param srvrObjRef
+	 *            A server object reference
+	 * @param stopType
+	 *            The stop type
+	 * 
+	 * @retrun A CancelReply class representing the reply from the association
+	 *         server is returned
+	 * 
+	 * @exception A
+	 *                SQLException is thrown
+	 */
+
+	static CancelReply cancel(T4Properties t4props, InterfaceConnection ic_, int dialogueId, int srvrType,
+			String srvrObjRef, int stopType) throws SQLException {
+		Locale locale = ic_.getLocale();
+
+		try {
+			LogicalByteArray rbuffer;
+			LogicalByteArray wbuffer;
+			//
+			// Do marshaling of input parameters.
+			//
+			wbuffer = CancelMessage.marshal(dialogueId, srvrType, srvrObjRef, stopType, ic_);
+
+			//
+			// Get the address of the ODBC Association server.
+			//
+			// T4Address address1 = new T4Address(t4props, locale,
+			// ic_.getUrl());
+			T4Address address1 = new T4Address(t4props, locale, t4props.getUrl());
+
+			//
+			// Send message to the ODBC Association server.
+			//
+			InputOutput io1 = address1.getInputOutput();
+
+			io1.openIO();
+			io1.setTimeout(ic_.t4props_.getNetworkTimeout());
+			io1.setConnectionIdleTimeout(ic_.getConnectionTimeout());
+
+			rbuffer = io1.doIO(TRANSPORT.AS_API_STOPSRVR, wbuffer);
+
+			//
+			// Process output parameters
+			//
+
+			CancelReply cr1 = new CancelReply(rbuffer, ic_);
+
+			//
+			// Close IO
+			//
+			// io1.setTimeout(ic_.t4props_.getCloseConnectionTimeout());
+			io1.setTimeout(ic_.t4props_.getNetworkTimeout());
+			io1.CloseIO(wbuffer); // Note, we are re-using the wbuffer
+
+			return cr1;
+		} // end try
+		catch (SQLException se) {
+			throw se;
+		} catch (Exception e) {
+			SQLException se = HPT4Messages.createSQLException(t4props, locale, "as_cancel_message_error", e
+					.getMessage());
+
+			se.initCause(e);
+			throw se;
+		} // end catch
+
+	} // end getConnection
+
+} // T4_Dcs_Connect

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4_Dcs_Connect.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4_Dcs_Connect.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4_Dcs_Connect.java
new file mode 100644
index 0000000..af94348
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4_Dcs_Connect.java
@@ -0,0 +1,123 @@
+// @@@ 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;
+import java.sql.SQLException;
+import java.util.Locale;
+
+class T4_Dcs_Connect {
+
+	/**
+	 * This method will establish an initial connection to the ODBC association
+	 * server.
+	 * 
+	 * @param locale
+	 *            The locale associated with this operation
+	 * @param inContext
+	 *            A CONNETION_CONTEXT_def object containing connection
+	 *            information
+	 * @param userDesc
+	 *            A USER_DESC_def object containing user information
+	 * @param srvrType
+	 *            A server type
+	 * @param retryCount
+	 *            The number of times to retry the connection
+	 * 
+	 * @retrun A ConnectReply class representing the reply from the association
+	 *         server is returned
+	 * 
+	 * @exception A
+	 *                SQLException is thrown
+	 */
+	static ConnectReply getConnection(T4Properties t4props, InterfaceConnection ic_, CONNECTION_CONTEXT_def inContext,
+			USER_DESC_def userDesc, int srvrType, short retryCount) throws SQLException {
+		Locale locale = ic_.getLocale();
+
+		if (inContext == null || userDesc == null) {
+			SQLException se = HPT4Messages.createSQLException(t4props, locale, "internal_error", null);
+			SQLException se2 = HPT4Messages.createSQLException(t4props, locale, "contact_hp_error", null);
+
+			se.setNextException(se2);
+			throw se;
+		}
+		try {
+			LogicalByteArray rbuffer;
+			LogicalByteArray wbuffer;
+
+			// Do marshaling of input parameters.
+			wbuffer = ConnectMessage.marshal(inContext, userDesc, srvrType, retryCount, T4Connection.INCONTEXT_OPT1_CLIENT_USERNAME, 0, Vproc.getVproc(), ic_);
+
+			// Get the address of the ODBC Association server.
+			T4Address address1 = new T4Address(t4props, locale, ic_.getUrl());
+
+			// Open the connection
+			InputOutput io1 = address1.getInputOutput();
+
+			io1.openIO();
+			io1.setTimeout(ic_.getLoginTimeout());
+			io1.setConnectionIdleTimeout(ic_.getConnectionTimeout());
+
+			// Send message to the ODBC Association server.
+			rbuffer = io1.doIO(TRANSPORT.AS_API_GETOBJREF, wbuffer);
+
+			// Process output parameters
+			ConnectReply cr1 = new ConnectReply(rbuffer, ic_);
+
+			// Close IO
+			io1.setTimeout(ic_.t4props_.getLoginTimeout());
+			io1.CloseIO(wbuffer); // Note, we are re-using the wbuffer
+
+			String name1 = null;
+			if (address1.m_ipAddress != null) {
+				name1 = address1.m_ipAddress;
+			} else if (address1.m_machineName != null) {
+				name1 = address1.m_machineName;
+
+			}
+			cr1.fixupSrvrObjRef(t4props, locale, name1);
+			
+			ic_.setConnStrHost(address1.getIPorName());
+
+			return cr1;
+		} catch (SQLException se) {
+			throw se;
+		} catch (CharacterCodingException e) {
+			SQLException se = HPT4Messages.createSQLException(ic_.t4props_, locale, "translation_of_parameter_failed",
+					"ConnectMessage", e.getMessage());
+			se.initCause(e);
+			throw se;
+		} catch (UnsupportedCharsetException e) {
+			SQLException se = HPT4Messages.createSQLException(ic_.t4props_, locale, "unsupported_encoding", e
+					.getCharsetName());
+			se.initCause(e);
+			throw se;
+		} catch (Exception e) {
+			SQLException se = HPT4Messages.createSQLException(t4props, locale, "as_connect_message_error", e
+					.getMessage());
+
+			se.initCause(e);
+			throw se;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TRANSPORT.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TRANSPORT.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TRANSPORT.java
new file mode 100644
index 0000000..296794b
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TRANSPORT.java
@@ -0,0 +1,263 @@
+// @@@ 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.math.BigDecimal;
+
+class TRANSPORT {
+	static final int size_long = 8;
+	static final int size_int = 4;
+	static final int size_short = 2;
+	static final int sql_identifier = 129;
+
+	static final int size_bytes(byte[] buf, boolean fixForServer) {
+		return (buf != null && buf.length > 0) ? size_int + buf.length + 1 : size_int + 1;
+	}
+
+	static final int size_bytes(byte[] buf) {
+		return (buf != null && buf.length > 0) ? size_int + buf.length + 1 : size_int;
+	}
+
+	static final int size_bytesWithCharset(byte[] buf) {
+		return (buf != null && buf.length > 0) ? size_int + buf.length + 1 + size_int : size_int;
+	}
+
+	// password types
+	static final int UNAUTHENTICATED_USER_TYPE = 2; // regular password
+	static final int PASSWORD_ENCRYPTED_USER_TYPE = 3; // used for SAS
+
+	//
+	// IO_BUFFER_LENGTH is used to determin the
+	// size of physical buffers as they are
+	// created and used by the transport layer
+	// for doing internal buffering as well
+	// as I/O.
+	//
+	// The static value here corresponds to the
+	// expected buffer size by the ODBC server.
+	// It's a fixed value here, but could
+	// easly be changed to a System properties
+	// value, or gotten programmatically from
+	// the ODBC server.
+	//
+
+	static final int IO_BUFFER_LENGTH = 4096;
+	static final int IO_BUFFER_BLOCKS = 8;
+
+	// ============== ERRORS ====================
+
+	static final int COMM_LINK_FAIL_EXCEPTION = 98;
+	static final int TIMEOUT_EXCEPTION = 99;
+	static final int WRONG_SIGNATURE = 100;
+	static final int MEMORY_ALLOC_FAILED = 101;
+	static final int DRVR_ERR_INCORRECT_LENGTH = 102;
+	static final int DRVR_ERR_ERROR_FROM_SERVER = 103;
+	static final int UNKNOWN_HEADER_TYPE = 104;
+
+	// ================ APIs ====================
+
+	static final short UNKNOWN_API = 0;
+	static final short AS_API_START = 1000;
+	static final short CFG_API_START = 2000;
+	static final short SRVR_API_START = 3000;
+	static final short ALL_API_MXCS_END = 9999; // end of all APIs that MXCS
+	// understands.
+
+	static final short AS_API_INIT = AS_API_START;
+	static final short AS_API_GETOBJREF_OLD = AS_API_INIT + 1; // OK
+	// NSKDRVR/CFGDRVR
+	static final short AS_API_REGPROCESS = AS_API_GETOBJREF_OLD + 1; // OK
+	// NSKSRVR/CFGSRVR
+	static final short AS_API_UPDATESRVRSTATE = AS_API_REGPROCESS + 1; // OK
+	// NSKSRVR
+	static final short AS_API_WOULDLIKETOLIVE = AS_API_UPDATESRVRSTATE + 1; // OK
+	// NSKSRVR
+	static final short AS_API_STARTAS = AS_API_WOULDLIKETOLIVE + 1; // OK
+	// CFGDRVR
+	static final short AS_API_STOPAS = AS_API_STARTAS + 1; // OK CFGDRVR
+	static final short AS_API_STARTDS = AS_API_STOPAS + 1; // OK CFGDRVR
+	static final short AS_API_STOPDS = AS_API_STARTDS + 1; // OK CFGDRVR
+	static final short AS_API_STATUSAS = AS_API_STOPDS + 1; // OK CFGDRVR
+	static final short AS_API_STATUSDS = AS_API_STATUSAS + 1; // OK CFGDRVR
+	static final short AS_API_STATUSDSDETAIL = AS_API_STATUSDS + 1; // OK
+	// CFGDRVR
+	static final short AS_API_STATUSSRVRALL = AS_API_STATUSDSDETAIL + 1; // OK
+	// CFGDRVR
+	static final short AS_API_STOPSRVR = AS_API_STATUSSRVRALL + 1; // OK
+	// CFGDRVR
+	static final short AS_API_STATUSDSALL = AS_API_STOPSRVR + 1; // OK
+	// CFGDRVR
+	static final short AS_API_DATASOURCECONFIGCHANGED = AS_API_STATUSDSALL + 1; // OK
+	// CFGSRVR
+	static final short AS_API_ENABLETRACE = AS_API_DATASOURCECONFIGCHANGED + 1; // OK
+	// CFGDRVR
+	static final short AS_API_DISABLETRACE = AS_API_ENABLETRACE + 1; // OK
+	// CFGDRVR
+	static final short AS_API_GETVERSIONAS = AS_API_DISABLETRACE + 1; // OK
+	// CFGDRVR
+	static final short AS_API_GETOBJREF = AS_API_GETVERSIONAS + 1; // OK
+	// NSKDRVR/CFGDRVR
+
+	static final short SRVR_API_INIT = SRVR_API_START;
+	static final short SRVR_API_SQLCONNECT = SRVR_API_INIT + 1; // OK NSKDRVR
+	static final short SRVR_API_SQLDISCONNECT = SRVR_API_SQLCONNECT + 1; // OK
+	// NSKDRVR
+	static final short SRVR_API_SQLSETCONNECTATTR = SRVR_API_SQLDISCONNECT + 1; // OK
+	// NSKDRVR
+	static final short SRVR_API_SQLENDTRAN = SRVR_API_SQLSETCONNECTATTR + 1; // OK
+	// NSKDRVR
+	static final short SRVR_API_SQLPREPARE = SRVR_API_SQLENDTRAN + 1; // OK
+	// NSKDRVR
+	static final short SRVR_API_SQLPREPARE_ROWSET = SRVR_API_SQLPREPARE + 1; // OK
+	// NSKDRVR
+	static final short SRVR_API_SQLEXECUTE_ROWSET = SRVR_API_SQLPREPARE_ROWSET + 1; // OK
+	// NSKDRVR
+	static final short SRVR_API_SQLEXECDIRECT_ROWSET = SRVR_API_SQLEXECUTE_ROWSET + 1; // OK
+	// NSKDRVR
+	static final short SRVR_API_SQLFETCH = SRVR_API_SQLEXECDIRECT_ROWSET + 1;
+	static final short SRVR_API_SQLFETCH_ROWSET = SRVR_API_SQLFETCH + 1; // OK
+	// NSKDRVR
+	static final short SRVR_API_SQLEXECUTE = SRVR_API_SQLFETCH_ROWSET + 1; // OK
+	// NSKDRVR
+	static final short SRVR_API_SQLEXECDIRECT = SRVR_API_SQLEXECUTE + 1; // OK
+	// NSKDRVR
+	static final short SRVR_API_SQLEXECUTECALL = SRVR_API_SQLEXECDIRECT + 1; // OK
+	// NSKDRVR
+	static final short SRVR_API_SQLFETCH_PERF = SRVR_API_SQLEXECUTECALL + 1; // OK
+	// NSKDRVR
+	static final short SRVR_API_SQLFREESTMT = SRVR_API_SQLFETCH_PERF + 1; // OK
+	// NSKDRVR
+	static final short SRVR_API_GETCATALOGS = SRVR_API_SQLFREESTMT + 1; // OK
+	// NSKDRVR
+	static final short SRVR_API_STOPSRVR = SRVR_API_GETCATALOGS + 1; // OK AS
+	static final short SRVR_API_ENABLETRACE = SRVR_API_STOPSRVR + 1; // OK AS
+	static final short SRVR_API_DISABLETRACE = SRVR_API_ENABLETRACE + 1; // OK
+	// AS
+	static final short SRVR_API_ENABLE_SERVER_STATISTICS = SRVR_API_DISABLETRACE + 1; // OK
+	// AS
+	static final short SRVR_API_DISABLE_SERVER_STATISTICS = SRVR_API_ENABLE_SERVER_STATISTICS + 1; // OK
+	// AS
+	static final short SRVR_API_UPDATE_SERVER_CONTEXT = SRVR_API_DISABLE_SERVER_STATISTICS + 1; // OK
+	// AS
+	static final short SRVR_API_MONITORCALL = SRVR_API_UPDATE_SERVER_CONTEXT + 1; // OK
+	// PCDRIVER
+	static final short SRVR_API_SQLPREPARE2 = SRVR_API_MONITORCALL + 1; // OK
+	// PCDRIVER
+	static final short SRVR_API_SQLEXECUTE2 = SRVR_API_SQLPREPARE2 + 1; // OK
+	// PCDRIVER
+	static final short SRVR_API_SQLFETCH2 = SRVR_API_SQLEXECUTE2 + 1; // OK
+	// PCDRIVER
+
+	static final short SQL_ATTR_ROWSET_RECOVERY = 2000;
+
+	static final int MAX_REQUEST = 300;
+	static final int MAX_BUFFER_LENGTH = 32000;
+	static final int MAX_PROCESS_NAME = 50;
+	static final int MAX_OBJECT_REF = 129;
+	static final int SIGNATURE = 12345; // 0x3039
+	static final int VERSION = 100;
+
+	static final byte FILE_SYSTEM = 70; // 'F'
+	static final byte TCPIP = 84; // 'T'
+	static final byte UNKNOWN_TRANSPORT = 78; // 'N'
+
+	static final byte NSK = 78; // 'N'
+	static final byte PC = 80; // 'P'
+
+	static final byte SWAP_YES = 89; // 'Y'
+	static final byte SWAP_NO = 78; // 'N'
+
+	static final int WRITE_REQUEST_FIRST = 1;
+	static final int WRITE_REQUEST_NEXT = WRITE_REQUEST_FIRST + 1;
+	static final int READ_RESPONSE_FIRST = WRITE_REQUEST_NEXT + 1;
+	static final int READ_RESPONSE_NEXT = READ_RESPONSE_FIRST + 1;
+	static final int CLEANUP = READ_RESPONSE_NEXT + 1;
+	static final int SRVR_TRANSPORT_ERROR = CLEANUP + 1;
+	static final int CLOSE_TCPIP_SESSION = SRVR_TRANSPORT_ERROR + 1;
+
+	// ================ SQL Statement type ====================
+
+	static final short TYPE_UNKNOWN = 0;
+	static final short TYPE_SELECT = 0x0001;
+	static final short TYPE_UPDATE = 0x0002;
+	static final short TYPE_DELETE = 0x0004;
+	static final short TYPE_INSERT = 0x0008;
+	static final short TYPE_EXPLAIN = 0x0010;
+	static final short TYPE_CREATE = 0x0020;
+	static final short TYPE_GRANT = 0x0040;
+	static final short TYPE_DROP = 0x0080;
+	static final short TYPE_INSERT_PARAM = 0x0100;
+	static final short TYPE_SELECT_CATALOG = 0x0200;
+	static final short TYPE_SMD = 0x0400;
+	static final short TYPE_CALL = 0x0800;
+	static final short TYPE_STATS = 0x1000;
+	static final short TYPE_CONFIG = 0x2000;
+	// qs_interface support
+	static final short TYPE_QS = 0x4000;
+	static final short TYPE_QS_OPEN = 0x4001;
+	static final short TYPE_QS_CLOSE = 0x4002;
+	static final short TYPE_CMD = 0x03000;
+	static final short TYPE_CMD_OPEN = 0x03001;
+	static final short TYPE_CMD_CLOSE = 0x03002;
+	static final short TYPE_BEGIN_TRANSACTION = 0x05001;
+	static final short TYPE_END_TRANSACTION = 0x05002;
+
+	// ================ SQL Query type ====================
+	//
+	// These values are taken from "Performace Updates External Specification,
+	// Database Software"
+	// document Version 0.4 Created on May 10, 2005.
+	//
+	static final int SQL_OTHER = -1;
+	static final int SQL_UNKNOWN = 0;
+	static final int SQL_SELECT_UNIQUE = 1;
+	static final int SQL_SELECT_NON_UNIQUE = 2;
+	static final int SQL_INSERT_UNIQUE = 3;
+	static final int SQL_INSERT_NON_UNIQUE = 4;
+	static final int SQL_UPDATE_UNIQUE = 5;
+	static final int SQL_UPDATE_NON_UNIQUE = 6;
+	static final int SQL_DELETE_UNIQUE = 7;
+	static final int SQL_DELETE_NON_UNIQUE = 8;
+	static final int SQL_CONTROL = 9;
+	static final int SQL_SET_TRANSACTION = 10;
+	static final int SQL_SET_CATALOG = 11;
+	static final int SQL_SET_SCHEMA = 12;
+
+	// ================ Execute2 return values ====================
+
+	static final int NO_DATA_FOUND = 100;
+
+	// =========================== NCS versions ==========
+
+	static final BigDecimal NCS_VERSION_3_3 = new BigDecimal("3.3");
+	static final BigDecimal NCS_VERSION_3_4 = new BigDecimal("3.4");
+
+	// From CEE class
+	static final int CEE_SUCCESS = 0;
+	// Added by SB 7/5/2005 for handling SUCCESS_WITH_INFO for Prepare2
+	static final int SQL_SUCCESS = 0; // ODBC Standard
+	static final int SQL_SUCCESS_WITH_INFO = 1; // ODBC Standard
+
+	// From Global.h
+	static final int ESTIMATEDCOSTRGERRWARN = 2;
+
+} // end class TRANSPORT

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TerminateDialogueMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TerminateDialogueMessage.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TerminateDialogueMessage.java
new file mode 100644
index 0000000..7db65fa
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TerminateDialogueMessage.java
@@ -0,0 +1,38 @@
+// @@@ 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;
+
+class TerminateDialogueMessage {
+	// ----------------------------------------------------------
+	static LogicalByteArray marshal(int dialogueId, InterfaceConnection ic) {
+		int wlength = Header.sizeOf();
+		LogicalByteArray buf;
+
+		wlength += TRANSPORT.size_int; // dialogueId
+
+		buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
+
+		buf.insertInt(dialogueId);
+
+		return buf;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TerminateDialogueReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TerminateDialogueReply.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TerminateDialogueReply.java
new file mode 100644
index 0000000..8c194a3
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TerminateDialogueReply.java
@@ -0,0 +1,39 @@
+// @@@ 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;
+import java.sql.SQLException;
+
+class TerminateDialogueReply {
+	odbc_SQLSvc_TerminateDialogue_exc_ m_p1;
+
+	// -------------------------------------------------------------
+	TerminateDialogueReply(LogicalByteArray buf, String addr, InterfaceConnection ic) throws CharacterCodingException,
+			UnsupportedCharsetException, SQLException {
+		buf.setLocation(Header.sizeOf());
+
+		m_p1 = new odbc_SQLSvc_TerminateDialogue_exc_();
+		m_p1.extractFromByteArray(buf, addr, ic);
+	}
+}