trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbirds...@apache.org
Subject [31/44] incubator-trafodion git commit: Refact package name
Date Tue, 18 Apr 2017 23:52:51 GMT
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/51a83dc2/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLob.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLob.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLob.java
new file mode 100644
index 0000000..f48c3ba
--- /dev/null
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLob.java
@@ -0,0 +1,456 @@
+// @@@ 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 @@@
+
+/* -*-java-*-
+ * Filename    : SQLMXLob.java
+ * Description : SQLMXClob and SQLMXBlob extends this class. Some of the 
+ *     common methods are implemented here
+ */
+
+package org.apache.trafodion.jdbc.t2;
+
+import java.sql.*;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+//import com.tandem.tmf.Current;	// Linux port - ToDo
+import java.util.Date;
+import java.io.PrintWriter;
+
+public abstract class SQLMXLob
+{
+	// public methods
+	public long length() throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_length].methodEntry();
+		try
+		{
+			long length = 0;
+
+			checkIfCurrent();
+			prepareGetLobLenStmt();
+			PreparedStatement GetLobLenStmt = getGetLobLenStmt();
+
+			if ((traceWriter_ != null) &&
+				((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
+			{
+				traceWriter_.println(getTraceId()
+					+ "length() - GetLobLenStmt params: tableName_=" + tableName_
+					+ " dataLocator_=" + dataLocator_);
+			}
+
+			synchronized (GetLobLenStmt)
+			{
+				GetLobLenStmt.setString(1, tableName_);
+				GetLobLenStmt.setLong(2, dataLocator_);
+				ResultSet rs = GetLobLenStmt.executeQuery();
+				try
+				{
+					if (rs.next())
+						length = rs.getLong(1);
+				}
+				finally
+				{
+					rs.close();
+				}
+			}
+			return length;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_length].methodExit();
+		}
+	}
+
+	public void truncate(long len) throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_truncate].methodEntry();
+		try
+		{
+			int chunkNo;
+			int offset;
+			byte[] chunk;
+
+			if (len < 0)
+			{
+				Object[] messageArguments = new Object[1];
+				messageArguments[0] = "SQLMXLob.truncate(long)";
+				throw Messages.createSQLException(conn_.locale_,"invalid_input_value", messageArguments);
+			}
+			checkIfCurrent();
+			chunkNo = (int)(len / chunkSize_);
+			offset = (int)(len % chunkSize_);
+			prepareDelLobDataStmt();
+			PreparedStatement DelLobStmt = getDelLobDataStmt();
+
+			if ((traceWriter_ != null) &&
+				((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
+			{
+				traceWriter_.println(getTraceId()
+					+ "truncate(" + len + ") - DelLobStmt params: tableName_=" + tableName_
+					+ " dataLocator_=" + dataLocator_
+					+ " chunkNo+1=" + chunkNo+1);
+			}
+
+			synchronized (DelLobStmt)
+			{
+				DelLobStmt.setString(1, tableName_);
+				DelLobStmt.setLong(2, dataLocator_);
+				DelLobStmt.setInt(3, chunkNo+1);
+				DelLobStmt.setInt(4, Integer.MAX_VALUE);
+				DelLobStmt.executeUpdate();
+			}
+			if (offset != 0)
+			{
+				prepareTrunLobDataStmt();
+				PreparedStatement TrunLobStmt = getTrunLobDataStmt();
+
+				if ((traceWriter_ != null) &&
+					((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
+				{
+					traceWriter_.println(getTraceId()
+						+ "truncate(" + len + ") - TrunLobStmt params: offset=" + offset
+						+ " tableName_=" + tableName_
+						+ " dataLocator_=" + dataLocator_
+						+ " chunkNo=" + chunkNo);
+				}
+
+				synchronized (TrunLobStmt)
+				{
+					TrunLobStmt.setInt(1, offset);
+					TrunLobStmt.setString(2, tableName_);
+					TrunLobStmt.setLong(3, dataLocator_);
+					TrunLobStmt.setInt(4, chunkNo);
+					TrunLobStmt.executeUpdate();
+				}
+			}
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_truncate].methodExit();
+		}
+	}
+
+	InputStream getInputStream() throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_getInputStream].methodEntry();
+		try
+		{
+			if (inputStream_ != null)
+			{
+				try
+				{
+					inputStream_.close();
+				}
+				catch (IOException e)
+				{
+				}
+				finally
+				{
+					inputStream_ = null;
+				}
+			}
+			inputStream_ = new SQLMXLobInputStream(conn_, this);
+			return inputStream_;
+
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_getInputStream].methodExit();
+		}
+	}
+
+	OutputStream setOutputStream(long pos) throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_setOutputStream].methodEntry();
+		try
+		{
+			if (outputStream_ != null)
+			{
+				try
+				{
+					outputStream_.close();
+				}
+				catch (IOException e)
+				{
+				}
+				finally
+				{
+					outputStream_ = null;
+				}
+			}
+			outputStream_ = new SQLMXLobOutputStream(conn_, this, pos);
+			return outputStream_;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_setOutputStream].methodExit();
+		}
+	}
+
+
+	void close()
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_close].methodEntry();
+		try
+		{
+			isCurrent_ = false;
+			try
+			{
+				if (inputStream_ != null)
+					inputStream_.close();
+				if (outputStream_ != null)
+					outputStream_.close();
+			}
+			catch (IOException e)
+			{
+			}
+			finally
+			{
+				inputStream_ = null;
+				outputStream_ = null;
+			}
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_close].methodExit();
+		}
+	}
+
+
+	static String convSQLExceptionToIO(SQLException e)
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_convSQLExceptionToIO].methodEntry();
+		try
+		{
+			SQLException e1;
+			e1 = e;
+			StringBuffer s = new StringBuffer(1000);
+			do
+			{
+				s.append("SQLState :");
+				s.append(e1.getSQLState());
+				s.append(" ErrorCode :");
+				s.append(e1.getErrorCode());
+				s.append(" Message:");
+				s.append(e1.getMessage());
+			}
+			while ((e1 = e1.getNextException()) != null);
+			return s.toString();
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_convSQLExceptionToIO].methodExit();
+		}
+	}
+
+	void checkIfCurrent() throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_checkIfCurrent].methodEntry();
+		try
+		{
+			if (! isCurrent_)
+			{
+				Object[] messageArguments = new Object[1];
+				messageArguments[0] = this;
+				throw Messages.createSQLException(conn_.locale_, "lob_not_current",
+					messageArguments);
+			}
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_checkIfCurrent].methodExit();
+		}
+	}
+
+// *******************************************************************
+// * If Autocommit is enabled, and no external transaction exists, an
+// * exception will be thrown. In this case, JDBC cannot play the role of
+// * Autocommit (updating the base and lob tables in a single unit of work)
+// * because we return an OutputStream or Writer object to the application,
+// * who could hold it indefinitely. This is the case for
+// * Clob.setAsciiStream, Clob.setCharacterStream, and Blob.setBinaryStream.
+// *******************************************************************
+	void checkAutoCommitExtTxn() throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_checkAutoCommitExtTxn].methodEntry();
+		try
+		{
+/* Linux port - ToDo com.tandem.util.FSException in tmf.jar
+			Current tx = null;
+			int txnState = -1;
+
+			try
+			{
+				tx = new Current();
+				txnState = tx.get_status();
+
+				if (conn_.autoCommit_ && (txnState == tx.StatusNoTransaction))
+				{
+					throw Messages.createSQLException(conn_.locale_,"invalid_lob_commit_state", null);
+				}
+			}
+			catch (com.tandem.util.FSException fe1)
+			{
+				Object[] messageArguments = new Object[2];
+				messageArguments[0] = Short.toString(fe1.error);
+				messageArguments[1] = fe1.getMessage();
+				throw Messages.createSQLException(conn_.locale_, "transaction_error_update",
+					messageArguments);
+			}
+*/
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_checkAutoCommitExtTxn].methodExit();
+		}
+	}
+
+    // Declare the following abstract methods to resolve symbols
+	abstract void prepareGetLobLenStmt() throws SQLException;
+	abstract void prepareDelLobDataStmt()  throws SQLException;
+	abstract void prepareGetLobDataStmt() throws SQLException;
+	abstract void prepareUpdLobDataStmt() throws SQLException;
+	abstract void prepareInsLobDataStmt() throws SQLException;
+	abstract void prepareTrunLobDataStmt() throws SQLException;
+	abstract PreparedStatement getGetLobLenStmt();
+	abstract PreparedStatement getDelLobDataStmt();
+	abstract PreparedStatement getTrunLobDataStmt();
+	abstract PreparedStatement getInsLobDataStmt();
+	abstract PreparedStatement getUpdLobDataStmt();
+	abstract PreparedStatement getGetLobDataStmt();
+
+
+
+	// Constructors
+	SQLMXLob(SQLMXConnection connection, String tableName, long dataLocator, String lobTableName, boolean isBlob)
+		throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXLob_LLJL].methodEntry();
+		try
+		{
+			conn_ = connection;
+			tableName_ = tableName;
+			isCurrent_ = true;
+			dataLocator_ = dataLocator;
+			if (lobTableName != null)
+			{
+				lobTableName_ = lobTableName;
+				SQLMXDataLocator tempLoc = (SQLMXDataLocator)SQLMXConnection.lobTableToDataLoc_.get(lobTableName);
+				if (tempLoc == null)
+				{
+					dataLocator = conn_.getDataLocator(lobTableName_, isBlob);
+				}
+				SQLMXDataLocator dataLoc = (SQLMXDataLocator)SQLMXConnection.lobTableToDataLoc_.get(lobTableName);
+				chunkSize_ = dataLoc.chunkSize_;
+			}
+
+
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXLob_LLJL].methodExit();
+		}
+	}
+
+	SQLMXLob(SQLMXConnection connection, String tableName, long dataLocator, InputStream x,
+		int length, String lobTableName, boolean isBlob) throws SQLException
+	{
+		this(connection, tableName, dataLocator, lobTableName, isBlob);
+
+		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXLob_LLJLIL].methodEntry();
+		try
+		{
+			is_ = x;
+			isLength_ = length;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXLob_LLJLIL].methodExit();
+		}
+	}
+	public void setTraceId(String traceId_) {
+		this.traceId_ = traceId_;
+	}
+
+	public String getTraceId() {
+		traceWriter_ = SQLMXDataSource.traceWriter_;
+
+		// Build up template portion of jdbcTrace output. Pre-appended to jdbcTrace entries.
+		// jdbcTrace:[XXXX]:[Thread[X,X,X]]:[XXXXXXXX]:ClassName.
+		if (traceWriter_ != null)
+		{
+			traceFlag_ = T2Driver.traceFlag_;
+			String className = getClass().getName();
+			setTraceId(T2Driver.traceText + T2Driver.dateFormat.format(new Date())
+				+ "]:[" + Thread.currentThread() + "]:[" + hashCode() +  "]:"
+				+ className.substring(T2Driver.REMOVE_PKG_NAME,className.length())
+				+ ".");
+		}
+		return traceId_;
+	}
+	// fields
+	private String					traceId_;
+	static PrintWriter		traceWriter_;
+	static int				traceFlag_;
+	SQLMXConnection			conn_;
+	String					tableName_;
+	long					dataLocator_;
+	SQLMXLobInputStream		inputStream_;
+	SQLMXLobOutputStream	outputStream_;
+	boolean					isCurrent_;
+	InputStream				is_;
+	int						isLength_;
+	String					lobTableName_;
+	int						chunkSize_;
+
+	private static int methodId_length					=  0;
+	private static int methodId_truncate				=  1;
+	private static int methodId_getInputStream			=  2;
+	private static int methodId_setOutputStream			=  3;
+	private static int methodId_close					=  4;
+	private static int methodId_convSQLExceptionToIO	=  5;
+	private static int methodId_checkIfCurrent			=  6;
+	private static int methodId_checkAutoCommitExtTxn	=  7;
+	private static int methodId_SQLMXLob_LLJL			=  8;
+	private static int methodId_SQLMXLob_LLJLIL			=  9;
+	private static int totalMethodIds					= 10;
+	private static JdbcDebug[] debug;
+
+	static
+	{
+		String className = "SQLMXLob";
+		if (JdbcDebugCfg.entryActive)
+		{
+			debug = new JdbcDebug[totalMethodIds];
+			debug[methodId_length] = new JdbcDebug(className,"length");
+			debug[methodId_truncate] = new JdbcDebug(className,"truncate");
+			debug[methodId_getInputStream] = new JdbcDebug(className,"getInputStream");
+			debug[methodId_setOutputStream] = new JdbcDebug(className,"setOutputStream");
+			debug[methodId_close] = new JdbcDebug(className,"close");
+			debug[methodId_convSQLExceptionToIO] = new JdbcDebug(className,"convSQLExceptionToIO");
+			debug[methodId_checkIfCurrent] = new JdbcDebug(className,"checkIfCurrent");
+			debug[methodId_checkAutoCommitExtTxn] = new JdbcDebug(className,"checkAutoCommitExtTxn");
+			debug[methodId_SQLMXLob_LLJL] = new JdbcDebug(className,"SQLMXLob[LLJL]");
+			debug[methodId_SQLMXLob_LLJLIL] = new JdbcDebug(className,"SQLMXLob[LLJLIL]");
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/51a83dc2/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLobInputStream.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLobInputStream.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLobInputStream.java
new file mode 100644
index 0000000..f4cf5e4
--- /dev/null
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLobInputStream.java
@@ -0,0 +1,497 @@
+// @@@ 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 @@@
+
+/* -*-java-*-
+ * Filename		: SQLMXLobInputStream.java
+ * Description	: This program implements the InputStream interface.
+ *      This object returned to the application when Clob.getInputStream()
+ *      method or Blob.getInputStream is called. The application can use
+ *      this object to read the clob/blob data
+ *
+ */
+
+package org.apache.trafodion.jdbc.t2;
+
+import java.sql.*;
+import java.io.InputStream;
+import java.io.IOException;
+import java.util.Date;
+import java.io.PrintWriter;
+
+public class SQLMXLobInputStream extends InputStream
+{
+	public int available() throws IOException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_available].methodEntry();
+		try
+		{
+			long length;
+			long readLength;
+
+			if (isClosed_)
+				throw new IOException("Input stream is in closed state");
+			try
+			{
+				length = lob_.length();
+				if (currentChunkNo_ > 0)
+					readLength = ((currentChunkNo_-1) * lob_.chunkSize_) + currentByte_;
+				else
+					readLength = currentByte_;
+				return (int)(length - readLength);
+			}
+			catch (SQLException e)
+			{
+				throw new IOException(SQLMXLob.convSQLExceptionToIO(e));
+			}
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_available].methodExit();
+		}
+	}
+
+	public void close() throws IOException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_close].methodEntry();
+		try
+		{
+			isClosed_ = true;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_close].methodExit();
+		}
+	}
+
+	public void mark(int readlimit)
+	{
+		if (JdbcDebugCfg.entryActive)
+		{
+			debug[methodId_mark].methodEntry();
+			debug[methodId_mark].methodExit();
+		}
+	}
+
+	public boolean markSupported()
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_markSupported].methodEntry();
+		try
+		{
+			return false;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_markSupported].methodExit();
+		}
+	}
+
+	public int read() throws IOException
+	{	
+		if (JdbcDebugCfg.entryActive) debug[methodId_read_V].methodEntry();
+		try
+		{
+			int retValue = 0;
+
+			if (isClosed_)
+				throw new IOException("Input stream is in closed state");
+			if (currentByte_ == bytesRead_)
+				retValue = readChunkThrowIO(null, 0, lob_.chunkSize_);
+			if (retValue != -1)
+			{
+				retValue = chunk_[currentByte_];
+				// Should be a value between 0 and 255 
+				// -1 is mapped to 255, -2 is 254 etc
+				if (retValue < 0)
+					retValue = 256 + retValue; 
+				if (currentByte_ != bytesRead_)
+					currentByte_++;
+			}
+			return retValue;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_read_V].methodExit();
+		}
+	}
+
+	public int read(byte[] b) throws IOException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_read_B].methodEntry();
+		try
+		{
+			if (b == null)
+				throw new IOException("Invalid input value");
+			return read(b, 0, b.length);
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_read_B].methodExit();
+		}
+	}
+
+	public int read(byte[] b, int off, int len) throws IOException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_read_BII].methodEntry();
+		try
+		{
+			int readLen;
+			int copyLen;
+			int copyOffset;
+			int tempLen = 0;
+			int retLen;
+
+			if (isClosed_)
+				throw new IOException("Input stream is in closed state");
+			if (b == null)
+				throw new IOException("Invalid input value");
+			copyLen = len;
+			copyOffset = off;
+			readLen = 0;
+			if (currentByte_ < bytesRead_)
+			{
+				if (copyLen+currentByte_ <= bytesRead_)
+				{
+					System.arraycopy(chunk_, currentByte_, b, copyOffset, copyLen);
+					currentByte_ += copyLen;
+					readLen = copyLen;
+					return readLen;
+				}
+				else
+				{
+					tempLen = bytesRead_- currentByte_;
+					System.arraycopy(chunk_, currentByte_, b, copyOffset, tempLen);
+					copyOffset += tempLen;
+					copyLen -= tempLen;
+					currentByte_ += tempLen;
+				}
+			}
+			readLen = readChunkThrowIO(b, copyOffset, copyLen);
+			if (readLen != -1)
+				retLen = readLen + tempLen;
+			else
+				retLen = tempLen;
+			if (retLen == 0)
+				return -1;
+			else
+				return retLen;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_read_BII].methodExit();
+		}
+	}
+
+	public void reset() throws IOException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_reset].methodEntry();
+		try
+		{
+			if (isClosed_)
+				throw new IOException("Input stream is in closed state");
+			currentByte_ = 0;
+			currentChunkNo_ = 0;
+			bytesRead_ = 0;
+			return;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_reset].methodExit();
+		}
+	}
+
+	public long skip(long n) throws IOException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_skip].methodEntry();
+		try
+		{
+			long bytesToSkip;
+			int noOfChunks = 0;
+			int remBytes;
+			long retLen = -1;
+			long bytesSkipped = 0;
+			int oldChunkNo;
+
+			if (isClosed_)
+				throw new IOException("Input stream is in closed state");
+			if (n <= 0)
+				throw new IOException("Invalid input Value");
+			if (currentByte_ + n > bytesRead_)
+			{
+				bytesSkipped = bytesRead_ - currentByte_;
+				bytesToSkip = n - bytesSkipped;
+				currentByte_ += bytesSkipped;
+			}
+			else
+			{
+				currentByte_ += n;
+				return n;
+			}
+			noOfChunks += (int)((bytesToSkip-1)/ lob_.chunkSize_);
+			if ((bytesToSkip % lob_.chunkSize_) == 0)
+				remBytes = lob_.chunkSize_;
+			else
+				remBytes = (int)(bytesToSkip % lob_.chunkSize_);
+			oldChunkNo = currentChunkNo_;	// Which is already 1 more
+			currentChunkNo_ = currentChunkNo_ + noOfChunks;
+			retLen = readChunkThrowIO(null, 0, lob_.chunkSize_);
+			if (retLen != -1)
+			{
+				bytesSkipped += (currentChunkNo_ - oldChunkNo - 1) * lob_.chunkSize_;
+				if (retLen < remBytes)
+					remBytes = (int)retLen;
+				currentByte_ = remBytes;
+				bytesSkipped += remBytes;
+			}
+			else
+			{
+				bytesSkipped += available();
+				// Exclude the bytes that are in chunk already
+				remBytes = (int)(bytesSkipped - (bytesRead_ - currentByte_));
+				noOfChunks += (int)((remBytes-1) / lob_.chunkSize_);
+				currentChunkNo_ = oldChunkNo + noOfChunks;
+				//calculate the bytes in the chunk and set currentByte and bytesRead
+				//to reach EOD
+				if (remBytes == 0)
+				{
+					currentByte_ = 0;
+					bytesRead_ = 0;
+				}
+				else
+				{
+					if ((remBytes % lob_.chunkSize_) == 0)
+						currentByte_ = lob_.chunkSize_;
+					else
+						currentByte_ = (int)(remBytes % lob_.chunkSize_);
+					bytesRead_ = currentByte_;
+				}
+			}
+			return bytesSkipped;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_skip].methodExit();
+		}
+	}
+
+	int readChunkThrowIO(byte[] b, int off, int len) throws IOException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_readChunkThrowIO].methodEntry();
+		try
+		{
+			int readLen;
+			try
+			{
+				readLen = readChunk(b, off, len);
+			}
+			catch (SQLException e)
+			{
+				throw new IOException(SQLMXLob.convSQLExceptionToIO(e));
+			}
+			return readLen;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_readChunkThrowIO].methodExit();
+		}
+	} 
+
+	int readChunk(byte[] b, int off, int len) throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_readChunk].methodEntry();
+		try
+		{
+			int endChunkNo;
+			byte[]	data;
+			int copyLen;
+			int	copyOffset;
+			int readLen = 0;
+
+			// The rows to read is calculated via ((len-1)/lob_.chunkSize_)
+			endChunkNo = currentChunkNo_ + ((len-1)/lob_.chunkSize_);
+			lob_.prepareGetLobDataStmt();
+			PreparedStatement GetLobStmt = lob_.getGetLobDataStmt();
+
+			if ((traceWriter_ != null) && 
+				((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
+			{
+				traceWriter_.println(getTraceId() 
+					+ "readChunk(<byte>," + off + "," + len + ") - GetLobDataStmt params: tableName_=" + lob_.tableName_ 
+					+ " dataLocator_=" + lob_.dataLocator_
+					+ " currentChunkNo_=" + currentChunkNo_
+					+ " endChunkNo=" + endChunkNo);
+			}
+
+			synchronized (GetLobStmt)
+			{
+				GetLobStmt.setString(1, lob_.tableName_);
+				GetLobStmt.setLong(2, lob_.dataLocator_);
+				GetLobStmt.setInt(3, currentChunkNo_);
+				GetLobStmt.setInt(4, endChunkNo);
+				ResultSet rs = GetLobStmt.executeQuery();
+				copyLen = len;
+				copyOffset = off;
+				try 
+				{
+					while (rs.next())
+					{
+						data = rs.getBytes(1);
+						currentChunkNo_++;
+						bytesRead_ = data.length;
+						if (b == null)
+						{
+							System.arraycopy(data, 0, chunk_, 0, data.length);
+							readLen += data.length;
+							currentByte_ = 0;
+							break;				
+						}
+						else
+						{
+							if (copyLen >= data.length)
+							{
+								System.arraycopy(data, 0, b, copyOffset, data.length);
+								copyLen -= data.length;
+								readLen += data.length;
+								copyOffset += data.length;
+								currentByte_ = data.length;
+							} 
+							else
+							{
+								System.arraycopy(data, 0, b, copyOffset, copyLen);
+								// copy the rest of data to chunk
+								System.arraycopy(data, copyLen, chunk_, copyLen, data.length - copyLen);
+								readLen += copyLen;
+								currentByte_ = copyLen;
+								break;
+							}
+						}
+					}
+				} 
+				finally 
+				{
+					rs.close();
+				}
+			}
+			
+			if ((traceWriter_ != null) && 
+				((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
+			{
+				traceWriter_.println(getTraceId() 
+					+ "readChunk(<byte>," + off + "," + len + ") - LOB data read: bytesRead_=" + bytesRead_ 
+					+ " readLen=" + readLen + " copyLen=" + copyLen + " currentChunkNo_=" + currentChunkNo_);
+			}
+
+			if (readLen == 0)
+				return -1;
+			else
+				return readLen;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_readChunk].methodExit();
+		}
+	}
+
+	// Constructor
+	SQLMXLobInputStream(SQLMXConnection connection, SQLMXLob lob)
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXLobInputStream].methodEntry();
+		try
+		{
+			lob_ = lob;
+			conn_ = connection;
+			chunk_ = new byte[lob_.chunkSize_];
+
+			
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXLobInputStream].methodExit();
+		}
+	}
+	public void setTraceId(String traceId_) {
+		this.traceId_ = traceId_;
+	}
+
+	public String getTraceId() {
+		traceWriter_ = SQLMXDataSource.traceWriter_;
+		
+		// Build up template portion of jdbcTrace output. Pre-appended to jdbcTrace entries.
+		// jdbcTrace:[XXXX]:[Thread[X,X,X]]:[XXXXXXXX]:ClassName.
+		if (traceWriter_ != null) 
+		{
+			traceFlag_ = T2Driver.traceFlag_;
+			String className = getClass().getName();
+			setTraceId(T2Driver.traceText + T2Driver.dateFormat.format(new Date()) 
+				+ "]:[" + Thread.currentThread() + "]:[" + hashCode() +  "]:" 
+				+ className.substring(T2Driver.REMOVE_PKG_NAME,className.length()) 
+				+ ".");
+		}
+		return traceId_;
+	}
+	
+
+	// Fields
+	private String				traceId_;
+	static PrintWriter	traceWriter_;
+	static int			traceFlag_;
+	SQLMXLob			lob_;
+	SQLMXConnection		conn_;
+	boolean				isClosed_;
+	byte[]				chunk_;
+	int					currentByte_;
+	int					currentChunkNo_;
+	int					bytesRead_;
+
+	private static int methodId_available			=  0;
+	private static int methodId_close				=  1;
+	private static int methodId_mark				=  2;
+	private static int methodId_markSupported		=  3;
+	private static int methodId_read_V				=  4;
+	private static int methodId_read_B				=  5;
+	private static int methodId_read_BII			=  6;
+	private static int methodId_reset				=  7;
+	private static int methodId_skip				=  8;
+	private static int methodId_readChunkThrowIO	=  9;
+	private static int methodId_readChunk			= 10;
+	private static int methodId_SQLMXLobInputStream	= 11;
+	private static int totalMethodIds				= 12;
+	private static JdbcDebug[] debug;
+	
+	static
+	{
+		String className = "SQLMXLobInputStream";
+		if (JdbcDebugCfg.entryActive)
+		{
+			debug = new JdbcDebug[totalMethodIds];
+			debug[methodId_available] = new JdbcDebug(className,"available");
+			debug[methodId_close] = new JdbcDebug(className,"close");
+			debug[methodId_markSupported] = new JdbcDebug(className,"markSupported");
+			debug[methodId_read_V] = new JdbcDebug(className,"read[V]");
+			debug[methodId_read_B] = new JdbcDebug(className,"read[B]");
+			debug[methodId_read_BII] = new JdbcDebug(className,"read[BII]");
+			debug[methodId_reset] = new JdbcDebug(className,"reset");
+			debug[methodId_skip] = new JdbcDebug(className,"skip");
+			debug[methodId_readChunkThrowIO] = new JdbcDebug(className,"readChunkThrowIO");
+			debug[methodId_readChunk] = new JdbcDebug(className,"readChunk");
+			debug[methodId_SQLMXLobInputStream] = new JdbcDebug(className,"SQLMXLobInputStream");
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/51a83dc2/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLobOutputStream.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLobOutputStream.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLobOutputStream.java
new file mode 100644
index 0000000..64da030
--- /dev/null
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLobOutputStream.java
@@ -0,0 +1,402 @@
+// @@@ 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 @@@
+
+/* -*-java-*-
+ * Filename    : SQLMXLobOutputStream.java
+ * Description : This program implements the OutputStream interface.
+ *      This object returned to the application when Clob.setOutputStream()
+ *      method or Blob.setOutputStream is called. The application can use 
+ *      this object to write the clob/blob data
+ */
+
+
+package org.apache.trafodion.jdbc.t2;
+
+import java.sql.*;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.io.PrintWriter;
+
+public class SQLMXLobOutputStream extends OutputStream
+{
+	public void close() throws IOException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_close].methodEntry();
+		try
+		{
+			if (! isClosed_)
+			{
+				flush();
+				isClosed_ = true;
+			}
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_close].methodExit();
+		}
+	}
+
+	public void flush() throws IOException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_flush].methodEntry();
+		try
+		{
+			if (isClosed_)
+				throw new IOException("Output stream is in closed state");
+			if (! isFlushed_)
+				writeChunkThrowIO();
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_flush].methodExit();
+		}
+	}
+
+	public void write(byte[] b) throws IOException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_write_B].methodEntry();
+		try
+		{
+			if (b == null)
+				throw new IOException("Invalid input value");
+			write(b, 0, b.length);
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_write_B].methodExit();
+		}
+	}
+
+	public void write(byte[] b, int off, int len) throws IOException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_write_BII].methodEntry();
+		try
+		{
+			int copyLen;
+			int	srcOffset;
+			int tempLen;
+
+			if (isClosed_)
+				throw new IOException("Output stream is in closed state");
+			if (b == null)
+				throw new IOException("Invalid input value");
+			if (off < 0 || len < 0 || off > b.length)
+				throw new IndexOutOfBoundsException(
+					"length or offset is less than 0 or offset is greater than the length of array");
+			srcOffset = off;
+			copyLen = len;
+			while (true)
+			{
+				if ((copyLen+currentByte_) < lob_.chunkSize_)
+				{
+					System.arraycopy(b, srcOffset, chunk_, currentByte_, copyLen);
+					currentByte_ += copyLen;
+					isFlushed_ = false;
+					break;
+				}
+				else
+				{
+					tempLen = lob_.chunkSize_-currentByte_;		
+					System.arraycopy(b, srcOffset, chunk_, currentByte_, tempLen);
+					currentByte_ += tempLen;
+					writeChunkThrowIO();
+					copyLen -= tempLen;
+					srcOffset += tempLen;
+					currentByte_ = 0;
+				}
+				
+			}
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_write_BII].methodExit();
+		}
+	}
+	
+	public void write(int b)
+		throws IOException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_write_I].methodEntry();
+		try
+		{
+			if (isClosed_)
+				throw new IOException("Output stream is in closed state");
+			chunk_[currentByte_] = (byte)b;
+			isFlushed_ = false;
+			currentByte_++;
+			if (currentByte_ == lob_.chunkSize_)
+				writeChunkThrowIO();
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_write_I].methodExit();
+		}
+	}
+
+	void writeChunk() throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_writeChunk].methodEntry();
+		try
+		{
+			byte[] tempChunk;
+
+			if (currentChunkNo_ > updChunkNo_)
+			{
+				lob_.prepareInsLobDataStmt();
+				PreparedStatement InsLobStmt = lob_.getInsLobDataStmt();
+
+				synchronized (InsLobStmt)
+				{
+					InsLobStmt.setString(1, lob_.tableName_);
+					InsLobStmt.setLong(2, lob_.dataLocator_);
+					InsLobStmt.setInt(3, currentChunkNo_);
+					if (currentByte_ != lob_.chunkSize_)
+					{
+						tempChunk = new byte[currentByte_];
+						System.arraycopy(chunk_, 0, tempChunk, 0, currentByte_);
+					}
+					else
+						tempChunk = chunk_;	
+					InsLobStmt.setBytes(4, tempChunk);
+					InsLobStmt.executeUpdate();
+					currentChunkNo_++;
+					currentByte_ = 0;
+				}
+			}
+			else
+			{
+				lob_.prepareUpdLobDataStmt();
+				PreparedStatement UpdLobStmt = lob_.getUpdLobDataStmt();
+
+				synchronized (UpdLobStmt)
+				{
+					UpdLobStmt.setString(4, lob_.tableName_);
+					UpdLobStmt.setLong(5, lob_.dataLocator_);
+					UpdLobStmt.setInt(6, currentChunkNo_);
+					UpdLobStmt.setInt(1, updOffset_);
+					if (updOffset_ != 0 || currentByte_ != lob_.chunkSize_)
+					{
+						tempChunk = new byte[currentByte_-updOffset_];
+						System.arraycopy(chunk_, updOffset_, tempChunk, 0, currentByte_-updOffset_);
+					}
+					else
+						tempChunk = chunk_;	
+					UpdLobStmt.setInt(3, currentByte_+1);
+					UpdLobStmt.setBytes(2, tempChunk);
+					UpdLobStmt.executeUpdate();
+					currentChunkNo_++;
+					currentByte_ = 0;
+					updOffset_ = 0;
+				}
+			}
+			isFlushed_ = true;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_writeChunk].methodExit();
+		}
+	}
+
+	void writeChunkThrowIO() throws IOException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_writeChunkThrowIO].methodEntry();
+		try
+		{
+			try
+			{
+				writeChunk();
+			}
+			catch (SQLException e)
+			{
+				throw new IOException(SQLMXLob.convSQLExceptionToIO(e));
+			}
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_writeChunkThrowIO].methodExit();
+		}
+	}
+
+	void populate(InputStream is, int length) throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_populate].methodEntry();
+		try
+		{
+			int tempLen;
+			int readLen;
+			int retLen=0;
+				
+			readLen = length;
+			try
+			{
+				while (readLen > 0)
+				{
+					if (readLen <= lob_.chunkSize_)
+						tempLen = readLen;
+					else
+						tempLen = lob_.chunkSize_;
+					retLen = is.read(chunk_, 0, tempLen);
+					if (retLen == -1)
+						break;
+					currentByte_ = retLen;
+
+					if ((traceWriter_ != null) && 
+						((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
+					{
+						// For tracing, only print the 1st and last LOB data chunk write info to limit 
+						// potential overflow of buffer for trace output.
+						if (readLen==length) 			// 1st writeChunk
+						{
+							traceWriter_.println(getTraceId()
+								+ "populate() -  First writeChunk data: tableName_=" + lob_.tableName_
+								+ " dataLocator_=" + lob_.dataLocator_ + " length=" + length 
+								+ " currentChunkNo_=" + currentChunkNo_ + " updChunkNo_=" + updChunkNo_ + " retLen=" + retLen);
+						}
+						if (readLen<=lob_.chunkSize_)	// last writeChunk (NOTE: last chunk can be exactly chunkSize_)
+						{
+							traceWriter_.println(getTraceId()
+								+ "populate() -  Last writeChunk data: tableName_=" + lob_.tableName_
+								+ " dataLocator_=" + lob_.dataLocator_ + " length=" + length 
+								+ " currentChunkNo_=" + currentChunkNo_ + " updChunkNo_=" + updChunkNo_ + " retLen=" + retLen);
+						}
+					}
+
+					writeChunk();
+					readLen -= retLen;
+				}
+			}
+			catch (IOException e)
+			{
+				Object[] messageArguments = new Object[1];
+				messageArguments[0] = e.getMessage();
+				throw Messages.createSQLException(conn_.locale_, "io_exception", 
+					messageArguments);
+			}
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_populate].methodExit();
+		}
+	}
+
+	// constructors
+	SQLMXLobOutputStream(SQLMXConnection connection, SQLMXLob lob, long pos) throws 
+		SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXLobOutputStream].methodEntry();
+		try
+		{
+			long length;
+
+			lob_ = lob;
+			length = lob_.length();
+			conn_ = connection;
+			if (pos < 1 || pos > length+1)
+				throw Messages.createSQLException(conn_.locale_,"invalid_position_value", null);
+			startingPos_ = pos;
+			chunk_ = new byte[lob_.chunkSize_];
+			isFlushed_ = false;
+			if (length == 0)
+				updChunkNo_ = -1;
+			else
+			{
+				if ((length % lob_.chunkSize_) == 0)
+					updChunkNo_ = (int)(length / lob_.chunkSize_)-1;
+				else
+					updChunkNo_ = (int)(length / lob_.chunkSize_);
+			}
+			currentChunkNo_ = (int)((pos-1)/ lob_.chunkSize_);
+			currentByte_ = (int)((pos-1) % lob_.chunkSize_);
+			updOffset_ = (int)((pos-1) % lob_.chunkSize_);
+
+			traceWriter_ = SQLMXDataSource.traceWriter_;
+			
+			// Build up template portion of jdbcTrace output. Pre-appended to jdbcTrace entries.
+			// jdbcTrace:[XXXX]:[Thread[X,X,X]]:[XXXXXXXX]:ClassName.
+			if (traceWriter_ != null) 
+			{
+				traceFlag_ = T2Driver.traceFlag_;
+				String className = getClass().getName();
+				setTraceId(T2Driver.traceText + T2Driver.dateFormat.format(new Date()) 
+					+ "]:[" + Thread.currentThread() + "]:[" + hashCode() +  "]:" 
+					+ className.substring(T2Driver.REMOVE_PKG_NAME,className.length()) 
+					+ ".");
+			}
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXLobOutputStream].methodExit();
+		}
+	}
+	public void setTraceId(String traceId_) {
+		this.traceId_ = traceId_;
+	}
+
+	public String getTraceId() {
+		return traceId_;
+	}
+	// Fields
+	private String				traceId_;
+	static PrintWriter	traceWriter_;
+	static int			traceFlag_;
+	SQLMXLob			lob_;
+	long				startingPos_;
+	SQLMXConnection		conn_;
+	boolean				isClosed_;
+	byte[]				chunk_;
+	int					currentByte_;
+	int					currentChunkNo_;
+	boolean				isFlushed_;
+	int					updChunkNo_;
+	int					updOffset_;
+
+	private static int methodId_close					= 0;
+	private static int methodId_flush					= 1;
+	private static int methodId_write_B					= 2;
+	private static int methodId_write_BII				= 3;
+	private static int methodId_write_I					= 4;
+	private static int methodId_writeChunk				= 5;
+	private static int methodId_writeChunkThrowIO		= 6;
+	private static int methodId_populate				= 7;
+	private static int methodId_SQLMXLobOutputStream	= 8;
+	private static int totalMethodIds					= 9;
+	private static JdbcDebug[] debug;
+	
+	static
+	{
+		String className = "SQLMXLobOutputStream";
+		if (JdbcDebugCfg.entryActive)
+		{
+			debug = new JdbcDebug[totalMethodIds];
+			debug[methodId_close] = new JdbcDebug(className,"close");
+			debug[methodId_flush] = new JdbcDebug(className,"flush");
+			debug[methodId_write_B] = new JdbcDebug(className,"write[B]");
+			debug[methodId_write_BII] = new JdbcDebug(className,"write[BII]");
+			debug[methodId_write_I] = new JdbcDebug(className,"write[I]");
+			debug[methodId_writeChunk] = new JdbcDebug(className,"writeChunk");
+			debug[methodId_writeChunkThrowIO] = new JdbcDebug(className,"writeChunkThrowIO");
+			debug[methodId_populate] = new JdbcDebug(className,"populate");
+			debug[methodId_SQLMXLobOutputStream] = new JdbcDebug(className,"SQLMXLobOutputStream");
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/51a83dc2/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXMaxIdleTimeRunnable.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXMaxIdleTimeRunnable.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXMaxIdleTimeRunnable.java
new file mode 100644
index 0000000..7413448
--- /dev/null
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXMaxIdleTimeRunnable.java
@@ -0,0 +1,283 @@
+// @@@ 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.apache.trafodion.jdbc.t2;
+
+import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import javax.sql.PooledConnection;
+
+/*
+ * This Class is the Runnable which will be run by the
+ * Deamon thread which scavenges for Pooled Connections
+ * whose maxIdleTime is reached.
+ */
+public class SQLMXMaxIdleTimeRunnable implements Runnable {
+
+	/*
+	 * sleepTime is the maxIdleTime
+	 */
+	private int sleepTime;
+	/*
+	 * List of SQLMXPooledConnectionManagers.
+	 */
+	private LinkedList<SQLMXPooledConnectionManager> listOfPCM;
+	/*
+	 * This is a Singleton Class hence a static variable of the
+	 * class.
+	 */
+	private static SQLMXMaxIdleTimeRunnable maxIdleTimeRunnable = null;
+	/*
+	 * This List will be cleared after every scavenging run.
+	 * This is to hold the removable PooledConnection from
+	 * which will remove the scavenged PooledConnections from
+	 * SQLMXPooledConnectionManager
+	 */
+	LinkedList<PooledConnection> listOfClosedPC = new LinkedList<PooledConnection>();
+
+	private SQLMXMaxIdleTimeRunnable() {
+		if (JdbcDebugCfg.entryActive)
+			debug[methodId_SQLMXMaxIdleTimeRunnable].methodEntry();
+		try{
+			sleepTime = 0;
+			listOfPCM = new LinkedList<SQLMXPooledConnectionManager>();
+		}finally{
+			if (JdbcDebugCfg.entryActive)
+				debug[methodId_SQLMXMaxIdleTimeRunnable].methodExit();
+		}
+	}
+
+	public static SQLMXMaxIdleTimeRunnable getSQLMXMaxIdleTimeRunnable() {
+		if (JdbcDebugCfg.entryActive)
+			debug[methodId_getSQLMXMaxIdleTimeRunnable].methodEntry();
+		try{
+			if(maxIdleTimeRunnable == null) {
+				maxIdleTimeRunnable = new SQLMXMaxIdleTimeRunnable();
+			}
+			return maxIdleTimeRunnable;
+		}finally{
+			if (JdbcDebugCfg.entryActive)
+				debug[methodId_getSQLMXMaxIdleTimeRunnable].methodExit();
+		}
+	}
+	public void run() {
+//		if (JdbcDebugCfg.entryActive)
+//			debug[methodId_run].methodEntry();
+//		try {
+			if (sleepTime == 0) {
+				return;
+			}
+			while (true) {
+				/*
+				 * Sleep for maxIdleTime
+				 */
+				try {
+					Thread.sleep(sleepTime * 1000);
+				} catch (InterruptedException e) {
+					e.printStackTrace();
+				}
+				/*
+				 * Get the current time.
+				 */
+				long currentTime = System.currentTimeMillis();
+				/*
+				 * Go over all the PooledConnectionManagers
+				 */
+				synchronized (listOfPCM) {
+
+					Iterator<SQLMXPooledConnectionManager> iterOfPCM = listOfPCM
+							.iterator();
+					while (iterOfPCM.hasNext()) {
+						SQLMXPooledConnectionManager pcm = iterOfPCM.next();
+						/*
+						 * Get the Free Connections list
+						 */
+						LinkedList<PooledConnection> listOfPC = pcm.getFree_();
+						/*
+						 * Lock the List of PooledConnections which are free.
+						 */
+						synchronized (listOfPC) {
+							Iterator<PooledConnection> iterOfPC = listOfPC
+									.iterator();
+							/*
+							 * Go over the List of PooledConnections.
+							 */
+							while (iterOfPC.hasNext()) {
+
+								SQLMXPooledConnection pc = (SQLMXPooledConnection) iterOfPC
+										.next();
+								long lastUsedTime = pc.getLastUsedTime();
+								/*
+								 * The Time difference from this time and last
+								 * used time of Connection should be positive.
+								 */
+								if ((currentTime - lastUsedTime) > 0) {
+									/*
+									 * If this time unit is greater than or
+									 * equal to the maxIdleTime seconds
+									 */
+									if ((currentTime - lastUsedTime) * 1000 >= sleepTime) {
+										/*
+										 * Mark this connection
+										 */
+										listOfClosedPC.add(pc);
+									}
+								}
+							}
+							/*
+							 * Remove the marked connections from the
+							 * PoolManagers free pool, but maintain the
+							 * minPoolSize.
+							 */
+							int minPoolSize = pcm.getMinPoolSize_();
+
+							/*
+							 * Have to maintain minPoolSize
+							 */
+							if (minPoolSize < listOfClosedPC.size()) {
+								for (int nfor = 0; nfor < (listOfClosedPC
+										.size() - minPoolSize); ++nfor) {
+									try {
+										/*
+										 * Physical close of Connection.
+										 */
+										if (pcm.out_ != null)
+										{
+											if ((pcm.traceFlag_ == T2Driver.POOLING_LVL) ||
+												(pcm.traceFlag_ == T2Driver.ENTRY_LVL))
+												pcm.out_.println(pcm.getTraceId() + "MaxIdleTime elapsed, This Connection will be Hard closed");
+										}
+										listOfClosedPC.get(nfor).close();
+										/*
+										 * Remove this closed PooledConnection
+										 * from the Pool of the
+										 * PooledConnectionManager
+										 */
+										listOfPC.remove(listOfClosedPC
+												.get(nfor));
+
+									} catch (SQLException e) {
+										// TODO Auto-generated catch block
+										e.printStackTrace();
+									}
+								}
+							}
+							// Clear the temp list.
+							listOfClosedPC.clear();
+						}
+					}
+				}
+			}
+		 //finally {
+//			if (JdbcDebugCfg.entryActive)
+//				debug[methodId_getSQLMXMaxIdleTimeRunnable].methodExit();
+//		}
+	}
+	/**
+	 * @param sleepTime same as maxIdleTime
+	 */
+	public void setSleepTime(int sleepTime) {
+		if (JdbcDebugCfg.entryActive)
+			debug[methodId_setSleepTime].methodEntry();
+		if (JdbcDebugCfg.traceActive)
+			debug[methodId_setSleepTime].methodParameters("sleepTime=" + sleepTime);
+		try{
+			this.sleepTime = sleepTime;
+		}finally{
+			if (JdbcDebugCfg.entryActive)
+				debug[methodId_setSleepTime].methodExit();
+		}
+	}
+	/**
+	 * @return the sleepTime
+	 */
+	public int getSleepTime() {
+		if (JdbcDebugCfg.entryActive)
+			debug[methodId_getSleepTime].methodEntry();
+		try{
+			if (JdbcDebugCfg.traceActive)
+				debug[methodId_getSleepTime].methodReturn("sleepTime="
+						+ sleepTime);
+			return sleepTime;
+		}finally{
+			if (JdbcDebugCfg.entryActive)
+				debug[methodId_getSleepTime].methodExit();
+		}
+	}
+
+	/*
+	 * This should be called from SQLMXPooledConnectionManager.
+	 */
+	public void addPoolManager(SQLMXPooledConnectionManager mgr) {
+		if (JdbcDebugCfg.entryActive)
+			debug[methodId_addPoolManager].methodEntry();
+		if (JdbcDebugCfg.traceActive)
+			debug[methodId_addPoolManager].methodParameters("mgr=" + JdbcDebug.debugObjectStr(mgr));
+		try{
+			listOfPCM.add(mgr);
+		}finally{
+			if (JdbcDebugCfg.entryActive)
+				debug[methodId_addPoolManager].methodExit();
+		}
+	}
+
+	public void removePoolManager(SQLMXPooledConnectionManager mgr) {
+		if (JdbcDebugCfg.entryActive)
+			debug[methodId_removePoolManager].methodEntry();
+		if (JdbcDebugCfg.traceActive)
+			debug[methodId_removePoolManager].methodParameters("mgr=" + JdbcDebug.debugObjectStr(mgr));
+		try{
+			listOfPCM.remove(mgr);
+		}finally{
+			if (JdbcDebugCfg.entryActive)
+				debug[methodId_removePoolManager].methodExit();
+		}
+
+	}
+
+	private static int methodId_getSQLMXMaxIdleTimeRunnable = 0;
+	private static int methodId_setSleepTime = 1;
+	private static int methodId_run = 2;
+	private static int methodId_getSleepTime = 3;
+	private static int methodId_addPoolManager = 4;
+	private static int methodId_removePoolManager = 5;
+	private static int methodId_SQLMXMaxIdleTimeRunnable = 6;
+	private static int totalMethodIds = 7;
+	private static JdbcDebug[] debug;
+
+	static
+	{
+		String className = "SQLMXMaxIdleTimeRunnable";
+		if (JdbcDebugCfg.entryActive)
+		{
+			debug = new JdbcDebug[totalMethodIds];
+			debug[methodId_getSQLMXMaxIdleTimeRunnable] = new JdbcDebug(className,"getSQLMXMaxIdleTimeRunnable");
+			debug[methodId_setSleepTime] = new JdbcDebug(className,"setSleepTime");
+			debug[methodId_run] = new JdbcDebug(className,"run");
+			debug[methodId_getSleepTime] = new JdbcDebug(className,"getSleepTime");
+			debug[methodId_addPoolManager] = new JdbcDebug(className,"addPoolManager");
+			debug[methodId_removePoolManager] = new JdbcDebug(className,"removePoolManager");
+			debug[methodId_SQLMXMaxIdleTimeRunnable] = new JdbcDebug(className,"SQLMXMaxIdleTimeRunnable");
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/51a83dc2/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXMessages.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXMessages.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXMessages.java
new file mode 100644
index 0000000..e95b292
--- /dev/null
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXMessages.java
@@ -0,0 +1,167 @@
+// @@@ 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 @@@
+
+/* -*-java-*-
+ * Filename    : SQLMXConnection.java
+ * Description :
+ *
+ */
+ 
+ package org.apache.trafodion.jdbc.t2;
+
+ import java.sql.*;
+ import java.util.MissingResourceException;
+ import java.util.Locale;
+ import java.util.ResourceBundle;
+ import java.util.PropertyResourceBundle;
+ import java.text.MessageFormat;
+
+ 
+ public class SQLMXMessages
+ {
+ 	static SQLException createSQLException(Locale msgLocale, String messageId, Object[] messageArguments)
+ 	{
+ 		Locale currentLocale;
+ 		int sqlcode;
+            
+ 		if (msgLocale == null)
+ 			currentLocale = Locale.getDefault();
+ 		else
+ 			currentLocale = msgLocale;
+ 		try 
+		{
+			PropertyResourceBundle messageBundle =
+			    (PropertyResourceBundle) ResourceBundle.getBundle("SQLMXT2Messages", currentLocale); //R321 changed property file name to SQLMXT2Messages_en.properties
+			MessageFormat formatter = new MessageFormat("");
+            formatter.setLocale(currentLocale);
+            formatter.applyPattern(messageBundle.getString(messageId+"_msg"));
+            String message = formatter.format(messageArguments);
+            String sqlState = messageBundle.getString(messageId+"_sqlstate");
+			String sqlcodeStr = messageBundle.getString(messageId+"_sqlcode");
+			if (sqlcodeStr != null)
+			{
+				try
+				{
+					sqlcode = Integer.parseInt(sqlcodeStr);
+					sqlcode = -sqlcode;
+				}
+				catch (NumberFormatException e1)
+				{
+					sqlcode = -1;
+				}
+			}
+			else
+				sqlcode = -1;
+			return new SQLException(message, sqlState, sqlcode);
+		}
+		catch (MissingResourceException e) 
+		{
+			// If the resource bundle is not found, concatenate the messageId and the parameters 
+			String message;
+			int i = 0;
+			
+			message = "The message id: " + messageId;
+			if (messageArguments != null)
+			{
+				message = message.concat(" With parameters: ");
+				while (true)
+				{
+					message = message.concat(messageArguments[i++].toString());
+					if (i >= messageArguments.length)
+						break;
+					else
+						message = message.concat(",");
+			    }
+			}
+			return new SQLException(message, "HY000", -1);
+		}
+ 	}
+ 	
+ 	static SQLWarning createSQLWarning(Locale msgLocale, String messageId, Object[] messageArguments)
+ 	{
+ 		Locale currentLocale;
+		int sqlcode;
+ 		
+ 		if (msgLocale == null)
+ 			currentLocale = Locale.getDefault();
+ 		else
+ 			currentLocale = msgLocale;
+ 		try 
+		{
+			PropertyResourceBundle messageBundle = 
+			 (PropertyResourceBundle) ResourceBundle.getBundle("SQLMXT2Messages", currentLocale); //R321 changed property file name to SQLMXT2Messages_en.properties
+			MessageFormat formatter = new MessageFormat("");
+            formatter.setLocale(currentLocale);
+            formatter.applyPattern(messageBundle.getString(messageId+"_msg"));
+            String message = formatter.format(messageArguments);
+            String sqlState = messageBundle.getString(messageId+"_sqlstate");
+			String sqlcodeStr = messageBundle.getString(messageId+"_sqlcode");
+			if (sqlcodeStr != null)
+			{
+				try
+				{
+					sqlcode = Integer.parseInt(sqlcodeStr);
+				}
+				catch (NumberFormatException e1)
+				{
+					sqlcode = 1;
+				}
+			}
+			else
+				sqlcode = 1;
+            return new SQLWarning(message, sqlState, sqlcode);
+		}
+		catch (MissingResourceException e) 
+		{
+			// If the resource bundle is not found, concatenate the messageId and the parameters 
+			String message;
+			int i = 0;
+			
+			message = "The message id: " + messageId;
+			if (messageArguments != null)
+			{
+				message = message.concat(" With parameters: ");
+				while (true)
+				{
+					message = message.concat(messageArguments[i++].toString());
+					if (i >= messageArguments.length)
+						break;
+					else
+						message = message.concat(",");
+				}
+			}
+			return new SQLWarning(message, "01000", 1);
+		}
+ 	}
+ 	static void throwUnsupportedFeatureException(Locale locale, String s) throws SQLException
+    {
+        Object[] messageArguments = new Object[1];
+		messageArguments[0] = s;
+        throw SQLMXMessages.createSQLException(locale, "unsupported_feature", messageArguments);
+    } 
+    static void throwDeprecatedMethodException(Locale locale, String s) throws SQLException
+    {
+        Object[] messageArguments = new Object[1];
+		messageArguments[0] = s;
+        throw SQLMXMessages.createSQLException(locale, "deprecated_method", messageArguments);
+    } 
+    
+ }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/51a83dc2/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXParameterMetaData.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXParameterMetaData.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXParameterMetaData.java
new file mode 100644
index 0000000..320b5a2
--- /dev/null
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXParameterMetaData.java
@@ -0,0 +1,497 @@
+// @@@ 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 @@@
+
+/* -*-java-*-
+ * Filename    : SQLMXParameterMetaData.java
+ */
+
+package org.apache.trafodion.jdbc.t2;
+
+import java.sql.*;
+
+public class SQLMXParameterMetaData implements java.sql.ParameterMetaData
+{
+	public String getParameterClassName(int param) throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_getParameterClassName].methodEntry();
+		try
+		{
+			if (param > inputDesc_.length)
+				throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+			return inputDesc_[param-1].getColumnClassName();
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_getParameterClassName].methodExit();
+		}
+	}
+	
+	public int getParameterCount() throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_getParameterCount].methodEntry();
+		try
+		{
+			return inputDesc_.length;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_getParameterCount].methodExit();
+		}
+	}
+ 	
+	public int getParameterMode(int param) throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_getParameterMode].methodEntry();
+		try
+		{
+			if (param > inputDesc_.length)
+				throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+			return inputDesc_[param-1].paramMode_;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_getParameterMode].methodExit();
+		}
+	}
+ 	
+	public int getParameterType(int param) throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_getParameterType].methodEntry();
+		try
+		{
+			if (param > inputDesc_.length)
+				throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+			return inputDesc_[param-1].dataType_; 
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_getParameterType].methodExit();
+		}
+	}
+ 	
+	public String getParameterTypeName(int param) throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_getParameterTypeName].methodEntry();
+		try
+		{
+			if (param > inputDesc_.length)
+				throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+			return inputDesc_[param-1].getColumnTypeName(connection_.locale_);	
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_getParameterTypeName].methodExit();
+		}
+	}
+	
+	public int getPrecision(int param) throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_getPrecision].methodEntry();
+		try
+		{
+			if (param > inputDesc_.length)
+				throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+			return inputDesc_[param-1].precision_;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_getPrecision].methodExit();
+		}
+	}
+ 	
+	public int getScale(int param) throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_getScale].methodEntry();
+		try
+		{
+			if (param > inputDesc_.length)
+				throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+			return inputDesc_[param-1].scale_;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_getScale].methodExit();
+		}
+	}
+ 	
+	/* cpqGetCharacterName (extended) method added to allow SQLJ to           */
+	/* pull character data types from SQL/MX encoding info in the COLS table. */  
+	public String cpqGetCharacterSet(int param) throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_cpqGetCharacterSet].methodEntry();
+		try
+		{
+			if ((param > inputDesc_.length) || (param <= 0))
+				throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+			return inputDesc_[param-1].getCharacterSetName();
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_cpqGetCharacterSet].methodExit();
+		}
+	}
+
+	public int isNullable(int param) throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_isNullable].methodEntry();
+		try
+		{
+			if (param > inputDesc_.length) 
+				throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+			return inputDesc_[param-1].isNullable_;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_isNullable].methodExit();
+		}
+	}
+ 	
+	public boolean isSigned(int param) throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_isSigned].methodEntry();
+		try
+		{
+			if (param > inputDesc_.length) 
+				throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+			return inputDesc_[param-1].isSigned_;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_isSigned].methodExit();
+		}
+	}
+ 	
+	// Constructors
+	SQLMXParameterMetaData(SQLMXPreparedStatement stmt, SQLMXDesc[] inputDesc)
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXParameterMetaData].methodEntry();
+		try
+		{
+			connection_ = stmt.connection_;
+			inputDesc_ = inputDesc;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXParameterMetaData].methodExit();
+		}
+	}
+  
+	// Fields
+	SQLMXConnection	connection_;
+	SQLMXDesc[]		inputDesc_;
+	private static int methodId_getParameterClassName	=  0;
+	private static int methodId_getParameterCount		=  1;
+	private static int methodId_getParameterMode		=  2;
+	private static int methodId_getParameterType		=  3;
+	private static int methodId_getParameterTypeName	=  4;
+	private static int methodId_getPrecision			=  5;
+	private static int methodId_getScale				=  6;
+	private static int methodId_cpqGetCharacterSet		=  7;
+	private static int methodId_isNullable				=  8;
+	private static int methodId_isSigned				=  9;
+	private static int methodId_SQLMXParameterMetaData	= 10;
+	private static int totalMethodIds					= 11;
+	private static JdbcDebug[] debug;
+
+	static
+	{
+		String className = "SQLMXParameterMetaData";
+		if (JdbcDebugCfg.entryActive)
+		{
+			debug = new JdbcDebug[totalMethodIds];
+			debug[methodId_getParameterClassName] = new JdbcDebug(className,"getParameterClassName");
+			debug[methodId_getParameterCount] = new JdbcDebug(className,"getParameterCount");
+			debug[methodId_getParameterMode] = new JdbcDebug(className,"getParameterMode");
+			debug[methodId_getParameterType] = new JdbcDebug(className,"getParameterType");
+			debug[methodId_getParameterTypeName] = new JdbcDebug(className,"getParameterTypeName");
+			debug[methodId_getPrecision] = new JdbcDebug(className,"getPrecision");
+			debug[methodId_getScale] = new JdbcDebug(className,"getScale");
+			debug[methodId_cpqGetCharacterSet] = new JdbcDebug(className,"cpqGetCharacterSet");
+			debug[methodId_isNullable] = new JdbcDebug(className,"isNullable");
+			debug[methodId_isSigned] = new JdbcDebug(className,"isSigned");
+			debug[methodId_SQLMXParameterMetaData] = new JdbcDebug(className,"SQLMXParameterMetaData");
+		}
+	}
+
+	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 int getSqlCharset(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].sqlCharset_;
+        }
+        finally
+        {
+        }
+    }
+    public int getOdbcCharset(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].odbcCharset_;
+        }
+        finally
+        {
+        }
+    }
+    public int getSqlDataType(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].sqlDataType_;
+        }
+        finally
+        {
+        }
+    }
+    public int getDataType(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].dataType_;
+        }
+        finally
+        {
+        }
+    }
+    public short getSqlPrecision(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].sqlPrecision_; 
+        }
+        finally
+        {
+        }
+    }
+    public int getOdbcPrecision(int param) throws SQLException{
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].odbcPrecision_;
+        }
+        finally
+        {
+        }
+    }
+    public short getSqlDatetimeCode(int param) throws SQLException{
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].sqlDatetimeCode_;
+        }
+        finally
+        {
+        }
+    }
+    public int getSqlOctetLength(int param) throws SQLException{
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].sqlOctetLength_;
+        }
+        finally
+        {
+        }
+    }
+    public int getMaxLen(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].maxLen_; 
+        }
+        finally
+        {
+        }
+    }
+    public boolean getIsCurrency(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].isCurrency_;
+        }
+        finally
+        {
+        }
+    }
+    public boolean getIsCaseSensitive(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].isCaseSensitive_;
+        }
+        finally
+        {
+        }
+    }
+    public int getFsDataType(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].fsDataType_;
+        }
+        finally
+        {
+        }
+    }
+    public int getIntLeadPrec(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].intLeadPrec_;
+        }
+        finally
+        {
+        }
+    }
+    public int getMode(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].paramMode_; 
+        }
+        finally
+        {
+        }
+    }
+    public int getIndex(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].paramIndex_;
+        }
+        finally
+        {
+        }
+    }
+    public int getPos(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].paramPos_;
+        }
+        finally
+        {
+        }
+    }
+    public int getDisplaySize(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].displaySize_; 
+        }
+        finally
+        {
+        }
+    }
+    public String getCatalogName(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].catalogName_;
+        }
+        finally
+        {
+        }
+    }
+    public String getSchemaName(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].schemaName_;
+        }
+        finally
+        {
+        }
+    }
+    public String getTableName(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].tableName_;
+        }
+        finally
+        {
+        }
+    }
+    public String getName(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].name_;
+        }
+        finally
+        {
+        }
+    }
+    public String getLabel(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].columnLabel_;
+        }
+        finally
+        {
+        }
+    }
+    public String getClassName(int param) throws SQLException {
+        try
+        {
+            if (param > inputDesc_.length)
+                throw Messages.createSQLException(connection_.locale_,"invalid_desc_index", null);
+            return inputDesc_[param - 1].columnClassName_;
+        }
+        finally
+        {
+        }
+    }
+//------------------------------------------------------
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/51a83dc2/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPooledConnection.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPooledConnection.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPooledConnection.java
new file mode 100644
index 0000000..6975932
--- /dev/null
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPooledConnection.java
@@ -0,0 +1,276 @@
+// @@@ 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 @@@
+
+/* -*-java-*-
+ * Filename	: SQLMXPooledConnection.java
+ * Description :
+ */
+/*
+ * Methods Changed:SQLMXPooledConnection(SQLMXConnectionPoolDataSource,Properties)
+ * Methods Added:setLastUsedTime(long), getLastUsedTime()
+ * 
+ */
+
+package org.apache.trafodion.jdbc.t2;
+
+import java.sql.*;
+import javax.sql.*;
+import java.util.Properties;
+import java.util.LinkedList;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.lang.ref.*;
+import java.util.Locale;
+import java.lang.ref.*;
+import java.util.*;
+
+
+public class SQLMXPooledConnection extends WeakConnection implements javax.sql.PooledConnection 
+{
+
+	public void addConnectionEventListener(ConnectionEventListener listener) 
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_addConnectionEventListener].methodEntry(JdbcDebug.debugLevelPooling);
+		if (JdbcDebugCfg.traceActive) debug[methodId_addConnectionEventListener].methodParameters(
+										  "listener=" + JdbcDebug.debugObjectStr(listener));
+		try
+		{
+			if (!isClosed_ && (connection_ != null))
+			{
+				if (JdbcDebugCfg.traceActive) debug[methodId_addConnectionEventListener].traceOut(
+												  JdbcDebug.debugLevelPooling,"Adding listener");
+				listenerList_.add(listener);
+			}
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_addConnectionEventListener].methodExit();
+		}
+	}
+
+	public void close() throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_close].methodEntry(JdbcDebug.debugLevelPooling);
+		try
+		{
+			if (!isClosed_) connection_.close(true, true);
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_close].methodExit();
+		}
+	}
+
+	public Connection getConnection() throws SQLException 
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_getConnection].methodEntry(JdbcDebug.debugLevelPooling);
+		try
+		{
+			if (isClosed_ || connection_ == null)
+				throw Messages.createSQLException(locale_, "invalid_connection", null);
+			if (LogicalConnectionInUse_)
+				connection_.close(true, false);
+			LogicalConnectionInUse_ = true;
+
+			if (connection_.connectInitialized_)
+				connection_.reuse();
+			else {
+				connection_.connectInit();
+				connection_.isClosed_=false; 
+			}
+
+			return connection_;
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_getConnection].methodExit();
+		}
+	}
+
+	public void removeConnectionEventListener(ConnectionEventListener listener) 
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_removeConnectionEventListener].methodEntry(JdbcDebug.debugLevelPooling);
+		if (JdbcDebugCfg.traceActive) debug[methodId_removeConnectionEventListener].methodParameters(
+										  "listener=" + JdbcDebug.debugObjectStr(listener));
+		try
+		{
+			if (!isClosed_ && (connection_ != null))
+			{
+				if (JdbcDebugCfg.traceActive) debug[methodId_removeConnectionEventListener].traceOut(
+												  JdbcDebug.debugLevelPooling,"Removing listener");
+				listenerList_.remove(listener);
+			}
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_removeConnectionEventListener].methodExit();
+		}
+	}
+
+	// Called by SQLMXConnection when the connection is closed by the application
+	void logicalClose(boolean sendEvents)
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_logicalClose].methodEntry(JdbcDebug.debugLevelPooling);
+		if (JdbcDebugCfg.traceActive) debug[methodId_logicalClose].methodParameters(
+										  "sendEvents=" + sendEvents);
+		try
+		{
+			int i;
+			int totalListener;
+			ConnectionEventListener listener;
+	
+			LogicalConnectionInUse_ = false;
+			
+			if (sendEvents)
+			{
+				totalListener = listenerList_.size();
+				ConnectionEvent event = new ConnectionEvent(this);
+				for (i = 0; i < totalListener ; i++)
+				{
+					listener = (ConnectionEventListener)listenerList_.get(i);
+					listener.connectionClosed(event);
+				}
+			}
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_logicalClose].methodExit();
+		}
+	}
+
+	void sendConnectionErrorEvent(SQLException ex) throws SQLException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_sendConnectionErrorEvent].methodEntry(JdbcDebug.debugLevelPooling);
+		if (JdbcDebugCfg.traceActive) debug[methodId_sendConnectionErrorEvent].methodParameters(
+										  "ex=" + JdbcDebug.debugObjectStr(ex));
+		try
+		{
+			int i;
+			int totalListener;
+			ConnectionEventListener listener;
+	
+			LogicalConnectionInUse_ = false;
+			totalListener = listenerList_.size();
+			ConnectionEvent event = new ConnectionEvent(this, ex);
+			for (i = 0; i < totalListener ; i++)
+			{
+				listener = (ConnectionEventListener)listenerList_.get(i);
+				listener.connectionErrorOccurred(event);
+			}
+			close();
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_sendConnectionErrorEvent].methodExit();
+		}
+	}
+
+	// Constructor
+	SQLMXPooledConnection(SQLMXConnectionPoolDataSource pds, T2Properties info) throws
+		SQLException
+	{
+		super();
+		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXPooledConnection].methodEntry(JdbcDebug.debugLevelPooling);
+		if (JdbcDebugCfg.traceActive) debug[methodId_SQLMXPooledConnection].methodParameters(
+										  "pds=" + JdbcDebug.debugObjectStr(pds) +
+										  ", info=" + JdbcDebug.debugObjectStr(info));
+		try
+		{
+			String lang = null;
+			pds_ = pds;
+//			info_ = info;
+			t2props_ = info;
+			
+			if (info != null)
+				lang = info.getLanguage();
+			if (lang == null)
+				locale_ = Locale.getDefault();
+			else
+			{
+				if (lang.equalsIgnoreCase("ja"))
+					locale_ = new Locale("ja", "", "");
+				else
+					if (lang.equalsIgnoreCase("en"))
+					locale_ = new Locale("en", "", "");
+				else
+					locale_ = Locale.getDefault();
+			}
+			listenerList_ = new LinkedList<ConnectionEventListener>();
+			connection_ = new SQLMXConnection(this, info);
+			refToDialogueId_.put(connection_.pRef_, new Long(connection_.getDialogueId_()));
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXPooledConnection].methodExit();
+		}
+	} 
+	public void setLastUsedTime(long lastUsedTime) {
+		this.lastUsedTime = lastUsedTime;
+	}
+	public long getLastUsedTime() {
+		return lastUsedTime;
+	} 
+
+	private LinkedList<ConnectionEventListener>			listenerList_;
+	private boolean							isClosed_ =	false;
+	private SQLMXConnectionPoolDataSource	pds_;
+	private Properties						info_;
+	private T2Properties					t2props_;
+	private SQLMXConnection					connection_;
+	private Locale							locale_;
+	private boolean							LogicalConnectionInUse_ = false;
+	private long                            lastUsedTime;
+	private static int methodId_addConnectionEventListener		= 0;
+	private static int methodId_close							= 1;
+	private static int methodId_getConnection					= 2;
+	private static int methodId_removeConnectionEventListener	= 3;
+	private static int methodId_logicalClose					= 4;
+	private static int methodId_sendConnectionErrorEvent		= 5;
+	private static int methodId_SQLMXPooledConnection			= 6;
+	private static int totalMethodIds							= 7;
+	private static JdbcDebug[] debug;
+
+	static
+	{
+		String className = "SQLMXPooledConnection";
+		if (JdbcDebugCfg.entryActive)
+		{
+			debug = new JdbcDebug[totalMethodIds];
+			debug[methodId_addConnectionEventListener] = new JdbcDebug(className,"addConnectionEventListener");
+			debug[methodId_close] = new JdbcDebug(className,"close");
+			debug[methodId_getConnection] = new JdbcDebug(className,"getConnection");
+			debug[methodId_removeConnectionEventListener] = new JdbcDebug(className,"removeConnectionEventListener");
+			debug[methodId_logicalClose] = new JdbcDebug(className,"logicalClose");
+			debug[methodId_sendConnectionErrorEvent] = new JdbcDebug(className,"sendConnectionErrorEvent");
+			debug[methodId_SQLMXPooledConnection] = new JdbcDebug(className,"SQLMXPooledConnection");
+		}
+	}
+
+        public void addStatementEventListener(StatementEventListener listener) {
+                // TODO Auto-generated method stub
+
+        }
+
+	public void removeStatementEventListener(StatementEventListener listener) {
+		// TODO Auto-generated method stub
+		
+	}
+}


Mime
View raw message