You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by db...@apache.org on 2016/05/02 18:11:40 UTC
[01/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Repository: incubator-trafodion
Updated Branches:
refs/heads/master 58a4000a0 -> 56f3dbe65
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/VERSION_LIST_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/VERSION_LIST_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/VERSION_LIST_def.java
deleted file mode 100644
index 62214a4..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/VERSION_LIST_def.java
+++ /dev/null
@@ -1,65 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class VERSION_LIST_def {
- VERSION_def[] list;
-
- int sizeOf() { // since VERSION_def is a constant size we can just call the
- // sizeOf() once
- return VERSION_def.sizeOf() * list.length + TRANSPORT.size_int;
- }
-
- void insertIntoByteArray(LogicalByteArray buf) {
- buf.insertInt(list.length);
-
- for (int i = 0; i < list.length; i++) {
- list[i].insertIntoByteArray(buf);
- }
- }
-
- int sizeOfChar() {
- return list.length * VERSION_def.sizeOfChar() + 10;
- }
-
- void insertIntoByteArrayChar(LogicalByteArray buf, InterfaceConnection ic) throws CharacterCodingException, UnsupportedCharsetException{
- buf.insertFixedString(ic.encodeString("" + list.length, 1), 10);
-
- for (int i = 0; i < list.length; i++) {
- list[i].insertIntoByteArrayChar(buf, ic);
- }
- }
-
- void extractFromByteArray(LogicalByteArray buf) {
- int len = buf.extractInt();
-
- list = new VERSION_def[len];
-
- for (int i = 0; i < list.length; i++) {
- list[i] = new VERSION_def();
- list[i].extractFromByteArray(buf);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/VERSION_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/VERSION_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/VERSION_def.java
deleted file mode 100644
index 108622a..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/VERSION_def.java
+++ /dev/null
@@ -1,61 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class VERSION_def {
- short componentId;
- short majorVersion;
- short minorVersion;
- int buildId;
-
- static int sizeOf() {
- return TRANSPORT.size_int + TRANSPORT.size_short * 3;
- }
-
- void insertIntoByteArray(LogicalByteArray buf) {
- buf.insertShort(componentId);
- buf.insertShort(majorVersion);
- buf.insertShort(minorVersion);
- buf.insertInt(buildId);
- }
-
- static int sizeOfChar() {
- return 50;
- }
-
- void insertIntoByteArrayChar(LogicalByteArray buf, InterfaceConnection ic) throws CharacterCodingException, UnsupportedCharsetException{
- buf.insertFixedString(ic.encodeString("" + componentId, 1), 10);
- buf.insertFixedString(ic.encodeString("" + majorVersion, 1), 10);
- buf.insertFixedString(ic.encodeString("" + minorVersion, 1), 10);
- buf.insertFixedString(ic.encodeString("" + buildId, 1), 20);
- }
-
- void extractFromByteArray(LogicalByteArray buf) {
- componentId = buf.extractShort();
- majorVersion = buf.extractShort();
- minorVersion = buf.extractShort();
- buildId = buf.extractInt();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Vproc.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Vproc.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Vproc.java
deleted file mode 100644
index 9ab6727..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Vproc.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// @@@ 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;
-
-public class Vproc {
- private static final String vprocStr = "@@@@";
- static final int jdbcMajorVersion = 1;
- static final int jdbcMinorVersion = 0;
-
- public static void main(String[] args) {
- System.out.println(vprocStr);
- }
-
- public static String getVproc() {
- return vprocStr;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_Dcs_GetObjRefHdl_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_Dcs_GetObjRefHdl_exc_.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_Dcs_GetObjRefHdl_exc_.java
deleted file mode 100644
index 564fe5b..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_Dcs_GetObjRefHdl_exc_.java
+++ /dev/null
@@ -1,95 +0,0 @@
-// @@@ 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 odbc_Dcs_GetObjRefHdl_exc_ {
- int exception_nr;
- int exception_detail;
-
- String ErrorText;
- int errorCode;
-
- //
- // It looks like ODBC doesn't generate error text in all
- // error cases, so the following variable will contain
- // any error text generated by this JDBC driver.
- // Note, this variable is not part of the message, but it
- // represents a value stored in the HPT4Messages_*.properties file.
- //
-
- String clientErrorText;
-
- static final int odbc_Dcs_GetObjRefHdl_ASParamError_exn_ = 1;
- static final int odbc_Dcs_GetObjRefHdl_ASTimeout_exn_ = 2;
- static final int odbc_Dcs_GetObjRefHdl_ASNoSrvrHdl_exn_ = 3;
- static final int odbc_Dcs_GetObjRefHdl_ASTryAgain_exn_ = 4;
- static final int odbc_Dcs_GetObjRefHdl_ASNotAvailable_exn_ = 5;
- static final int odbc_Dcs_GetObjRefHdl_DSNotAvailable_exn_ = 6;
- static final int odbc_Dcs_GetObjRefHdl_PortNotAvailable_exn_ = 7;
- static final int odbc_Dcs_GetObjRefHdl_InvalidUser_exn_ = 8;
- static final int odbc_Dcs_GetObjRefHdl_LogonUserFailure_exn_ = 9;
-
- // -------------------------------------------------------------------
- void extractFromByteArray(LogicalByteArray buffer1, InterfaceConnection ic) throws SQLException,
- UnsupportedCharsetException, CharacterCodingException {
- exception_nr = buffer1.extractInt();
- exception_detail = buffer1.extractInt();
-
- String temp0 = Integer.toString(exception_nr);
- String temp1 = Integer.toString(exception_detail);
-
- ErrorText = ic.decodeBytes(buffer1.extractString(), 1);
-
- switch (exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
- break;
- case odbc_Dcs_GetObjRefHdl_ASParamError_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ErrorText);
- case odbc_Dcs_GetObjRefHdl_LogonUserFailure_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unable_to_logon", "");
- case odbc_Dcs_GetObjRefHdl_ASNotAvailable_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_dcs_srvr_not_available", ErrorText);
- case odbc_Dcs_GetObjRefHdl_DSNotAvailable_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_ds_not_available", new T4Properties()
- .getServerDataSource());
- case odbc_Dcs_GetObjRefHdl_PortNotAvailable_exn_:
- case odbc_Dcs_GetObjRefHdl_ASTryAgain_exn_:
- case odbc_Dcs_GetObjRefHdl_ASNoSrvrHdl_exn_:
- case -27:
- case -29:
-
- // should be retried by the driver so dont throw exception
- clientErrorText = "ids_port_not_available";
- break;
- case odbc_Dcs_GetObjRefHdl_InvalidUser_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_28_000", null);
- case odbc_Dcs_GetObjRefHdl_ASTimeout_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_s1_t00", null);
- default:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "unknown_connect_error", null);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_Dcs_StopSrvr_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_Dcs_StopSrvr_exc_.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_Dcs_StopSrvr_exc_.java
deleted file mode 100644
index 44b6796..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_Dcs_StopSrvr_exc_.java
+++ /dev/null
@@ -1,86 +0,0 @@
-// @@@ 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 odbc_Dcs_StopSrvr_exc_ {
-
- int exception_nr;
- int exception_detail;
- //
- // If the third element is not zero, then it is an offset
- // to a character array that contains a message.
- //
- String ErrorText;
- int errorCode;
-
- //
- // It looks like ODBC doesn't generate error text in all
- // error cases, so the following variable will contain
- // any error text generated by this JDBC driver.
- // Note, this variable is not part of the message, but it
- // represents a value stored in the HPT4Messages_*.properties file.
- //
-
- String clientErrorText;
-
- static final int odbcas_ASSvc_StopSrvr_ASParamError_exn_ = 1;
- static final int odbcas_ASSvc_StopSrvr_ASNotAvailable_exn_ = 2;
- static final int odbcas_ASSvc_StopSrvr_SrvrNotFound_exn_ = 3;
- static final int odbcas_ASSvc_StopSrvr_SrvrInUseByAnotherClient_exn_ = 4;
- static final int odbcas_ASSvc_StopSrvr_ProcessStopError_exn_ = 5;
-
- // -------------------------------------------------------------------
- odbc_Dcs_StopSrvr_exc_() {
- // Do nothing constructor
- }
-
- // -------------------------------------------------------------------
- void extractFromByteArray(LogicalByteArray buffer1, InterfaceConnection ic) throws SQLException,
- UnsupportedCharsetException, CharacterCodingException {
- exception_nr = buffer1.extractInt();
- exception_detail = buffer1.extractInt();
-
- String temp0 = Integer.toString(exception_nr);
- String temp1 = Integer.toString(exception_detail);
-
- switch (exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
- break;
- case odbcas_ASSvc_StopSrvr_ASParamError_exn_:
- case odbcas_ASSvc_StopSrvr_SrvrNotFound_exn_:
- case odbcas_ASSvc_StopSrvr_ProcessStopError_exn_:
- case odbcas_ASSvc_StopSrvr_SrvrInUseByAnotherClient_exn_:
- ErrorText = ic.decodeBytes(buffer1.extractString(), 1);
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ErrorText);
- case odbcas_ASSvc_StopSrvr_ASNotAvailable_exn_:
- ErrorText = ic.decodeBytes(buffer1.extractString(), 1);
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_dcs_srvr_not_available", ErrorText);
-
- default:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "unknown_error", null);
- } // end switch
- } // end extractFromByteArray
-} // end odbc_Dcs_StopSrvr_exc_
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_Close_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_Close_exc_.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_Close_exc_.java
deleted file mode 100644
index 619bece..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_Close_exc_.java
+++ /dev/null
@@ -1,69 +0,0 @@
-// @@@ 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 odbc_SQLSvc_Close_exc_ {
- int exception_nr;
- int exception_detail;
- String ParamError;
- ERROR_DESC_LIST_def SQLError;
-
- String clientErrorText = null;
-
- static final int odbc_SQLSvc_Close_ParamError_exn_ = 1;
- static final int odbc_SQLSvc_Close_InvalidConnection_exn_ = 2;
- static final int odbc_SQLSvc_Close_SQLError_exn_ = 3;
- static final int odbc_SQLSvc_Close_TransactionError_exn_ = 4;
-
- // -------------------------------------------------------------------
- void extractFromByteArray(LogicalByteArray buf, String addr, InterfaceConnection ic)
- throws CharacterCodingException, UnsupportedCharsetException, SQLException {
- exception_nr = buf.extractInt();
- exception_detail = buf.extractInt();
-
- String temp0 = Integer.toString(exception_nr);
- String temp1 = Integer.toString(exception_detail);
-
- switch (exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
- break;
- case odbc_SQLSvc_Close_SQLError_exn_:
- SQLError = new ERROR_DESC_LIST_def();
- SQLError.extractFromByteArray(buf, ic);
- break;
- case odbc_SQLSvc_Close_ParamError_exn_:
- ParamError = ic.decodeBytes(buf.extractString(), 1);
- ;
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
- case odbc_SQLSvc_Close_InvalidConnection_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
- case odbc_SQLSvc_Close_TransactionError_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_transaction_error", temp1, addr);
- default:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0, temp1);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_EndTransaction_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_EndTransaction_exc_.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_EndTransaction_exc_.java
deleted file mode 100644
index f46d161..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_EndTransaction_exc_.java
+++ /dev/null
@@ -1,87 +0,0 @@
-// @@@ 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 odbc_SQLSvc_EndTransaction_exc_ {
- int exception_nr;
- int exception_detail;
- String ParamError;
- ERROR_DESC_LIST_def SQLError;
-
- //
- // From odbc_cl.h
- //
- // struct odbc_SQLSvc_EndTransaction_exc_ {
- // size_int exception_nr;
- // size_int exception_detail;
- // union {
- // odbc_SQLSvc_ParamError ParamError;
- // odbc_SQLSvc_SQLError SQLError;
- // } u;
- // };
-
- String clientErrorText = null;
-
- //
- // Exception number constants for
- // operation 'odbc_SQLSvc_EndTransaction'
- //
-
- static final int odbc_SQLSvc_EndTransaction_ParamError_exn_ = 1;
- static final int odbc_SQLSvc_EndTransaction_InvalidConnection_exn_ = 2;
- static final int odbc_SQLSvc_EndTransaction_SQLError_exn_ = 3;
- static final int odbc_SQLSvc_EndTransaction_SQLInvalidHandle_exn_ = 4;
- static final int odbc_SQLSvc_EndTransaction_TransactionError_exn_ = 5;
-
- // ----------------------------------------------------------
- void extractFromByteArray(LogicalByteArray buffer1, String addr, InterfaceConnection ic)
- throws CharacterCodingException, UnsupportedCharsetException, SQLException {
- exception_nr = buffer1.extractInt();
- exception_detail = buffer1.extractInt();
-
- String temp0 = Integer.toString(exception_nr);
- String temp1 = Integer.toString(exception_detail);
-
- switch (exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
- break;
- case odbc_SQLSvc_EndTransaction_SQLError_exn_:
- SQLError = new ERROR_DESC_LIST_def();
- SQLError.extractFromByteArray(buffer1, ic);
- break;
- case odbc_SQLSvc_EndTransaction_ParamError_exn_:
- ParamError = ic.decodeBytes(buffer1.extractString(), 1);
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
- case odbc_SQLSvc_EndTransaction_InvalidConnection_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
- case odbc_SQLSvc_EndTransaction_SQLInvalidHandle_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_transaction_error", temp1, addr);
- default:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0, temp1);
- } // end switch
- } // end extractFromByteArray
-
-} // end class odbc_SQLSvc_EndTransaction_exc_
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_Execute_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_Execute_exc_.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_Execute_exc_.java
deleted file mode 100644
index ebf444e..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_Execute_exc_.java
+++ /dev/null
@@ -1,89 +0,0 @@
-// @@@ 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 odbc_SQLSvc_Execute_exc_ {
- int exception_nr;
- int exception_detail;
-
- String ParamError;
- ERROR_DESC_LIST_def SQLError;
- ERROR_DESC_LIST_def SQLRetryCompile;
- int SQLQueryCancelled;
-
- //
- // Taken from odbc_cl.h
- // Exception number constants for
- // operation 'odbc_SQLSvc_ExecuteRowset'
- //
- static final int odbc_SQLSvc_Execute_ParamError_exn_ = 1;
- static final int odbc_SQLSvc_Execute_InvalidConnection_exn_ = 2;
- static final int odbc_SQLSvc_Execute_SQLError_exn_ = 3;
- static final int odbc_SQLSvc_Execute_SQLInvalidHandle_exn_ = 4;
- static final int odbc_SQLSvc_ExecuteSQLNeedData_exn_ = 5;
- static final int odbc_SQLSvc_Execute_SQLRetryCompile_exn_ = 6;
- static final int odbc_SQLSvc_Execute_SQLStillExecuting_exn_ = 7;
- static final int odbc_SQLSvc_Execute_SQLQueryCancelled_exn_ = 8;
- static final int odbc_SQLSvc_Execute_TransactionError_exn_ = 9;
-
- odbc_SQLSvc_Execute_exc_() {
- }
-
- void extractFromByteArray(LogicalByteArray buf, String addr, InterfaceConnection ic)
- throws CharacterCodingException, UnsupportedCharsetException, SQLException {
- exception_nr = buf.extractInt();
- exception_detail = buf.extractInt();
-
- String temp0 = Integer.toString(exception_nr);
- String temp1 = Integer.toString(exception_detail);
-
- switch (exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
- break;
- case odbc_SQLSvc_Execute_SQLStillExecuting_exn_:
- break;
- case odbc_SQLSvc_Execute_SQLQueryCancelled_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_s1_008", null);
- case odbc_SQLSvc_Execute_SQLError_exn_:
- SQLError = new ERROR_DESC_LIST_def();
- SQLError.extractFromByteArray(buf, ic);
- break;
- case odbc_SQLSvc_Execute_SQLRetryCompile_exn_:
- SQLRetryCompile = new ERROR_DESC_LIST_def();
- SQLRetryCompile.extractFromByteArray(buf, ic);
- break;
- case odbc_SQLSvc_Execute_ParamError_exn_:
- ParamError = ic.decodeBytes(buf.extractString(), 1);
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
- case odbc_SQLSvc_Execute_InvalidConnection_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
- case odbc_SQLSvc_Execute_TransactionError_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_transaction_error", temp1, addr);
- default:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0, temp1);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_Fetch_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_Fetch_exc_.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_Fetch_exc_.java
deleted file mode 100644
index b125b5d..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_Fetch_exc_.java
+++ /dev/null
@@ -1,87 +0,0 @@
-// @@@ 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 odbc_SQLSvc_Fetch_exc_ {
- int exception_nr;
- int exception_detail;
-
- String ParamError;
- ERROR_DESC_LIST_def SQLError;
- int SQLQueryCancelled;
-
- //
- // Taken from odbc_cl.h
- // Exception number constants for
- // operation 'odbc_SQLSvc_Fetch'
- //
- static final int odbc_SQLSvc_Fetch_ParamError_exn_ = 1;
- static final int odbc_SQLSvc_Fetch_InvalidConnection_exn_ = 2;
- static final int odbc_SQLSvc_Fetch_SQLError_exn_ = 3;
- static final int odbc_SQLSvc_Fetch_SQLInvalidHandle_exn_ = 4;
- static final int odbc_SQLSvc_Fetch_SQLNoDataFound_exn_ = 5;
- static final int odbc_SQLSvc_Fetch_SQLStillExecuting_exn_ = 6;
- static final int odbc_SQLSvc_Fetch_SQLQueryCancelled_exn_ = 7;
- static final int odbc_SQLSvc_Fetch_TransactionError_exn_ = 8;
-
- odbc_SQLSvc_Fetch_exc_() {
- // Do nothing constructor
- }
-
- void extractFromByteArray(LogicalByteArray buffer1, String addr, InterfaceConnection ic)
- throws CharacterCodingException, UnsupportedCharsetException, SQLException {
- exception_nr = buffer1.extractInt();
- exception_detail = buffer1.extractInt();
-
- String temp0 = Integer.toString(exception_nr);
- String temp1 = Integer.toString(exception_detail);
-
- switch (exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
- break;
- case odbc_SQLSvc_Fetch_SQLStillExecuting_exn_:
- break;
- case odbc_SQLSvc_Fetch_SQLNoDataFound_exn_:
- break;
- case odbc_SQLSvc_Fetch_SQLQueryCancelled_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_s1_008", null);
- case odbc_SQLSvc_Fetch_SQLError_exn_:
- SQLError = new ERROR_DESC_LIST_def();
- SQLError.extractFromByteArray(buffer1, ic);
- break;
- case odbc_SQLSvc_Fetch_ParamError_exn_:
- ParamError = ic.decodeBytes(buffer1.extractString(), 1);
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
- case odbc_SQLSvc_Fetch_InvalidConnection_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
- case odbc_SQLSvc_Fetch_TransactionError_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_transaction_error", temp1, addr);
- default:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0, temp1);
- }
- } // end extractFromByteArray
-
-} // end odbc_SQLSvc_Fetch_exc_
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_GetSQLCatalogs_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_GetSQLCatalogs_exc_.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_GetSQLCatalogs_exc_.java
deleted file mode 100644
index c48c67f..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_GetSQLCatalogs_exc_.java
+++ /dev/null
@@ -1,100 +0,0 @@
-// @@@ 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 odbc_SQLSvc_GetSQLCatalogs_exc_ {
-
- // From odbc_cl.h
- //
- // struct odbc_SQLSvc_GetSQLCatalogs_exc_
- // {
- // size_int exception_nr;
- // size_int exception_detail;
- // union {
- // odbc_SQLSvc_ParamError ParamError;
- // odbc_SQLSvc_SQLError SQLError;
- // } u;
- // };
-
- int exception_nr;
- int exception_detail;
-
- //
- // The third element is special when it is stored in
- // the buffer. It may be:
- //
- // an offset to a character array (ParamError)
- // an offset to an odbc_SQLSvc_SQLError (SQLError)
- // or it may be an integer (SQLQueryCancelled).
- //
-
- int p3Index;
- String ParamError;
- ERROR_DESC_LIST_def SQLError;
- int SQLQueryCancelled;
-
- //
- // Taken from odbc_cl.h
- // Exception number constants for
- // operation 'odbc_SQLSvc_GetSQLCatalogs'
- //
- static final int odbc_SQLSvc_GetSQLCatalogs_ParamError_exn_ = 1;
- static final int odbc_SQLSvc_GetSQLCatalogs_InvalidConnection_exn_ = 2;
- static final int odbc_SQLSvc_GetSQLCatalogs_SQLError_exn_ = 3;
- static final int odbc_SQLSvc_GetSQLCatalogs_SQLInvalidHandle_exn_ = 4;
-
- odbc_SQLSvc_GetSQLCatalogs_exc_() {
- // Do nothing constructor
- }
-
- void extractFromByteArray(LogicalByteArray buffer1, String addr, InterfaceConnection ic)
- throws CharacterCodingException, UnsupportedCharsetException, SQLException {
- exception_nr = buffer1.extractInt();
- exception_detail = buffer1.extractInt();
-
- String temp0 = Integer.toString(exception_nr);
- String temp1 = Integer.toString(exception_detail);
-
- switch (exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
- break;
- case odbc_SQLSvc_GetSQLCatalogs_SQLError_exn_:
- SQLError = new ERROR_DESC_LIST_def();
- SQLError.extractFromByteArray(buffer1, ic);
- break;
- case odbc_SQLSvc_GetSQLCatalogs_ParamError_exn_:
- ParamError = ic.decodeBytes(buffer1.extractString(), 1);
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
- case odbc_SQLSvc_GetSQLCatalogs_SQLInvalidHandle_exn_:
- break;
- case odbc_SQLSvc_GetSQLCatalogs_InvalidConnection_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
- default:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0, temp1);
- }
- } // end extractFromByteArray
-
-} // end odbc_SQLSvc_GetSQLCatalogs_exc_
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_InitializeDialogue_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_InitializeDialogue_exc_.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_InitializeDialogue_exc_.java
deleted file mode 100644
index 0488eef..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_InitializeDialogue_exc_.java
+++ /dev/null
@@ -1,76 +0,0 @@
-// @@@ 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 odbc_SQLSvc_InitializeDialogue_exc_ {
- int exception_nr;
- int exception_detail;
- String ParamError;
- ERROR_DESC_LIST_def SQLError;
- ERROR_DESC_LIST_def InvalidUser;
-
- String clientErrorText;
-
- static final int odbc_SQLSvc_InitializeDialogue_ParamError_exn_ = 1;
- static final int odbc_SQLSvc_InitializeDialogue_InvalidConnection_exn_ = 2;
- static final int odbc_SQLSvc_InitializeDialogue_SQLError_exn_ = 3;
- static final int odbc_SQLSvc_InitializeDialogue_SQLInvalidHandle_exn_ = 4;
- static final int odbc_SQLSvc_InitializeDialogue_SQLNeedData_exn_ = 5;
- static final int odbc_SQLSvc_InitializeDialogue_InvalidUser_exn_ = 6;
-
- static final int SQL_PASSWORD_EXPIRING = 8857;
- static final int SQL_PASSWORD_GRACEPERIOD = 8837;
-
- // ----------------------------------------------------------
- void extractFromByteArray(LogicalByteArray buf, String addr, InterfaceConnection ic)
- throws CharacterCodingException, UnsupportedCharsetException, SQLException {
- exception_nr = buf.extractInt();
- exception_detail = buf.extractInt();
-
- String temp0 = Integer.toString(exception_nr);
- String temp1 = Integer.toString(exception_detail);
-
- switch (exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
- break;
- case odbc_SQLSvc_InitializeDialogue_SQLError_exn_:
- SQLError = new ERROR_DESC_LIST_def();
- SQLError.extractFromByteArray(buf, ic);
- break;
- case odbc_SQLSvc_InitializeDialogue_InvalidUser_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_28_000", null);
- case odbc_SQLSvc_InitializeDialogue_ParamError_exn_:
- ParamError = ic.decodeBytes(buf.extractString(), 1);
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
- case odbc_SQLSvc_InitializeDialogue_InvalidConnection_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
-
- default:
- clientErrorText = "unknown_initialize_dialogue_reply_error";
- break;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_Prepare_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_Prepare_exc_.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_Prepare_exc_.java
deleted file mode 100644
index 62d056a..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_Prepare_exc_.java
+++ /dev/null
@@ -1,68 +0,0 @@
-// @@@ 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 odbc_SQLSvc_Prepare_exc_ {
- int returnCode;
- String sqlError;
- int rowsAffected;
- int outValuesFormat;
- byte[] outValues;
-
- static final int odbc_SQLSvc_Prepare_ParamError_exn_ = 1;
- static final int odbc_SQLSvc_Prepare_InvalidConnection_exn_ = 2;
- static final int odbc_SQLSvc_Prepare_SQLError_exn_ = 3;
- static final int odbc_SQLSvc_Prepare_SQLStillExecuting_exn_ = 4;
- static final int odbc_SQLSvc_Prepare_SQLQueryCancelled_exn_ = 5;
- static final int odbc_SQLSvc_Prepare_TransactionError_exn_ = 6;
-
- void extractFromByteArray(LogicalByteArray buf, String addr, InterfaceConnection ic) throws SQLException,
- UnsupportedCharsetException, CharacterCodingException {
- returnCode = buf.extractInt();
-
- String temp0 = Integer.toString(returnCode);
-
- switch (returnCode) {
- case TRANSPORT.CEE_SUCCESS:
- break;
- case odbc_SQLSvc_Prepare_SQLStillExecuting_exn_:
- break;
- case odbc_SQLSvc_Prepare_SQLQueryCancelled_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_s1_008", null);
- case odbc_SQLSvc_Prepare_SQLError_exn_:
- break;
- case odbc_SQLSvc_Prepare_ParamError_exn_:
- sqlError = ic.decodeBytes(buf.extractString(), 1);
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", sqlError, addr);
- case odbc_SQLSvc_Prepare_InvalidConnection_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
- case odbc_SQLSvc_Prepare_TransactionError_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_transaction_error", temp0, addr);
- default:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_SetConnectionOption_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_SetConnectionOption_exc_.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_SetConnectionOption_exc_.java
deleted file mode 100644
index 192e527..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_SetConnectionOption_exc_.java
+++ /dev/null
@@ -1,70 +0,0 @@
-// @@@ 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 odbc_SQLSvc_SetConnectionOption_exc_ {
- int exception_nr;
- int exception_detail;
- String ParamError;
- SQLWarningOrError[] errorList;
- ERROR_DESC_LIST_def SQLError;
-
- static final int odbc_SQLSvc_SetConnectionOption_ParamError_exn_ = 1;
- static final int odbc_SQLSvc_SetConnectionOption_InvalidConnection_exn_ = 2;
- static final int odbc_SQLSvc_SetConnectionOption_SQLError_exn_ = 3;
- static final int odbc_SQLSvc_SetConnectionOption_SQLInvalidHandle_exn_ = 4;
-
- // ----------------------------------------------------------
- void extractFromByteArray(LogicalByteArray buf, String addr, InterfaceConnection ic) throws SQLException,
- UnsupportedCharsetException, CharacterCodingException {
- exception_nr = buf.extractInt();
- exception_detail = buf.extractInt();
-
- String temp0 = Integer.toString(exception_nr);
- String temp1 = Integer.toString(exception_detail);
-
- switch (exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
- break;
- case odbc_SQLSvc_SetConnectionOption_SQLError_exn_:
- SQLError = new ERROR_DESC_LIST_def();
- SQLError.extractFromByteArray(buf, ic);
- HPT4Messages.throwSQLException(ic.t4props_, SQLError);
- case odbc_SQLSvc_SetConnectionOption_ParamError_exn_:
- ParamError = ic.decodeBytes(buf.extractString(), 1);
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
- case odbc_SQLSvc_SetConnectionOption_InvalidConnection_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
- case odbc_SQLSvc_SetConnectionOption_SQLInvalidHandle_exn_:
- // SQLInvalidHandle
- // throw HPT4Messages.createSQLException(null, locale, "ids_08_s01",
- // null);
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "autocommit_txn_in_progress", null);
- default:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0, temp1);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_TerminateDialogue_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_TerminateDialogue_exc_.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_TerminateDialogue_exc_.java
deleted file mode 100644
index 6242b6e..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/odbc_SQLSvc_TerminateDialogue_exc_.java
+++ /dev/null
@@ -1,66 +0,0 @@
-// @@@ 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 odbc_SQLSvc_TerminateDialogue_exc_ {
- int exception_nr;
- int exception_detail;
- String ParamError;
- ERROR_DESC_LIST_def SQLError;
-
- static final int odbc_SQLSvc_TerminateDialogue_ParamError_exn_ = 1;
- static final int odbc_SQLSvc_TerminateDialogue_InvalidConnection_exn_ = 2;
- static final int odbc_SQLSvc_TerminateDialogue_SQLError_exn_ = 3;
-
- // ----------------------------------------------------------
- void extractFromByteArray(LogicalByteArray buffer1, String addr, InterfaceConnection ic)
- throws CharacterCodingException, UnsupportedCharsetException, SQLException {
- exception_nr = buffer1.extractInt();
- exception_detail = buffer1.extractInt();
-
- String temp0 = Integer.toString(exception_nr);
- String temp1 = Integer.toString(exception_detail);
-
- switch (exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
- break;
- case odbc_SQLSvc_TerminateDialogue_SQLError_exn_:
- if (exception_detail == 25000) {
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_25_000", null);
- }
- SQLError = new ERROR_DESC_LIST_def();
- SQLError.extractFromByteArray(buffer1, ic);
- break;
- case odbc_SQLSvc_TerminateDialogue_ParamError_exn_:
- ParamError = ic.decodeBytes(buffer1.extractString(), 1);
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
- case odbc_SQLSvc_TerminateDialogue_InvalidConnection_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
- default:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0, temp1);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/secClient.properties
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/secClient.properties b/core/conn/jdbc_type4/src/secClient.properties
deleted file mode 100644
index 4b71fa2..0000000
--- a/core/conn/jdbc_type4/src/secClient.properties
+++ /dev/null
@@ -1,53 +0,0 @@
-#**********************************************************************
-# @@@ 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 Security Client error messages
-
-# Make sure the file SecClientMsgKeys.java is also updated if a new error
-# message is added to this file
-
-ERR_RETRIEVE_KEY_FROM_FILE = 29701 *** ERROR[29701] failed to retrieve the public key from the certificate file {0}.
-SESSION_KEY_GENERATION_FAILED = 29702 *** ERROR[29702] Internal error: Session key generation failed.
-INPUT_PARAMETER_IS_NULL = 29703 *** ERROR[29703] Internal error: The input parameter {0} is null.
-PWD_LENGTH_TOO_LONG = 29704 *** ERROR[29704] The password was too long.
-ENCRYPTION_FAILED = 29705 *** ERROR[29705] Internal error: Failed to encrypt the password.
-HMAC_FAILED = 29706 *** ERROR[29706] Internal error: Failed to create the keyed-Hash Message Authentication Code.
-PUBKEY_LENGTH_IS_ZERO = 29707 *** ERROR[29707] Internal error: The public key length was zero.
-ERR_CREATE_SYMMETRIC_KEY = 29708 *** ERROR[29708] Internal error: Symmetric key creation failed.
-ERR_READ_CERT_FILE = 29709 *** ERROR[29709] Error reading the certificate file {0}.
-FAILED_GENERATE_RANDOM_NUM = 29710 *** ERROR[29710] Internal error: Random number generation failed.
-CIPHER_TEXT_LEN_NOT_EQUAL_KEY_LEN = 29711 *** ERROR[29711] Internal error: The length of the cipher text was not equal to the length of the public key.
-BAD_MESSAGE_DIGEST_LEN = 29712 *** ERROR[29712] Internal error: The length of the HMAC message was less than the expected length.
-FILE_NOTFOUND = 29713 *** ERROR[29713] Certificate file {0} is not found.
-DATA_ENCRYPTION_FAILED = 29714 *** ERROR[29714] Internal error: Failed to encrypt the data.
-DECRYPTION_FAILED = 29715 *** ERROR[29715] Internal error: Failed to decrypt the password.
-ERR_WRITE_CERT_FILE = 29716 *** ERROR[29716] Error writing to the certificate file {0}.
-GET_LOCAL_HOST_NAME_FAILED = 29717 *** ERROR[29717] Internal error: Error getting the name of the local host.
-BAD_TOKEN_LEN = 29718 *** ERROR[29718] Internal error: The length of the token was not equal to the expected length.
-INCORRECT_TOKEN_FORMAT = 29719 *** ERROR[29719] Internal error: Unexpected token format.
-HOME_ENVIRONMENT_VAR_IS_NULL = 29720 *** ERROR[29720] No HOME environment variables are set on the system.
-FILE_CORRUPTION = 29721 *** ERROR[29721] The certificate file {0} is corrupted.
-FAILED_BUILDING_PWDKEY = 29722 *** ERROR[29722] Internal error: Error building the password key.
-DIR_NOTFOUND = 29723 *** ERROR[29723] Directory {0} is not found.
-ERR_OPEN_INPUT_FILE = 29729 *** ERROR[29729] Failed to open the certificate file {0}.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/trafci/install/Installer.java
----------------------------------------------------------------------
diff --git a/core/conn/trafci/install/Installer.java b/core/conn/trafci/install/Installer.java
index 4fda133..cc5e94b 100644
--- a/core/conn/trafci/install/Installer.java
+++ b/core/conn/trafci/install/Installer.java
@@ -2288,7 +2288,7 @@ public class Installer
{
System.out.print("\n"+ NEW_JDBC +
"\n--------------------------------------"+
- "\nEnter the location and file name: " + defaultInstallJDBC);
+ "\nEnter the location and file name [" + defaultInstallJDBC +"]:");
line=bufReader.readLine();
Thread.sleep(100);
} catch (IOException ioe)
[49/60] incubator-trafodion git commit: additional files
Posted by db...@apache.org.
additional files
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/e17dce61
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/e17dce61
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/e17dce61
Branch: refs/heads/master
Commit: e17dce614702af782db997db5bbca47c99b50aa6
Parents: 842caed
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Fri Apr 22 16:55:38 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Fri Apr 22 16:55:38 2016 +0000
----------------------------------------------------------------------
core/conn/jdbcT4/Makefile | 2 +-
core/conn/jdbcT4/pom.xml | 1 -
.../java/org/trafodion/jdbc/t4/BaseTest.java | 60 ++++++++++++++++++++
.../org/trafodion/jdbc/t4/T4DriverTest.java | 47 +++++++++++++++
.../test/org/trafodion/jdbc/t4/BaseTest.java | 60 --------------------
.../org/trafodion/jdbc/t4/T4DriverTest.java | 47 ---------------
6 files changed, 108 insertions(+), 109 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e17dce61/core/conn/jdbcT4/Makefile
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/Makefile b/core/conn/jdbcT4/Makefile
index 6006abb..189a053 100644
--- a/core/conn/jdbcT4/Makefile
+++ b/core/conn/jdbcT4/Makefile
@@ -27,7 +27,7 @@ all: build_all
build_all:
echo "$(MAVEN) package -DskipTests"
- set -o pipefail && $(MAVEN) package -DskipTests | tee build_jdbct4.log | grep --line-buffered -E -e '^\[[^WId]' -e '^\[INFO\] B[Uu][Ii][Ll][Dd]' -e 'to compile'
+ set -o pipefail && $(MAVEN) package | tee build_jdbct4.log | grep --line-buffered -E -e '^\[[^WId]' -e '^\[INFO\] B[Uu][Ii][Ll][Dd]' -e 'to compile'
cp target/jdbcT4-${TRAFODION_VER}.jar ${MY_SQROOT}/export/lib
mkdir -p ../clients
mv target/jdbcT4-${TRAFODION_VER}.zip ../clients
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e17dce61/core/conn/jdbcT4/pom.xml
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/pom.xml b/core/conn/jdbcT4/pom.xml
index e46ffd5..8e19b9f 100644
--- a/core/conn/jdbcT4/pom.xml
+++ b/core/conn/jdbcT4/pom.xml
@@ -29,7 +29,6 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.trafodion.jdbc.t4</groupId>
<artifactId>jdbcT4</artifactId>
- <packaging>jar</packaging>
<version>${env.TRAFODION_VER}</version>
<name>Trafodion JDBC Type4 Driver</name>
<url>http://wiki.trafodion.org</url>
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e17dce61/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/BaseTest.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/BaseTest.java b/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/BaseTest.java
new file mode 100644
index 0000000..71a9486
--- /dev/null
+++ b/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/BaseTest.java
@@ -0,0 +1,60 @@
+/*
+* @@@ 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 org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+public class BaseTest {
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e17dce61/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/T4DriverTest.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/T4DriverTest.java b/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/T4DriverTest.java
new file mode 100644
index 0000000..5619784
--- /dev/null
+++ b/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/T4DriverTest.java
@@ -0,0 +1,47 @@
+/*
+* @@@ 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 org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class T4DriverTest extends BaseTest {
+ private static T4Driver driver;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ driver = (T4Driver) Class.forName("org.trafodion.jdbc.t4.T4Driver").newInstance();
+ }
+
+
+ @Test
+ public void acceptsURL() throws SQLException {
+ String url = "jdbc:t4jdbc://localhost:23400/:";
+ Assert.assertTrue(driver.acceptsURL(url));
+ url = "jdbc:abc://localhost:23400/:";
+ Assert.assertFalse(driver.acceptsURL(url));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e17dce61/core/conn/jdbc_type4/test/org/trafodion/jdbc/t4/BaseTest.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/test/org/trafodion/jdbc/t4/BaseTest.java b/core/conn/jdbc_type4/test/org/trafodion/jdbc/t4/BaseTest.java
deleted file mode 100644
index 71a9486..0000000
--- a/core/conn/jdbc_type4/test/org/trafodion/jdbc/t4/BaseTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-* @@@ 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 org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-
-public class BaseTest {
-
- /**
- * @throws java.lang.Exception
- */
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
-
- /**
- * @throws java.lang.Exception
- */
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
- /**
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- }
-
- /**
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws Exception {
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e17dce61/core/conn/jdbc_type4/test/org/trafodion/jdbc/t4/T4DriverTest.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/test/org/trafodion/jdbc/t4/T4DriverTest.java b/core/conn/jdbc_type4/test/org/trafodion/jdbc/t4/T4DriverTest.java
deleted file mode 100644
index a464910..0000000
--- a/core/conn/jdbc_type4/test/org/trafodion/jdbc/t4/T4DriverTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-* @@@ 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 org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class T4DriverTest extends BaseTest {
- private static T4Driver driver;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- driver = (T4Driver) Class.forName("org.trafodion.jdbc.t4.T4Driver").newInstance();
- }
-
-
- @Test
- public void acceptsURL() throws SQLException {
- String url = "jdbc:t4jdbc://192.168.1.103:37800/:";
- Assert.assertTrue(driver.acceptsURL(url));
- url = "jdbc:abc://192.168.1.103:37800/:";
- Assert.assertFalse(driver.acceptsURL(url));
- }
-
-}
[42/60] incubator-trafodion git commit: Merge branch 'master' of
github.com:apache/incubator-trafodion into wrkbrnch
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a0f21cde/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java
----------------------------------------------------------------------
diff --cc core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java
index c181bee,0000000..b08d539
mode 100644,000000..100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java
@@@ -1,5389 -1,0 +1,5106 @@@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URL;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DataTruncation;
+import java.sql.DatabaseMetaData;
+import java.sql.Date;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Calendar;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
++// ----------------------------------------------------------------------------
++// This class partially implements the result set class as defined in
++// java.sql.ResultSet.
++// ----------------------------------------------------------------------------
+public class TrafT4ResultSet extends HPT4Handle implements java.sql.ResultSet {
+
+ // java.sql.ResultSet interface methods
+ public boolean absolute(int row) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, row);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "absolute", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, row);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("absolute");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ boolean flag = false;
+ int absRow;
+
+ clearWarnings();
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (getType() == ResultSet.TYPE_FORWARD_ONLY) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "forward_only_cursor",
+ null);
+ }
+ if (row == 0) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_row_number",
+ null);
+ }
+
+
+ if (row > 0) {
+ if (row <= numRows_) {
+ currentRow_ = row;
+ isBeforeFirst_ = false;
+ isAfterLast_ = false;
+ onInsertRow_ = false;
+ flag = true;
+ } else {
+ do {
+ flag = next();
+ if (!flag) {
+ break;
+ }
+ } while (currentRow_ < row);
+ }
+ } else {
+ absRow = -row;
+ afterLast();
+ if (absRow <= numRows_) {
+ currentRow_ = numRows_ - absRow + 1;
+ isAfterLast_ = false;
+ isBeforeFirst_ = false;
+ onInsertRow_ = false;
+ flag = true;
+ } else {
+ beforeFirst();
+ }
+ }
+ return flag;
+ }
+
+ public void afterLast() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "afterLast", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("afterLast");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (getType() == ResultSet.TYPE_FORWARD_ONLY) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "forward_only_cursor",
+ null);
+ }
+ last();
+ // currentRow_++;
+ isAfterLast_ = true;
+ isBeforeFirst_ = false;
+ }
+
+ public void beforeFirst() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "beforeFirst", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("beforeFirst");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (getType() == ResultSet.TYPE_FORWARD_ONLY) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "forward_only_cursor",
+ null);
+ }
+
+
+ currentRow_ = 0;
+ isBeforeFirst_ = true;
+ isAfterLast_ = false;
+ onInsertRow_ = false;
+ }
+
++ // Method not implemented
+ public void cancelRowUpdates() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "cancelRowUpdates", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("cancelRowUpdates");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- clearWarnings();
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- if (getConcurrency() == ResultSet.CONCUR_READ_ONLY) {
- throw HPT4Messages
- .createSQLException(connection_.props_, connection_.getLocale(), "read_only_concur", null);
- }
- if (onInsertRow_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cursor_position", null);
- }
- Row row = (Row) getCurrentRow();
- if (!row.getUpdated()) {
- row.clearUpdated();
- }
++ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
++ "cancelRowUpdates - not supported", null);
+ }
+
+ /**
+ * Close the resultSet. This method is synchronized to prevent many threads
+ * talking to the same server after close().
+ *
+ * @throws SQLException
+ */
+ synchronized public void close() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "close", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("close");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ if (isClosed_) {
+ return;
+ }
+ if (connection_._isClosed()) {
+ connection_.closeErroredConnection(null);
+ return;
+ }
+
+
+ if (stmt_ instanceof org.trafodion.jdbc.t4.TrafT4PreparedStatement) {
+ close(false);
+ } else {
+ close(true);
+ }
+ }
+
++ // Method not implemented
+ public void deleteRow() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "deleteRow", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("deleteRow");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- clearWarnings();
-
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- if (getConcurrency() == ResultSet.CONCUR_READ_ONLY) {
- throw HPT4Messages
- .createSQLException(connection_.props_, connection_.getLocale(), "read_only_concur", null);
- }
- if (onInsertRow_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cursor_position", null);
- }
-
-
- try {
- prepareDeleteStmt();
- Row row = (Row) getCurrentRow();
- // Remove the row from database
- row.deleteRow(connection_.getLocale(), deleteStmt_, paramCols_);
- // Remove the row from the resultSet
- cachedRows_.remove(--currentRow_);
- --numRows_;
-
- if ((getType() == ResultSet.TYPE_FORWARD_ONLY) && (getConcurrency() == ResultSet.CONCUR_UPDATABLE)) {
- int temp;
- temp = currentRowCount_;
-
- if (!next()) {
- if (temp == 1) {
- isBeforeFirst_ = true;
- }
- currentRowCount_ = 0;
- } else {
- --currentRowCount_;
- }
- } else {
- if (currentRow_ == 0) {
- isBeforeFirst_ = true;
- }
- }
- } catch (SQLException e) {
- performConnectionErrorChecks(e);
- throw e;
- }
- }
++ throw HPT4Messages.createSQLException(connection_.props_,
++ connection_.getLocale(),
++ "deleteRow - not supported",
++ null);
++ }
+
+ public int findColumn(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "findColumn", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("findColumn");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int i;
+
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ for (i = 0; i < outputDesc_.length; i++) {
+ if (columnName.equalsIgnoreCase(outputDesc_[i].name_)) {
+ return i + 1;
+ }
+ }
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_column_name", null);
+ }
+
+ public boolean first() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "first", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("first");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ boolean flag = true;
+
+ clearWarnings();
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (getType() == ResultSet.TYPE_FORWARD_ONLY) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "forward_only_cursor",
+ null);
+ }
+
+
+ if (isBeforeFirst_) {
+ flag = next();
+ }
+ if (numRows_ > 0) {
+ currentRow_ = 1;
+ isAfterLast_ = false;
+ isBeforeFirst_ = false;
+ onInsertRow_ = false;
+ }
+ return flag;
+ }
+
+ // JDK 1.2
+ public Array getArray(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getArray", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getArray");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateGetInvocation(columnIndex);
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getArray()");
+ return null;
+ }
+
+ // JDK 1.2
+ public Array getArray(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getArray", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getArray");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getArray(columnIndex);
+ }
+
+ public InputStream getAsciiStream(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getAsciiStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getAsciiStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+ // For LOB Support - SB 10/8/2004
+ int dataType;
+
+
+ dataType = outputDesc_[columnIndex - 1].dataType_;
+ switch (dataType) {
+
+
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BINARY:
+ case Types.VARBINARY:
+ case Types.LONGVARBINARY:
+ case Types.BLOB:
+ case Types.CLOB:
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ try {
+ return new java.io.DataInputStream(new java.io.ByteArrayInputStream(data.getBytes("ASCII")));
+ } catch (java.io.UnsupportedEncodingException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "unsupported_encoding", messageArguments);
+ }
+ } else {
+ return null;
+ }
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+
+ }
+
+ public InputStream getAsciiStream(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getAsciiStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getAsciiStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getAsciiStream(columnIndex);
+ }
+
+ public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBigDecimal", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBigDecimal");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+
+ String data;
+ BigDecimal retValue;
+ Double d;
+
+ validateGetInvocation(columnIndex);
+ outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ // String returned may not be numeric in case of SQL_CHAR, SQL_VARCHAR
+ // and SQL_LONGVARCHAR
+ // fields. Hoping that java might throw invalid value exception
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ data = data.trim();
+ try {
+ retValue = new BigDecimal(data);
+ } catch (NumberFormatException e) {
+ try {
+ d = new Double(data);
+ } catch (NumberFormatException e1) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ retValue = new BigDecimal(d.doubleValue());
+ }
+ return retValue;
+ } else {
+ return null;
+ }
+ }
+
+ public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, scale);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBigDecimal", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, scale);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBigDecimal");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ BigDecimal retValue;
+
+ retValue = getBigDecimal(columnIndex);
+ if (retValue != null) {
+ return retValue.setScale(scale);
+ } else {
+ return null;
+ }
+ }
+
+ public BigDecimal getBigDecimal(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBigDecimal", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBigDecimal");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getBigDecimal(columnIndex);
+ }
+
+ public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, scale);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBigDecimal", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, scale);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBigDecimal");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getBigDecimal(columnIndex, scale);
+ }
+
+ public InputStream getBinaryStream(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBinaryStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBinaryStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateGetInvocation(columnIndex);
+ byte[] data;
+
+ // For LOB Support - SB 10/8/2004
+ int dataType;
+
+
+ dataType = outputDesc_[columnIndex - 1].dataType_;
+ switch (dataType) {
+
+
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BINARY:
+ case Types.VARBINARY:
+ case Types.LONGVARBINARY:
+ case Types.BLOB:
+ case Types.CLOB:
+ data = getBytes(columnIndex);
+ if (data != null) {
+ return new java.io.ByteArrayInputStream(data);
+ } else {
+ return null;
+ }
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ }
+
+ public InputStream getBinaryStream(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBinaryStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBinaryStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getBinaryStream(columnIndex);
+ }
+
+
+ public boolean getBoolean(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBoolean", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBoolean");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+ short shortValue;
+
+ validateGetInvocation(columnIndex);
+ outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ data = data.trim();
+ if ((data.equalsIgnoreCase("true")) || (data.equalsIgnoreCase("1"))) {
+ return true;
+ } else if ((data.equalsIgnoreCase("false")) || (data.equalsIgnoreCase("false"))) {
+ return false;
+ } else {
+ try {
+ shortValue = getShort(columnIndex);
+ } catch (NumberFormatException e) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ switch (shortValue) {
+ case 0:
+ return false;
+ case 1:
+ return true;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "numeric_out_of_range", null);
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public boolean getBoolean(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBoolean", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBoolean");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getBoolean(columnIndex);
+ }
+
+ public byte getByte(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getByte", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getByte");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+ byte retValue;
+ Double d;
+ double d1;
+
+ validateGetInvocation(columnIndex);
+ outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ try {
+ retValue = Byte.parseByte(data);
+ } catch (NumberFormatException e) {
+ try {
+ d = new Double(data);
+ } catch (NumberFormatException e1) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ d1 = d.doubleValue();
+ // To allow -128.999.. and 127.999...
+ if (d1 > (double) Byte.MIN_VALUE - 1 && d1 < (double) Byte.MAX_VALUE + 1) {
+ retValue = d.byteValue();
+ if ((double) retValue != d1) {
+ setSQLWarning(null, "data_truncation", null);
+ }
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "numeric_out_of_range", null);
+ }
+ }
+ return retValue;
+ } else {
+ return 0;
+ }
+ }
+
+ public byte getByte(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getByte", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getByte");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getByte(columnIndex);
+ }
+
+ public byte[] getBytes(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBytes", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBytes");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateGetInvocation(columnIndex);
+ int dataType;
+
+
+ dataType = outputDesc_[columnIndex - 1].dataType_;
+
+ switch (dataType) {
+ case Types.BINARY:
+ case Types.VARBINARY:
+ case Types.LONGVARBINARY:
+ case Types.CHAR:
+ case Types.VARCHAR: // Extension allows varchar and
+ case Types.LONGVARCHAR: // longvarchar data types
+ case Types.BLOB:
+ case Types.CLOB:
+
- Object x = getCurrentRow().getColumnObject(columnIndex);
++ Object x = getCurrentRow().getUpdatedArrayElement(columnIndex);
+ if (x == null) {
+ wasNull_ = true;
+ return null;
+ } else {
+ wasNull_ = false;
+ if (x instanceof byte[]) {
+ return (byte[]) x;
+ } else if (x instanceof String) {
+ return ((String) x).getBytes();
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ }
+
+
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ }
+
+ public byte[] getBytes(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBytes", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBytes");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getBytes(columnIndex);
+ }
+
+ public Reader getCharacterStream(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getCharacterStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getCharacterStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+ int dataType;
+
+
+ validateGetInvocation(columnIndex);
+ dataType = outputDesc_[columnIndex - 1].dataType_;
+ switch (dataType) {
+
+
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BINARY:
+ case Types.VARBINARY:
+ case Types.LONGVARBINARY:
+ case Types.BLOB:
+ case Types.CLOB:
+ data = getString(columnIndex);
+ if (data != null) {
+ return new java.io.StringReader(data);
+ } else {
+ return null;
+ }
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+
+ }
+
+ public Reader getCharacterStream(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getCharacterStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getCharacterStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getCharacterStream(columnIndex);
+ }
+
+ public int getConcurrency() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getConcurrency", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getConcurrency");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (stmt_ != null) {
+ return stmt_.resultSetConcurrency_;
+ } else {
+ return ResultSet.CONCUR_READ_ONLY;
+ }
+ }
+
+ public String getCursorName() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getCursorName", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getCursorName");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (spj_rs_ && stmtLabel_ != null) {
+ return stmtLabel_;
+ } else if (stmt_ != null) {
+ String cursorName;
+ cursorName = stmt_.cursorName_;
+ if (cursorName == null) {
+ cursorName = stmt_.stmtLabel_;
+ }
+ return cursorName;
+ } else {
+ return null;
+ }
+ }
+
+ // wm_merge - AM
+ static String convertDateFormat(String dt) {
+ String tokens[] = dt.split("[/]", 3);
+
+ if (tokens.length != 3) {
+ return dt;
+ }
+ StringBuffer sb = new StringBuffer();
+ sb.append(tokens[0]).append("-").append(tokens[1]).append("-").append(tokens[2]);
+ return sb.toString();
+ }
+
+ public Date getDate(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ String data;
+ Date retValue;
+ int endIndex;
+
+ validateGetInvocation(columnIndex);
+ dataType = outputDesc_[columnIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.DATE && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ try {
+ boolean convertDate = connection_.getDateConversion();
+
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ String temp = "Convert Date=" + convertDate;
+ connection_.props_.t4Logger_.logp(Level.FINEST, "TrafT4ResultSet", "getDate", temp, p);
+ }
+ if (convertDate) {
+ String dt = convertDateFormat(data);
+ retValue = valueOf(dt);
+ } else {
+ retValue = Date.valueOf(data);
+ }
+ } catch (IllegalArgumentException e) {
+ data = data.trim();
+ if ((endIndex = data.indexOf(' ')) != -1) {
+ data = data.substring(0, endIndex);
+ }
+ try {
+ retValue = Date.valueOf(data);
+ setSQLWarning(null, "data_truncation", null);
+
+ } catch (IllegalArgumentException ex) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ }
+ return retValue;
+ } else {
+ return null;
+ }
+ }
+
+ /* TODO: this is a horrible hack but what else can be done with random 2 digit/4 digit years for dates?
+ * Note: The date constructor wants (year-1900) as a parameter
+ * We use the following table for conversion:
+ *
+ * Year Value Assumed Year Action
+ * <50 Value + 2000 must add 100
+ * >=100 Value must subtract 1900
+ * >=50 Value + 1900 no change in value needed
+ *
+ */
+ static Date valueOf(String s) {
+ int year;
+ int month;
+ int day;
+ int firstDash;
+ int secondDash;
+
+ if (s == null)
+ throw new java.lang.IllegalArgumentException();
+
+ firstDash = s.indexOf('-');
+ secondDash = s.indexOf('-', firstDash + 1);
+ if ((firstDash > 0) & (secondDash > 0) & (secondDash < s.length() - 1)) {
+ year = Integer.parseInt(s.substring(0, firstDash));
+
+ if (year < 50) {//handles 2 digit years: <50 assume 2000, >=50 assume 1900
+ year += 100;
+ }
+ else if(year >= 100) { //handles 4 digit years
+ year -= 1900;
+ }
+
+ month = Integer.parseInt(s.substring(firstDash + 1, secondDash)) - 1;
+ day = Integer.parseInt(s.substring(secondDash + 1));
+ } else {
+ throw new java.lang.IllegalArgumentException();
+ }
+
+ return new Date(year, month, day);
+ }
+
+ public Date getDate(int columnIndex, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Date sqlDate;
+ java.util.Date d;
+
+ sqlDate = getDate(columnIndex);
+ if (sqlDate != null) {
+ if (cal != null) {
+ cal.setTime(sqlDate);
+ d = cal.getTime();
+ sqlDate = new Date(d.getTime());
+ }
+ return sqlDate;
+ } else {
+ return (sqlDate);
+ }
+ }
+
+ public Date getDate(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getDate(columnIndex);
+ }
+
+ public Date getDate(String columnName, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getDate(columnIndex, cal);
+ }
+
+ public double getDouble(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDouble", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getDouble");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+
+ validateGetInvocation(columnIndex);
+ outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ try {
+ return Double.parseDouble(data);
+ } catch (NumberFormatException e1) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ } else {
+ return 0;
+ }
+ }
+
+ public double getDouble(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDouble", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getDouble");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getDouble(columnIndex);
+ }
+
+ public int getFetchDirection() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getFetchDirection", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getFetchDirection");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ return fetchDirection_;
+ }
+
+ public int getFetchSize() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getFetchSize", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getFetchSize");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ return fetchSize_;
+ }
+
+ public float getFloat(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getFloat", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getFloat");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ double data;
+ validateGetInvocation(columnIndex);
+
+ outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ // parseFloat doesn't return error when
+ // the value exceds the float max
+ data = getDouble(columnIndex);
+ if (data >= Float.NEGATIVE_INFINITY && data <= Float.POSITIVE_INFINITY) {
+ return (float) data;
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "numeric_out_of_range",
+ null);
+ }
+ }
+
+ public float getFloat(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getFloat", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getFloat");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getFloat(columnIndex);
+ }
+
+ public int getInt(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getInt", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getInt");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+ int retValue;
+ double d;
+
+ validateGetInvocation(columnIndex);
+ outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ try {
+ retValue = Integer.parseInt(data);
+ } catch (NumberFormatException e) {
+ try {
+ d = new Double(data).doubleValue();
+ } catch (NumberFormatException e1) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+
+ if (d > (double) Integer.MIN_VALUE - 1 && d < (double) Integer.MAX_VALUE + 1) {
+ retValue = (int) d;
+ if ((double) retValue != d) {
+ setSQLWarning(null, "data_truncation", null);
+ }
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "numeric_out_of_range", null);
+ }
+ }
+ } else {
+ retValue = 0;
+ }
+
+ return retValue;
+ }
+
+ public int getInt(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getInt", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getInt");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getInt(columnIndex);
+ }
+
+ public long getLong(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getLong", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getLong");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+ long retValue;
+ double d;
+
+ BigDecimal bd;
+
+ validateGetInvocation(columnIndex);
+ outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ data = getLocalString(columnIndex);
+
+ if (data != null) {
+ try {
+ retValue = Long.parseLong(data);
+ } catch (NumberFormatException e) {
+ try {
+ bd = new BigDecimal(data);
+ retValue = bd.longValue();
+ if (bd.compareTo(BigDecimal.valueOf(Long.MAX_VALUE)) <= 0
+ && bd.compareTo(BigDecimal.valueOf(Long.MIN_VALUE)) >= 0) {
+
+ if (bd.compareTo(BigDecimal.valueOf(retValue)) != 0) {
+ setSQLWarning(null, "data_truncation", null);
+ }
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "numeric_out_of_range", null);
+ }
+ } catch (NumberFormatException e2) {
+
+ try {
+ d = new Double(data).doubleValue();
+ } catch (NumberFormatException e1) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+
+ if (d >= Long.MIN_VALUE && d <= Long.MAX_VALUE) {
+ retValue = (long) d;
+
+ if ((double) retValue != d) {
+ setSQLWarning(null, "data_truncation", null);
+ }
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "numeric_out_of_range", null);
+ }
+ }
+ }
+ } else {
+ retValue = 0;
+ }
+
+ return retValue;
+ }
+
+ public long getLong(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getLong", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getLong");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getLong(columnIndex);
+ }
+
+ public ResultSetMetaData getMetaData() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getMetaData", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getMetaData");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ return new HPT4ResultSetMetaData(this, outputDesc_);
+ }
+
+ public Object getObject(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ int precision;
+ byte byteValue;
+ short shortValue;
+ int intValue;
+ long longValue;
+ float floatValue;
+ double doubleValue;
+ boolean booleanValue;
+
+ validateGetInvocation(columnIndex);
+ dataType = outputDesc_[columnIndex - 1].dataType_;
+ precision = outputDesc_[columnIndex - 1].sqlPrecision_;
+ switch (dataType) {
+ case Types.TINYINT:
+ byteValue = getByte(columnIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Byte(byteValue);
+ }
+ case Types.SMALLINT:
+ shortValue = getShort(columnIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Short(shortValue);
+ }
+ case Types.INTEGER:
+ intValue = getInt(columnIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Integer(intValue);
+ }
+ case Types.BIGINT:
+ longValue = getLong(columnIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Long(longValue);
+ }
+ case Types.REAL:
+ floatValue = getFloat(columnIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Float(floatValue);
+ }
+ case Types.FLOAT:
+ case Types.DOUBLE:
+ doubleValue = getDouble(columnIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Double(doubleValue);
+ }
+ case Types.DECIMAL:
+ case Types.NUMERIC:
+ return getBigDecimal(columnIndex);
+ case Types.BIT:
+ booleanValue = getBoolean(columnIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Boolean(booleanValue);
+ }
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BLOB:
+ case Types.CLOB:
+ return getString(columnIndex);
+ case Types.BINARY:
+ case Types.VARBINARY:
+ return getBytes(columnIndex);
+ case Types.LONGVARBINARY:
+ return getBinaryStream(columnIndex);
+ case Types.DATE:
+ return getDate(columnIndex);
+ case Types.TIME:
+ if (precision > 0)
+ return getString(columnIndex);
+
+ return getTime(columnIndex);
+ case Types.TIMESTAMP:
+ return getTimestamp(columnIndex);
+ // For LOB Support - SB 10/8/2004
+
+
+ case Types.OTHER:
+ return getString(columnIndex);
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ }
+
+ // JDK 1.2
+ public Object getObject(int columnIndex, Map map) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateGetInvocation(columnIndex);
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getObject()");
+ return null;
+ }
+
+ public Object getObject(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getObject(columnIndex);
+ }
+
+ // JDK 1.2
+ public Object getObject(String columnName, Map map) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, map);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, map);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getObject(columnIndex, map);
+ }
+
+ // JDK 1.2
+ public Ref getRef(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getRef", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getRef");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateGetInvocation(columnIndex);
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getRef()");
+ return null;
+ }
+
+ // JDK 1.2
+ public Ref getRef(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getRef", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getRef");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getRef(columnIndex);
+ }
+
+ public int getRow() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getRow", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getRow");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (isBeforeFirst_ || isAfterLast_ || onInsertRow_) {
+ return 0;
+ }
+
+ if ((getType() == ResultSet.TYPE_FORWARD_ONLY) && (getConcurrency() == ResultSet.CONCUR_UPDATABLE)) {
+ return currentRowCount_;
+ }
+ return currentRow_;
+ }
+
+ public short getShort(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getShort", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getShort");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ String data;
+ short retValue;
+ double d;
+
+ validateGetInvocation(columnIndex);
+ outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
+
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ try {
+ retValue = Short.parseShort(data);
+ } catch (NumberFormatException e) {
+ try {
+ d = new Double(data).doubleValue();
+ } catch (NumberFormatException e1) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+
+ if (d > (double) Short.MIN_VALUE - 1 && d < (double) Short.MAX_VALUE + 1) {
+ retValue = (short) d;
+ if ((double) retValue != d)
+
+ {
+ setSQLWarning(null, "data_truncation", null);
+ }
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "numeric_out_of_range", null);
+ }
+ }
+
+ } else {
+ retValue = 0;
+ }
+
+ return retValue;
+ }
+
+ public short getShort(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getShort", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getShort");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getShort(columnIndex);
+ }
+
+ public Statement getStatement() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getStatement", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getStatement");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ return stmt_;
+ }
+
+ public String getString(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getString", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getString");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+ int targetSqlType;
+ int precision;
+ Object x;
- BaseRow currentRow;
++ ObjectArray currentRow;
+
+ validateGetInvocation(columnIndex);
+ currentRow = getCurrentRow();
- x = currentRow.getColumnObject(columnIndex);
++ x = currentRow.getUpdatedArrayElement(columnIndex);
+
+ if (x == null) {
+ wasNull_ = true;
+ return null;
+ }
+
+ wasNull_ = false;
+ targetSqlType = outputDesc_[columnIndex - 1].dataType_;
+ precision = outputDesc_[columnIndex - 1].sqlPrecision_;
+ switch (targetSqlType) {
+
+
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BLOB:
+ case Types.CLOB:
+ data = getLocalString(columnIndex);
+ if (stmt_ != null && stmt_.maxFieldSize_ != 0) {
+ if (data.length() > stmt_.maxFieldSize_) {
+ data = data.substring(0, stmt_.maxFieldSize_);
+ }
+ }
+ break;
+ case Types.VARBINARY:
+ case Types.BINARY:
+ case Types.LONGVARBINARY:
+ data = String.valueOf(getBytes(columnIndex));
+ break;
+ case Types.TIMESTAMP:
+ Timestamp t = getTimestamp(columnIndex);
+ data = "" + t.getNanos();
+ int l = data.length();
+ data = t.toString();
+
+ if(precision > 0) {
+ for(int i=0;i<precision-l;i++)
+ data += '0';
+ } else {
+ data = data.substring(0,data.lastIndexOf('.'));
+ }
+
+ break;
+ case Types.TIME:
+ if (precision > 0)
+ data = x.toString();
+ else
+ data = String.valueOf(getTime(columnIndex));
+ break;
+ case Types.DATE:
+ data = String.valueOf(getDate(columnIndex));
+ break;
+ case Types.BOOLEAN:
+ data = String.valueOf(getBoolean(columnIndex));
+ break;
+ case Types.SMALLINT:
+ data = String.valueOf(getShort(columnIndex));
+ break;
+ case Types.TINYINT:
+ data = String.valueOf(getByte(columnIndex));
+ break;
+ case Types.REAL:
+ data = String.valueOf(getFloat(columnIndex));
+ break;
+ case Types.DOUBLE:
+ case Types.FLOAT:
+ data = String.valueOf(getDouble(columnIndex));
+ break;
+ case Types.DECIMAL:
+ case Types.NUMERIC:
+ BigDecimal bd = getBigDecimal(columnIndex);
+ if (_javaVersion >= 1.5) {
+ // as of Java 5.0 and above, BigDecimal.toPlainString() should be used.
+ try {
+ data = (String) _toPlainString.invoke(bd, (Object[]) null);
+ } catch (Exception e) {
+ data = bd.toString();
+ }
+ } else {
+ data = bd.toString();
+ }
+ break;
+ case Types.BIGINT:
+ data = String.valueOf(getLong(columnIndex));
+ break;
+ case Types.INTEGER:
+ data = String.valueOf(getInt(columnIndex));
+ break;
+ case Types.OTHER: {
+ if (x instanceof byte[]) {
+ try {
+ data = new String((byte[]) x, "ASCII");
+ } catch (Exception e) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "unsupported_encoding", "ASCII");
+ }
+ } else {
+ data = x.toString();
+ }
+ // only 2 supported today
+ // 1. SQLTYPECODE_INTERVAL
+ // 2. SQLTYPECODE_DATETIME
+ // Within DATETIME we check for only the SQL/MP specific data types
+ // in another switch-case statement
+ switch (outputDesc_[columnIndex - 1].fsDataType_) {
+ case InterfaceResultSet.SQLTYPECODE_INTERVAL: {
+ // if data does no start with a hyphen (representing a negative
+ // sign)
+ // then send back data without the byte that holds the hyphen
+ // Reason: for Interval data types first byte is holding either
+ // the
+ // a negative sign or if number is positive, it is just an extra
+ // space
+ data = Utility.trimRightZeros(data);
+ if (!data.startsWith(hyphen_string)) {
+ data = data.substring(1);
+ }
+ }
+ break;
+ case InterfaceResultSet.SQLTYPECODE_DATETIME: {
+ switch (outputDesc_[columnIndex - 1].sqlDatetimeCode_) {
+ case HPT4Desc.SQLDTCODE_YEAR:
+ case HPT4Desc.SQLDTCODE_YEAR_TO_MONTH:
+ case HPT4Desc.SQLDTCODE_MONTH:
+ case HPT4Desc.SQLDTCODE_MONTH_TO_DAY:
+ case HPT4Desc.SQLDTCODE_DAY:
+ case HPT4Desc.SQLDTCODE_HOUR:
+ case HPT4Desc.SQLDTCODE_HOUR_TO_MINUTE:
+ case HPT4Desc.SQLDTCODE_MINUTE:
+ case HPT4Desc.SQLDTCODE_MINUTE_TO_SECOND:
+ // case HPT4Desc.SQLDTCODE_MINUTE_TO_FRACTION:
+ case HPT4Desc.SQLDTCODE_SECOND:
+ // case HPT4Desc.SQLDTCODE_SECOND_TO_FRACTION:
+ case HPT4Desc.SQLDTCODE_YEAR_TO_HOUR:
+ case HPT4Desc.SQLDTCODE_YEAR_TO_MINUTE:
+ case HPT4Desc.SQLDTCODE_MONTH_TO_HOUR:
+ case HPT4Desc.SQLDTCODE_MONTH_TO_MINUTE:
+ case HPT4Desc.SQLDTCODE_MONTH_TO_SECOND:
+ // case HPT4Desc.SQLDTCODE_MONTH_TO_FRACTION:
+ case HPT4Desc.SQLDTCODE_DAY_TO_HOUR:
+ case HPT4Desc.SQLDTCODE_DAY_TO_MINUTE:
+ case HPT4Desc.SQLDTCODE_DAY_TO_SECOND:
+ // case HPT4Desc.SQLDTCODE_DAY_TO_FRACTION:
+ case HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION:
+ break;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "object_type_not_supported", null);
+ }
+ }
+ break;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "object_type_not_supported", null);
+ }
+ }
+ break;
+ case Types.ARRAY:
+ case Types.BIT:
+ case Types.REF:
+ case Types.DATALINK:
+ case Types.DISTINCT:
+ case Types.JAVA_OBJECT:
+ case Types.STRUCT:
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "object_type_not_supported", null);
+ }
+ return data;
+ }
+
+ public String getString(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getString", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getString");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getString(columnIndex);
+ }
+
+ public Time getTime(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ String data;
+ Time retValue;
+ Timestamp timestamp;
+
+ validateGetInvocation(columnIndex);
+ dataType = outputDesc_[columnIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ switch (dataType) {
+ case Types.TIMESTAMP:
+ try {
+ timestamp = Timestamp.valueOf(data);
+ retValue = new Time(timestamp.getTime());
+ } catch (IllegalArgumentException e) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ break;
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BLOB:
+ case Types.CLOB:
+ data = data.trim(); // Fall Thru
+ case Types.TIME:
+ try {
+ retValue = Time.valueOf(data);
+ } catch (IllegalArgumentException e) {
+ try {
+ timestamp = Timestamp.valueOf(data);
+ retValue = new Time(timestamp.getTime());
+ } catch (IllegalArgumentException ex) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ }
+ break;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "restricted_data_type", null);
+ }
+ return retValue;
+ } else {
+ return null;
+ }
+ }
+
+ public Time getTime(int columnIndex, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Time sqlTime;
+ java.util.Date d;
+
+ sqlTime = getTime(columnIndex);
+ if (sqlTime != null) {
+ if (cal != null) {
+ cal.setTime(sqlTime);
+ d = cal.getTime();
+ sqlTime = new Time(d.getTime());
+ }
+ return sqlTime;
+ } else {
+ return (sqlTime);
+ }
+ }
+
+ public Time getTime(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getTime(columnIndex);
+ }
+
+ public Time getTime(String columnName, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getTime(columnIndex, cal);
+ }
+
+ public Timestamp getTimestamp(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ String data;
+ Timestamp retValue;
+ Date dateValue;
+ Time timeValue;
+
+ validateGetInvocation(columnIndex);
+ dataType = outputDesc_[columnIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.DATE && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ switch (dataType) {
+ case Types.DATE:
+ try {
+ dateValue = Date.valueOf(data);
+ retValue = new Timestamp(dateValue.getTime());
+ } catch (IllegalArgumentException e) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ break;
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BLOB:
+ case Types.CLOB:
+ data = data.trim();
+ case Types.TIMESTAMP:
+ case Types.TIME:
+ try {
+ retValue = Timestamp.valueOf(data);
+ } catch (IllegalArgumentException e) {
+ try {
+ dateValue = Date.valueOf(data);
+ retValue = new Timestamp(dateValue.getTime());
+ } catch (IllegalArgumentException e1) {
+ try {
+ int nano = 0;
+ if (outputDesc_[columnIndex - 1].sqlPrecision_ > 0) {
+ nano = Integer.parseInt(data.substring(data.indexOf(".") + 1));
+ nano *= Math.pow(10, 9 - outputDesc_[columnIndex - 1].sqlPrecision_);
+ data = data.substring(0, data.indexOf("."));
+ }
+
+ timeValue = Time.valueOf(data);
+ retValue = new Timestamp(timeValue.getTime());
+ retValue.setNanos(nano);
+ } catch (IllegalArgumentException e2) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+
+ }
+ }
+ break;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "restricted_data_type", null);
+ }
+ return retValue;
+ } else {
+ return null;
+ }
+ }
+
+ public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Timestamp sqlTimestamp;
+ java.util.Date d;
+ int nanos;
+
+ sqlTimestamp = getTimestamp(columnIndex);
+ if (sqlTimestamp != null) {
+ if (cal != null) {
+ nanos = sqlTimestamp.getNanos();
+ cal.setTime(sqlTimestamp);
+ d = cal.getTime();
+ sqlTimestamp = new Timestamp(d.getTime());
+ sqlTimestamp.setNanos(nanos);
+ }
+ return sqlTimestamp;
+ } else {
+ return (sqlTimestamp);
+ }
+ }
+
+ public Timestamp getTimestamp(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getTimestamp(columnIndex);
+ }
+
+ public Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getTimestamp(columnIndex, cal);
+ }
+
+ public int getType() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE)
<TRUNCATED>
[07/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Statement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Statement.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Statement.java
deleted file mode 100644
index c32f3b9..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Statement.java
+++ /dev/null
@@ -1,204 +0,0 @@
-// @@@ 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/jdbc_type4/src/org/trafodion/jdbc/t4/T4TimerThread.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4TimerThread.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4TimerThread.java
deleted file mode 100644
index 7e81a12..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4TimerThread.java
+++ /dev/null
@@ -1,116 +0,0 @@
-// @@@ 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/jdbc_type4/src/org/trafodion/jdbc/t4/T4_Dcs_Cancel.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4_Dcs_Cancel.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4_Dcs_Cancel.java
deleted file mode 100644
index 7357535..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4_Dcs_Cancel.java
+++ /dev/null
@@ -1,115 +0,0 @@
-// @@@ 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/jdbc_type4/src/org/trafodion/jdbc/t4/T4_Dcs_Connect.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4_Dcs_Connect.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4_Dcs_Connect.java
deleted file mode 100644
index af94348..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4_Dcs_Connect.java
+++ /dev/null
@@ -1,123 +0,0 @@
-// @@@ 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/jdbc_type4/src/org/trafodion/jdbc/t4/TRANSPORT.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TRANSPORT.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TRANSPORT.java
deleted file mode 100644
index 296794b..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TRANSPORT.java
+++ /dev/null
@@ -1,263 +0,0 @@
-// @@@ 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/jdbc_type4/src/org/trafodion/jdbc/t4/TerminateDialogueMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TerminateDialogueMessage.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TerminateDialogueMessage.java
deleted file mode 100644
index 7db65fa..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TerminateDialogueMessage.java
+++ /dev/null
@@ -1,38 +0,0 @@
-// @@@ 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/jdbc_type4/src/org/trafodion/jdbc/t4/TerminateDialogueReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TerminateDialogueReply.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TerminateDialogueReply.java
deleted file mode 100644
index 8c194a3..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TerminateDialogueReply.java
+++ /dev/null
@@ -1,39 +0,0 @@
-// @@@ 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);
- }
-}
[56/60] incubator-trafodion git commit: Included LICENSE and NOTICE
in T4 zip file
Posted by db...@apache.org.
Included LICENSE and NOTICE in T4 zip file
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/780f976a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/780f976a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/780f976a
Branch: refs/heads/master
Commit: 780f976a6b3412f9f0bc8bb946fe25adf400dde3
Parents: b508299
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Fri Apr 29 16:04:34 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Fri Apr 29 16:04:34 2016 +0000
----------------------------------------------------------------------
core/conn/jdbcT4/.gitignore | 4 +++-
core/conn/jdbcT4/Makefile | 12 ++++++++++--
2 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/780f976a/core/conn/jdbcT4/.gitignore
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/.gitignore b/core/conn/jdbcT4/.gitignore
index 6d90c7e..90bf5f8 100644
--- a/core/conn/jdbcT4/.gitignore
+++ b/core/conn/jdbcT4/.gitignore
@@ -1,2 +1,4 @@
/target/
-build_jdbct4.log
+*.log
+/LICENSE
+/NOTICE
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/780f976a/core/conn/jdbcT4/Makefile
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/Makefile b/core/conn/jdbcT4/Makefile
index a53e50c..828416c 100644
--- a/core/conn/jdbcT4/Makefile
+++ b/core/conn/jdbcT4/Makefile
@@ -25,14 +25,22 @@ include ../../macros.gmk #top level
all: build_all
-build_all:
+build_all: LICENSE NOTICE
echo "$(MAVEN) package -DskipTests"
set -o pipefail && $(MAVEN) package -DskipTests | tee build_jdbct4.log | grep --line-buffered -E -e '^\[[^WId]' -e '^\[INFO\] B[Uu][Ii][Ll][Dd]' -e 'to compile'
cp target/jdbcT4-${TRAFODION_VER}.jar ${MY_SQROOT}/export/lib
mkdir -p ../clients
mv target/jdbcT4-${TRAFODION_VER}.zip ../clients
-
clean:
-$(MAVEN) clean | grep ERROR
$(RM) build_jdbct4.log ${MY_SQROOT}/export/lib/jdbcT4*.jar
+
+LICENSE: ../../../licenses/LICENSE-clients
+ cp -f $? $@
+
+../../../licenses/LICENSE-clients:
+ cd $(@D) && $(MAKE) $(@F)
+
+NOTICE: ../../../NOTICE
+ cp -f $? $@
[09/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Driver.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Driver.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Driver.java
deleted file mode 100644
index a1724aa..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Driver.java
+++ /dev/null
@@ -1,367 +0,0 @@
-// @@@ 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.DriverManager;
-import java.sql.DriverPropertyInfo;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-/**
- * <p>
- * JDBC Type 4 Driver implementation.
- * </p>
- * <p>
- * Description: <code>T4Driver</code> is an implementation of the
- * <code>java.sql.Driver</code> interface. The Java SQL framework allows for
- * multiple database drivers to be loaded in single java program. The
- * <code>T4Driver</code> can be loaded programatically by
- * <code>Class.forName("org.trafodion.jdbc.t4.T4Driver") </code> or by passing
- * <code>-Djdbc.drivers=org.trafodion.jdbc.t4.T4Driver</code> in the command line of
- * the Java program.
- * </p>
- * <p>
- * Licensed to the Apache Software Foundation (ASF)
- * </p>
- *
- * @see java.sql.DriverManager
- * @see java.sql.Connection
- */
-public class T4Driver extends T4Properties implements java.sql.Driver {
- /**
- * Retrieves whether the Type 4 driver determined that it can open a
- * connection to the given URL. Typically drivers return true if they
- * recognize the subprotocol specified in the URL and false if they do not.
- * For Type 4 driver to recognize the protocol, the URL must start with
- * <code>jdbc:t4jdbc</code>.
- *
- * @param url
- * The URL of the database.
- * @return true if the Type 4 driver recognizes the given URL; otherwise,
- * false.
- */
- public boolean acceptsURL(String url) throws SQLException {
- if (t4GlobalLogger.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null,filterOutPWD(url));
- t4GlobalLogger.logp(Level.FINE, "T4Driver", "acceptsURL", "", p);
- }
- if (getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null, filterOutPWD(url));
- lr.setParameters(p);
- lr.setSourceClassName("T4Driver");
- lr.setSourceMethodName("acceptsURL");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- getLogWriter().println(temp);
- }
-
- return T4Address.acceptsURL(url);
- }
-
- /**
- * Attempts to make an NDCS connection to the given URL. The Type 4 driver
- * returns "null" when it determines that the driver is the wrong kind of
- * driver to connect to the given URL. This occurence is common; for
- * example, when the JDBC driver manager is requested to connect to a given
- * URL, the driver manager it passes the URL to each loaded driver in turn.
- * The Type 4 driver throws an SQLException when it has trouble connecting
- * to NDCS. You can use the <code>java.util.Properties</code> argument to
- * pass arbitrary string name-value pairs as connection arguments.
- * Typically, you should include "user" and "password" properties in the
- * Properties object.
- *
- * @param url
- * The URL string of format
- * <code>jdbc:t4jdbc://host:port/:</code>
- * @param info
- * <code>java.util.Properties</code> object containing
- * name-value pair.
- * @return The <code>TrafT4Connection</code> object.
- * @throws SQLException
- * When an error occurs connecting to NDCS.
- * @see T4Properties
- */
- public java.sql.Connection connect(String url, Properties info) throws SQLException {
- Properties tempinfo = null;
- if (t4GlobalLogger.isLoggable(Level.FINE) == true) {
- tempinfo = new Properties();
- tempinfo.putAll(info);
- tempinfo.remove("password");
- Object p[] = T4LoggingUtilities.makeParams(null, filterOutPWD(url), tempinfo);
- t4GlobalLogger.logp(Level.FINE, "T4Driver", "connect", "", p);
- }
- if (getLogWriter() != null) {
- if (tempinfo == null) {
- tempinfo = new Properties();
- tempinfo.putAll(info);
- tempinfo.remove("password");
- }
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null, filterOutPWD(url), tempinfo);
- lr.setParameters(p);
- lr.setSourceClassName("T4Driver");
- lr.setSourceMethodName("connect");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- getLogWriter().println(temp);
- }
-
- if (logger.isLoggable(Level.INFO)) {
- logger.entering("HPT4DataSource", "getConnection");
- }
-
- String key = null;
- HPT4DataSource ds = null;
-
- if (acceptsURL(url)) {
- synchronized(this) {
- // properties in the info take precedence.
- // Note, setURL also assigns the T4Properties that are on the URL
- Properties urlProps = setURL(url);
-
- //
- // Merge any property that is in the url but not in info.
- //
- if (urlProps != null && info != null) {
- Enumeration en1 = urlProps.propertyNames();
- String key1 = null;
-
- while (en1 != null && en1.hasMoreElements() == true) {
- key1 = (String) en1.nextElement();
- if (info.getProperty(key1) == null) {
- info.setProperty(key1, urlProps.getProperty(key1));
- }
- }
- }
-
- // If info is false, but there were properties on the URL,
- // the URL properties were already set when we called setURL.
- if (info != null) {
- initialize(info);
- if (getSQLException() != null) {
- throw HPT4Messages.createSQLException(null, getLocale(), "invalid_property", getSQLException());
- }
- }
- if (getMaxPoolSize() != -1) {
- key = getUrl() + getCatalog() + getSchema() + getUser() + getPassword() + getServerDataSource()
- + getBlobTableName() + getClobTableName();
-
- ds = (HPT4DataSource) dsCache_.get(key);
-
- if (ds == null) {
- ds = new HPT4DataSource(getProperties());
- dsCache_.put(key, ds);
- }
- } else {
- ds = new HPT4DataSource(getProperties());
- }
- }
-
- return ds.getConnection(ds.getUser(), ds.getPassword());
- } else {
- return null;
- }
- }
-
- private String filterOutPWD(String url) {
- return url.replaceAll("password\\s*\\=\\s*[^;]*", "");
- }
-
- /**
- * Retrieves the driver's major JDBC version number. For the Type 4 Driver,
- * the number should be 3.
- *
- * @return 3.
- */
- public int getMajorVersion() {
- if (t4GlobalLogger.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null);
- t4GlobalLogger.logp(Level.FINE, "T4Driver", "getMajorVersion", "", p);
- }
- try {
- if (getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null);
- lr.setParameters(p);
- lr.setSourceClassName("T4Driver");
- lr.setSourceMethodName("getMajorVersion");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- getLogWriter().println(temp);
- }
- } catch (SQLException se) {
- // ignore
- }
-
- return 3;
- }
-
- /**
- * Gets the Type 4 driver's minor version number. For the Type 4 driver, the
- * number should be 11.
- *
- * @return 11
- */
- public int getMinorVersion() {
- if (t4GlobalLogger.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null);
- t4GlobalLogger.logp(Level.FINE, "T4Driver", "getMinorVersion", "", p);
- }
- try {
- if (getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null);
- lr.setParameters(p);
- lr.setSourceClassName("T4Driver");
- lr.setSourceMethodName("getMinorVersion");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- getLogWriter().println(temp);
- }
- } catch (SQLException se) {
- // ignore
- }
-
- return 11;
- }
-
- /**
- * Gets information about the possible properties for the Type 4 driver. The
- * <code>getPropertyInfo</code> method is intended to allow a generic GUI
- * tool to determine the properties that the tool should prompt from a human
- * to get enough information to connect to NDCS. Depending on the values the
- * human has supplied so far, additional values might be necessary, so you
- * might need to iterate though several calls to the
- * <code>getPropertyInfo</code> method.
- *
- * @param url
- * The URL of the database to which to connect
- * @param info
- * <code>java.util.Properties</code> object containing
- * name-value pairs. The Type 4 driver ignores the Properties
- * parameter passed to the driver.
- * @return array of <code>DriverPropertyInfo</code> containing property
- * details.
- */
-
- public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
- Properties tempinfo = null;
- if (t4GlobalLogger.isLoggable(Level.FINE) == true) {
- tempinfo = new Properties();
- tempinfo.putAll(info);
- tempinfo.remove("password");
- Object p[] = T4LoggingUtilities.makeParams(null, filterOutPWD(url), tempinfo);
- t4GlobalLogger.logp(Level.FINE, "T4Driver", "getPropertyInfo", "", p);
- }
- if (getLogWriter() != null) {
- if(tempinfo == null){
- tempinfo = new Properties();
- tempinfo.putAll(info);
- tempinfo.remove("password");
- }
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null, filterOutPWD(url), tempinfo);
- lr.setParameters(p);
- lr.setSourceClassName("T4Driver");
- lr.setSourceMethodName("getPropertyInfo");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- getLogWriter().println(temp);
- }
- if (acceptsURL(url)) {
- return super.getPropertyInfo(url, info);
- } else {
- return null;
- }
- }
-
- /**
- * Returns whether the Type 4 driver is JDBC compliant.
- *
- * @return true
- */
- public boolean jdbcCompliant() {
- if (t4GlobalLogger.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null);
- t4GlobalLogger.logp(Level.FINE, "T4Driver", "jdbcCompliant", "", p);
- }
- try {
- if (getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null);
- lr.setParameters(p);
- lr.setSourceClassName("T4Driver");
- lr.setSourceMethodName("jdbcCompliant");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- getLogWriter().println(temp);
- }
- } catch (SQLException se) {
- // ignore
- }
-
- return true;
- };
-
- // Fields
- private static T4Driver singleton_;
- static Hashtable dsCache_;
-
- /**
- * Instantiated by either <code>
- * Class.forName("org.trafodion.jdbc.t4.T4Driver")</code>
- * or by passing <code>-Djdbc.drivers=org.trafodion.jdbc.t4.T4Driver</code>
- * property in the command line of the JDBC program.
- */
- public T4Driver() {
- super();
- if (logger.isLoggable(Level.INFO)) {
- logger.entering("HPT4DataSource", "getConnection");
- }
- }
-
- // initializer to register the Driver with the Driver manager
- static {
- // Register the Driver with the Driver Manager
- try {
- singleton_ = new T4Driver();
- DriverManager.registerDriver(singleton_);
- } catch (SQLException e) {
- singleton_ = null;
- e.printStackTrace();
- }
-
- dsCache_ = new Hashtable();
- }
-
- public Logger getParentLogger() throws SQLFeatureNotSupportedException {
- // TODO Auto-generated method stub
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4LogFormatter.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4LogFormatter.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4LogFormatter.java
deleted file mode 100644
index b61b207..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4LogFormatter.java
+++ /dev/null
@@ -1,236 +0,0 @@
-// @@@ 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.text.DateFormat;
-import java.text.DecimalFormat;
-import java.util.logging.LogRecord;
-
-public class T4LogFormatter extends java.util.logging.Formatter {
-
- static DecimalFormat df = new DecimalFormat("########################################################00000000");
-
- // ----------------------------------------------------------
- public T4LogFormatter() {
- }
-
- // ----------------------------------------------------------
- public String format(LogRecord lr) {
- String m1;
- String separator = " ~ ";
- Object params[] = lr.getParameters();
- Object tempParam = null;
-
- try {
- long sequence_number = lr.getSequenceNumber();
- String time_stamp = null;
- long thread_id = lr.getThreadID();
- String connection_id = "";
- String server_id = "";
- String dialogue_id = "";
- String class_name = lr.getSourceClassName();
- String method = lr.getSourceMethodName();
- String parameters = ""; // need to fix
- String message = lr.getMessage();
-
- long time_mills = lr.getMillis();
- java.util.Date d1 = new java.util.Date(time_mills);
- DateFormat df1 = java.text.DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.FULL);
-
- time_stamp = df1.format(d1);
-
- //
- // By convension, the first parameter is a TrafT4Connection object or
- // a T4Properties object
- //
- TrafT4Connection sc = null;
- T4Properties tp = null;
-
- if (params != null && params.length > 0) {
- if (params[0] instanceof TrafT4Connection)
- tp = ((TrafT4Connection) params[0]).props_;
- else
- tp = (T4Properties) params[0];
- }
-
- if (tp != null) {
- connection_id = tp.getConnectionID();
- server_id = tp.getServerID();
- dialogue_id = tp.getDialogueID();
- }
-
- //
- // Format for message:
- //
- // sequence-number ~ time-stamp ~ thread-id ~ [connection-id] ~
- // [server-id]
- // ~ [dialogue-id] ~ [class] ~ [method] ~ [parameters] ~ [text]
- //
-
- Long l1 = new Long(sequence_number);
- String t1 = df.format(l1);
- String p1 = "";
-
- m1 = t1 + separator + time_stamp + separator + thread_id + separator + connection_id + separator
- + server_id + separator + dialogue_id + separator + class_name + "." + method + "(";
-
- if (params != null) {
- String paramText = null;
-
- //
- // Skip the first parameter, which is a T4Connection, and is
- // handled above.
- //
- for (int i = 1; i < params.length; i++) {
- tempParam = params[i];
- if (tempParam != null) {
- //
- // If the parameter is an array, try to print each
- // element of the array.
- //
- tempParam = makeObjectArray(tempParam);
-
- if (tempParam instanceof Object[]) {
- Object[] tempOa = (Object[]) tempParam;
- String tempOas = "";
- String tempStr2 = null;
-
- for (int j = 0; j < tempOa.length; j++) {
- if (tempOa[j] != null) {
- tempStr2 = tempOa[j].toString();
- } else {
- tempStr2 = "null";
- }
- tempOas = tempOas + " [" + j + "]" + tempStr2;
- }
- paramText = tempOas;
- } else {
- paramText = tempParam.toString();
- }
- } else {
- paramText = "null";
-
- }
- p1 = p1 + "\"" + paramText + "\"";
- if (i + 1 < params.length) {
- p1 = p1 + ", ";
- }
- }
- }
-
- m1 = m1 + p1 + ")" + separator + message + "\n";
-
- } catch (Exception e) {
- //
- // Tracing should never cause an internal error, but if it does, we
- // do want to
- // capture it here. An internal error here has no effect on the user
- // program,
- // so we don't want to throw an exception. We'll put the error in
- // the trace log
- // instead, and instruct the user to report it
- //
- m1 = "An internal error has occurred in the tracing logic. Please report this to your representative. \n"
- + " exception = "
- + e.toString()
- + "\n"
- + " message = "
- + e.getMessage()
- + "\n"
- + " Stack trace = \n";
-
- StackTraceElement st[] = e.getStackTrace();
-
- for (int i = 0; i < st.length; i++) {
- m1 = m1 + " " + st[i].toString() + "\n";
- }
- m1 = m1 + "\n";
- } // end catch
-
- //
- // The params array is reused, so we must null it out before returning.
- //
- if (params != null) {
- for (int i = 0; i < params.length; i++) {
- params[i] = null;
- }
- }
-
- return m1;
-
- } // end formatMessage
-
- // ---------------------------------------------------------------------
- Object makeObjectArray(Object obj) {
- Object retVal = obj;
- Object[] newVal = null;
- int i;
-
- if (obj instanceof boolean[]) {
- boolean[] temp = (boolean[]) obj;
- newVal = new Boolean[temp.length];
- for (i = 0; i < temp.length; i++)
- newVal[i] = new Boolean(temp[i]);
- } else if (obj instanceof char[]) {
- char[] temp = (char[]) obj;
- newVal = new Character[temp.length];
- for (i = 0; i < temp.length; i++)
- newVal[i] = new Character(temp[i]);
- } else if (obj instanceof byte[]) {
- byte[] temp = (byte[]) obj;
- newVal = new Byte[temp.length];
- for (i = 0; i < temp.length; i++)
- newVal[i] = new Byte(temp[i]);
- } else if (obj instanceof short[]) {
- short[] temp = (short[]) obj;
- newVal = new Short[temp.length];
- for (i = 0; i < temp.length; i++)
- newVal[i] = new Short(temp[i]);
- } else if (obj instanceof int[]) {
- int[] temp = (int[]) obj;
- newVal = new Integer[temp.length];
- for (i = 0; i < temp.length; i++)
- newVal[i] = new Integer(temp[i]);
- } else if (obj instanceof long[]) {
- long[] temp = (long[]) obj;
- newVal = new Long[temp.length];
- for (i = 0; i < temp.length; i++)
- newVal[i] = new Long(temp[i]);
- } else if (obj instanceof float[]) {
- float[] temp = (float[]) obj;
- newVal = new Float[temp.length];
- for (i = 0; i < temp.length; i++)
- newVal[i] = new Float(temp[i]);
- } else if (obj instanceof double[]) {
- double[] temp = (double[]) obj;
- newVal = new Double[temp.length];
- for (i = 0; i < temp.length; i++)
- newVal[i] = new Double(temp[i]);
- }
-
- if (newVal != null)
- retVal = newVal;
-
- return retVal;
- } // end makeObjectArray
-
-} // end class T4LogFormatter
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4LoggingUtilities.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4LoggingUtilities.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4LoggingUtilities.java
deleted file mode 100644
index e29da5e..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4LoggingUtilities.java
+++ /dev/null
@@ -1,816 +0,0 @@
-// @@@ 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;
-
-public class T4LoggingUtilities {
-
- static final Long m_syncL = new Long(1L);
-
- // ----------------------------------------------------------
- public T4LoggingUtilities() {
- }
-
- // ----------------------------------------------------------
- static String getUniqueID() {
- synchronized (m_syncL) {
- try {
- Thread.sleep(m_syncL.longValue()); // wait 1 millisecond
- } catch (Exception e) {
- }
- }
-
- java.util.Date d1 = new java.util.Date();
- long t1 = d1.getTime();
- String name = null;
-
- name = Long.toString(t1);
- return name;
- }
-
- // ----------------------------------------------------------
- static String getUniqueLogFileName(String uniqueID) {
- String name = null;
-
- name = "%h/t4jdbc" + uniqueID + ".log";
- return name;
- }
-
- // ----------------------------------------------------------
- static String getUniqueLoggerName(String uniqueID) {
- String name = null;
-
- name = "org.trafodion.jdbc.t4.logger" + uniqueID;
- return name;
- }
-
- // ----------------------------------------------------------
- static Object[] makeParams() {
- return null;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props) {
- Object obj[] = new Object[1];
-
- obj[0] = t4props;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, boolean b1) {
- Object obj[] = new Object[2];
-
- obj[0] = t4props;
- obj[1] = Boolean.toString(b1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, int i1) {
- Object obj[] = new Object[2];
-
- obj[0] = t4props;
- obj[1] = Integer.toString(i1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1) {
- Object obj[] = new Object[2];
-
- obj[0] = t4props;
- obj[1] = obj1;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, long l1) {
- Object obj[] = new Object[2];
-
- obj[0] = t4props;
- obj[1] = Long.toString(l1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, int i1, int i2) {
- Object obj[] = new Object[3];
-
- obj[0] = t4props;
- obj[1] = Integer.toString(i1);
- obj[2] = Integer.toString(i2);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, int i1) {
- Object obj[] = new Object[3];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = Integer.toString(i1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2) {
- Object obj[] = new Object[3];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = obj2;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, int i1, Object obj1) {
- Object obj[] = new Object[3];
-
- obj[0] = t4props;
- obj[1] = Integer.toString(i1);
- obj[2] = obj1;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, int i1, boolean b1) {
- Object obj[] = new Object[3];
-
- obj[0] = t4props;
- obj[1] = Integer.toString(i1);
- obj[2] = Boolean.toString(b1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, int i1, double d1) {
- Object obj[] = new Object[3];
-
- obj[0] = t4props;
- obj[1] = Integer.toString(i1);
- obj[2] = Double.toString(d1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, boolean b1, boolean b2) {
- Object obj[] = new Object[3];
-
- obj[0] = t4props;
- obj[1] = Boolean.toString(b1);
- obj[2] = Boolean.toString(b2);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, boolean b1) {
- Object obj[] = new Object[3];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = Boolean.toString(b1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, short s1) {
- Object obj[] = new Object[3];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = Short.toString(s1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, double d1) {
- Object obj[] = new Object[3];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = Double.toString(d1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, long l1, int i1) {
- Object obj[] = new Object[3];
-
- obj[0] = t4props;
- obj[1] = Long.toString(l1);
- obj[2] = Integer.toString(i1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, long l1, Object o1) {
- Object obj[] = new Object[3];
-
- obj[0] = t4props;
- obj[1] = Long.toString(l1);
- obj[2] = o1;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, long l1) {
- Object obj[] = new Object[3];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = Long.toString(l1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, int i1, int i2) {
- Object obj[] = new Object[4];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = Integer.toString(i1);
- obj[3] = Integer.toString(i2);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, int i1, Object obj1, int i2) {
- Object obj[] = new Object[4];
-
- obj[0] = t4props;
- obj[1] = Integer.toString(i1);
- obj[2] = obj1;
- obj[3] = Integer.toString(i2);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, int i1, Object obj1, Object obj2) {
- Object obj[] = new Object[4];
-
- obj[0] = t4props;
- obj[1] = Integer.toString(i1);
- obj[2] = obj1;
- obj[3] = obj2;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, int i1, int i2, Object obj1) {
- Object obj[] = new Object[4];
-
- obj[0] = t4props;
- obj[1] = Integer.toString(i1);
- obj[2] = Integer.toString(i2);
- obj[3] = obj1;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, int i1, int i2, int i3) {
- Object obj[] = new Object[4];
-
- obj[0] = t4props;
- obj[1] = Integer.toString(i1);
- obj[2] = Integer.toString(i2);
- obj[3] = Integer.toString(i3);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, Object o2, Object o3) {
- Object obj[] = new Object[4];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = o2;
- obj[3] = o3;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, int i1, Object o2) {
- Object obj[] = new Object[4];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = Integer.toString(i1);
- obj[3] = o2;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, Object o2, int i1) {
- Object obj[] = new Object[4];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = o2;
- obj[3] = Integer.toString(i1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object[] oa1, int i1, Object o1) {
- Object obj[] = new Object[4];
-
- obj[0] = t4props;
- obj[1] = oa1;
- obj[2] = Integer.toString(i1);
- obj[3] = o1;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, Object o2, long l1) {
- Object obj[] = new Object[4];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = o2;
- obj[3] = Long.toString(l1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, long l1, Object o2) {
- Object obj[] = new Object[4];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = Long.toString(l1);
- obj[3] = o2;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, boolean b1, Object o2) {
- Object obj[] = new Object[4];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = Boolean.toString(b1);
- obj[3] = o2;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, int i1, Object obj1, int i2, int i3) {
- Object obj[] = new Object[5];
-
- obj[0] = t4props;
- obj[1] = Integer.toString(i1);
- obj[2] = obj1;
- obj[3] = Integer.toString(i2);
- obj[4] = Integer.toString(i3);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, int i1, int i2) {
- Object obj[] = new Object[5];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = obj2;
- obj[3] = Integer.toString(i1);
- obj[4] = Integer.toString(i2);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, int i1, int i2, int i3) {
- Object obj[] = new Object[5];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = Integer.toString(i1);
- obj[3] = Integer.toString(i2);
- obj[4] = Integer.toString(i3);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, int i1, long l1, Object obj2) {
- Object obj[] = new Object[5];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = Integer.toString(i1);
- obj[3] = Long.toString(l1);
- obj[4] = obj1;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, Object obj3, int i1) {
- Object obj[] = new Object[5];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = obj2;
- obj[3] = obj3;
- obj[4] = Integer.toString(i1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, int i1, Object[] oa1, int i2, Object o1) {
- Object obj[] = new Object[5];
-
- obj[0] = t4props;
- obj[1] = Integer.toString(i1);
- obj[2] = oa1;
- obj[3] = Integer.toString(i2);
- obj[4] = o1;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, Object o2, Object o3, Object o4) {
- Object obj[] = new Object[5];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = o2;
- obj[3] = o3;
- obj[4] = o4;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, int i1, boolean b1, int i2) {
- Object obj[] = new Object[5];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = Integer.toString(i1);
- obj[3] = Boolean.toString(b1);
- obj[4] = Integer.toString(i2);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, Object o2, int i1, Object o3) {
- Object obj[] = new Object[5];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = o2;
- obj[3] = Integer.toString(i1);
- obj[4] = o3;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, long l1, Object o1, int i1, int i2) {
- Object obj[] = new Object[5];
-
- obj[0] = t4props;
- obj[1] = Long.toString(l1);
- obj[2] = o1;
- obj[3] = Integer.toString(i1);
- obj[4] = Integer.toString(i2);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, Object o2, long l1, Object o3) {
- Object obj[] = new Object[5];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = o2;
- obj[3] = Long.toString(l1);
- obj[4] = o3;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, int i1, int i2, int i3) {
- Object obj[] = new Object[6];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = obj2;
- obj[3] = Integer.toString(i1);
- obj[4] = Integer.toString(i2);
- obj[5] = Integer.toString(i3);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, Object obj3, int i1, int i2) {
- Object obj[] = new Object[6];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = obj2;
- obj[3] = obj3;
- obj[4] = Integer.toString(i1);
- obj[5] = Integer.toString(i2);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, boolean b1, Object obj3, Object obj4) {
- Object obj[] = new Object[6];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = obj2;
- obj[3] = Boolean.toString(b1);
- obj[4] = obj3;
- obj[5] = obj4;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, int i1, boolean b1, int i2) {
- Object obj[] = new Object[6];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = obj2;
- obj[3] = Integer.toString(i1);
- obj[4] = Boolean.toString(b1);
- obj[5] = Integer.toString(i2);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, int i1, int i2, Object[] oa1, int i3, Object o1) {
- Object obj[] = new Object[6];
-
- obj[0] = t4props;
- obj[1] = Integer.toString(i1);
- obj[2] = Integer.toString(i2);
- obj[3] = oa1;
- obj[4] = Integer.toString(i3);
- obj[5] = o1;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, int i1, long l1, Object obj3) {
- Object obj[] = new Object[6];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = obj2;
- obj[3] = Integer.toString(i1);
- obj[4] = Long.toString(l1);
- obj[5] = obj3;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, Object o2, Object o3, int i1, boolean b1) {
- Object obj[] = new Object[6];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = o2;
- obj[3] = o3;
- ;
- obj[4] = Integer.toString(i1);
- obj[5] = Boolean.toString(b1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, Object o2, Object o3, boolean b1, boolean b2) {
- Object obj[] = new Object[6];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = o2;
- obj[3] = o3;
- ;
- obj[4] = Boolean.toString(b1);
- obj[5] = Boolean.toString(b2);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, int i1, int i2, Object o1, int i3, boolean b1) {
- Object obj[] = new Object[6];
-
- obj[0] = t4props;
- obj[1] = Integer.toString(i1);
- obj[2] = Integer.toString(i2);
- obj[3] = o1;
- obj[4] = Integer.toString(i3);
- obj[5] = Boolean.toString(b1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, Object o2, long l1, Object o3, int i1) {
- Object obj[] = new Object[6];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = o2;
- obj[3] = Long.toString(l1);
- obj[4] = o3;
- obj[5] = Integer.toString(i1);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, int i1, long l1, Object obj2, int i2, int i3) {
- Object obj[] = new Object[7];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = Integer.toString(i1);
- obj[3] = Long.toString(l1);
- obj[4] = obj2;
- obj[5] = Integer.toString(i2);
- obj[6] = Integer.toString(i3);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, Object o2, Object o3, Object o4, Object o5, Object o6) {
- Object obj[] = new Object[7];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = o2;
- obj[3] = o3;
- obj[4] = o4;
- obj[5] = o5;
- obj[6] = o6;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, int i1, long l1, Object obj3,
- boolean b1, int i2) {
- Object obj[] = new Object[8];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = obj2;
- obj[3] = Integer.toString(i1);
- obj[4] = Long.toString(l1);
- obj[5] = obj3;
- obj[6] = Boolean.toString(b1);
- obj[7] = Integer.toString(i2);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, Object obj3, boolean b1, int i1, int i2,
- Object obj4, int i3) {
- Object obj[] = new Object[9];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = obj2;
- obj[3] = obj3;
- obj[4] = Boolean.toString(b1);
- obj[5] = Integer.toString(i1);
- obj[6] = Integer.toString(i2);
- obj[7] = obj4;
- obj[8] = Integer.toString(i3);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, int i1, int i2, int i3, int i4, int i5,
- int i6)
-
- {
- Object obj[] = new Object[9];
-
- obj[0] = t4props;
- obj[1] = obj1;
- obj[2] = obj2;
- obj[3] = Integer.toString(i1);
- obj[4] = Integer.toString(i2);
- obj[5] = Integer.toString(i3);
- obj[6] = Integer.toString(i4);
- obj[7] = Integer.toString(i5);
- obj[8] = Integer.toString(i6);
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, short s1, Object o2, Object o3, Object o4, Object o5,
- Object o6, int i1, int i2, long l1, int i3, int i4, short s2, int i5, Object o7, Object o8, Object o9) {
- Object obj[] = new Object[18];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = Short.toString(s1);
- obj[3] = o2;
- obj[4] = o3;
- obj[5] = o4;
- obj[6] = o5;
- obj[7] = o6;
- obj[8] = Integer.toString(i1);
- obj[9] = Integer.toString(i2);
- obj[10] = Long.toString(l1);
- obj[11] = Integer.toString(i3);
- obj[12] = Integer.toString(i4);
- obj[13] = Short.toString(s2);
- obj[14] = Integer.toString(i5);
- obj[15] = o7;
- obj[16] = o8;
- obj[17] = o9;
-
- return obj;
- } // end makeParams
-
- // ----------------------------------------------------------
- static Object[] makeParams(T4Properties t4props, Object o1, Object o2, Object o3, boolean b1) {
- Object obj[] = new Object[5];
-
- obj[0] = t4props;
- obj[1] = o1;
- obj[2] = o2;
- obj[3] = o3;
- obj[4] = Boolean.toString(b1);
-
- return obj;
- } // end makeParams
-
-} // end class T4LogFormatter
[08/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Properties.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Properties.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Properties.java
deleted file mode 100644
index 49100b4..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Properties.java
+++ /dev/null
@@ -1,2511 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.math.BigDecimal;
-import java.sql.DriverPropertyInfo;
-import java.sql.SQLException;
-import java.util.Locale;
-import java.util.Properties;
-import java.util.logging.FileHandler;
-import java.util.logging.Formatter;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.naming.Reference;
-import javax.naming.StringRefAddr;
-
-/**
- * <p>
- * JDBC Type 4 driver connetion properties class.
- * </p>
- * <p>
- * Description: The <code>T4Properties</code> class contains all the
- * properties associated with Type 4 connection. <code>T4Properties</code> is
- * inherited directy or indirectly by the <code>T4Driver, HPT4DataSource,
- * HPT4ConnectionPooledDataSource</code>
- * classes for configuring Type 4 connection properties.
- * </p>
- * <p>
- * The properties passed to the Type 4 driver have this precedence order in
- * event of the values set through more than one option:
- * </p>
- * <blockquote>
- * <p>
- * 1. java.util.properties parameter in the
- * <code>DriverManager.getConnection</code> call or through
- * <code>DataSource.setXXX()</code> call.
- * </p>
- * <p>
- * 2. <code>java.util.properties</code> file properties set through
- * <code>-Dt4jdbc.properties</code> option.
- * </p>
- * <p>
- * 3. Command line properties using -D option. All the system properties passed
- * through the command-line option have to be prefixed with
- * <code>t4jdbc</code>, to distinguish JDBC Type 4 driver properties
- * from other system properties. For example: property <code>user</code> when
- * specified with -D has to be qualified as
- * <code>-Dt4jdbc.user=super.super</code>.
- * </p>
- * </blockquote>
- * <p>
- * Licensed to the Apache Software Foundation (ASF)
- * </p>
- */
-public class T4Properties {
- private String description_;
- private String dataSourceName_;
- private String serverDataSource_;
- private String catalog_;
- private String schema_;
- private String user_;
- private String url_;
- private String pwd_;
- private Locale locale_;
- private int maxPoolSize_;
- private int minPoolSize_;
- private int initialPoolSize_;
- private int maxStatements_;
- private int loginTimeout_;
- // private int closeConnectionTimeout_;
- private int networkTimeout_;
- private int connectionTimeout_;
- private int maxIdleTime_;
- private Level t4LogLevel;
- private String T4LogFile_;
- private Properties defaults_;
- private Properties inprops_;
- private PrintWriter logWriter_;
- // For LOB Support - SB 9/28/04
- static long reserveDataLocator_;
- private int roundMode_;
- private String language_;
-
- private short fetchBufferSize_;
-
- private String connectionID_;
- private String dialogueID_;
- private String serverID_;
- private short ncsMajorVersion_;
- private short ncsMinorVersion_;
- private short sqlmxMajorVersion_;
- private short sqlmxMinorVersion_;
-
- // LOB Support
- String clobTableName_;
- String blobTableName_;
-
- // private short transportBufferSize_;
- private boolean useArrayBinding_;
- private boolean batchRecovery_;
- private final String propPrefix_ = "t4jdbc.";
-
- // Default catalog
- static final String DEFAULT_CATALOG = "TRAFODION";
-
- // propertiy queryTimeout_ for future use.
- private short queryTimeout_;
- private T4Address t4addr_;
-
- // Error handling while setting Type 4 properties.
- String sqlExceptionMessage_;
-
- // Logger for this connection.
- Logger logger;
- Logger t4Logger_;
-
- // Log file handler for this connection.
- FileHandler t4LogFileHandler_;
-
- private boolean SPJEnv_ = false;
- private boolean keepRawFetchBuffer_ = false;
- private short cpuToUse_ = -1;
- private String sessionName;
- private String replacementString_;
- private String ISO88591_;
-
- private String _roleName;
- private String _applicationName;
- private boolean _sessionToken;
- private boolean _fetchAhead;
- private boolean _delayedErrorMode;
- private boolean _compression;
- private String _certificateDir;
- private String _certificateFileActive;
- private String _certificateFile;
- private boolean _keepAlive = false;
- private boolean _tokenAuth;
-
- private static int DEFAULT_MAX_IDLE_TIMEOUT = 0; // Max idle timeout
- // default = infinite
-
- //TCP Nagle's algorithm
- private boolean _tcpNoDelay = true;
-
- // -----------------------------------------------------------
- //
- // The following static members and static block are ment to
- // establish the one and only global t4 logger for this JVM.
- //
- static Level t4GlobalLogLevel = null;
- static String t4GlobalLogFile = null;
- static Logger t4GlobalLogger = null;
- static FileHandler t4GlobalLogFileHandler = null;
-
- void initializeLogging() {
- if (t4GlobalLogger != null) {
- return;
- }
-
- t4GlobalLogger = Logger.getLogger("org.trafodion.jdbc.t4.logger");
-
- try {
- boolean createGlobalLogFile = false;
- String userSpecifiedLogFile = null;
- Level userSpecifiedLogLevel = null;
- Properties p = getPropertiesFileValues();
-
- t4GlobalLogger.setUseParentHandlers(false);
- //
- // See if the user specified a log file and/or log level via the
- // properties file or the system properties.
- //
- if (p != null) {
- userSpecifiedLogFile = p.getProperty("T4LogFile");
- String temp = p.getProperty("T4LogLevel");
- if (temp != null) {
- userSpecifiedLogLevel = Level.parse(temp);
- }
- }
-
- if (userSpecifiedLogFile == null) {
- userSpecifiedLogFile = System.getProperty("t4jdbc.T4LogFile");
-
- }
- if (userSpecifiedLogLevel == null) {
- String temp = System.getProperty("t4jdbc.T4LogLevel");
- if (temp != null) {
- userSpecifiedLogLevel = Level.parse(temp);
- } else {
- userSpecifiedLogLevel = null;
- }
- }
-
- //
- // At this point, if the user specified a log file and/or log level,
- // we have captured
- // that information.
- //
-
- //
- // Decide if we should create a global log file now or wait until
- // someone
- // asks for it. That is, until a connection turns on logging and
- // doesn't
- // specify its own log file.
- //
- if (userSpecifiedLogFile != null || (userSpecifiedLogLevel != null && userSpecifiedLogLevel != Level.OFF)) {
- createGlobalLogFile = true;
- }
-
- //
- // Set the global log file and global log level.
- //
- if (userSpecifiedLogFile == null) {
- t4GlobalLogFile = T4LoggingUtilities.getUniqueLogFileName(T4LoggingUtilities.getUniqueID());
- } else {
- t4GlobalLogFile = userSpecifiedLogFile;
- }
- if (userSpecifiedLogLevel == null) {
- t4GlobalLogLevel = Level.OFF;
- } else {
- t4GlobalLogLevel = userSpecifiedLogLevel;
- }
- t4GlobalLogger.setLevel(t4GlobalLogLevel);
-
- //
- // If we decided to make the log file now, make the file (i.e.
- // FileHandler) and
- // it the global logger.
- //
- if (createGlobalLogFile == true) {
- t4GlobalLogFileHandler = new FileHandler(t4GlobalLogFile);
-
- t4GlobalLogger.addHandler(t4GlobalLogFileHandler);
-
- Formatter ff1 = new T4LogFormatter();
-
- t4GlobalLogFileHandler.setFormatter(ff1);
- }
- } catch (Exception e) {
- // SQLException se = HPT4Messages.createSQLException(null, null,
- // "problem_with_logging", e.getMessage());
- // sqlExceptionMessage_ = se.getMessage();
-
- SQLException se = HPT4Messages.createSQLException(null, null, "problem_with_logging", e.getMessage());
- sqlExceptionMessage_ = se.getMessage();
- // RuntimeException rte = new RuntimeException(se.getMessage(), se);
- // throw rte;
- // e.printStackTrace();
- // throw HPT4Messages.createSQLException(null, null,
- // "problem_with_logging", e.getMessage());
- }
- } // end initializeLogging
-
- // -----------------------------------------------------------------
-
- public T4Properties() {
- initializeLogging();
- initialize(null);
- }
-
- public T4Properties(Properties props) {
- initializeLogging();
- initialize(props);
- }
-
- void initialize(Properties props) {
- sqlExceptionMessage_ = null;
- inprops_ = props;
- setProperties();
- }
-
- // ---------------------------------------------------------------
- private Object getHashTableEntry(String token) {
- Object outObj = null;
-
- // if the token is present in input-props get it
- if (inprops_ != null) {
- outObj = inprops_.get((Object) token);
-
- }
- return outObj;
- } // end getHashTableEntry
-
- // ---------------------------------------------------------------
- private String getProperty(String token) {
- String ret = null;
-
- // check input props first
- if (inprops_ != null) {
- ret = inprops_.getProperty(token);
- }
- // props file next
- if (ret == null && defaults_ != null) {
- ret = defaults_.getProperty(token);
- }
- // system properties with the t4jdbc prefix
- if (ret == null) {
- ret = System.getProperty(propPrefix_ + token);
- }
-
- return ret;
- }
-
- private void setProperties() {
- defaults_ = null;
- String propsFile = getProperty("properties");
- if (propsFile != null) {
- propsFile = propsFile.trim();
- if (propsFile.length() != 0) {
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(new File(propsFile));
- defaults_ = new Properties();
- defaults_.load(fis);
- } catch (Exception ex) {
- fis = null;
- sqlExceptionMessage_ = "Error while loading " + propPrefix_ + "properties file: " + ex.getMessage();
- } finally {
- try {
- if (fis != null) {
- fis.close();
- }
- } catch (IOException ioe) {
- // ignore
- }
- }
- }
- }
-
- setDescription(getProperty("description"));
- setDataSourceName(getProperty("dataSourceName"));
- setServerDataSource(getProperty("serverDataSource"));
- setCatalog(getProperty("catalog"));
- setSchema(getProperty("schema"));
-
- // DriverManager passes property user. HPUX does not like
- // property user. System properties must be prefixed with t4jdbc.
- // For example user should be t4jdbc.user if set as system property.
- setUser(getProperty("user"));
- setPassword(getProperty("password"));
-
- // url is special. Set it from properties only when it is not already
- // set.
- if (url_ == null) {
- setUrl(getProperty("url"));
-
- }
- setMaxPoolSize(getProperty("maxPoolSize"));
- setMinPoolSize(getProperty("minPoolSize"));
- setInitialPoolSize(getProperty("initialPoolSize"));
- setMaxStatements(getProperty("maxStatements"));
- setLoginTimeout(getProperty("loginTimeout"));
- // setCloseConnectionTimeout(getProperty("closeConnectionTimeout"));
- setNetworkTimeout(getProperty("networkTimeout"));
- setT4LogLevel(getProperty("T4LogLevel"));
- setT4LogFile(getProperty("T4LogFile"));
- setLogger(getHashTableEntry("logger"));
- setT4LogFileHandler(getHashTableEntry("T4LogFileHandler"));
- setUseArrayBinding(getProperty("useArrayBinding"));
- setBatchRecovery(getProperty("batchRecovery"));
- // setTransportBufferSize(getProperty("TransportBufferSize"));
- setLanguage(getProperty("language"));
-
- setMaxIdleTime(getProperty("maxIdleTime"));
- setConnectionTimeout(getProperty("connectionTimeout"));
- setFetchBufferSize(getProperty("fetchBufferSize"));
-
- // For LOB Support - SB 9/28/04
- try {
- setClobTableName(getProperty("clobTableName"));
- } catch (SQLException se) {
- sqlExceptionMessage_ = "Error while reading the clobTableName property: " + se.getMessage();
- }
-
- try {
- setBlobTableName(getProperty("blobTableName"));
- } catch (SQLException se2) {
- sqlExceptionMessage_ = "Error while reading the blobTableName property: " + se2.getMessage();
- }
-
- setReserveDataLocator(getProperty("reserveDataLocator"));
- setQueryTimeout(getProperty("queryTimeout"));
- setRoundingMode(getProperty("roundingMode"));
- setSPJEnv(getProperty("SPJEnv"));
- setKeepRawFetchBuffer(getProperty("keepRawFetchBuffer"));
- setCpuToUse(getProperty("cpuToUse"));
- setSessionName(getProperty("sessionName"));
- setReplacementString(getProperty("replacementString"));
- setISO88591(getProperty("ISO88591"));
-
- setRoleName(getProperty("roleName"));
- setApplicationName(getProperty("applicationName"));
- setSessionToken(getProperty("sessionToken"));
- setFetchAhead(getProperty("fetchAhead"));
- setDelayedErrorMode(getProperty("delayedErrorMode"));
- setCompression(getProperty("compression"));
- setCertificateDir(getProperty("certificateDir"));
- setCertificateFileActive(getProperty("certificateFileActive"));
- setCertificateFile(getProperty("certificateFile"));
- setKeepAlive(getProperty("keepAlive"));
- setTokenAuth(getProperty("tokenAuth"));
- setTcpNoDelay(getProperty("tcpNoDelay"));
- }
-
- T4Properties getT4Properties() {
- return this;
- }
-
- /**
- * Returns all the connection properties associated with the current Type 4
- * connection object in the <code>java.util.Properties</code> object.
- *
- * @return The properties associated with the current Type 4 connection.
- */
- public Properties getProperties() {
- Properties props = new Properties();
- if (getCatalog() != null) {
- props.setProperty("catalog", catalog_);
- }
- if (getSchema() != null) {
- props.setProperty("schema", schema_);
- }
- if (url_ != null) {
- props.setProperty("url", url_);
- }
-
- props.setProperty("user", user_);
- props.setProperty("password", pwd_);
- props.setProperty("maxPoolSize", String.valueOf(maxPoolSize_));
- props.setProperty("minPoolSize", String.valueOf(minPoolSize_));
- props.setProperty("initialPoolSize", String.valueOf(initialPoolSize_));
- props.setProperty("maxStatements", String.valueOf(maxStatements_));
- props.setProperty("T4LogLevel", t4LogLevel.toString());
- props.setProperty("fetchBufferSize", String.valueOf(fetchBufferSize_));
-
- if (logger != null) {
- props.put("logger", logger);
- }
- if (t4LogFileHandler_ != null) {
- props.put("T4LogFileHandler", t4LogFileHandler_);
-
- }
- props.setProperty("T4LogFile", T4LogFile_);
- props.setProperty("loginTimeout", String.valueOf(loginTimeout_));
- // props.setProperty("closeConnectionTimeout",
- // String.valueOf(closeConnectionTimeout_));
- props.setProperty("networkTimeout", String.valueOf(networkTimeout_));
- props.setProperty("connectionTimeout", String.valueOf(connectionTimeout_));
- props.setProperty("description", description_);
- props.setProperty("dataSourceName", dataSourceName_);
- props.setProperty("serverDataSource", serverDataSource_);
- // props.setProperty("transportBufferSize",
- // String.valueOf(transportBufferSize_));
- props.setProperty("useArrayBinding", String.valueOf(useArrayBinding_));
- props.setProperty("batchRecovery", String.valueOf(batchRecovery_));
- props.setProperty("maxIdleTime", String.valueOf(maxIdleTime_));
- props.setProperty("language", language_);
-
- if (getBlobTableName() != null) {
- props.setProperty("blobTableName", blobTableName_);
- }
- if (getClobTableName() != null) {
- props.setProperty("clobTableName", clobTableName_);
-
- }
-
- // properties queryTimeout_ for future use.
- props.setProperty("queryTimeout", String.valueOf(queryTimeout_));
- props.setProperty("roundingMode", String.valueOf(roundMode_));
- props.setProperty("SPJEnv", String.valueOf(SPJEnv_));
- props.setProperty("keepRawFetchBuffer", String.valueOf(keepRawFetchBuffer_));
- props.setProperty("cpuToUse", String.valueOf(cpuToUse_));
- props.setProperty("sessionName", String.valueOf(sessionName));
- props.setProperty("replacementString", String.valueOf(replacementString_));
- props.setProperty("ISO88591", String.valueOf(ISO88591_));
-
- if (_roleName != null)
- props.setProperty("roleName", _roleName);
- if (_applicationName != null)
- props.setProperty("applicationName", _applicationName);
-
- props.setProperty("sessionToken", String.valueOf(_sessionToken));
- props.setProperty("fetchAhead", String.valueOf(_fetchAhead));
- props.setProperty("delayedErrorMode", String.valueOf(_delayedErrorMode));
- props.setProperty("compression", String.valueOf(_compression));
- if(_certificateDir != null)
- props.setProperty("certificateDir", _certificateDir);
- if(_certificateFileActive != null)
- props.setProperty("certFileActive", _certificateFileActive);
- if(_certificateFile != null)
- props.setProperty("certificateFile", _certificateFile);
- props.setProperty("keepAlive", String.valueOf(_keepAlive));
- props.setProperty("tokenAuth", String.valueOf(_tokenAuth));
- props.setProperty("tcpNoDelay", String.valueOf(_tcpNoDelay));
-
- return props;
- }
-
- /**
- * Sets the description for the current Type 4 connection.
- *
- * @param description
- * For the current Type 4 connection.
- * @see #getDescription()
- */
- void setDescription(String description) {
- if (description == null) {
- description_ = "JDBC T4 DataSource.";
- } else {
- description_ = description;
- }
- }
-
- /**
- * Returns the description associated with the current Type 4 connection.
- *
- * @return The description associated with the current Type 4 connection.
- * @see #setDescription(String)
- */
- String getDescription() {
- return description_;
- }
-
- /**
- * Sets the data source name for the current Type 4 connection.
- *
- * @param dataSourceName
- * For the client side <code>DataSource</code> object.
- * @see #getDataSourceName()
- */
- void setDataSourceName(String dataSourceName) {
- if (dataSourceName == null) {
- dataSourceName_ = "";
- } else {
- dataSourceName_ = dataSourceName;
- }
- }
-
- /**
- * Return the data source name given to the client side data source.
- *
- * @return data source name.
- * @see #setDataSourceName(String)
- */
- String getDataSourceName() {
- return dataSourceName_;
- }
-
- /**
- * Sets the data source name to use on the NDCS server side.
- *
- * @param serverDataSource
- * the data source name to use on the NDCS server side. The
- * default value is a blank string.
- * @see #getDataSourceName()
- */
- void setServerDataSource(String serverDataSource) {
- if (serverDataSource == null) {
- serverDataSource_ = "";
- } else {
- serverDataSource_ = serverDataSource;
- }
- }
-
- /**
- * Returns the NDCS server side data source name used for the current Type 4
- * connection. The default server data source name is
- * <code>TDM_Defaullt_DataSource</code>.
- *
- * @return NDCS server side data source Name.
- * @see #setServerDataSource(String)
- */
- String getServerDataSource() {
- return serverDataSource_;
- }
-
- /**
- * Sets the default catalog that will be used to access SQL objects
- * referenced in SQL statements if the SQL objects are not fully qualified.
- *
- * @param catalog
- * Database catalog name. The default catalog name is set by
- * the NDCS server side data source.
- * @see #getCatalog()
- */
- void setCatalog(String catalog) {
- catalog_ = catalog;
- if (catalog_ == null) {
- catalog_ = getProperty("catalog");
-
- }
- if (catalog_ != null) {
- if (catalog_.length() == 0) {
- catalog_ = DEFAULT_CATALOG;
- } else if (!catalog_.startsWith("\"")) {
- catalog_ = catalog_.trim().toUpperCase();
- }
- } else {
- // catalog_ = null;
- catalog_ = DEFAULT_CATALOG;
- }
- }
-
- /**
- * Gets the default catalog that will be used to access SQL objects
- * referenced in SQL statements if the SQL objects are not fully qualified.
- *
- * @return T4 2.0 catalog name.
- * @see #setCatalog(String)
- */
- String getCatalog() {
- return catalog_;
- }
-
- /**
- * Sets the default schema that will be used to access SQL objects
- * referenced in SQL statements if the SQL objects are not fully qualified.
- *
- * @param schema
- * Sets the database schema name. The default schema name is set
- * by the NDCS server side data source.
- * @see #getSchema()
- */
- void setSchema(String schema) {
- schema_ = schema;
- if (schema_ == null) {
- schema_ = getProperty("schema");
-
- }
- if (schema_ != null) {
- if (!schema_.startsWith("\"")) {
- schema_ = schema_.trim().toUpperCase();
- }
- } else {
- schema_ = null;
- }
- }
-
- /**
- * Gets the default schema that will be used to access SQL objects
- * referenced in SQL statements if the SQL objects are not fully qualified.
- *
- * @return The schema associated with the current Type 4 connection.
- * @see #setSchema(String)
- */
- String getSchema() {
- return schema_;
- }
-
- /**
- * Returns the <code>java.util.Locale</code> object associated with the
- * current Type 4 connection.
- *
- * @return <code>java.util.Locale</code> object.
- * @see #setLanguage(String language)
- */
- Locale getLocale() {
- return locale_;
- }
-
- /**
- * The maximum number of physical connections that the pool (free and inuse
- * pool) should contain. When the maximum number of physical connections is
- * reached, the Type 4 driver throws an <code>SQLException
- * </code> with the
- * message "Maximum pool size reached". Specifying a value of 0 (zero)
- * indicates there is no maximum size for the pool. Specifying a value of -1
- * indicates no connection pooling is performed. The default value is -1
- * indicating that no pooling of physical connections is done.
- *
- * @param maxPoolSize
- * the maximum number of physical connections the pool should
- * contain in the pool (free and inuse).
- * @see #setMaxPoolSize(int)
- */
- void setMaxPoolSize(String maxPoolSize) {
- int maxPs = -1;
- if (maxPoolSize != null) {
- try {
- maxPs = Integer.parseInt(maxPoolSize);
- } catch (NumberFormatException ex) {
- sqlExceptionMessage_ = "Incorrect maxPoolSize value set: " + maxPoolSize + ". " + ex.getMessage();
- maxPs = -1;
- }
- }
- setMaxPoolSize(maxPs);
- }
-
- /**
- * The maximum number of physical connections that the pool (free and inuse
- * pool) should contain. When the maximum number of physical connections is
- * reached, the Type 4 driver throws an <code>SQLException
- * </code> with the
- * message "Maximum pool size reached". Specifying a value of 0 (zero)
- * indicates there is no maximum size for the pool. Specifying a value of -1
- * indicates no connection pooling is performed. The default value is -1
- * indicating that no pooling of physical connections is done.
- *
- * @param maxPoolSize
- * the maximum number of physical connections the pool should
- * contain in the pool (free and inuse).
- * @see #setMaxPoolSize(String)
- */
- void setMaxPoolSize(int maxPoolSize) {
- if (maxPoolSize < -1) {
- // The ES says that we set maxPoolSize to -1. It doesn't say we
- // produce an error.
- // sqlExceptionMessage_ = "Incorrect maxPoolSize value set: " +
- // maxPoolSize;
- maxPoolSize_ = -1;
- } else if (maxPoolSize > 0) {
- if (minPoolSize_ != 0 && minPoolSize_ > maxPoolSize) {
- maxPoolSize_ = minPoolSize_;
- } else {
- maxPoolSize_ = maxPoolSize;
- }
- } else {
- maxPoolSize_ = maxPoolSize;
- }
- }
-
- /**
- * Returns the maximum number of physical connections that the pool (free
- * and inuse) should contain. A value of zero (0) indicates no maximum size.
- * A value of -1 indicates that connection pooling is not being done.
- *
- * @return maxPoolSize the maximum number of physical connections that the
- * pool should contain.
- * @see #setMaxPoolSize(int)
- */
- int getMaxPoolSize() {
- return maxPoolSize_;
- }
-
- /**
- * Sets the number of physical connections the pool should keep available at
- * all times.
- *
- * @param minPoolSize
- * Limits the number of physical connection that can be in the
- * free pool. When the number of physical connections in the free
- * pool reaches the value of minPoolSize, subsequent connections
- * that are closed are physically closed and are not added to the
- * free pool. Specifying a value of 0 means that the value of
- * minPoolSize is the same as the value of maxPoolSize. If the
- * value of maxPoolSize is -1, the value of minPoolSize is
- * ignored. The default value is 0. For this data source it is
- * recommended that you use the default value.
- * @return the number of physical connections the pool should keep available
- * at all times.
- * @see #getMinPoolSize()
- * @see #setMinPoolSize(int minPoolSize)
- */
- void setMinPoolSize(String minPoolSize) {
- int minPs = -1;
- if (minPoolSize != null) {
- try {
- minPs = Integer.parseInt(minPoolSize);
- } catch (NumberFormatException ex) {
- sqlExceptionMessage_ = "Incorrect value for minPoolSize set: " + minPoolSize + ". " + ex.getMessage();
- minPs = -1;
- }
- }
- setMinPoolSize(minPs);
- }
-
- /**
- * Sets the number of physical connections the pool should keep available at
- * all times.
- *
- * @param minPoolSize
- * Limits the number of physical connection that can be in the
- * free pool. When the number of physical connections in the free
- * pool reaches the value of minPoolSize, subsequent connections
- * that are closed are physically closed and are not added to the
- * free pool. Specifying a value of 0 means that the value of
- * minPoolSize is the same as the value of maxPoolSize. If the
- * value of maxPoolSize is -1, the value of minPoolSize is
- * ignored. The default value is 0. For this data source it is
- * recommended that you use the default value.
- * @return the number of physical connections the pool should keep available
- * at all times.
- * @see #getMinPoolSize()
- * @see #setMinPoolSize(String minPoolSize)
- */
- void setMinPoolSize(int minPoolSize) {
- if (maxPoolSize_ == -1) {
- // minPoolSize_ = minPoolSize;
- minPoolSize_ = -1;
- return;
- }
- if (minPoolSize < -1) {
- // Swastik: Commented on 14th Feb 2005 to match behavior in
- // setMaxPoolSize(int)
- // sqlExceptionMessage_ = "Incorrect value for minPoolSize set: " +
- // minPoolSize;
- minPoolSize_ = -1;
- } else if (minPoolSize == 0) {
- minPoolSize_ = 0;
- } else {
- if (minPoolSize > 0) {
- if (maxPoolSize_ != 0 && maxPoolSize_ < minPoolSize) {
- minPoolSize_ = maxPoolSize_;
- } else {
- minPoolSize_ = minPoolSize;
- }
- } else {
- minPoolSize_ = minPoolSize;
- }
- }
- }
-
- /**
- * Returns the number of physical connections the pool should keep in the
- * free pool. A value of 0 (zero) indicates that minPoolSize is equal to
- * maxPoolsize. If maxPoolsize is equal to -1, the value of minPoolSize is
- * ignored. The default value is 0.
- *
- * @return The number of physical connections the pool should maintain in
- * the free pool.
- * @see #setMinPoolSize(int)
- * @see #setMaxPoolSize(int)
- */
- int getMinPoolSize() {
- return minPoolSize_;
- }
-
- /**
- * The initial number of physical connections that the pool should be
- * created with. Specifying a valueof 0 (zero) or less indicates that the
- * pool should not be created with any initial connections. The default
- * value is -1 indicating that no initial pool of physical connections is
- * created. The value can be less than minPoolSize but must be less than or
- * equal to the value of maxPoolSize. Specifying a value greater than
- * maxPoolSize will set the initialPoolSize to the value of maxPoolSize.
- *
- * @param initialPoolSize
- * the initial number of physical connections the pool should be
- * created with.
- * @see #setInitialPoolSize(int)
- */
- void setInitialPoolSize(String initialPoolSize) {
- int initPs = -1;
- if (initialPoolSize != null) {
- try {
- initPs = Integer.parseInt(initialPoolSize);
- } catch (NumberFormatException ex) {
- sqlExceptionMessage_ = "Incorrect initialPoolSize value set: " + initialPoolSize + ". "
- + ex.getMessage();
- initPs = -1;
- }
- }
- setInitialPoolSize(initPs);
- }
-
- /**
- * The initial number of physical connections that the pool should be
- * created with. Specifying a valueof 0 (zero) or less indicates that the
- * pool should not be created with any initial connections. The default
- * value is -1 indicating that no initial pool of physical connections is
- * created. The value can be less than minPoolSize but must be less than or
- * equal to the value of maxPoolSize. Specifying a value greater than
- * maxPoolSize will set the initialPoolSize to the value of maxPoolSize.
- *
- * @param initialPoolSize
- * the initial number of physical connections the pool should be
- * created with.
- * @see #setInitialPoolSize(String)
- */
- void setInitialPoolSize(int initialPoolSize) {
- if (initialPoolSize <= 0) {
- initialPoolSize_ = -1;
- return;
- }
- // otherwise initialPoolSize > 0
- if (initialPoolSize > maxPoolSize_) {
- initialPoolSize_ = maxPoolSize_;
- } else {
- initialPoolSize_ = initialPoolSize;
- }
- }
-
- /**
- * Returns the number of physical connections that the pool should be
- * created with. A value of -1 indicates that the pool is not created with
- * any initial connections.
- *
- * @return initialPoolSize the number of physical connections that the pool
- * should be created with.
- * @see #setInitialPoolSize(int)
- */
- int getInitialPoolSize() {
- return initialPoolSize_;
- }
-
- /**
- * Total number of statements that can be pooled. A value of zero (0)
- * indicates that caching of statements is disabled.
- *
- * @param maxStatements
- * The number of statements that can be pooled.
- * @see #setMaxStatements(int)
- */
- void setMaxStatements(String maxStatements) {
- int maxstmt = 0;
- if (maxStatements != null) {
- try {
- maxstmt = Integer.parseInt(maxStatements);
- } catch (NumberFormatException ex) {
- sqlExceptionMessage_ = "Incorrect value for maxStatements set: " + maxStatements + ex.getMessage();
- maxstmt = 0;
- }
- }
- setMaxStatements(maxstmt);
- }
-
- /**
- * Total number of statements that can be pooled. A value of zero (0)
- * indicates that caching of statements is disabled.
- *
- * @param maxStatements
- * The number of statements that can be pooled.
- * @see #setMaxStatements(int)
- */
- void setMaxStatements(int maxStatements) {
- if (maxStatements < 0) {
- sqlExceptionMessage_ = "Incorrect value for maxStatements set: " + maxStatements;
- maxStatements_ = 0;
- } else {
- maxStatements_ = maxStatements;
- }
- }
-
- /**
- * Returns the total number of statements that can be pooled. A value of
- * zero (0) indicates that pooling of statements is disabled.
- *
- * @return The total number of statements that can be pooled.
- */
- int getMaxStatements() {
- return maxStatements_;
- }
-
- /**
- * Returns the URL used in the current Type 4 connection. JDBC Type 4
- * driver URL uses the following format:-
- * <code>jdbc:t4jdbc://host:port/:</code>
- *
- * @deprecated Use <code>getUrl()</code> to obtain the URL string.
- * @return the URL string.
- * @see #getUrl()
- */
- String getURL() {
- return getUrl();
- }
-
- /**
- * Returns the URL used in the current Type 4 connection. JDBC Type 4
- * driver URL uses the following format:-
- * <code>jdbc:t4jdbc://host:port/:</code>
- *
- * @return the URL string.
- * @see #setUrl(String)
- */
- public String getUrl() {
- return url_;
- }
-
- /**
- * Sets the URL for the Type 4 connection. JDBC Type 4 driver URL uses
- * the following format:-
- * <code>jdbc:t4jdbc://host:port/:prop-name=value</code> This method
- * does not validate the url value.
- *
- * @param url
- * the URL.
- * @see #getUrl()
- */
- void setUrl(String url) {
- if (url != null) {
- url_ = url;
- } else {
- url_ = "";
- }
- }
-
- /**
- * Validates the input url string follows the correct jdbc:t4jdbc:<host>:<port>/:<prop-name=prop-val>;<prop-name=prop-val>
- * format.
- *
- * @param url
- * of the Type 4 driver.
- * @return <code>true</code> when the <url> is in the Type 4 driver
- * format.
- */
- boolean acceptsUrl(String url) {
- try {
- new T4Address(this, locale_, url);
- } catch (SQLException sqlex) {
- return false;
- }
- return true;
- }
-
- /**
- * Sets the URL for the Type 4 connection. JDBC Type 4 driver URL uses
- * the following format:-
- * <code>jdbc:t4jdbc://host:port/:prop-name=value</code>. This
- * validates the url value and throws SQLException if the URL value is
- * incorrect.
- *
- * @param url
- * the URL.
- * @see #getUrl()
- */
- Properties setURL(String url) throws SQLException {
- String host = null;
- String port = null;
- Properties props = null;
-
- t4addr_ = new T4Address(this, locale_, url);
- props = t4addr_.getProps();
- initialize(props);
- setUrl(t4addr_.getUrl());
- return props;
- }
-
- /**
- * Retunrs the Type 4 <code>T4Address</code> class.
- *
- * @return the current <code>T4Address</code> class.
- */
- T4Address getAddress() {
- return t4addr_;
- }
-
- /**
- * Sets the Safeguard user name to be used while connecting to NDCS server
- * for authentication.
- *
- * @param user
- * Sets the user for the current Type 4 connection.
- * @see #getUser()
- */
- void setUser(String user) {
- if (user == null) {
- user_ = "";
- } else {
- user_ = user;
- }
- }
-
- /**
- * Returns the Safeguard user name associated with this Type 4 connection.
- *
- * @return The user name.
- * @see #setUser(String)
- */
- String getUser() {
- return user_;
- }
-
- /**
- * Sets the Safeguard password to be used for authentication when connecting
- * to the NDCS server.
- *
- * @param pwd
- * The Safeguard password for the current Type 4 connection.
- */
- void setPassword(String pwd) {
- if (pwd == null) {
- pwd_ = "";
- } else {
- pwd_ = pwd;
- }
- }
-
- /**
- * @deprecated <code>getPassword()</code> would not be supported in the
- * future releases.
- * @return the password associated with this Type 4 connection.
- */
- String getPassword() {
- return pwd_;
- }
-
- /**
- * Sets the login timeout in seconds for the Type 4 connection. The default
- * login timeout value is set to 30 minutes.
- *
- * @param loginTimeout
- * The login timeout value in seconds.
- * @see #setLoginTimeout(int)
- * @see #getLoginTimeout()
- */
- void setLoginTimeout(String loginTimeout) {
- int loginTo = 1800;
- if (loginTimeout != null) {
- try {
- loginTo = Short.parseShort(loginTimeout);
- } catch (NumberFormatException ex) {
- sqlExceptionMessage_ = "Incorrect value for loginTimeout set: " + loginTimeout + ex.getMessage();
- loginTo = 1800;
- }
- }
- setLoginTimeout(loginTo);
- }
-
- /**
- * Sets the login timeout in seconds for the Type 4 connection. The default
- * login timeout value is set to 30 minutes.
- *
- * @param loginTimeout
- * The login timeout value in seconds.
- * @see #setLoginTimeout(String)
- * @see #getLoginTimeout()
- */
- void setLoginTimeout(int loginTimeout) {
- if (loginTimeout < 0) {
- sqlExceptionMessage_ = "Incorrect value for loginTimeout set: " + loginTimeout + ".";
- loginTimeout_ = 1800;
- } else {
- loginTimeout_ = loginTimeout;
- }
- }
-
- /**
- * Returns the login timeout value set for the current Type 4 connection.
- *
- * @return the login timeout value in seconds.
- * @see #setLoginTimeout(int)
- * @see #setLoginTimeout(String)
- */
- int getLoginTimeout() {
- return loginTimeout_;
- }
-
- // -----------------------------------------------------------------
-
- /***************************************************************************
- * Start comment out seciont ************* * Sets the close connection
- * timeout in seconds for the Type 4 connection. The default close
- * connection timeout value is set to 60 seconds.
- *
- * @param closeConnectionTimeout
- * The close connection timeout value in seconds.
- * @see #setCloseConnectionTimeout(int)
- * @see #getCloseConnectionTimeout()
- *
- * public void setCloseConnectionTimeout(String closeConnectionTimeout) {
- * int closeConnectionTo = 60; if (closeConnectionTimeout != null) { try {
- * closeConnectionTo = Integer.parseInt(closeConnectionTimeout); } catch
- * (NumberFormatException ex) { sqlExceptionMessage_ = "Incorrect value for
- * closeConnectionTimeout set: " + closeConnectionTimeout + ex.getMessage();
- * closeConnectionTo = 60; } } setCloseConnectionTimeout(closeConnectionTo); } *
- * Sets the close connection timeout in seconds for the Type 4 connection.
- * The default close connection timeout value is set to 60 seconds.
- * @param closeConnectionTimeout
- * The close connection timeout value in seconds.
- * @see #setCloseConnectionTimeout(String)
- * @see #getCloseConnectionTimeout()
- *
- * public void setCloseConnectionTimeout(int closeConnectionTimeout) { if
- * (closeConnectionTimeout < 0) { sqlExceptionMessage_ = "Incorrect value
- * for closeConnectionTimeout set: " + closeConnectionTimeout + ".";
- * closeConnectionTimeout_ = 60; } else { closeConnectionTimeout_ =
- * closeConnectionTimeout; } } * Returns the close connection timeout value
- * set for the current Type 4 connection.
- * @return the close connection timeout value in seconds.
- * @see #setCloseConnectionTimeout(int)
- * @see #setCloseConnectionTimeout(String)
- *
- * public int getCloseConnectionTimeout() { return closeConnectionTimeout_; }
- **************************************************************************/
-
- // -----------------------------------------------------------------
- /**
- * Sets the network timeout in seconds for the Type 4 connection. The
- * default network timeout value is set to infinity seconds.
- *
- * @param networkTimeout
- * The network timeout value in seconds.
- * @see #setNetworkTimeout(int)
- * @see #getNetworkTimeout()
- */
- void setNetworkTimeout(String networkTimeout) {
- int networkTo = 0;
- if (networkTimeout != null) {
- try {
- networkTo = Integer.parseInt(networkTimeout);
- } catch (NumberFormatException ex) {
- sqlExceptionMessage_ = "Incorrect value for networkTimeout set: " + networkTimeout + ex.getMessage();
- networkTo = 0;
- }
- }
- setNetworkTimeout(networkTo);
- }
-
- /**
- * Sets the network timeout in seconds for the Type 4 connection. The
- * default network timeout value is set to infinity seconds.
- *
- * @param networkTimeout
- * The network timeout value in seconds.
- * @see #setNetworkTimeout(String)
- * @see #getNetworkTimeout()
- */
- void setNetworkTimeout(int networkTimeout) {
- if (networkTimeout < 0) {
- sqlExceptionMessage_ = "Incorrect value for networkTimeout set: " + networkTimeout + ".";
- networkTimeout_ = 0;
- } else {
- networkTimeout_ = networkTimeout;
- }
- }
-
- /**
- * Returns the network timeout value set for the current Type 4 connection.
- *
- * @return the network timeout value in seconds.
- * @see #setNetworkTimeout(int)
- * @see #setNetworkTimeout(String)
- */
- int getNetworkTimeout() {
- return networkTimeout_;
- }
-
- // -----------------------------------------------------------------
-
- /*
- * Sets the connection timeout value for the Type 4 connection. Set this
- * value to 0 for infinite timeout. The default is set to -1. A negative
- * value indicates the NDCS server to use the connection timeout value set
- * by the administrator on the NDCS data source. @param connectionTimeout
- * The connection timeout value in seconds.
- *
- * @see #setConnectionTimeout(int)
- * @see #setServerDataSource(String)
- */
- void setConnectionTimeout(String connectionTimeout) {
- int tmpTimeout = -1;
- if (connectionTimeout != null) {
- try {
- tmpTimeout = Integer.parseInt(connectionTimeout);
- } catch (NumberFormatException ex) {
- sqlExceptionMessage_ = "Incorrect value for connectionTimeout set: " + connectionTimeout + ". "
- + ex.getMessage();
- tmpTimeout = -1;
- }
- }
- setConnectionTimeout(tmpTimeout);
- }
-
- /*
- * Sets the connection timeout value for the Type 4 connection. Set this
- * value to 0 for infinite timeout. The default is set to -1. A negative
- * value indicates the NDCS server to use the connection timeout value set
- * by the administrator on the NDCS data source. @param connectionTimeout
- * The connection timeout value in seconds.
- *
- * @see #setConnectionTimeout(String)
- * @see #setServerDataSource(String)
- */
- void setConnectionTimeout(int connectionTimeout) {
- if (connectionTimeout < 0) {
- /*
- * sqlExceptionMessage_ = "Incorrect value for connectionTimeout
- * set: " + connectionTimeout + ". ";
- */
- connectionTimeout_ = -1;
- } else {
- connectionTimeout_ = connectionTimeout;
- }
- }
-
- /**
- * Sets the max idle time value for the Type 4 connection. The default is
- * set to 0 (no timeout). Negative values are treated as 0.
- *
- * @param maxIdleTime
- * The timeout value in seconds.
- * @see #setMaxIdleTime(int)
- */
- void setMaxIdleTime(String maxIdleTime) {
- int tmpTimeout = DEFAULT_MAX_IDLE_TIMEOUT;
- if (maxIdleTime != null) {
- try {
- tmpTimeout = Integer.parseInt(maxIdleTime);
- } catch (NumberFormatException ex) {
- sqlExceptionMessage_ = "Incorrect value for maxIdleTime set: " + maxIdleTime + ". " + ex.getMessage();
- tmpTimeout = DEFAULT_MAX_IDLE_TIMEOUT;
- }
- }
- setMaxIdleTime(tmpTimeout);
- }
-
- /**
- * Sets the max idle time value for the Type 4 connection. The default is
- * set to 0 (no timeout). Negative values are treated as 0.
- *
- * @param maxIdleTime
- * The timeout value in seconds.
- * @see #setMaxIdleTime(String)
- */
- void setMaxIdleTime(int maxIdleTime) {
- if (maxIdleTime < 0) {
- maxIdleTime_ = DEFAULT_MAX_IDLE_TIMEOUT;
- } else {
- maxIdleTime_ = maxIdleTime;
- }
- }
-
- /*
- * Returns the connection timeout value associated with this Type 4
- * connection. @return The connection timeout value in seconds.
- *
- * @see #setConnectionTimeout(int)
- */
-
- int getConnectionTimeout() {
- return connectionTimeout_;
- }
-
- /**
- * Returns the max idle time value associated with this Type 4 connection.
- *
- * @return The connection timeout value in seconds.
- * @see #setMaxIdleTime(int)
- */
- int getMaxIdleTime() {
- return maxIdleTime_;
- }
-
- /**
- * Sets the logging level for the current Type 4 connection. Default value
- * is OFF. Other valid values are SEVERE (highest value) WARNING INFO CONFIG
- * FINE FINER FINEST (lowest value).
- *
- * @param level
- * logging level.
- * @see #getT4LogLevel()
- * @see java.util.logging.Level
- */
- void setT4LogLevel(String level) {
- t4LogLevel = Level.parse("OFF");
- if (level != null) {
- try {
- t4LogLevel = Level.parse(level);
- } catch (Exception ex) {
-
- SQLException se = HPT4Messages.createSQLException(null, null, "problem_with_logging", ex.getMessage());
- sqlExceptionMessage_ = se.getMessage();
- // throw se;
- // RuntimeException rte = new RuntimeException(se.getMessage(),
- // se);
- // throw rte;
- // sqlExceptionMessage_ = "Incorrect value for T4LogLevel set: "
- // +
- // level + ". " + ex.getMessage();
- // t4LogLevel = Level.parse("INFO");
- }
- }
- }
-
- /**
- * Returns the Type 4 log level associated with the current Type 4
- * connection. The value returned must one of the following strings. SEVERE
- * (highest value) WARNING INFO CONFIG FINE FINER FINEST (lowest value).
- *
- * @return <code>java.util.logging.Level</code> associated with the
- * current Type 4 connection.
- * @see #setT4LogLevel(String)
- * @see java.util.logging.Level
- */
- Level getT4LogLevel() {
- return t4LogLevel;
- }
-
- /**
- * Sets the location of the file to which the logging is to be done.
- * Changing this location after making a connection has no effect; because
- * the Type 4 reads this property before the connection is made. The default
- * name is a generated file name defined by the following pattern:
- * %h/t4jdbc%u.log where: "/" represents the local pathname separator "%h"
- * represents the value of the "user.home" system property. If %h is not
- * defined, then the behavior is undefined "%u" represents a unique number
- * to resolve conflicts
- *
- * @param t4LogFile
- * The Type 4 log file location. If the parameter is null, then
- * the T4LogFile is set to the global log file.
- * @see #getT4LogFile()
- * @see java.util.logging.Logger
- */
- void setT4LogFile(String t4LogFile) {
- if (t4LogFile != null) {
- T4LogFile_ = t4LogFile;
- } else {
- T4LogFile_ = t4GlobalLogFile;
- }
- }
-
- /**
- * Returns the Type 4 log file location associated with the current Type 4
- * connection.
- *
- * @return The Type 4 log file location.
- * @see #setT4LogFile(String)
- */
- String getT4LogFile() {
- return T4LogFile_;
- }
-
- String getT4GlobalLogFile() {
- return t4GlobalLogFile;
- }
-
- void setT4GlobalLogFile(String lgf) {
- t4GlobalLogFile = lgf;
- }
-
- // --------------------------------------------
- FileHandler getT4GlobalLogFileHandler() {
- return t4GlobalLogFileHandler;
- } // end getT4GlobalLogFileHandler
-
- // --------------------------------------------
- void setT4GlobalLogFileHandler(Object fh) {
- t4GlobalLogFileHandler = (FileHandler) fh;
- }
-
- // --------------------------------------------
-
- Logger getLogger() {
- return logger;
- }
-
- void setLogger(Object log) {
- if (log != null) {
- logger = (Logger) log;
- t4Logger_ = logger;
- } else {
- logger = t4GlobalLogger;
- t4Logger_ = logger;
- }
- }
-
- // --------------------------------------------
- /**
- * This method will return the log file handlder It also has the side effect
- * of creating a log file handler if one doesn't exist.
- */
- FileHandler getT4LogFileHandler() {
- try {
- if (t4LogFileHandler_ == null) {
- if (T4LogFile_.equals(t4GlobalLogFile)) {
- t4LogFileHandler_ = t4GlobalLogFileHandler;
- } else {
- t4LogFileHandler_ = new FileHandler(T4LogFile_);
- t4LogFileHandler_.setFormatter(new T4LogFormatter());
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return t4LogFileHandler_;
- } // end getT4LogFileHandler
-
- // --------------------------------------------
- void setT4LogFileHandler(Object fh) {
- t4LogFileHandler_ = (FileHandler) fh;
- }
-
- // ----------------------------------------------------------
-
- /**
- * Returns the <code>PrintWriter</code> object associated with the current
- * Type 4 connection.
- *
- * @return <code>java.io.PrintWriter</code> object associated with current
- * connection.
- * @throws SQLException
- * when error occurs.
- * @see #setLogWriter(PrintWriter)
- * @see javax.sql.ConnectionPoolDataSource
- */
- public PrintWriter getLogWriter() throws SQLException {
- return logWriter_;
- }
-
- /**
- * Sets the <code>PrintWriter</code> object for the current Type 4
- * connection.
- *
- * @param printWriter
- * For the current Type 4 logging.
- * @throws SQLException
- * when error occurs.
- * @see #getLogWriter()
- * @see javax.sql.ConnectionPoolDataSource
- */
- public void setLogWriter(PrintWriter printWriter) throws SQLException {
- logWriter_ = printWriter;
- }
-
- // properties queryTimeout_ for future use.
- // setter/getter methods for queryTimeout. These methods are not public YET.
- /**
- * @param queryTimeout
- * Sets the query timeout value in seconds. For future use only
- * this property is not supported in the current release.
- */
- void setQueryTimeout(String queryTimeout) {
- short tmpQTimeOut = 0;
- if (queryTimeout != null) {
- try {
- tmpQTimeOut = Short.parseShort(queryTimeout);
- } catch (NumberFormatException ex) {
- sqlExceptionMessage_ = "Incorrect value for queryTimeout set: " + queryTimeout + ex.getMessage();
- tmpQTimeOut = 0;
- }
- }
- setQueryTimeout(tmpQTimeOut);
- }
-
- /**
- * @param queryTimeout
- * Sets the query timeout value in seconds. For future use only
- * this property is not supported in the current release.
- */
- void setQueryTimeout(short queryTimeout) {
- queryTimeout_ = queryTimeout;
- }
-
- /**
- * @return queryTimeOut value in seconds. For future use only this property
- * is not supported in the current release.
- */
- short getQueryTimeout() {
- return queryTimeout_;
- }
-
- /**
- * Sets the value (in KB) for the size of the fetch buffer. This is used
- * when rows are fetched are performed from a ResultSet object after a
- * successful executeQuery() operation on a statement. The default size is
- * 4. Zero and negative values are treated as default values.
- *
- * @param fetchBufferSize
- * @see #getFetchBufferSize()
- * @see #setFetchBufferSize(String)
- */
- void setFetchBufferSize(short fetchBufferSize) {
- fetchBufferSize_ = 512;
- if (fetchBufferSize > 512) {
- fetchBufferSize_ = fetchBufferSize;
- }
- }
-
- /**
- * Sets the value (in KB) for the size of the fetch buffer. This is used
- * when rows are fetched are performed from a ResultSet object after a
- * successful executeQuery() operation on a statement. The default size is
- * 4. Zero and negative values are treated as default values.
- *
- * @param fetchBufferSize
- * @see #getFetchBufferSize()
- * @see #setFetchBufferSize(short)
- */
- void setFetchBufferSize(String fetchBufferSize) {
- short setFetchSizeVal = 4;
- if (fetchBufferSize != null) {
- try {
- setFetchSizeVal = Short.parseShort(fetchBufferSize);
- } catch (NumberFormatException ex) {
- sqlExceptionMessage_ = "Incorrect fetchBufferSize value set: " + setFetchSizeVal + ". "
- + ex.getMessage();
- setFetchSizeVal = 1;
- }
- }
- setFetchBufferSize(setFetchSizeVal);
- }
-
- /**
- * Returns the size of the fetch buffer.
- *
- * @see #setFetchBufferSize(short)
- * @see #setFetchBufferSize(String)
- */
- short getFetchBufferSize() {
- return fetchBufferSize_;
- }
-
- /**
- * Configure to use array binding feature for the Type 4 connection. Default
- * value is true.
- *
- * @param useArrayBinding
- */
- void setUseArrayBinding(String useArrayBinding) {
- boolean boolUseArrayBinding = false;
- if (useArrayBinding != null) {
- if (useArrayBinding.equalsIgnoreCase("true")) {
- boolUseArrayBinding = true;
- }
- }
- setUseArrayBinding(boolUseArrayBinding);
- }
-
- /**
- * Configure to use array binding feature for the Type 4 connection. Default
- * value is true.
- *
- * @param useArrayBinding
- */
- void setUseArrayBinding(boolean useArrayBinding) {
- useArrayBinding_ = useArrayBinding;
- }
-
- /**
- * Return whether the connection uses Database array binding feature.
- *
- * @return useArrayBinding boolean flag indicates Database RowSet (array
- * binding) feature is used or not.
- */
- boolean getUseArrayBinding() {
- return useArrayBinding_;
- }
-
- /**
- * Configure the Type 4 connection to continue batch processing of next
- * commands even after errors. Default value is true.
- *
- * @param batchRecovery
- */
- void setBatchRecovery(String batchRecovery) {
- boolean boolBatchRecovery = true;
- if (batchRecovery != null) {
- if (batchRecovery.equalsIgnoreCase("false")) {
- boolBatchRecovery = false;
- }
- }
- setBatchRecovery(boolBatchRecovery);
- }
-
- /**
- * Configure the Type 4 connection to continue batch processing of next
- * commands even after errors. Default value is true.
- *
- * @param batchRecovery
- */
- void setBatchRecovery(boolean batchRecovery) {
- batchRecovery_ = batchRecovery;
- }
-
- /**
- * Return whether the Type 4 connection is configured to continue batch
- * processing of next commands even after errors.
- *
- * @return batchRecovery
- */
- boolean getBatchRecovery() {
- return batchRecovery_;
- }
-
- /**
- * Sets the buffer size in bytes used by the transport layer between Type 4
- * client classes and NDCS server on the NSK system.
- *
- * @param transportBufferSize
- * set the transport buffer size in bytes for the current Type 4
- * connection. Default value is 32000.
- */
- /*
- * public void setTransportBufferSize(String transportBufferSize) { short
- * tmpbuf = 32000; if (transportBufferSize != null) { try { tmpbuf = (new
- * Short(transportBufferSize)).shortValue(); } catch (Exception ex) {
- * sqlExceptionMessage_ = "Incorrect value for transportBufferSize set: " +
- * transportBufferSize + ex.getMessage(); tmpbuf = 32000; } }
- * setTransportBufferSize(tmpbuf); }
- */
-
- /**
- * Sets the buffer size in bytes used by the transport layer between Type 4
- * client classes and NDCS server on the NSK system. Transport buffer
- * minimum acceptable size is 2000 bytes. If the value set is below 2000
- * default buffer size of 3200 is set instead.
- *
- * @param transportBufferSize
- * set the transport buffer size in bytes for the current
- * connection. Default value for the driver is 32000 bytes.
- */
- /*
- * public void setTransportBufferSize(short transportBufferSize) { if
- * (transportBufferSize < 2000) { transportBufferSize_ = 32000; } else {
- * transportBufferSize_ = transportBufferSize; } }
- */
-
- /**
- * Returns the buffer size in bytes used by the transport layer between Type
- * 4 client classes and NDCS server on the NSK system.
- *
- * @return The transport buffer size used by the current Type 4 connection.
- */
- /*
- * public short getTransportBufferSize() { return transportBufferSize_; }
- */
-
- /**
- * Sets the table name to store and retrieve the CLOB data for all CLOB
- * columns accessed in the connection using the data source.
- *
- * @param clobTableName
- * The clob table name which is of the format
- * <code><var>catalog_name.schema_name.clob_table_name</code></var>
- *
- * @since 1.1
- */
- void setClobTableName(String clobTableName) throws SQLException {
- int fromIndex = -1;
- int count = 0;
-
- if (clobTableName != null) {
- while (((fromIndex = clobTableName.indexOf('.', fromIndex + 1)) != -1) && count < 2) {
- count++;
- }
- if (count < 2) {
- SQLException se = HPT4Messages.createSQLException(null, null, "no_clobTableName", null);
- sqlExceptionMessage_ = se.getMessage();
- }
- clobTableName_ = clobTableName;
- } else { // If the name is null, let it be null
- clobTableName_ = null;
- // throw HPT4Messages.createSQLException(null,
- // null,"no_clobTableName",null);
- }
- }
-
- /**
- * Retrieves the table name used to store CBLOB data for all CLOB columns
- * accessed in the connection using the data source.
- *
- * @return the clob table name which is of the format
- * <code><var>catalog_name.schema_name.clob_table_name</code></var>
- *
- * @since 1.1
- */
- String getClobTableName() {
- return clobTableName_;
- }
-
- /**
- * @return any sql exception associated while setting the properties on this
- * Type 4 connection. This mthod is accessed by InterfaceConnection
- * to check if there is any SQL error setting the Type 4 properties.
- */
- String getSQLException() {
- // System.out.println("sqlExceptionMessage_ = " + sqlExceptionMessage_);
- return sqlExceptionMessage_;
- }
-
- /**
- * Sets the table name to store and retrieve the BLOB data for all BLOB
- * columns accessed in the connection using the data source.
- *
- * @param blobTableName
- * the blob table name which is of the format
- * <code><var>catalog_name.schema_name.blob_table_name</code></var>
- *
- * @since 1.1
- */
- void setBlobTableName(String blobTableName) throws SQLException {
- int fromIndex = -1;
- int count = 0;
-
- if (blobTableName != null) {
- while (((fromIndex = blobTableName.indexOf('.', fromIndex + 1)) != -1) && count < 2) {
- count++;
- }
- if (count < 2) {
- SQLException se = HPT4Messages.createSQLException(null, null, "no_blobTableName", null);
- sqlExceptionMessage_ = se.getMessage();
- }
- blobTableName_ = blobTableName;
- }
- // If the name is null, then let it be null
- else {
- blobTableName_ = null;
- // throw HPT4Messages.createSQLException(null, null,
- // "no_blobTableName", null);
- }
- }
-
- /**
- * Retrieves the table name used to store BLOB data for all BLOB columns
- * accessed in the connection using the data source.
- *
- * @return the blob table name which is of the format
- * <code><var>catalog_name.schema_name.blob_table_name</code></var>
- *
- * @since 1.1
- */
- String getBlobTableName() {
- return blobTableName_;
- }
-
- /**
- * Configure to set the number of data locators to be reserved by the Type 4
- * connection. Default value is 100.
- *
- * @param reserveDataLocator
- * Set the value of the reserve data locator length for the
- * binding) feature.
- *
- * @since 1.1
- */
- void setReserveDataLocator(String reserveDataLocator) {
- long reserveDataLocatorLen = 100;
- if (reserveDataLocator != null) {
- try {
- reserveDataLocatorLen = Long.parseLong(reserveDataLocator);
- } catch (NumberFormatException ex) {
- sqlExceptionMessage_ = "Incorrect value for setReserveDataLocator set: " + reserveDataLocator
- + ex.getMessage();
- reserveDataLocatorLen = 100;
- }
- }
- setReserveDataLocator(reserveDataLocatorLen);
- }
-
- /**
- * Configure to set the number of data locators to be reserved by the Type 4
- * connection. Default value is 100.
- *
- * @param reserveDataLocatorLen
- * Set the value of the reserve data locator length for the Type
- * 4 connection.
- *
- * @since 1.1
- */
- void setReserveDataLocator(long reserveDataLocatorLen) {
- if (reserveDataLocatorLen < 0) {
- sqlExceptionMessage_ = "Incorrect value for reserveDataLocator set: " + reserveDataLocatorLen + ".";
- reserveDataLocator_ = 100;
- } else {
- reserveDataLocator_ = reserveDataLocatorLen;
- }
- }
-
- /**
- * Return the value of the reserve data locator length.
- *
- * @return reserveDataLocatorLength int indicates the value of the reserved
- * data locator length.
- *
- * @since 1.1
- */
- long getReserveDataLocator() {
- return reserveDataLocator_;
- }
-
- /**
- * Returns the rounding mode set for the driver as an Integer value with one
- * of the following values. static int ROUND_CEILING Rounding mode to round
- * towards positive infinity. static int ROUND_DOWN Rounding mode to round
- * towards zero. static int ROUND_FLOOR Rounding mode to round towards
- * negative infinity. static int ROUND_HALF_DOWN Rounding mode to round
- * towards "nearest neighbor" unless both neighbors are equidistant, in
- * which case round down. static int ROUND_HALF_EVEN Rounding mode to round
- * towards the "nearest neighbor" unless both neighbors are equidistant, in
- * which case, round towards the even neighbor. static int ROUND_HALF_UP
- * Rounding mode to round towards "nearest neighbor" unless both neighbors
- * are equidistant, in which case round up. static int ROUND_UNNECESSARY
- * Rounding mode to assert that the requested operation has an exact result,
- * hence no rounding is necessary. static int ROUND_UP Rounding mode to
- * round away from zero.
- */
- int getRoundingMode() {
- return roundMode_;
- }
-
- /**
- * This method sets the round mode behaviour for the driver.
- *
- * @param roundMode
- * Integer value with one of the following values: static int
- * ROUND_CEILING Rounding mode to round towards positive
- * infinity. static int ROUND_DOWN Rounding mode to round towards
- * zero. static int ROUND_FLOOR Rounding mode to round towards
- * negative infinity. static int ROUND_HALF_DOWN Rounding mode to
- * round towards "nearest neighbor" unless both neighbors are
- * equidistant, in which case round down. static int
- * ROUND_HALF_EVEN Rounding mode to round towards the "nearest
- * neighbor" unless both neighbors are equidistant, in which
- * case, round towards the even neighbor. static int
- * ROUND_HALF_UP Rounding mode to round towards "nearest
- * neighbor" unless both neighbors are equidistant, in which case
- * round up. static int ROUND_UNNECESSARY Rounding mode to assert
- * that the requested operation has an exact result, hence no
- * rounding is necessary. static int ROUND_UP Rounding mode to
- * round away from zero. The default behaviour is to do
- * ROUND_HALF_EVEN.
- */
- void setRoundingMode(String roundMode) {
- roundMode_ = Utility.getRoundingMode(roundMode);
- }
-
- /**
- * This method sets the round mode behaviour for the driver.
- *
- * @param roundMode
- * Integer value with one of the following values: static int
- * ROUND_CEILING Rounding mode to round towards positive
- * infinity. static int ROUND_DOWN Rounding mode to round towards
- * zero. static int ROUND_FLOOR Rounding mode to round towards
- * negative infinity. static int ROUND_HALF_DOWN Rounding mode to
- * round towards "nearest neighbor" unless both neighbors are
- * equidistant, in which case round down. static int
- * ROUND_HALF_EVEN Rounding mode to round towards the "nearest
- * neighbor" unless both neighbors are equidistant, in which
- * case, round towards the even neighbor. static int
- * ROUND_HALF_UP Rounding mode to round towards "nearest
- * neighbor" unless both neighbors are equidistant, in which case
- * round up. static int ROUND_UNNECESSARY Rounding mode to assert
- * that the requested operation has an exact result, hence no
- * rounding is necessary. static int ROUND_UP Rounding mode to
- * round away from zero. The default behaviour is to do
- * ROUND_HALF_EVEN.
- */
- void setRoundingMode(int roundMode) {
- roundMode_ = Utility.getRoundingMode(roundMode);
- }
-
- // ----------------------------------------------------------
- void setConnectionID(String connID) {
- connectionID_ = connID;
- }
-
- String getConnectionID() {
- return connectionID_;
- }
-
- // ----------------------------------------------------------
- void setDialogueID(String diaID) {
- dialogueID_ = diaID;
- }
-
- String getDialogueID() {
- return dialogueID_;
- }
-
- // ----------------------------------------------------------
- void setNcsMajorVersion(short majorVer) {
- ncsMajorVersion_ = majorVer;
- }
-
- void setNcsMajorVersion(String majorVer) {
- short mv = 0;
-
- if (majorVer != null) {
- try {
- mv = Short.parseShort(majorVer);
- } catch (NumberFormatException ex) {
- sqlExceptionMessage_ = "Incorrect value for NDCS major version set: " + majorVer + ex.getMessage();
- mv = 0;
- }
- }
- setNcsMajorVersion(mv);
- ncsMajorVersion_ = mv;
- }
-
- short getNcsMajorVersion() {
- return ncsMajorVersion_;
- }
-
- // ----------------------------------------------------------
- void setNcsMinorVersion(short minorVer) {
- ncsMinorVersion_ = minorVer;
- }
-
- void setNcsMinorVersion(String minorVer) {
- short mv = 0;
-
- if (minorVer != null) {
- try {
- mv = Short.parseShort(minorVer);
- } catch (NumberFormatException ex) {
- sqlExceptionMessage_ = "Incorrect value for NDCS minor version set: " + minorVer + ex.getMessage();
- mv = 0;
- }
- }
- setNcsMinorVersion(mv);
- ncsMinorVersion_ = mv;
- }
-
- short getNcsMinorVersion() {
- return ncsMinorVersion_;
- }
-
- void setSqlmxMajorVersion(short majorVer) {
- sqlmxMajorVersion_ = majorVer;
- }
-
- void setSqlmxMajorVersion(String majorVer) {
- short mv = 0;
-
- if (majorVer != null) {
- try {
- mv = Short.parseShort(majorVer);
- } catch (NumberFormatException ex) {
- sqlExceptionMessage_ = "Incorrect value for Database major version set: " + majorVer
- + ex.getMessage();
- mv = 0;
- }
- }
- setSqlmxMajorVersion(mv);
- }
-
- public void setSPJEnv(String SPJEnv) {
- if (SPJEnv == null) {
- SPJEnv_ = false;
- } else {
- SPJEnv_ = (SPJEnv.equalsIgnoreCase("true"));
- }
- }
-
- public void setSPJEnv(boolean SPJEnv) {
- SPJEnv_ = SPJEnv;
- }
-
- public boolean getSPJEnv() {
- return SPJEnv_;
- }
-
- public void setKeepRawFetchBuffer(String keep) {
- if (keep == null) {
- keepRawFetchBuffer_ = false;
- } else {
- keepRawFetchBuffer_ = (keep.equalsIgnoreCase("true"));
- }
- }
-
- public void setKeepRawFetchBuffer(boolean keep) {
- keepRawFetchBuffer_ = keep;
- }
-
- public boolean getKeepRawFetchBuffer() {
- return keepRawFetchBuffer_;
- }
-
- short getSqlmxMajorVersion() {
- return sqlmxMajorVersion_;
- }
-
- public void setCpuToUse(String cpu) {
- if (cpu == null) {
- cpuToUse_ = -1;
- } else {
- cpuToUse_ = Short.parseShort(cpu);
- }
- }
-
- public void setCpuToUse(short cpu) {
- cpuToUse_ = cpu;
- }
-
- public short getCpuToUse() {
- return cpuToUse_;
- }
-
- public void setSessionName(String name) {
- if (name == null)
- sessionName = "";
- else {
- sessionName = name;
- }
- }
-
- public String getSessionName() {
- return sessionName;
- }
-
- public void setReplacementString(String str) {
- if (str == null) {
- replacementString_ = "?";
- } else {
- replacementString_ = str;
- }
- }
-
- public String getReplacementString() {
- return replacementString_;
- }
-
- void setISO88591(String lang) {
- if (lang == null) {
- ISO88591_ = InterfaceUtilities.getCharsetName(InterfaceUtilities.SQLCHARSETCODE_ISO88591);
- } else {
- ISO88591_ = lang;
- }
- }
-
- String getISO88591() {
- return ISO88591_;
- }
-
- public String getRoleName() {
- return _roleName;
- }
-
- public void setRoleName(String roleName) {
- if (roleName != null && roleName.length() > 0) {
- if (roleName.length() > 128)
- sqlExceptionMessage_ = "Invalid RoleName. Max length: 128";
- }
-
- this._roleName = roleName;
- }
-
- public String getApplicationName() {
- return _applicationName;
- }
-
- public void setApplicationName(String applicationName) {
- if (applicationName == null || applicationName.length() == 0)
- this._applicationName = "FASTJDBC";
- else
- this._applicationName = applicationName;
- }
-
- public void setCertificateFileActive(String file) {
- _certificateFileActive = file;
- }
-
- public String getCertificateFileActive() {
- return _certificateFileActive;
- }
-
- public void setCertificateFile(String file) {
- _certificateFile = file;
- }
-
- public String getCertificateFile() {
- return _certificateFile;
- }
-
- public void setCertificateDir(String dir) {
- _certificateDir = dir;
- }
-
- public String getCertificateDir() {
- return _certificateDir;
- }
-
- public void setDelayedErrorMode(String mode) {
- _delayedErrorMode = Boolean.valueOf(mode).booleanValue();
- }
-
- public void setDelayedErrorMode(boolean mode) {
- _delayedErrorMode = mode;
- }
-
- public boolean getDelayedErrorMode() {
- return _delayedErrorMode;
- }
-
- public void setCompression(String compression) {
- _compression = Boolean.valueOf(compression).booleanValue();
- }
-
- public void setCompression(boolean compression) {
- _compression = compression;
- }
-
- public boolean getCompression() {
- return _compression;
- }
-
- public void setKeepAlive(String val) {
- if(val == null)
- {
- _keepAlive = true;
- }
- else
- {
- _keepAlive = Boolean.valueOf(val).booleanValue();
- }
- }
-
- public void setKeepAlive(boolean val) {
- _keepAlive = val;
- }
-
- public boolean getKeepAlive() {
- return _keepAlive;
- }
-
- public void setTcpNoDelay(String val) {
- if(val == null) {
- _tcpNoDelay = true;
- }
- else {
- _tcpNoDelay = Boolean.valueOf(val).booleanValue();
- }
- }
-
- public void setTcp_NoDelay(boolean val) {
- _tcpNoDelay = val;
- }
-
- public boolean getTcpNoDelay() {
- return _tcpNoDelay;
- }
-
- public void setTokenAuth(String val) {
- if(val == null)
- {
- _tokenAuth = true;
- }
- else
- {
- _tokenAuth = Boolean.valueOf(val).booleanValue();
- }
- }
-
- public void setTokenAuth(boolean val) {
- _tokenAuth = val;
- }
-
- public boolean getTokenAuth() {
- return _tokenAuth;
- }
-
- boolean getSessionToken() {
- return this._sessionToken;
- }
-
- void setSessionToken(boolean sessionToken) {
- this._sessionToken = sessionToken;
- }
-
- void setSessionToken(String sessionToken) {
- setSessionToken(Boolean.valueOf(sessionToken).booleanValue());
- }
-
- boolean getFetchAhead() {
- return this._fetchAhead;
- }
-
- void setFetchAhead(boolean fetchAhead) {
- this._fetchAhead = fetchAhead;
- }
-
- void setFetchAhead(String fetchAhead) {
- setFetchAhead(Boolean.valueOf(fetchAhead).booleanValue());
- }
-
- // ----------------------------------------------------------
- void setSqlmxMinorVersion(short minorVer) {
- sqlmxMinorVersion_ = minorVer;
- }
-
- void setSqlmxMinorVersion(String minorVer) {
- short mv = 0;
-
- if (minorVer != null) {
- try {
- mv = Short.parseShort(minorVer);
- } catch (NumberFormatException ex) {
- sqlExceptionMessage_ = "Incorrect value for Database minor version set: " + minorVer
- + ex.getMessage();
- mv = 0;
- }
- }
- setSqlmxMinorVersion(mv);
- }
-
- short getSqlmxMinorVersion() {
- return sqlmxMinorVersion_;
- }
-
- // ----------------------------------------------------------
- BigDecimal getNcsVersion() {
- String minor = new Short(getNcsMinorVersion()).toString();
- String major = new Short(getNcsMajorVersion()).toString();
- BigDecimal bigD = new BigDecimal(major + "." + minor);
- return bigD;
- }
-
- // ----------------------------------------------------------
- void setServerID(String serID) {
- serverID_ = serID;
- }
-
- String getServerID() {
- return serverID_;
- }
-
- /**
- * Sets the language to use for the error messages.
- *
- * @param language
- * Sets the language for the current Type 4 connection. The
- * default language used by the Type 4 driver is American
- * English.
- * @see #getLanguage()
- */
- void setLanguage(String language) {
- if (language == null) {
- locale_ = Locale.getDefault();
- } else {
- locale_ = new Locale(language, "", "");
- }
- language_ = locale_.getLanguage();
- }
-
- /**
- * Returns the language in which to the Type 4 error messages will be
- * returned to the application.
- *
- * @return The language associated with the current Type 4 connection.
- * @see #setLanguage(String language)
- */
- String getLanguage() {
- return language_;
- }
-
- // ----------------------------------------------------------
-
- /**
- * @return Reference object containing all the Type 4 connection properties.
- * The reference object can be used to register with naming
- * services.
- */
- Reference addReferences(Reference ref) {
- ref.add(new StringRefAddr("dataSourceName", getDataSourceName()));
- ref.add(new StringRefAddr("serverDataSource", getServerDataSource()));
- ref.add(new StringRefAddr("description", getDescription()));
- String val = getCatalog();
- if (val != null) {
- ref.add(new StringRefAddr("catalog", val));
- }
- val = getSchema();
- if (val != null) {
- ref.add(new StringRefAddr("schema", val));
-
- }
- ref.add(new StringRefAddr("language", getLanguage()));
- ref.add(new StringRefAddr("maxPoolSize", Integer.toString(getMaxPoolSize())));
- ref.add(new StringRefAddr("minPoolSize", Integer.toString(getMinPoolSize())));
- ref.add(new StringRefAddr("initialPoolSize", Integer.toString(getInitialPoolSize())));
- ref.add(new StringRefAddr("maxStatements", Integer.toString(getMaxStatements())));
-
- ref.add(new StringRefAddr("connectionTimeout", Integer.toString(getConnectionTimeout())));
- ref.add(new StringRefAddr("maxIdleTime", Integer.toString(getMaxIdleTime())));
- ref.add(new StringRefAddr("loginTimeout", Integer.toString(getLoginTimeout())));
- // ref.add(new StringRefAddr("closeConnectionTimeout",
- // Integer.toString(getCloseConnectionTimeout())));
- ref.add(new StringRefAddr("networkTimeout", Integer.toString(getNetworkTimeout())));
- ref.add(new StringRefAddr("T4LogLevel", getT4LogLevel().toString()));
- ref.add(new StringRefAddr("T4LogFile", getT4LogFile()));
-
- ref.add(new StringRefAddr("url", getUrl()));
- ref.add(new StringRefAddr("user", getUser()));
- ref.add(new StringRefAddr("password", getPassword()));
- /*
- * ref.add(new StringRefAddr("transportBufferSize",
- * Short.toString(getTransportBufferSize())));
- */
- /*
- * ref.add(new StringRefAddr("useArrayBinding",
- * Boolean.toString(getUseArrayBinding())));
- */
-
- // LOB Support - SB 9/28/04
- val = getClobTableName();
- if (val != null) {
- ref.add(new StringRefAddr("clobTableName", val));
- }
- val = getBlobTableName();
- if (val != null) {
- ref.add(new StringRefAddr("blobTableName", val));
-
- }
- ref.add(new StringRefAddr("reserveDataLocator", Long.toString(reserveDataLocator_)));
- ref.add(new StringRefAddr("roundingMode", Integer.toString(getRoundingMode())));
-
- // propertiy queryTimeout_ for future use.
- ref.add(new StringRefAddr("queryTimeout", Integer.toString(getQueryTimeout())));
- ref.add(new StringRefAddr("fetchBufferSize", Short.toString(this.getFetchBufferSize())));
- ref.add(new StringRefAddr("batchRecovery", Boolean.toString(this.getBatchRecovery())));
- return ref;
- }
-
- /**
- * Instantiated by either <code>
- * Class.forName("org.trafodion.jdbc.t4.T4Driver")</code>
- * or by passing <code>-Djdbc.drivers=org.trafodion.jdbc.t4.T4Driver</code>
- * property in the command line of the JDBC program.
- */
- DriverPropertyInfo[] getPropertyInfo(String url, Properties defaults) throws SQLException {
-
- String level[] = { "OFF", "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", "FINEST" };
- String roundingMode[] = { "ROUND_CEILING", "ROUND_DOWN", "ROUND_UP", "ROUND_FLOOR", "ROUND_HALF_UP",
- "ROUND_UNNECESSARY", "ROUND_HALF_EVEN", "ROUND_HALF_DOWN", "ROUND_DOWN" };
-
- Properties props = new Properties(defaults);
- props.setProperty("url", url);
-
- // catalog setting
- DriverPropertyInfo[] propertyInfo = {
- setPropertyInfo("catalog", props, true, "Database catalog name", null),
- setPropertyInfo("schema", props, true, "Database schema name", null),
- setPropertyInfo("url", props, false, "jdbc:t4jdbc://<host>:<port>/:", null),
- setPropertyInfo("user", props, true, "NSK safeguard user name", null),
- setPropertyInfo("password", props, true, "NSK safeguard user password", null),
- setPropertyInfo("maxPoolSize", props, false, "Maximum connection pool size", null),
- setPropertyInfo("minPoolSize", props, false, "Minimum connection pool size", null),
- setPropertyInfo("initialPoolSize", props, false, "Initial connection pool size", null),
- setPropertyInfo("maxStatements", props, false, "Maximum statement pool size", null),
- setPropertyInfo("T4LogLevel", props, false, "Logging Level", level),
- setPropertyInfo("T4LogFile", props, false, "Logging file location", null),
- setPropertyInfo("loginTimeout", props, false, "Login time out in secs", null),
- setPropertyInfo("networkTimeout", props, false, "Network time out in secs", null),
- setPropertyInfo("connectionTimeout", props, false, "Connection time out in secs", null),
- setPropertyInfo("maxIdleTime", props, false, "Max idle time for a free pool connection in secs", null),
- setPropertyInfo("language", props, false, "Locale language to use", null),
- setPropertyInfo("serverDataSource", props, false, "NDCS data source name", null),
- setPropertyInfo("roundingMode", props, false, "Data rounding mode", roundingMode),
- setPropertyInfo("blobTableName", props, false, "Table name to store and retrieve BLOB column data",
- null),
- setPropertyInfo("clobTableName", props, false, "Table name to store and retrieve CLOB column data",
- null),
- setPropertyInfo("reserveDataLocator", props, false,
- "Number of data locators (for LOB) to be reserved by the connection", null),
- setPropertyInfo("fetchBufferSize", props, false,
- "Value (in KB) for the size of the fetch buffer to be used when rows are fetched", null),
- setPropertyInfo("batchRecovery", props, false,
- "Continue batch processing of next commands even after errors", null) };
-
- return propertyInfo;
-
- }
-
- private DriverPropertyInfo setPropertyInfo(String name, Properties props, boolean required, String description,
- String[] choices) {
- String value = props.getProperty(name);
- DriverPropertyInfo propertyInfo = new DriverPropertyInfo(name, value);
- propertyInfo.required = required;
- propertyInfo.description = description;
- propertyInfo.choices = choices;
- return propertyInfo;
- }
-
- // ---------------------------------------------------------------
- static private Properties getPropertiesFileValues() {
- Properties values = null;
- String propsFile = System.getProperty("t4jdbc.properties");
-
- if (propsFile != null) {
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(new File(propsFile));
- values = new Properties();
- values.load(fis);
- } catch (Exception ex) {
- fis = null;
- // sqlExceptionMessage_ = "Error while loading " +
- // prefix_ + "properties file: " + ex.getMessage();
- } finally {
- if (fis != null) {
- try {
- fis.close();
- } catch (IOException ioe) {
- // ignore
- }
- }
- }
- } // end if
-
- return values;
- } // end getPropertiesFileValues
-
- // -------------------------------------------------------------------------
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4ResultSet.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4ResultSet.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4ResultSet.java
deleted file mode 100644
index 45410c7..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4ResultSet.java
+++ /dev/null
@@ -1,164 +0,0 @@
-// @@@ 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 T4ResultSet extends T4Connection {
- private String m_stmtLabel;
- static final short SQL_CLOSE = 0;
-
- boolean m_processing = false;
-
- T4ResultSet(InterfaceResultSet ir) throws SQLException {
- super(ir.ic_);
- m_stmtLabel = ir.stmtLabel_;
-
- if (m_stmtLabel == null) {
- throwInternalException();
-
- }
- }
-
- /**
- * This method will send a fetch rowset command to the server.
- *
- * @param maxRowCnt
- * the maximum rowset count to return
- * @param maxRowLen
- * the maximum row length to return
- * @param sqlAsyncEnable
- * a flag to enable/disable asynchronies execution
- * @param queryTimeout
- * the number of seconds before the query times out
- *
- * @retrun a FetchPerfReply class representing the reply from the ODBC
- * server is returned
- *
- * @exception A
- * SQLException is thrown
- */
-
- FetchReply Fetch(int sqlAsyncEnable, int queryTimeout, int stmtHandle, int stmtCharset, int maxRowCnt,
- String cursorName, int cursorCharset, String stmtOptions) throws SQLException {
-
- try {
- getInputOutput().setTimeout(m_ic.t4props_.getNetworkTimeout());
-
- LogicalByteArray wbuffer = FetchMessage.marshal(m_dialogueId, sqlAsyncEnable, queryTimeout, stmtHandle,
- m_stmtLabel, stmtCharset, maxRowCnt, 0 // infinite row size
- , cursorName, cursorCharset, stmtOptions, this.m_ic);
-
- LogicalByteArray rbuffer = getReadBuffer(TRANSPORT.SRVR_API_SQLFETCH, wbuffer);
-
- //
- // Process output parameters
- //
- FetchReply frr = new FetchReply(rbuffer, m_ic);
-
- return frr;
- } // end try
- catch (SQLException se) {
- throw se;
- } catch (CharacterCodingException e) {
- SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale,
- "translation_of_parameter_failed", "FetchMessage", 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, "fetch_perf_message_error", e
- .getMessage());
-
- se.initCause(e);
- throw se;
- } // end catch
-
- } // end FetchPerf
-
- /**
- * This method will send an close command, which does not return any
- * rowsets, to the ODBC server.
- *
- * @retrun A CloseReply class representing the reply from the ODBC server is
- * returned
- *
- * @exception A
- * SQLException is thrown
- */
-
- CloseReply Close() throws SQLException {
-
- try {
- getInputOutput().setTimeout(m_ic.t4props_.getNetworkTimeout());
-
- LogicalByteArray wbuffer = CloseMessage.marshal(m_dialogueId, m_stmtLabel, SQL_CLOSE, this.m_ic);
-
- LogicalByteArray rbuffer = getReadBuffer(TRANSPORT.SRVR_API_SQLFREESTMT, wbuffer);
-
- CloseReply cr = new CloseReply(rbuffer, m_ncsAddress.getIPorName(), m_ic);
-
- return cr;
- } // end try
- 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;
- } // end catch
-
- } // end Close
-
- // --------------------------------------------------------------------------------
- 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;
- }
-}
[37/60] incubator-trafodion git commit: Merge branch 'master' of
github.com:apache/incubator-trafodion into wrkbrnch
Posted by db...@apache.org.
Merge branch 'master' of github.com:apache/incubator-trafodion into wrkbrnch
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/5ac5a9f2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/5ac5a9f2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/5ac5a9f2
Branch: refs/heads/master
Commit: 5ac5a9f2ac17a45ff7b6c2f39254f26e550cb5e3
Parents: 72e1701 bc009d5
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Mon Apr 18 16:32:11 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Mon Apr 18 16:32:11 2016 +0000
----------------------------------------------------------------------
core/conn/jdbc_type2/build.xml | 6 +
core/conn/jdbc_type4/build.xml | 8 +
.../java/org/trafodion/rest/ServerResource.java | 2 +-
core/sqf/sqenvcom.sh | 17 +-
core/sqf/sql/scripts/ilh_cleanhb | 4 +-
core/sqf/sql/scripts/install_local_hadoop | 8 +-
core/sqf/sql/scripts/sqnodestatus | 4 +-
core/sqf/src/seatrans/.gitignore | 3 +
.../hbase/client/ClientScanner98.java.tmpl | 490 ++++
.../client/TrafParallelClientScanner.java.tmpl | 325 +++
.../hbase/client/transactional/RMInterface.java | 4 +-
.../transactional/SsccTransactionalTable.java | 8 +-
.../transactional/TransactionalTable.java | 8 +-
.../transactional/TransactionalTableClient.java | 3 +-
core/sql/arkcmp/CmpContext.h | 1 +
core/sql/bin/SqlciErrors.txt | 2 +-
core/sql/cli/Statement.cpp | 5 +-
core/sql/comexe/ComTdbHbaseAccess.h | 4 +
core/sql/comexe/ComTdbHdfsScan.h | 5 +-
core/sql/executor/ExHbaseIUD.cpp | 6 +-
core/sql/executor/ExHbaseSelect.cpp | 3 +
core/sql/executor/ExHdfsScan.cpp | 27 +-
core/sql/executor/ExHdfsScan.h | 99 +-
core/sql/executor/HBaseClient_JNI.cpp | 5 +-
core/sql/executor/HBaseClient_JNI.h | 1 +
core/sql/exp/ExpHbaseInterface.cpp | 4 +-
core/sql/exp/ExpHbaseInterface.h | 2 +
core/sql/exp/exp_datetime.cpp | 3 +-
core/sql/generator/GenExpGenerator.cpp | 47 +-
core/sql/generator/GenExplain.cpp | 7 +
core/sql/generator/GenPreCode.cpp | 96 +-
core/sql/generator/GenRelScan.cpp | 7 +-
core/sql/generator/GenRelUpdate.cpp | 24 -
core/sql/generator/Generator.cpp | 3 +
core/sql/generator/Generator.h | 2 +-
core/sql/optimizer/BindItemExpr.cpp | 22 +-
core/sql/optimizer/NARoutine.cpp | 47 +-
core/sql/optimizer/NARoutineDB.h | 4 +-
core/sql/optimizer/NATable.cpp | 1 +
core/sql/optimizer/RelExeUtil.cpp | 8 +-
core/sql/optimizer/RelExeUtil.h | 2 +
core/sql/optimizer/SynthType.cpp | 5 +-
core/sql/pom.xml.apache | 2 +-
core/sql/regress/core/EXPECTED116 | 102 +-
core/sql/regress/core/TEST116 | 18 +
core/sql/regress/executor/EXPECTED140 | 435 ++-
core/sql/regress/executor/TEST140 | 28 +-
core/sql/regress/hive/EXPECTED005 | 61 +
core/sql/regress/hive/TEST005 | 17 +
core/sql/regress/hive/TEST005_a.hive.sql | 18 +
core/sql/regress/hive/tbl_dos.data | 10 +
core/sql/regress/hive/tbl_dos_numeric.data | 10 +
core/sql/regress/seabase/EXPECTED027 | 98 +-
core/sql/regress/seabase/EXPECTED030 | 34 +-
core/sql/regress/seabase/EXPECTED031 | 24 +
core/sql/regress/seabase/TEST030 | 2 +
core/sql/regress/seabase/TEST031 | 8 +
core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp | 3 +-
core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp | 87 +-
core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp | 16 +-
core/sql/sqlcomp/CmpSeabaseDDLtable.cpp | 24 +-
core/sql/sqlcomp/DefaultConstants.h | 9 +
core/sql/sqlcomp/nadefaults.cpp | 7 +-
.../java/org/trafodion/sql/HTableClient.java | 7 +-
docs/.gitignore | 2 -
.../src/asciidoc/_chapters/introduction.adoc | 2 +-
.../src/asciidoc/_chapters/odb.adoc | 6 +-
.../src/asciidoc/_chapters/trickle_load.adoc | 2 +-
docs/shared/license.txt | 11 +
docs/spj_guide/pom.xml | 10 +-
.../spj_guide/src/asciidoc/_chapters/about.adoc | 31 +-
.../src/asciidoc/_chapters/create_spjs.adoc | 725 +++--
.../src/asciidoc/_chapters/deploy_spjs.adoc | 649 ++---
.../src/asciidoc/_chapters/develop_spjs.adoc | 171 +-
.../src/asciidoc/_chapters/execute_spjs.adoc | 625 ++--
.../src/asciidoc/_chapters/get_started.adoc | 57 +-
.../asciidoc/_chapters/grant_privileges.adoc | 254 +-
.../src/asciidoc/_chapters/introduction.adoc | 57 +-
.../_chapters/performance_troubleshooting.adoc | 461 +--
.../src/asciidoc/_chapters/sample_database.adoc | 826 +-----
.../src/asciidoc/_chapters/sample_spjs.adoc | 2678 ++++++------------
docs/spj_guide/src/asciidoc/index.adoc | 61 +-
.../src/images/call-statement-elements.jpg | Bin 0 -> 33415 bytes
.../src/resources/acknowledgements.txt | 38 +
.../src/resources/source/Inventory.java | 120 +
.../spj_guide/src/resources/source/Payroll.java | 151 +
docs/spj_guide/src/resources/source/Sales.java | 346 +++
.../src/resources/source/adjustSalary.java | 41 +
.../src/resources/source/employeeJob.java | 32 +
.../resources/source/invent_partloc_table.sql | 56 +
.../resources/source/invent_partsupp_table.sql | 128 +
.../src/resources/source/invent_schema.sql | 2 +
.../resources/source/invent_supplier_table.sql | 35 +
.../src/resources/source/lowerPrice.java | 44 +
.../src/resources/source/numDailyOrders.java | 29 +
.../src/resources/source/numMonthlyOrders.java | 41 +
.../src/resources/source/orderSummary.java | 76 +
.../src/resources/source/partData.java | 103 +
.../src/resources/source/partlocations.java | 42 +
.../src/resources/source/persnl_dept_table.sql | 70 +
.../resources/source/persnl_employee_table.sql | 99 +
.../src/resources/source/persnl_job_table.sql | 20 +
.../resources/source/persnl_project_table.sql | 45 +
.../src/resources/source/persnl_schema.sql | 2 +
.../src/resources/source/projectTeam.java | 25 +
.../resources/source/sales_customer_table.sql | 30 +
.../resources/source/sales_odetail_table.sql | 84 +
.../src/resources/source/sales_orders_table.sql | 66 +
.../src/resources/source/sales_parts_table.sql | 45 +
.../src/resources/source/sales_schema.sql | 2 +
.../src/resources/source/supplierinfo.java | 38 +
.../src/resources/source/supplyquantities.java | 32 +
.../src/resources/source/topSalesReps.java | 43 +
.../src/resources/source/totalPrice.java | 47 +
.../src/asciidoc/_chapters/sql_statements.adoc | 163 +-
docs/src/site/markdown/documentation.md | 63 +-
docs/src/site/markdown/index.md | 25 +-
.../resources/images/logo-carousel/slide-1.png | Bin 0 -> 58887 bytes
.../resources/images/logo-carousel/slide-2.png | Bin 0 -> 57783 bytes
docs/src/site/site.xml | 14 +-
install/Makefile | 2 +-
install/installer/acceptKeys | 61 +
pom.xml | 5 +-
tests/phx/phoenix_test.py | 10 +-
124 files changed, 6537 insertions(+), 4718 deletions(-)
----------------------------------------------------------------------
[36/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
TRAFODION-1933 JDBC TYpe4 driver build scripts migrated to use maven instead of ant
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/72e17019
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/72e17019
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/72e17019
Branch: refs/heads/master
Commit: 72e170198fa80baa9891fc40fc7b66da8cbb6a32
Parents: b7ecf18
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Mon Apr 18 16:11:06 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Mon Apr 18 16:11:06 2016 +0000
----------------------------------------------------------------------
core/Makefile | 9 +-
.../jdbcT4/src/main/java/T4Messages.properties | 686 ++
.../java/org/trafodion/jdbc/t4/Address.java | 117 +
.../java/org/trafodion/jdbc/t4/BaseRow.java | 65 +
.../main/java/org/trafodion/jdbc/t4/Bytes.java | 269 +
.../jdbc/t4/CONNECTION_CONTEXT_def.java | 149 +
.../jdbc/t4/CachedPreparedStatement.java | 67 +
.../org/trafodion/jdbc/t4/CancelMessage.java | 49 +
.../java/org/trafodion/jdbc/t4/CancelReply.java | 38 +
.../java/org/trafodion/jdbc/t4/Certificate.java | 112 +
.../main/java/org/trafodion/jdbc/t4/Cipher.java | 201 +
.../org/trafodion/jdbc/t4/CloseMessage.java | 48 +
.../java/org/trafodion/jdbc/t4/CloseReply.java | 48 +
.../java/org/trafodion/jdbc/t4/Compression.java | 149 +
.../org/trafodion/jdbc/t4/ConnectMessage.java | 62 +
.../org/trafodion/jdbc/t4/ConnectReply.java | 148 +
.../java/org/trafodion/jdbc/t4/Descriptor2.java | 85 +
.../trafodion/jdbc/t4/ERROR_DESC_LIST_def.java | 42 +
.../org/trafodion/jdbc/t4/ERROR_DESC_def.java | 65 +
.../jdbc/t4/EndTransactionMessage.java | 49 +
.../trafodion/jdbc/t4/EndTransactionReply.java | 49 +
.../org/trafodion/jdbc/t4/ExecuteMessage.java | 107 +
.../org/trafodion/jdbc/t4/ExecuteReply.java | 127 +
.../org/trafodion/jdbc/t4/FetchMessage.java | 63 +
.../java/org/trafodion/jdbc/t4/FetchReply.java | 63 +
.../org/trafodion/jdbc/t4/GenericMessage.java | 45 +
.../org/trafodion/jdbc/t4/GenericReply.java | 43 +
.../jdbc/t4/GetSQLCatalogsMessage.java | 88 +
.../trafodion/jdbc/t4/GetSQLCatalogsReply.java | 54 +
.../jdbc/t4/HPT4ConnectionPoolDataSource.java | 346 +
.../t4/HPT4ConnectionPoolDataSourceFactory.java | 68 +
.../org/trafodion/jdbc/t4/HPT4DataSource.java | 366 ++
.../jdbc/t4/HPT4DataSourceFactory.java | 62 +
.../java/org/trafodion/jdbc/t4/HPT4Desc.java | 542 ++
.../org/trafodion/jdbc/t4/HPT4Exception.java | 38 +
.../java/org/trafodion/jdbc/t4/HPT4Handle.java | 84 +
.../org/trafodion/jdbc/t4/HPT4Messages.java | 324 +
.../jdbc/t4/HPT4ParameterMetaData.java | 243 +
.../trafodion/jdbc/t4/HPT4PooledConnection.java | 238 +
.../jdbc/t4/HPT4PooledConnectionManager.java | 385 ++
.../jdbc/t4/HPT4ResultSetMetaData.java | 309 +
.../main/java/org/trafodion/jdbc/t4/Header.java | 157 +
.../jdbc/t4/InitializeDialogueMessage.java | 66 +
.../jdbc/t4/InitializeDialogueReply.java | 90 +
.../java/org/trafodion/jdbc/t4/InputOutput.java | 682 ++
.../java/org/trafodion/jdbc/t4/InsertRow.java | 82 +
.../trafodion/jdbc/t4/InterfaceConnection.java | 1420 +++++
.../trafodion/jdbc/t4/InterfaceResultSet.java | 927 +++
.../trafodion/jdbc/t4/InterfaceStatement.java | 1392 +++++
.../trafodion/jdbc/t4/InterfaceUtilities.java | 235 +
.../main/java/org/trafodion/jdbc/t4/Key.java | 161 +
.../org/trafodion/jdbc/t4/LogicalByteArray.java | 345 +
.../org/trafodion/jdbc/t4/MessageDigest.java | 84 +
.../java/org/trafodion/jdbc/t4/NCSAddress.java | 220 +
.../jdbc/t4/OUT_CONNECTION_CONTEXT_def.java | 97 +
.../org/trafodion/jdbc/t4/PrepareMessage.java | 82 +
.../org/trafodion/jdbc/t4/PrepareReply.java | 103 +
.../jdbc/t4/PreparedStatementManager.java | 242 +
.../main/java/org/trafodion/jdbc/t4/Row.java | 233 +
.../trafodion/jdbc/t4/SQLItemDescList_def.java | 46 +
.../trafodion/jdbc/t4/SQLItemDescOld_def.java | 54 +
.../org/trafodion/jdbc/t4/SQLItemDesc_def.java | 70 +
.../org/trafodion/jdbc/t4/SQLValueList_def.java | 64 +
.../org/trafodion/jdbc/t4/SQLValue_def.java | 55 +
.../trafodion/jdbc/t4/SQLWarningOrError.java | 47 +
.../trafodion/jdbc/t4/SQL_DataValue_def.java | 54 +
.../org/trafodion/jdbc/t4/SecClientMsgKeys.java | 58 +
.../main/java/org/trafodion/jdbc/t4/SecPwd.java | 274 +
.../trafodion/jdbc/t4/SecResourceBundle.java | 57 +
.../org/trafodion/jdbc/t4/SecdefsCommon.java | 84 +
.../java/org/trafodion/jdbc/t4/Security.java | 319 +
.../trafodion/jdbc/t4/SecurityException.java | 47 +
.../jdbc/t4/SetConnectionOptionMessage.java | 50 +
.../jdbc/t4/SetConnectionOptionReply.java | 45 +
.../java/org/trafodion/jdbc/t4/SymCrypto.java | 87 +
.../java/org/trafodion/jdbc/t4/T4Address.java | 315 +
.../org/trafodion/jdbc/t4/T4Connection.java | 505 ++
.../org/trafodion/jdbc/t4/T4DSProperties.java | 967 +++
.../trafodion/jdbc/t4/T4DatabaseMetaData.java | 5901 ++++++++++++++++++
.../java/org/trafodion/jdbc/t4/T4Driver.java | 367 ++
.../org/trafodion/jdbc/t4/T4LogFormatter.java | 236 +
.../trafodion/jdbc/t4/T4LoggingUtilities.java | 816 +++
.../org/trafodion/jdbc/t4/T4Properties.java | 2511 ++++++++
.../java/org/trafodion/jdbc/t4/T4ResultSet.java | 164 +
.../java/org/trafodion/jdbc/t4/T4Statement.java | 204 +
.../org/trafodion/jdbc/t4/T4TimerThread.java | 116 +
.../org/trafodion/jdbc/t4/T4_Dcs_Cancel.java | 115 +
.../org/trafodion/jdbc/t4/T4_Dcs_Connect.java | 123 +
.../java/org/trafodion/jdbc/t4/TRANSPORT.java | 263 +
.../jdbc/t4/TerminateDialogueMessage.java | 38 +
.../jdbc/t4/TerminateDialogueReply.java | 39 +
.../jdbc/t4/TrafT4CallableStatement.java | 2462 ++++++++
.../org/trafodion/jdbc/t4/TrafT4Connection.java | 1987 ++++++
.../jdbc/t4/TrafT4PreparedStatement.java | 2558 ++++++++
.../org/trafodion/jdbc/t4/TrafT4ResultSet.java | 5389 ++++++++++++++++
.../org/trafodion/jdbc/t4/TrafT4Statement.java | 1690 +++++
.../org/trafodion/jdbc/t4/USER_DESC_def.java | 61 +
.../java/org/trafodion/jdbc/t4/Utility.java | 636 ++
.../org/trafodion/jdbc/t4/VERSION_LIST_def.java | 65 +
.../java/org/trafodion/jdbc/t4/VERSION_def.java | 61 +
.../java/org/trafodion/jdbc/t4/Vproc.java-tmpl | 36 +
.../jdbc/t4/odbc_Dcs_GetObjRefHdl_exc_.java | 95 +
.../jdbc/t4/odbc_Dcs_StopSrvr_exc_.java | 86 +
.../jdbc/t4/odbc_SQLSvc_Close_exc_.java | 69 +
.../t4/odbc_SQLSvc_EndTransaction_exc_.java | 87 +
.../jdbc/t4/odbc_SQLSvc_Execute_exc_.java | 89 +
.../jdbc/t4/odbc_SQLSvc_Fetch_exc_.java | 87 +
.../t4/odbc_SQLSvc_GetSQLCatalogs_exc_.java | 100 +
.../t4/odbc_SQLSvc_InitializeDialogue_exc_.java | 76 +
.../jdbc/t4/odbc_SQLSvc_Prepare_exc_.java | 68 +
.../odbc_SQLSvc_SetConnectionOption_exc_.java | 70 +
.../t4/odbc_SQLSvc_TerminateDialogue_exc_.java | 66 +
.../jdbcT4/src/main/java/secClient.properties | 53 +
.../CallableStatementSample.java | 83 -
.../CallableStatementSample/IntegerSPJ.java | 28 -
.../samples/CallableStatementSample/README | 42 -
.../samples/DBMetaSample/DBMetaSample.java | 132 -
.../conn/jdbc_type4/samples/DBMetaSample/README | 904 ---
.../PreparedStatementSample.java | 151 -
.../samples/PreparedStatementSample/README | 232 -
core/conn/jdbc_type4/samples/README | 47 -
.../jdbc_type4/samples/ResultSetSample/README | 91 -
.../ResultSetSample/ResultSetSample.java | 104 -
.../jdbc_type4/samples/StatementSample/README | 92 -
.../StatementSample/StatementSample.java | 104 -
core/conn/jdbc_type4/samples/build.xml | 44 -
.../jdbc_type4/samples/common/sampleUtils.java | 268 -
core/conn/jdbc_type4/samples/t4jdbc.properties | 26 -
core/conn/jdbc_type4/src/T4Messages.properties | 686 --
.../src/org/trafodion/jdbc/t4/Address.java | 117 -
.../src/org/trafodion/jdbc/t4/BaseRow.java | 65 -
.../src/org/trafodion/jdbc/t4/Bytes.java | 269 -
.../jdbc/t4/CONNECTION_CONTEXT_def.java | 149 -
.../jdbc/t4/CachedPreparedStatement.java | 67 -
.../org/trafodion/jdbc/t4/CancelMessage.java | 49 -
.../src/org/trafodion/jdbc/t4/CancelReply.java | 38 -
.../src/org/trafodion/jdbc/t4/Certificate.java | 112 -
.../src/org/trafodion/jdbc/t4/Cipher.java | 201 -
.../src/org/trafodion/jdbc/t4/CloseMessage.java | 48 -
.../src/org/trafodion/jdbc/t4/CloseReply.java | 48 -
.../src/org/trafodion/jdbc/t4/Compression.java | 149 -
.../org/trafodion/jdbc/t4/ConnectMessage.java | 62 -
.../src/org/trafodion/jdbc/t4/ConnectReply.java | 148 -
.../src/org/trafodion/jdbc/t4/Descriptor2.java | 85 -
.../trafodion/jdbc/t4/ERROR_DESC_LIST_def.java | 42 -
.../org/trafodion/jdbc/t4/ERROR_DESC_def.java | 65 -
.../jdbc/t4/EndTransactionMessage.java | 49 -
.../trafodion/jdbc/t4/EndTransactionReply.java | 49 -
.../org/trafodion/jdbc/t4/ExecuteMessage.java | 107 -
.../src/org/trafodion/jdbc/t4/ExecuteReply.java | 127 -
.../src/org/trafodion/jdbc/t4/FetchMessage.java | 63 -
.../src/org/trafodion/jdbc/t4/FetchReply.java | 63 -
.../org/trafodion/jdbc/t4/GenericMessage.java | 45 -
.../src/org/trafodion/jdbc/t4/GenericReply.java | 43 -
.../jdbc/t4/GetSQLCatalogsMessage.java | 88 -
.../trafodion/jdbc/t4/GetSQLCatalogsReply.java | 54 -
.../jdbc/t4/HPT4ConnectionPoolDataSource.java | 346 -
.../t4/HPT4ConnectionPoolDataSourceFactory.java | 68 -
.../org/trafodion/jdbc/t4/HPT4DataSource.java | 366 --
.../jdbc/t4/HPT4DataSourceFactory.java | 62 -
.../src/org/trafodion/jdbc/t4/HPT4Desc.java | 542 --
.../org/trafodion/jdbc/t4/HPT4Exception.java | 38 -
.../src/org/trafodion/jdbc/t4/HPT4Handle.java | 84 -
.../src/org/trafodion/jdbc/t4/HPT4Messages.java | 324 -
.../jdbc/t4/HPT4ParameterMetaData.java | 243 -
.../trafodion/jdbc/t4/HPT4PooledConnection.java | 238 -
.../jdbc/t4/HPT4PooledConnectionManager.java | 385 --
.../jdbc/t4/HPT4ResultSetMetaData.java | 309 -
.../src/org/trafodion/jdbc/t4/Header.java | 157 -
.../jdbc/t4/InitializeDialogueMessage.java | 66 -
.../jdbc/t4/InitializeDialogueReply.java | 90 -
.../src/org/trafodion/jdbc/t4/InputOutput.java | 682 --
.../src/org/trafodion/jdbc/t4/InsertRow.java | 82 -
.../trafodion/jdbc/t4/InterfaceConnection.java | 1420 -----
.../trafodion/jdbc/t4/InterfaceResultSet.java | 927 ---
.../trafodion/jdbc/t4/InterfaceStatement.java | 1392 -----
.../trafodion/jdbc/t4/InterfaceUtilities.java | 235 -
.../src/org/trafodion/jdbc/t4/Key.java | 161 -
.../org/trafodion/jdbc/t4/LogicalByteArray.java | 345 -
.../org/trafodion/jdbc/t4/MessageDigest.java | 84 -
.../src/org/trafodion/jdbc/t4/NCSAddress.java | 220 -
.../jdbc/t4/OUT_CONNECTION_CONTEXT_def.java | 97 -
.../org/trafodion/jdbc/t4/PrepareMessage.java | 82 -
.../src/org/trafodion/jdbc/t4/PrepareReply.java | 103 -
.../jdbc/t4/PreparedStatementManager.java | 242 -
.../src/org/trafodion/jdbc/t4/Row.java | 233 -
.../trafodion/jdbc/t4/SQLItemDescList_def.java | 46 -
.../trafodion/jdbc/t4/SQLItemDescOld_def.java | 54 -
.../org/trafodion/jdbc/t4/SQLItemDesc_def.java | 70 -
.../org/trafodion/jdbc/t4/SQLValueList_def.java | 64 -
.../src/org/trafodion/jdbc/t4/SQLValue_def.java | 55 -
.../trafodion/jdbc/t4/SQLWarningOrError.java | 47 -
.../trafodion/jdbc/t4/SQL_DataValue_def.java | 54 -
.../org/trafodion/jdbc/t4/SecClientMsgKeys.java | 58 -
.../src/org/trafodion/jdbc/t4/SecPwd.java | 274 -
.../trafodion/jdbc/t4/SecResourceBundle.java | 57 -
.../org/trafodion/jdbc/t4/SecdefsCommon.java | 84 -
.../src/org/trafodion/jdbc/t4/Security.java | 319 -
.../trafodion/jdbc/t4/SecurityException.java | 47 -
.../jdbc/t4/SetConnectionOptionMessage.java | 50 -
.../jdbc/t4/SetConnectionOptionReply.java | 45 -
.../src/org/trafodion/jdbc/t4/SymCrypto.java | 87 -
.../src/org/trafodion/jdbc/t4/T4Address.java | 315 -
.../src/org/trafodion/jdbc/t4/T4Connection.java | 505 --
.../org/trafodion/jdbc/t4/T4DSProperties.java | 967 ---
.../trafodion/jdbc/t4/T4DatabaseMetaData.java | 5901 ------------------
.../src/org/trafodion/jdbc/t4/T4Driver.java | 367 --
.../org/trafodion/jdbc/t4/T4LogFormatter.java | 236 -
.../trafodion/jdbc/t4/T4LoggingUtilities.java | 816 ---
.../src/org/trafodion/jdbc/t4/T4Properties.java | 2511 --------
.../src/org/trafodion/jdbc/t4/T4ResultSet.java | 164 -
.../src/org/trafodion/jdbc/t4/T4Statement.java | 204 -
.../org/trafodion/jdbc/t4/T4TimerThread.java | 116 -
.../org/trafodion/jdbc/t4/T4_Dcs_Cancel.java | 115 -
.../org/trafodion/jdbc/t4/T4_Dcs_Connect.java | 123 -
.../src/org/trafodion/jdbc/t4/TRANSPORT.java | 263 -
.../jdbc/t4/TerminateDialogueMessage.java | 38 -
.../jdbc/t4/TerminateDialogueReply.java | 39 -
.../jdbc/t4/TrafT4CallableStatement.java | 2462 --------
.../org/trafodion/jdbc/t4/TrafT4Connection.java | 1987 ------
.../jdbc/t4/TrafT4PreparedStatement.java | 2558 --------
.../org/trafodion/jdbc/t4/TrafT4ResultSet.java | 5389 ----------------
.../org/trafodion/jdbc/t4/TrafT4Statement.java | 1690 -----
.../org/trafodion/jdbc/t4/USER_DESC_def.java | 61 -
.../src/org/trafodion/jdbc/t4/Utility.java | 636 --
.../org/trafodion/jdbc/t4/VERSION_LIST_def.java | 65 -
.../src/org/trafodion/jdbc/t4/VERSION_def.java | 61 -
.../src/org/trafodion/jdbc/t4/Vproc.java | 36 -
.../jdbc/t4/odbc_Dcs_GetObjRefHdl_exc_.java | 95 -
.../jdbc/t4/odbc_Dcs_StopSrvr_exc_.java | 86 -
.../jdbc/t4/odbc_SQLSvc_Close_exc_.java | 69 -
.../t4/odbc_SQLSvc_EndTransaction_exc_.java | 87 -
.../jdbc/t4/odbc_SQLSvc_Execute_exc_.java | 89 -
.../jdbc/t4/odbc_SQLSvc_Fetch_exc_.java | 87 -
.../t4/odbc_SQLSvc_GetSQLCatalogs_exc_.java | 100 -
.../t4/odbc_SQLSvc_InitializeDialogue_exc_.java | 76 -
.../jdbc/t4/odbc_SQLSvc_Prepare_exc_.java | 68 -
.../odbc_SQLSvc_SetConnectionOption_exc_.java | 70 -
.../t4/odbc_SQLSvc_TerminateDialogue_exc_.java | 66 -
core/conn/jdbc_type4/src/secClient.properties | 53 -
core/conn/trafci/install/Installer.java | 2 +-
241 files changed, 42697 insertions(+), 45048 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/Makefile
----------------------------------------------------------------------
diff --git a/core/Makefile b/core/Makefile
index 99fdd5e..6c4b865 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -68,10 +68,7 @@ foundation: sqroot dbsecurity $(MPI_TARGET) $(SEAMONSTER_TARGET)
cd sqf && $(MAKE) all
jdbc_jar: verhdr
- cd conn/jdbc_type4 && $(ANT) deploy 2>&1 | sed -e "s/$$/ ##(JDBCT4)/";exit $${PIPESTATUS[0]}
- $(MAVEN) install:install-file -Dfile=conn/jdbc_type4/lib/jdbcT4.jar \
- -DgroupId=org.trafodion.jdbc.t4.T4Driver -DartifactId=t4driver -Dversion="$$TRAFODION_VER" \
- -Dpackaging=jar -DgeneratePom=true | sed -e "s/$$/ ##(JDBCT4)/";exit $${PIPESTATUS[0]}
+ cd conn/jdbcT4 && $(MAKE) 2>&1 && $(MAVEN) install | sed -e "s/$$/ ##(JDBCT4)/";exit $${PIPESTATUS[0]}
dcs: jdbc_jar jdbc_type2_jar
cd ../dcs && $(MAKE) 2>&1 | sed -e "s/$$/ ##(DCS)/" ; exit $${PIPESTATUS[0]}
@@ -109,7 +106,7 @@ clean: sqroot
cd sqf && $(MAKE) clean
cd conn/odbc/src/odbc && $(MAKE) clean
cd conn/trafci && $(ANT) clean
- cd conn/jdbc_type4 && $(ANT) clean
+ cd conn/jdbcT4 && $(MAKE) clean
cd conn && $(MAKE) clean
cd conn/jdbc_type2 && $(ANT) clean && $(MAKE) clean
cd rest && $(MAKE) clean
@@ -123,7 +120,7 @@ cleanall: sqroot eclipseclean cleantests
cd sqf && $(MAKE) cleanall
cd conn/odbc/src/odbc && $(MAKE) cleanall
cd conn/trafci && $(ANT) clean
- cd conn/jdbc_type4 && $(ANT) clean
+ cd conn/jdbcT4 && $(MAKE) clean
cd conn && $(MAKE) clean
cd conn/jdbc_type2 && $(ANT) clean && $(MAKE) clean
cd rest && $(MAKE) clean
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/T4Messages.properties
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/T4Messages.properties b/core/conn/jdbcT4/src/main/java/T4Messages.properties
new file mode 100644
index 0000000..24d6fb1
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/T4Messages.properties
@@ -0,0 +1,686 @@
+# @@@ 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 @@@
+##############################################################
+
+#
+# Messages for T2 Driver
+#
+
+unsupported_feature_msg=Unsupported feature - {0}
+unsupported_feature_sqlstate=HYC00
+unsupported_feature_sqlcode=29001
+
+invalid_connection_msg=Connection does not exist
+invalid_connection_sqlstate=08003
+invalid_connection_sqlcode=29002
+
+invalid_statement_msg=Statement does not exist
+invalid_statement_sqlstate=HY000
+invalid_statement_sqlcode=29003
+
+invalid_transaction_isolation_msg=Invalid transaction isolation value
+invalid_transaction_isolation_sqlstate=HY024
+invalid_transaction_isolation_sqlcode=29004
+
+invalid_resultset_type_msg=Invalid ResultSet Type
+invalid_resultset_type_sqlstate=HY024
+invalid_resultset_type_sqlcode=29005
+
+invalid_resultset_concurrency_msg=Invalid Result Set Concurrency
+invalid_resultset_concurrency_sqlstate=HY000
+invalid_resultset_concurrency_sqlcode=29006
+
+invalid_desc_index_msg=Invalid descriptor index
+invalid_desc_index_sqlstate=07009
+invalid_desc_index_sqlcode=29007
+
+invalid_cursor_state_msg=Invalid cursor State
+invalid_cursor_state_sqlstate=24000
+invalid_cursor_state_sqlcode=29008
+
+invalid_cursor_position_msg=Invalid cursor position
+invalid_cursor_position_sqlstate=HY109
+invalid_cursor_position_sqlcode=29009
+
+invalid_column_name_msg=Invalid column name
+invalid_column_name_sqlstate=07009
+invalid_column_name_sqlcode=29010
+
+invalid_column_index_msg=Invalid column index or descriptor index
+invalid_column_index_sqlstate=07009
+invalid_column_index_sqlcode=29011
+
+restricted_data_type_msg=Restricted data type attribute violation
+restricted_data_type_sqlstate=07006
+restricted_data_type_sqlcode=29012
+
+invalid_fetch_size_msg=Fetch size is less than 0
+invalid_fetch_size_sqlstate=HY024
+invalid_fetch_size_sqlcode=29013
+
+fetch_output_inconsistent_msg=General Error - Programming error in next()
+fetch_output_inconsistent_sqlstate=HY000
+fetch_output_inconsistent_sqlcode=29014
+
+invalid_fetch_direction_msg=Invalid fetch direction
+invalid_fetch_direction_sqlstate=HY024
+invalid_fetch_direction_sqlcode=29015
+
+reverse_fetch_not_supported_msg=ResultSet.FETCH_REVERSE not supported
+reverse_fetch_not_supported_sqlstate=HYC00
+reverse_fetch_not_supported_sqlcode=29016
+
+datatype_not_supported_msg=SQL Data type not supported
+datatype_not_supported_sqlstate=HY004
+datatype_not_supported_sqlcode=29017
+
+invalid_cast_specification_msg=Invalid character value in cast specification
+invalid_cast_specification_sqlstate=22018
+invalid_cast_specification_sqlcode=29018
+
+parameter_not_set_msg=Parameter {0, number, integer} for {1, number, integer} set of parameters is not set
+parameter_not_set_sqlstate=07002
+parameter_not_set_sqlcode=29019
+
+invalid_parameter_index_msg=Invalid Parameter Index
+invalid_parameter_index_sqlstate=07009
+invalid_parameter_index_sqlcode=29020
+
+object_type_not_supported_msg=Object Type Not Supported
+object_type_not_supported_sqlstate=HY004
+object_type_not_supported_sqlcode=29021
+
+function_sequence_error_msg=Function Sequence Error
+function_sequence_error_sqlstate=HY010
+function_sequence_error_sqlcode=29022
+
+commit_not_allowed_msg=Commit not allowed in Transaction Aware driver
+commit_not_allowd_sqlstate=HY000
+commit_not_allowd_sqlcode=29023
+
+rollback_not_allowed_msg=Rollback not allowed in Transaction Aware Driver
+rollback_not_allowed_sqlstate=HY000
+rollback_not_allowed_sqlcode=29024
+
+setautocommit_not_allowed_msg=SetAutoCommit not allowed in Transaction Aware Driver
+setautocommit_not_allowed_sqlstate=HY000
+setautocommit_not_allowed_sqlcode=29025
+
+invalid_commit_mode_msg=Transaction can't be committed or rolled back when AutoCommit mode is on
+invalid_commit_mode_sqlstate=HY000
+invalid_commit_mode_sqlcode=29026
+
+autocommit_txn_in_progress_msg=SetAutoCommit not possible, since a transaction is active
+autocommit_txn_in_progress_sqlstate=HY011
+autocommit_txn_in_progress_sqlcode=29027
+
+read_only_connect_msg=Connection is set to read only
+read_only_connect_sqlstate=HY000
+read_only_connect_sqlcode=29028
+
+txn_isolation_txn_in_progress_msg=SetTransactionIsolation not possible, since a transaction is active
+txn_isolation_txn_in_progress_sqlstate=HY011
+txn_isolation_txn_in_progress_sqlcode=29029
+
+forward_only_cursor_msg=Result Set type is TYPE_FORWARD_ONLY
+forward_only_cursor_sqlstate=HY109
+forward_only_cursor_sqlcode=29029
+
+read_only_concur_msg=Result Set Concurrecy is CONCUR_READ_ONLY
+read_only_concur_sqlstate=HY109
+read_only_concur_sqlcode=29030
+
+select_in_batch_not_supported_msg=SELECT sql statements in batch is illgeal
+select_in_batch_not_supported_sqlstate=HY000
+select_in_batch_not_supported_sqlcode=29031
+
+row_modified_msg=The row is modified since it is last read
+row_modified_sqlstate=23000
+row_modified_sqlcode=29032
+
+primary_key_not_updateable_msg=The primary key column value can't be updated
+primary_key_not_updateable_sqlstate=23000
+primary_key_not_updateable_sqlcode=29033
+
+deprecated_method_msg=The method {0} is deprecated
+deprecated_method_sqlstate=HY000
+deprecated_method_sqlcode=29034
+
+io_exception_msg=IO Exception occurred {0}
+io_exception_sqlstate=HY000
+io_exception_sqlcode=29035
+
+unsupported_encoding_msg=Unsupported encoding {0}
+unsupported_encoding_sqlstate=HY000
+unsupported_encoding_sqlcode=29036
+
+forward_only_cursor_msg=The Result Set Type is TYPE_FORWARD_ONLY
+forward_only_cursor_sqlstate=HY106
+forward_only_cursor_sqlcode=29037
+
+invalid_row_number_msg=The row number is not valid
+invalid_row_number_sqlstate=HY107
+invalid_row_number_sqlcode=29038
+
+read_only_concur_msg=The concurrency mode of the result set is CONCUR_READ_ONLY
+read_only_concur_sqlstate=HY092
+read_only_concur_sqlcode=29039
+
+invalid_operation_msg=Operation invalid, since the current row is insert row
+invalid_operation_sqlstate=HY000
+invalid_operation_sqlcode=29040
+
+no_primary_key_msg=Operation not allowed since there is no primary key for the table
+no_primary_key_sqlstate=HY000
+no_primary_key_sqlcode=29041
+
+invalid_fetchSize_value_msg=Fetch size value is not valid
+invalid_fetchSize_value_sqlstate=HY000
+invalid_fetchSize_value_sqlcode=29042
+
+invalid_maxRows_value_msg=Max rows value is not valid
+invalid_maxRows_value_sqlstate=HY000
+invalid_maxRows_value_sqlcode=29043
+
+invalid_queryTimeout_value_msg=Query timeout value is not valid
+invalid_queryTimeout_value_sqlstate=HY000
+invalid_queryTimeout_value_sqlcode=29044
+
+data_truncation_msg=Fractional truncation
+data_truncation_sqlstate=01S07
+data_truncation_sqlcode=29045
+
+numeric_out_of_range_msg=Numeric value out of range
+numeric_out_of_range_sqlstate=22003
+numeric_out_of_range_sqlcode=29046
+
+batch_command_failed_msg=Batch Update Failed, See next exception for details
+batch_command_failed_sqlstate=HY000
+batch_command_failed_sqlcode=29047
+
+invalid_use_of_null_msg=Invalid use of null
+invalid_use_of_null_sqlstate=HY009
+invalid_use_of_null_sqlcode=29048
+
+invalid_transaction_state_msg=Invalid transaction state
+invalid_transaction_state_sqlstate=25000
+invalid_transaction_state_sqlcode=29049
+
+invalid_row_msg=Row value out of range
+invalid_row_sqlstate=HY107
+invalid_row_sqlcode=29050
+
+scrollResultSetChanged_msg=Result Set Type changed to TYPE_SCROLL_INSENSITIVE
+scrollResultSetChanged_sqlstate=01S02
+scrollResultSetChanged_sqlcode=29051
+
+invalid_holdability_state_msg=Invalid cursor holdability
+invalid_holdability_state_sqlstate=25000
+invalid_holdability_state_sqlcode=29052
+
+select_invalid_msg=Select SQL statement is invalid in executeUpdate() method
+select_invalid_sqlstate=HY000
+select_invalid_sqlcode=29053
+
+non_select_invalid_msg=Non-Select SQL statement is invalid in executeQuery() method
+non_select_invalid_sqlstate=HY000
+non_select_invalid_sqlcode=29054
+
+connection_in_use_msg=Connection is in use
+connection_in_use_sqlstate=HY000
+connection_in_use_sqlcode=29055
+
+stmt_closed_msg=Statement is already closed
+stmt_closed_sqlstate=HY000
+stmt_closed_sqlcode=29056
+
+auto_generated_keys_not_supported_msg=Auto generated keys not supported
+auto_generated_keys_not_supported_sqlstate=HY000
+auto_generated_keys_not_supported_sqlcode=29057
+
+null_pooled_connection_msg=Connection is not associated with a PooledConnection object
+null_pooled_connection_sqlstate=HY000
+null_pooled_connection_sqlcode=29058
+
+#
+# New messages for T4 driver
+#
+
+internal_error_msg=An internal error occurred
+internal_error_sqlstate=HY000
+internal_error_sqlcode=29100
+
+contact_hp_error_msg=Contact your service provider
+contact_hp_error_sqlstate=HY000
+contact_hp_error_sqlcode=29101
+
+address_parsing_error_msg=Error while parsing address {0}
+address_parsing_error_sqlstate=HY000
+address_parsing_error_sqlcode=29102
+
+address_null_error_msg=Address is null
+address_null_error_sqlstate=HY000
+address_null_error_sqlcode=29103
+
+odbc_server_suffix_error_msg=Expected suffix: {0}
+odbc_server_suffix_error_sqlstate=HY000
+odbc_server_suffix_error_sqlcode=29104
+
+unknown_prefix_error_msg=Unknown prefix for address
+unknown_prefix_error_sqlstate=HY000
+unknown_prefix_error_sqlcode=29105
+
+jdbc_address_error_msg=Expected address format: jdbc:subprotocol:subname
+jdbc_address_error_sqlstate=HY000
+jdbc_address_error_sqlcode=29106
+
+min_address_length_error_msg=Address is not long enough to be a valid address
+min_address_length_error_sqlstate=HY000
+min_address_length_error_sqlcode=29107
+
+address_format_1_error_msg=Expecting \\<machine name>.<process name>/<port number>
+address_format_1_error_sqlstate=HY000
+address_format_1_error_sqlcode=29108
+
+address_format_2_error_msg=//<{IP Address|Machine Name}[:port]>/<database name>
+address_format_2_error_sqlstate=HY000
+address_format_2_error_sqlcode=29109
+
+missing ip_or_name_error_msg=Address is missing an IP address or machine name
+missing ip_or_name_error_sqlstate=HY000
+missing ip_or_name_error_sqlcode=29110
+
+address_lookup_error_msg=Unable to evaluate address {0} Cause: {1}
+address_lookup_error_sqlstate=HY000
+address_lookup_error_sqlcode=29111
+
+address_missing_close_bracket_msg=Missing ']'
+address_missing_close_bracket_sqlstate=HY000
+address_missing_close_bracket_sqlcode=29112
+
+socket_open_error_msg=error while opening socket. Cause: {0}
+socket_open_error_sqlstate=HY000
+socket_open_error_sqlcode=29113
+
+socket_write_error_msg=error while writing to socket
+socket_write_error_sqlstate=HY000
+socket_write_error_sqlcode=29114
+
+socket_read_error_msg=error while reading from socket. Cause: {0}
+socket_read_error_sqlstate=HY000
+socket_read_error_sqlcode=29115
+
+socket_is_closed_error_msg=Socket is closed
+socket_is_closed_error_sqlstate=HY000
+socket_is_closed_error_sqlcode=29116
+
+session_close_error_msg=Error while closing session. Cause: {0}
+session_close_error_sqlstate=HY000
+session_close_error_sqlcode=29117
+
+bad_map_ptr=A write to a bad map pointer occurred
+bad_map_ptr_sqlstate=HY000
+bad_map_ptr_sqlcode=29118
+
+bad_par_ptr=A write to a bad par pointer occurred
+bad_par_ptr_sqlstate=HY000
+bad_par_ptr_sqlcode=29119
+
+dcs_connect_message_error_msg=An dcs server connect message error occurred. Cause: {0}
+dcs_connect_message_error_sqlstate=HY000
+dcs_connect_message_error_sqlcode=29120
+
+close_message_error_msg=A close message error occurred. Cause: {0}
+close_message_error_sqlstate=HY000
+close_message_error_sqlcode=29121
+
+end_transaction_message_error_msg=An end transaction message error occurred. Cause: {0}
+end_transaction_message_error_sqlstate=HY000
+end_transaction_message_error_sqlcode=29122
+
+execute_call_message_error_msg=An execute call message error occurred. Cause: {0}
+execute_call_message_error_sqlstate=HY000
+execute_call_message_error_sqlcode=29123
+
+execute_direct_message_error_msg=An execute direct message error occurred. Cause: {0}
+execute_direct_message_error_sqlstate=HY000
+execute_direct_message_error_sqlcode=29124
+
+execute_direct_rowset_message_error_msg=An execute direct rowset message error occurred. Cause: {0}
+execute_direct_rowset_message_error_sqlstate=HY000
+execute_direct_rowset_message_error_sqlcode=29125
+
+execute_n_message_error_msg =An execute N message error occurred. Cause: {0}
+execute_n_message_error_sqlstate=HY000
+execute_n_message_error_sqlcode=29126
+
+execute_rowset_message_error_msg=An execute rowset message error occurred. Cause: {0}
+execute_rowset_message_error_sqlstate=HY000
+execute_rowset_message_error_sqlcode=29127
+
+fetch_perf_message_error_msg=A fetch perf message error occurred. Cause: {0}
+fetch_perf_message_error_sqlstate=HY000
+fetch_perf_message_error_sqlcode=29128
+
+fetch_rowset_message_error_msg=A fetch rowset message error occurred. Cause: {0}
+fetch_rowset_message_error_sqlstate=HY000
+fetch_rowset_message_error_sqlcode=29129
+
+get_sql_catalogs_message_error_msg=A get sql catalogs message error occurred. Cause: {0}
+get_sql_catalogs_message_error_sqlstate=HY000
+get_sql_catalogs_message_error_sqlcode=29130
+
+initialize_dialogue_message_error=An initialize dialogue message error occurred. Cause: {0}
+initialize_dialogue_message_error_sqlstate=HY000
+initialize_dialogue_message_error_sqlcode=29131
+
+prepare_message_error_msg=A prepare message error occurred. Cause: {0}
+prepare_message_error_sqlstate=HY000
+prepare_message_error_sqlcode=29132
+
+prepare_rowset_message_error_msg=A prepare rowset message error occurred. Cause: {0}
+prepare_rowset_message_error_sqlstate=HY000
+prepare_rowset_message_error_sqlcode=29133
+
+set_connection_option_message_error_msg=A set connection option message error occurred. Cause: {0}
+set_connection_option_message_error_sqlstate=HY000
+set_connection_option_message_error_sqlcode=29134
+
+terminate_dialogue_message_error_msg=A terminate dialogue message error occurred: Cause {0}
+terminate_dialogue_message_error_sqlstate=HY000
+terminate_dialogue_message_error_sqlcode=29135
+
+dcs_connect_reply_error_msg=An dcs server connect reply error occurred. Exception: {0} Exception detail: {1} Error text/code: {2}
+dcs_connect_reply_error_sqlstate=HY000
+dcs_connect_reply_error_sqlcode=29136
+
+close_reply_error_msg=A close reply error occurred
+close_reply_error_sqlstate=HY000
+close_reply_error_sqlcode=29137
+
+end_transaction_reply_error_msg=An end transaction reply error occurred
+end_transaction_reply_error_sqlstate=HY000
+end_transaction_reply_error_sqlcode=29138
+
+execute_call_reply_error_msg=An execute call reply error occurred
+execute_call_reply_error_sqlstate=HY000
+execute_call_reply_error_sqlcode=29139
+
+execute_direct_reply_error_msg=An execute direct reply error occurred
+execute_direct_reply_error_sqlstate=HY000
+execute_direct_reply_error_sqlcode=29140
+
+execute_direct_rowset_reply_error_msg=An execute direct rowset reply error occurred
+execute_direct_rowset_reply_error_sqlstate=HY000
+execute_direct_rowset_reply_error_sqlcode=29141
+
+execute_n_reply_error_msg=An execute N reply error occurred
+execute_n_reply_error_sqlstate=HY000
+execute_n_reply_error_sqlcode=29142
+
+execute_rowset_reply_error_msg=An execute rowset reply error occurred
+execute_rowset_reply_error_sqlstate=HY000
+execute_rowset_reply_error_sqlcode=29143
+
+fetch_perf_reply_error_msg=A fetch perf reply error occurred
+fetch_perf_reply_error_sqlstate=HY000
+fetch_perf_reply_error_sqlcode=29144
+
+fetch_rowset_reply_error_msg=A fetch rowset reply error occurred
+fetch_rowset_reply_error_sqlstate=HY000
+fetch_rowset_reply_error_sqlcode=29145
+
+get_sql_catalogs_reply_error_msg=A get sql catalogs reply error occurred
+get_sql_catalogs_reply_error_sqlstate=HY000
+get_sql_catalogs_reply_error_sqlcode=29146
+
+initialize_dialogue_reply_error_msg=An initialize dialogue reply error occurred
+initialize_dialogue_reply_error_sqlstate=HY000
+initialize_dialogue_reply_error_sqlcode=29147
+
+prepare_reply_error_msg=A prepare reply error occurred
+prepare_reply_error_sqlstate=HY000
+prepare_reply_error_sqlcode=29148
+
+prepare_rowset_reply_error_msg=A prepare rowset reply error occurred
+prepare_rowset_reply_error_sqlstate=HY000
+prepare_rowset_reply_error_sqlcode=29149
+
+set_connection_option_reply_error_msg=A set connection option reply error occurred
+set_connection_option_reply_error_sqlstate=HY000
+set_connection_option_reply_error_sqlcode=29150
+
+terminate_dialogue_reply_error_msg=A terminate dialogue reply error occurred
+terminate_dialogue_reply_error_sqlstate=HY000
+terminate_dialogue_reply_error_sqlcode=29151
+
+ids_port_not_available_msg=No more ports available to start NDCS servers
+ids_port_not_available_sqlstate=HY000
+ids_port_not_available_sqlcode=29152
+
+ids_28_000_msg=Invalid authorization specification
+ids_28_000_sqlstate=HY000
+ids_28_000_sqlcode=29153
+
+ids_s1_t00_msg=Timeout expired
+ids_s1_t00_sqlstate=HY000
+ids_s1_t00_sqlcode=29154
+
+unknown_message_type_error_msg=Unknown message type
+unknown_message_type_error_sqlstate=HY000
+unknown_message_type_error_sqlcode=29155
+
+driver_err_error_from_server_msg=An error was returned from the server. Error: {0} Error detail: {1}
+driver_err_error_from_server_sqlstate=HY000
+driver_err_error_from_server_sqlcode=29156
+
+problem_with_server_read_msg=There was a problem reading from the server
+problem_with_server_read_sqlstate=HY000
+problem_with_server_read_sqlcode=29157
+
+wrong_header_version_msg=The message header contained the wrong version: {0}
+wrong_header_version_sqlstate=HY000
+wrong_header_version_sqlcode=29158
+
+wrong_header_signature_msg=The message header contained the wrong signature. Expected: {0} Actual: {1}
+wrong_header_signature_sqlstate=HY000
+wrong_header_signature_sqlcode=29159
+
+header_not_long_enough_msg=The message header was not long enough
+header_not_long_enough_sqlstate=HY000
+header_not_long_enough_sqlcode=29160
+
+ids_unable_to_logon_msg=Unable to authenticate the user because of an NT error: {0}
+ids_unable_to_logon_sqlstate=S1000
+ids_unable_to_logon_sqlcode=29161
+
+ids_program_error_msg=Unexpected programming exception has been found: {0}. Check the server event log on node {1} for details.
+ids_program_error_sqlstate=S1000
+ids_program_error_sqlcode=29162
+
+ids_dcs_srvr_not_available_msg=DCS Services not yet available: {0}
+ids_dcs_srvr_not_available_sqlstate=08001
+ids_dcs_srvr_not_available_sqlcode=29163
+
+ids_ds_not_available_msg=DataSource not yet available or not found: {0}
+ids_ds_not_available_sqlstate=08001
+ids_ds_not_available_sqlcode=29164
+
+unknown_connect_error_msg=Unknown connect reply error: {0}
+unknown_connect_error_sqlstate=HY000
+unknown_connect_error_sqlcode= 29165
+
+ids_08_004_01_msg=Data source rejected establishment of connection since the NDCS Server is connected to a different client now
+ids_08_004_01_sqlstate=08004
+ids_08_004_01_sqlcode=HY000
+
+ids_transaction_error_msg=A TIP transaction error {0} has been detected. Check the server event log on Node {1} for Transaction Error details.
+ids_transaction_error_sqlstate=S1000
+ids_transaction_error_sqlcode=HY000
+
+ids_08_s01_msg=Communication link failure. The server timed out or disappeared.
+ids_08_s01_sqlstate=08S01
+ids_08_s01_sqlcode=01032
+
+ids_s1_008_msg=Operation cancelled.
+ids_s1_008_sqlstate=S1008
+ids_s1_008_sqlcode=01118
+
+ids_25_000_msg=Invalid transaction state.
+ids_25_000_sqlstate=25000
+ids_25_000_sqlcode=01056
+
+internal_error_method_not_implemented_msg=Internal error. This method is not implemented.
+internal_error_method_not_implemented_sqlstate=HY000
+internal_error_method_not_implemented_sqlcode=29166
+
+internal_error_inconsistency_check_msg=Internal error. An internal index failed consistency check.
+internal_error_inconsistency_check_sqlstate=HY000
+internal_error_inconsistency_check_sqlcode=29167
+
+ids_unknown_reply_error_msg=Unknown reply message error: {0} error detail: {1}
+ids_unknown_reply_error_sqlstate=HY000
+ids_unknown_reply_error_sqlcode=29168
+
+ids_retry_attempt_exceeded_msg=Retry attempts to connect to the datasource failed. Maybe NDCS server is not available.
+ids_retry_attempt_exceeded_sqlstate=08001
+ids_retry_attempt_exceeded_sqlcode=HY000
+
+invalid_property_msg=Invalid connection property setting: {0}
+invalid_property_sqlstate=HY000
+invalid_property_sqlcode=29169
+
+invalid_parameter_value_msg=Invalid Parameter Value: {0}
+invalid_parameter_value_sqlstate=HY000
+invalid_parameter_value_sqlcode=29170
+
+resource_governing_msg=Failed since resource governing policy is hit
+resource_governing_sqlstate=S1000
+resource_governing_sqlcode=29171
+
+translation_of_parameter_failed_msg=Translation of parameter to {0} failed. Cause: {1}
+translation_of_parameter_failed_sqlstate=HY000
+translation_of_parameter_failed_sqlcode=29172
+
+#
+# New Messages for LOB Support From Type 2
+#
+
+no_blobTableName_msg='blobTableName' property is not set or set to null value or set to invalid value
+no_blobTableName_sqlstate=HY000
+no_blobTableName_sqlcode=29059
+
+no_clobTableName_msg='clobTableName' property is not set or set to null value or set to invalid value
+no_clobTableName_sqlstate=HY000
+no_clobTableName_sqlcode=29060
+
+invalid_lob_commit_state_msg=Autocommit is on and LOB objects are involved
+invalid_lob_commit_state_sqlstate=HY000
+invalid_lob_commit_state_sqlcode=29069
+
+lob_not_current_msg=Lob object {0} is not current
+lob_not_current_sqlstate=HY000
+lob_not_current_sqlcode=29061
+
+invalid_input_value_msg=Invalid input value in the method {0}
+invalid_input_value_sqlstate=07009
+invalid_input_value_sqlcode=29067
+
+invalid_position_value_msg=The value for position can be any value between 1 and one more than the length of the lob data
+invalid_position_value_sqlstate=07009
+invalid_position_value_sqlcode=29068
+
+problem_with_logging_msg=There was a problem while logging: {0}
+problem_with_logging_sqlstate=HY000
+problem_with_logging_sqlcode=29070
+
+initial_pool_creation_error_msg=Error occurred while creating the initial pool of {0} connection(s)
+initial_pool_creation_error_sqlstate=HY000
+initial_pool_creation_error_sqlcode=29173
+
+resultSet_updateRow_with_autocommit_msg=Autocommit is on and updateRow was called on the ResultSet object
+resultSet_updateRow_with_autocommit_sqlstate=HY000
+resultSet_updateRow_with_autocommit_sqlcode=29174
+
+unknown_error_msg=Unknown Error {0}
+unknown_error_sqlstate=HY000
+unknown_error_sqlcode=29175
+
+fill_in_SQL_Values_msg=Failed while converting objects to SQL values.
+fill_in_SQL_Values_sqlstate=HY000
+fill_in_SQL_Values_sqlcode=29176
+
+null_data_msg=Data cannot be null.
+null_data_sqlstate=HY000
+null_data_sqlcode=29177
+
+no_column_value_specified_msg=No column value has been inserted
+no_column_value_specified_sqlstate=HY000
+no_column_value_specified_sqlcode=29178
+
+
+execute_2_message_error_msg =An Execute2 message error occurred. Cause: {0}
+execute_2_message_error_sqlstate=HY000
+execute_2_message_error_sqlcode=29179
+
+infostats_invalid_error_msg=INFOSTATS command is supported only via the Statement.execute(String sql) method.
+infostats_invalid_error_sqlstate=HY000
+infostats_invalid_error_sqlcode=29180
+
+dcs_cancel_message_error_msg=A dcs server cancel message error occurred. Cause: {0}
+dcs_cancel_message_error_sqlstate=HY000
+dcs_cancel_message_error_sqlcode=29181
+
+connected_to_Default_DS_msg= General warning. Connected to the default data source: {0}
+connected_to_Default_DS_sqlstate=HY000
+connected_to_Default_DS_sqlcode=29182
+
+invalid_string_parameter_msg=Invalid Parameter Value: {0}
+invalid_string_parameter_sqlstate=22001
+invalid_string_parameter_sqlcode=29183
+
+null_parameter_for_not_null_column_msg=NULL cannot be assigned to a NOT NULL column, parameter {0}.
+null_parameter_for_not_null_column_sqlstate=23000
+null_parameter_for_not_null_column_sqlcode=29184
+
+security_error_msg=A Security Exception Occurred: {0}
+security_error_sqlstate=HY000
+security_error_sqlcode=29185
+
+certificate_download_error_msg=An error occurred while downloading the certificate: {0}
+certificate_download_error_sqlstate=HY000
+certificate_download_error_sqlcode=29186
+
+data_truncation_exceed_msg=The data length {0} exceeds the max length {1}
+data_truncation_exceed_sqlstate=HY000
+data_truncation_exceed_sqlcode=29187
+
+numeric_out_of_range_d_msg=Numeric value {0} is out of range [{1}, {2}]
+numeric_out_of_range_d_sqlstate=22003
+numeric_out_of_range_d_sqlcode=29188
+
+cursor_is_before_first_row_msg=The cursor is before the first row, therefore no data can be retrieved
+cursor_is_before_first_row_sqlstate=HY109
+cursor_is_before_first_row_sqlcode=29189
+
+cursor_after_last_row_msg=The cursor is after last row, which could be due to the result set containing no rows, or all rows have been retrieved.
+cursor_after_last_row_sqlstate=HY109
+cursor_after_last_row_sqlcode=29190
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Address.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Address.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Address.java
new file mode 100644
index 0000000..d486f57
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Address.java
@@ -0,0 +1,117 @@
+// @@@ 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;
+
+/**********************************************************
+ * This class represents an address reference.
+ *
+ *
+ **********************************************************/
+
+import java.net.InetAddress;
+import java.sql.SQLException;
+import java.util.Locale;
+import java.util.Properties;
+
+abstract class Address {
+ protected Locale m_locale;
+ protected T4Properties m_t4props;
+ protected String m_ipAddress;
+ protected String m_machineName;
+ protected String m_processName;
+ protected Integer m_portNumber;
+ protected Properties m_properties;
+ InetAddress[] m_inetAddrs;
+ protected int m_type;
+ protected String m_url;
+ protected InputOutput m_io;
+
+ /**
+ * The constructor.
+ *
+ * @param addr
+ * The addr has two forms:
+ *
+ * DriverManager getConnection addr parameter format for connecting via the
+ * Fast JDBC Type 3 driver.
+ *
+ * jdbc:subprotocol:subname
+ *
+ * Where:
+ *
+ * subprotocol = t4jdbc
+ *
+ * subname = //<{IP Address|Machine Name}[:port]>/<database name>
+ *
+ * Example: jdbc:t4jdbc://130.168.200.30:1433/database1
+ *
+ *
+ * ODBC server connect format returned by the ODBC Association Server.
+ *
+ * TCP:\<{IP Address|Machine Name}>.<Process Name>/<port>:ODBC
+ *
+ */
+
+ // ----------------------------------------------------------
+ Address(T4Properties t4props, Locale locale, String addr) throws SQLException {
+ m_t4props = t4props;
+ m_locale = locale;
+ m_url = addr;
+ }
+
+ abstract String recreateAddress();
+
+ // ----------------------------------------------------------
+ String getIPorName() {
+ if (m_machineName != null) {
+ return m_machineName;
+ } else {
+ return m_ipAddress;
+ }
+ } // end getIPorName
+
+ protected boolean validateAddress() throws SQLException {
+ String IPorName = getIPorName();
+ try {
+ m_inetAddrs = InetAddress.getAllByName(IPorName);
+ } catch (Exception e) {
+ SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_lookup_error", m_url, e
+ .getMessage());
+ se.initCause(e);
+ throw se;
+ }
+ return true;
+ }
+
+ // ----------------------------------------------------------
+ Integer getPort() {
+ return m_portNumber;
+ } // end getIPorName
+
+ void setInputOutput() {
+ m_io = new InputOutput(m_locale, this);
+ }
+
+ InputOutput getInputOutput() {
+ return m_io;
+ }
+} // end class Address
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/BaseRow.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/BaseRow.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/BaseRow.java
new file mode 100644
index 0000000..3d28248
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/BaseRow.java
@@ -0,0 +1,65 @@
+// @@@ 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 @@@
+
+/*
+ * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.trafodion.jdbc.t4;
+
+import java.io.Serializable;
+import java.sql.SQLException;
+
+abstract class BaseRow implements Serializable, Cloneable {
+
+ protected Object origVals[];
+
+ BaseRow() {
+ }
+
+ protected abstract Object getColumnObject(int i) throws SQLException;
+
+ protected Object[] getOrigRow() {
+ return origVals;
+ }
+
+ protected abstract void setColumnObject(int i, Object obj) throws SQLException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Bytes.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Bytes.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Bytes.java
new file mode 100644
index 0000000..78803c3
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Bytes.java
@@ -0,0 +1,269 @@
+// @@@ 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;
+
+/**
+ * <code>Bytes</code> contains a set of static methods used for byte
+ * manipulation. There are three basic types of methods:
+ * <ul>
+ * <li>extract</li>
+ * <li>insert</li>
+ * <li>create</li>
+ * </ul>
+ * <p>
+ * Extract methods will copy from a raw byte array into a basic Java type.
+ * Insert methods will copy from a basic Java type into a raw byte array. Create
+ * methods will copy from a basic Java type into a new raw byte array which is
+ * returned to the user.
+ *
+ * As Java is always BigEndian, set the swap parameter to <code>true</code> to
+ * convert to and from LittleEndian.
+ *
+ * There is no error checking in order to improve performance. Length checking
+ * should be done before calling these methods or the resulting exceptions
+ * should be handled by the user.
+ *
+ */
+class Bytes {
+
+ static short extractShort(byte[] array, int offset, boolean swap) {
+ short value;
+
+ if (swap) {
+ value = (short) (((array[offset]) & 0x00ff) | ((array[offset + 1] << 8) & 0xff00));
+ } else {
+ value = (short) (((array[offset + 1]) & 0x00ff) | ((array[offset] << 8) & 0xff00));
+ }
+
+ return value;
+ }
+
+ static int extractUShort(byte[] array, int offset, boolean swap) {
+ int value;
+
+ if (swap) {
+ value = ((array[offset]) & 0x00ff) | ((array[offset + 1] << 8) & 0xff00);
+ } else {
+ value = ((array[offset + 1]) & 0x00ff) | ((array[offset] << 8) & 0xff00);
+ }
+
+ return value & 0xffff;
+ }
+
+ static int extractInt(byte[] array, int offset, boolean swap) {
+ int value;
+
+ if (swap) {
+ value = ((array[offset]) & 0x000000ff) | ((array[offset + 1] << 8) & 0x0000ff00)
+ | ((array[offset + 2] << 16) & 0x00ff0000) | ((array[offset + 3] << 24) & 0xff000000);
+ } else {
+ value = ((array[offset + 3]) & 0x000000ff) | ((array[offset + 2] << 8) & 0x0000ff00)
+ | ((array[offset + 1] << 16) & 0x00ff0000) | ((array[offset] << 24) & 0xff000000);
+ }
+
+ return value;
+ }
+
+ static long extractUInt(byte[] array, int offset, boolean swap) {
+ long value;
+
+ if (swap) {
+ value = ((array[offset]) & 0x000000ff) | ((array[offset + 1] << 8) & 0x0000ff00)
+ | ((array[offset + 2] << 16) & 0x00ff0000) | ((array[offset + 3] << 24) & 0xff000000);
+ } else {
+ value = ((array[offset + 3]) & 0x000000ff) | ((array[offset + 2] << 8) & 0x0000ff00)
+ | ((array[offset + 1] << 16) & 0x00ff0000) | ((array[offset] << 24) & 0xff000000);
+ }
+
+ return value & 0xffffffffL;
+ }
+
+ static long extractLong(byte[] array, int offset, boolean swap) {
+ long value = 0;
+ int i=offset;
+
+ if(swap) {
+ for (int shift = 0; shift < 64; shift += 8) {
+ value |= ( (long)( array[i] & 0xff ) ) << shift;
+ i++;
+ }
+
+ }else {
+ for (int shift = 56; shift >= 0; shift -= 8) {
+ value |= ( (long)( array[i] & 0xff ) ) << shift;
+ i++;
+ }
+ }
+
+ return value;
+ }
+
+ static int insertShort(byte[] array, int offset, short value, boolean swap) {
+ if (swap) {
+ array[offset + 1] = (byte) ((value >>> 8) & 0xff);
+ array[offset] = (byte) ((value) & 0xff);
+ } else {
+ array[offset] = (byte) ((value >>> 8) & 0xff);
+ array[offset + 1] = (byte) ((value) & 0xff);
+ }
+
+ return offset + 2;
+ }
+
+ /*
+ * static int insertUShort(byte[] array, int offset, int value, boolean
+ * swap) {
+ *
+ * return offset + 2; }
+ */
+
+ static int insertInt(byte[] array, int offset, int value, boolean swap) {
+ if (swap) {
+ array[offset + 3] = (byte) ((value >>> 24) & 0xff);
+ array[offset + 2] = (byte) ((value >>> 16) & 0xff);
+ array[offset + 1] = (byte) ((value >>> 8) & 0xff);
+ array[offset] = (byte) ((value) & 0xff);
+ } else {
+ array[offset] = (byte) ((value >>> 24) & 0xff);
+ array[offset + 1] = (byte) ((value >>> 16) & 0xff);
+ array[offset + 2] = (byte) ((value >>> 8) & 0xff);
+ array[offset + 3] = (byte) ((value) & 0xff);
+ }
+
+ return offset + 4;
+ }
+
+ /*
+ * static int insertUInt(byte[] array, int offset, long value, boolean swap) {
+ * return offset + 4; }
+ */
+
+ static int insertLong(byte[] array, int offset, long value, boolean swap) {
+ if (swap) {
+ array[offset + 7] = (byte) ((value >>> 56) & 0xff);
+ array[offset + 6] = (byte) ((value >>> 48) & 0xff);
+ array[offset + 5] = (byte) ((value >>> 40) & 0xff);
+ array[offset + 4] = (byte) ((value >>> 32) & 0xff);
+ array[offset + 3] = (byte) ((value >>> 24) & 0xff);
+ array[offset + 2] = (byte) ((value >>> 16) & 0xff);
+ array[offset + 1] = (byte) ((value >>> 8) & 0xff);
+ array[offset] = (byte) ((value) & 0xff);
+ } else {
+ array[offset] = (byte) ((value >>> 56) & 0xff);
+ array[offset + 1] = (byte) ((value >>> 48) & 0xff);
+ array[offset + 2] = (byte) ((value >>> 40) & 0xff);
+ array[offset + 3] = (byte) ((value >>> 32) & 0xff);
+ array[offset + 4] = (byte) ((value >>> 24) & 0xff);
+ array[offset + 5] = (byte) ((value >>> 16) & 0xff);
+ array[offset + 6] = (byte) ((value >>> 8) & 0xff);
+ array[offset + 7] = (byte) ((value) & 0xff);
+ }
+
+ return offset + 8;
+ }
+
+ static byte[] createShortBytes(short value, boolean swap) {
+ byte[] b = new byte[2];
+ Bytes.insertShort(b, 0, value, swap);
+
+ return b;
+ }
+
+ /*
+ * static byte[] createUShortBytes(int value, boolean swap) { byte[] b = new
+ * byte[2]; Bytes.insertUShort(b, 0, value, swap);
+ *
+ * return b; }
+ */
+
+ static byte[] createIntBytes(int value, boolean swap) {
+ byte[] b = new byte[4];
+ Bytes.insertInt(b, 0, value, swap);
+
+
+ return b;
+ }
+
+ /*
+ * static byte[] createUIntBytes(long value, boolean swap) { byte[] b = new
+ * byte[4]; Bytes.insertUInt(b, 0, value, swap);
+ *
+ * return b; }
+ */
+
+ static byte[] createLongBytes(long value, boolean swap) {
+ byte[] b = new byte[8];
+ Bytes.insertLong(b, 0, value, swap);
+
+ return b;
+ }
+
+ // -------------------------------------------------------------
+ // -------------------------------------------------------------
+ // ---------------TODO: get rid of these methods!---------------
+ // -------------------------------------------------------------
+ // -------------------------------------------------------------
+
+ /**
+ * @deprecated
+ */
+ static char[] read_chars(byte[] buffer, int index) {
+ int len = 0;
+
+ // find the null terminator
+ while (buffer[index + len] != 0) {
+ len = len + 1;
+ }
+
+ char[] temp1 = read_chars(buffer, index, len);
+
+ return temp1;
+ } // end read_chars
+
+ /**
+ * @deprecated
+ */
+ static char[] read_chars(byte[] buffer, int index, int tLen) {
+ char[] la_chars;
+ int len = tLen;
+
+ if (len == -1) // must find null to get length
+ {
+ int ii = index;
+ while (buffer[ii] != (byte) 0) {
+ ii = ii + 1;
+ }
+ len = ii - index;
+ }
+
+ la_chars = new char[len];
+
+ int i = 0;
+ while (i < len) {
+ la_chars[i] = (char) (buffer[index] & 0xff);
+ i = i + 1;
+ index = index + 1;
+ }
+
+ return la_chars;
+ } // end read_chars
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CONNECTION_CONTEXT_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CONNECTION_CONTEXT_def.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CONNECTION_CONTEXT_def.java
new file mode 100644
index 0000000..d38b178
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CONNECTION_CONTEXT_def.java
@@ -0,0 +1,149 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class CONNECTION_CONTEXT_def {
+ String datasource = "";
+ String catalog = "";
+ String schema = "";
+ String location = "";
+ String userRole = "";
+
+ short accessMode;
+ short autoCommit;
+ short queryTimeoutSec;
+ short idleTimeoutSec;
+ short loginTimeoutSec;
+ short txnIsolationLevel;
+ short rowSetSize;
+
+ int diagnosticFlag;
+ int processId;
+
+ String computerName = "";
+ String windowText = "";
+
+ int ctxACP;
+ int ctxDataLang;
+ int ctxErrorLang;
+ short ctxCtrlInferNXHAR;
+
+ short cpuToUse = -1;
+ short cpuToUseEnd = -1; // for future use by DBTransporter
+
+ String connectOptions = "";
+
+ VERSION_LIST_def clientVersionList = new VERSION_LIST_def();
+
+ byte[] datasourceBytes;
+ byte[] catalogBytes;
+ byte[] schemaBytes;
+ byte[] locationBytes;
+ byte[] userRoleBytes;
+ byte[] computerNameBytes;
+ byte[] windowTextBytes;
+ byte[] connectOptionsBytes;
+
+ // ----------------------------------------------------------
+ int sizeOf(InterfaceConnection ic) throws CharacterCodingException, UnsupportedCharsetException {
+ int size = 0;
+
+ datasourceBytes = ic.encodeString(datasource, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ catalogBytes = ic.encodeString(catalog, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ schemaBytes = ic.encodeString(schema, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ locationBytes = ic.encodeString(location, 1);
+ userRoleBytes = ic.encodeString(userRole, 1);
+ computerNameBytes = ic.encodeString(computerName, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ windowTextBytes = ic.encodeString(windowText, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ connectOptionsBytes = ic.encodeString(connectOptions, 1);
+
+ size = TRANSPORT.size_bytes(datasourceBytes);
+ size += TRANSPORT.size_bytes(catalogBytes);
+ size += TRANSPORT.size_bytes(schemaBytes);
+ size += TRANSPORT.size_bytes(locationBytes);
+ size += TRANSPORT.size_bytes(userRoleBytes);
+
+ size += TRANSPORT.size_short; // accessMode
+ size += TRANSPORT.size_short; // autoCommit
+ size += TRANSPORT.size_int; // queryTimeoutSec
+ size += TRANSPORT.size_int; // idleTimeoutSec
+ size += TRANSPORT.size_int; // loginTimeoutSec
+ size += TRANSPORT.size_short; // txnIsolationLevel
+ size += TRANSPORT.size_short; // rowSetSize
+
+ size += TRANSPORT.size_short; // diagnosticFlag
+ size += TRANSPORT.size_int; // processId
+
+ size += TRANSPORT.size_bytes(computerNameBytes);
+ size += TRANSPORT.size_bytes(windowTextBytes);
+
+ size += TRANSPORT.size_int; // ctxACP
+ size += TRANSPORT.size_int; // ctxDataLang
+ size += TRANSPORT.size_int; // ctxErrorLang
+ size += TRANSPORT.size_short; // ctxCtrlInferNCHAR
+
+ size += TRANSPORT.size_short; // cpuToUse
+ size += TRANSPORT.size_short; // cpuToUseEnd
+ size += TRANSPORT.size_bytes(connectOptionsBytes);
+
+ size += clientVersionList.sizeOf();
+
+ return size;
+ }
+
+ // ----------------------------------------------------------
+ void insertIntoByteArray(LogicalByteArray buf) {
+ buf.insertString(datasourceBytes);
+ buf.insertString(catalogBytes);
+ buf.insertString(schemaBytes);
+ buf.insertString(locationBytes);
+ buf.insertString(userRoleBytes);
+
+ buf.insertShort(accessMode);
+ buf.insertShort(autoCommit);
+ buf.insertInt(queryTimeoutSec);
+ buf.insertInt(idleTimeoutSec);
+ buf.insertInt(loginTimeoutSec);
+ buf.insertShort(txnIsolationLevel);
+ buf.insertShort(rowSetSize);
+
+ buf.insertInt(diagnosticFlag);
+ buf.insertInt(processId);
+
+ buf.insertString(computerNameBytes);
+ buf.insertString(windowTextBytes);
+
+ buf.insertInt(ctxACP);
+ buf.insertInt(ctxDataLang);
+ buf.insertInt(ctxErrorLang);
+ buf.insertShort(ctxCtrlInferNXHAR);
+
+ buf.insertShort(cpuToUse);
+ buf.insertShort(cpuToUseEnd);
+ buf.insertString(connectOptionsBytes);
+
+ clientVersionList.insertIntoByteArray(buf);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CachedPreparedStatement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CachedPreparedStatement.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CachedPreparedStatement.java
new file mode 100644
index 0000000..5866e04
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CachedPreparedStatement.java
@@ -0,0 +1,67 @@
+// @@@ 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.PreparedStatement;
+import java.sql.SQLException;
+
+public class CachedPreparedStatement {
+
+ PreparedStatement getPreparedStatement() {
+ inUse_ = true;
+ return pstmt_;
+ }
+
+ void setLastUsedInfo() {
+ lastUsedTime_ = System.currentTimeMillis();
+ noOfTimesUsed_++;
+ }
+
+ long getLastUsedTime() {
+ return lastUsedTime_;
+ }
+
+ String getLookUpKey() {
+ return key_;
+ }
+
+ void close(boolean hardClose) throws SQLException {
+ inUse_ = false;
+ pstmt_.close(hardClose);
+ }
+
+ CachedPreparedStatement(PreparedStatement pstmt, String key) {
+ pstmt_ = (TrafT4PreparedStatement) pstmt;
+ key_ = key;
+ creationTime_ = System.currentTimeMillis();
+ lastUsedTime_ = creationTime_;
+ noOfTimesUsed_ = 1;
+ inUse_ = true;
+ }
+
+ private TrafT4PreparedStatement pstmt_;
+ private String key_;
+ private long lastUsedTime_;
+ private long creationTime_;
+ private long noOfTimesUsed_;
+ boolean inUse_;
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CancelMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CancelMessage.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CancelMessage.java
new file mode 100644
index 0000000..b8347a2
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CancelMessage.java
@@ -0,0 +1,49 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class CancelMessage {
+ static LogicalByteArray marshal(int dialogueId, int srvrType, String srvrObjRef, int stopType,
+ InterfaceConnection ic) throws UnsupportedCharsetException, CharacterCodingException {
+ int wlength = Header.sizeOf();
+ LogicalByteArray buf = null;
+
+ byte[] srvrObjRefBytes = ic.encodeString(srvrObjRef, 1);
+
+ wlength += TRANSPORT.size_int; // dialogueId
+ wlength += TRANSPORT.size_int; // srvrType
+ wlength += TRANSPORT.size_bytes(srvrObjRefBytes); // srvrObjReference
+ wlength += TRANSPORT.size_int; // stopType
+
+ buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
+
+ buf.insertInt(dialogueId);
+ buf.insertInt(srvrType);
+ buf.insertString(srvrObjRefBytes);
+ buf.insertInt(stopType);
+
+ return buf;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CancelReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CancelReply.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CancelReply.java
new file mode 100644
index 0000000..b3eb6f0
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CancelReply.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;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+import java.sql.SQLException;
+
+class CancelReply {
+ odbc_Dcs_StopSrvr_exc_ m_p1_exception;
+
+ // -------------------------------------------------------------
+ CancelReply(LogicalByteArray buf, InterfaceConnection ic) throws SQLException, CharacterCodingException,
+ UnsupportedCharsetException {
+ buf.setLocation(Header.sizeOf());
+
+ m_p1_exception = new odbc_Dcs_StopSrvr_exc_();
+ m_p1_exception.extractFromByteArray(buf, ic);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Certificate.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Certificate.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Certificate.java
new file mode 100644
index 0000000..eedc663
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Certificate.java
@@ -0,0 +1,112 @@
+/**********************************************************************
+// @@@ 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 @@@
+ //
+ **********************************************************************/
+/**
+ * Certificate.java
+ * This class get the x509 certificate from an input file and stores
+ * the certificate in the m_cert member.
+ */
+
+package org.trafodion.jdbc.t4;
+
+import java.security.cert.X509Certificate;
+import java.security.cert.CertificateFactory;
+import java.security.cert.CertificateException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.util.Date;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
+
+public class Certificate
+{
+ /**
+ * Ctor - Gets certificate and the certificate's expiration
+ * date from the certificate file.
+ * @param certFile - the certificate file which stores the
+ * public key.
+ * @throws SecurityException
+ */
+ public Certificate(File certFile)
+ throws SecurityException
+ {
+ InputStream inStream = null;
+ try
+ {
+ inStream = new FileInputStream(certFile);
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ m_cert = (X509Certificate) cf.generateCertificate(inStream);
+ // Get certificate expiration date
+ Date expDate = m_cert.getNotAfter();
+
+ SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmss");
+ sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
+ String fDate = sdf.format(expDate);
+ m_certExpDate = fDate.getBytes();
+ }
+ catch (CertificateException cex)
+ {
+ throw new SecurityException(SecClientMsgKeys.FILE_CORRUPTION, new Object[]{certFile.getName()} );
+ }
+ catch (Exception ex)
+ {
+ // This should never happen
+ throw new SecurityException(SecClientMsgKeys.FILE_NOTFOUND, new Object[]{certFile.getName()} );
+ }
+ finally
+ {
+ try
+ {
+ if (inStream != null) inStream.close();
+ }
+ catch (IOException io)
+ {
+ // Notmuch to do at this point
+ }
+ }
+ }
+
+ /**
+ * returns the expiration date of the certificate
+ * @return an array of byte representing the expiration
+ * date of the certificate in the String format
+ * "yyMMddHHmmss"
+ */
+ public byte[] getCertExpDate()
+ {
+ return m_certExpDate;
+ }
+
+ /**
+ * @return the X509Certificate
+ */
+ public X509Certificate getCert()
+ {
+ return m_cert;
+ }
+
+ private X509Certificate m_cert;
+ private byte[] m_certExpDate;
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Cipher.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Cipher.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Cipher.java
new file mode 100644
index 0000000..32c0ef9
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Cipher.java
@@ -0,0 +1,201 @@
+/**********************************************************************
+// @@@ 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 @@@
+//
+**********************************************************************/
+
+/**
+ * class Cipher - Encrypts and decrypts data and password using
+ * symmetric key and key pair
+ *
+ */
+
+package org.trafodion.jdbc.t4;
+
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.SecretKey;
+
+
+
+public class Cipher
+{
+ private static class Holder
+ {
+ private static Cipher instance = new Cipher();
+ }
+
+ /**
+ *
+ * @return Cipher
+ */
+ public static Cipher getInstance()
+ {
+ return Holder.instance;
+ }
+
+ /** Encrypts plain text and stores the
+ * cipher text in cipherText using public key for password encryption.
+ * @param plainText - plain text to be encrypted
+ * @param cipherText - encrypted plain text is returned
+ * @param key - password encryption: public key
+ * @Return the length of the cipher text or -1 in case of error
+ * @throws SecurityException
+ */
+ public int encrypt(byte[] plainText, byte[] cipherText,
+ java.security.Key key) throws SecurityException
+ {
+ int len = 0;
+
+ if (plainText == null)
+ throw new SecurityException(SecClientMsgKeys.
+ INPUT_PARAMETER_IS_NULL, new Object[]{"plainText"});
+ if (cipherText == null)
+ throw new SecurityException(SecClientMsgKeys.
+ INPUT_PARAMETER_IS_NULL, new Object[]{"cipherText"});
+ if (key == null)
+ throw new SecurityException(SecClientMsgKeys.
+ INPUT_PARAMETER_IS_NULL, new Object[]{"key"});
+
+ try {
+ // Obtain a RSA Cipher Object
+ // RSA algorithm, ECB:Electronic Codebook Mode mode,
+ // PKCS1Padding: PKCS1 padding
+ javax.crypto.Cipher cipher = javax.crypto.Cipher.
+ getInstance("RSA/ECB/PKCS1Padding");
+ byte[] tmpCipherText;
+ synchronized(cipher) {
+ cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, key);
+
+ tmpCipherText = cipher.doFinal(plainText);
+ }
+
+ System.arraycopy(tmpCipherText, 0, cipherText, 0, tmpCipherText.length);
+
+ len = cipherText.length;
+ }catch (Exception ex) {
+ throw new SecurityException(SecClientMsgKeys.ENCRYPTION_FAILED, null);
+ }
+ return len;
+ }
+
+ public static javax.crypto.Cipher getEASInstance(String algorithm) throws SecurityException
+ {
+ if (algorithm == null)
+ throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"algorithm"});
+ try {
+ // Obtain a AES Cipher Object
+ // AES algorithm using a cryptographic key of 128 bits
+ // to encrypt data in blocks of 128 bits,
+ // CBC cipher mode, PKCS5Padding padding
+
+ return javax.crypto.Cipher.getInstance("AES/CBC/PKCS5Padding");
+ } catch (Exception ex) {
+ throw new SecurityException(SecClientMsgKeys.ENCRYPTION_FAILED, null);
+ }
+ }
+
+ /** Encrypts the plain text data message using "EAS256/CBC/PKCS7"
+ * @param plainText - plain text to be encrypted
+ * @param key - session key is used as secret key
+ * @param iv - 16 lower bytes of the nonce is used as the initial vector.
+ * Can't use the whole 32 bytes nonce because the IV size has
+ * to be equal to the block size which is a Java requirement.
+ * @Return the cipher text in byte
+ * @throws SecurityException
+ */
+ public static byte[] encryptData(byte[] plainText, SecretKey key, byte[] iv,
+ javax.crypto.Cipher cipher)
+ throws SecurityException
+ {
+ if (plainText == null)
+ throw new SecurityException(SecClientMsgKeys.
+ INPUT_PARAMETER_IS_NULL, new Object[]{"plainText"});
+ if (key == null)
+ throw new SecurityException(SecClientMsgKeys.
+ INPUT_PARAMETER_IS_NULL, new Object[]{"key"});
+ if (iv == null)
+ throw new SecurityException(SecClientMsgKeys.
+ INPUT_PARAMETER_IS_NULL, new Object[]{"iv"});
+
+ try {
+ IvParameterSpec initialVector = new IvParameterSpec(iv);
+
+ synchronized (cipher) {
+ cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, key, initialVector);
+
+ return cipher.doFinal(plainText);
+ }
+
+ }catch (Exception ex) {
+ throw new SecurityException(SecClientMsgKeys.DATA_ENCRYPTION_FAILED, null);
+ }
+ }
+
+ /** Decrypts cipherText and stores the
+ * plain text in plainText using private key for password
+ * decryption or symmetric key for data decryption
+ *
+ * @param cipherText cipher text to be decrypted
+ * @param plainText decrypted cipher text is returned
+ * @param key password decryption: private key
+ * message encryption: session key
+ * @param iv 8 sequence nonce is used as the initial vector for symmetric
+ * key encryption. Null if is private key encryption
+ * @return the length of the plain text or -1 in case of error
+ * @throws SecurityException
+ */
+ public int decrypt(byte[] cipherText, byte[] plainText,
+ java.security.Key key, byte[] iv) throws SecurityException
+ {
+ int len = 0;
+ if (iv == null) //Private key decyption
+ {
+ if (plainText == null)
+ throw new SecurityException(SecClientMsgKeys.
+ INPUT_PARAMETER_IS_NULL, new Object[]{"plainText"});
+ if (cipherText == null)
+ throw new SecurityException(SecClientMsgKeys.
+ INPUT_PARAMETER_IS_NULL, new Object[]{"cipherText"});
+ if (key == null)
+ throw new SecurityException(SecClientMsgKeys.
+ INPUT_PARAMETER_IS_NULL, new Object[]{"key"});
+ try {
+ // Obtain a RSA Cipher Object
+ // RSA algorithm, ECB:Electronic Code book Mode mode,
+ // PKCS1Padding: PKCS1 padding
+ javax.crypto.Cipher cipher = javax.crypto.Cipher.
+ getInstance("RSA/ECB/PKCS1Padding");
+ byte[] tmpPlainText ;
+ synchronized (cipher) {
+ cipher.init(javax.crypto.Cipher.DECRYPT_MODE, key);
+ tmpPlainText = cipher.doFinal(cipherText);
+ }
+ System.arraycopy(tmpPlainText, 0, plainText, 0, tmpPlainText.length);
+
+ len = plainText.length;
+ }catch (Exception ex) {
+ throw new SecurityException(SecClientMsgKeys.DECRYPTION_FAILED, null);
+ }
+ }
+
+ return len;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CloseMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CloseMessage.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CloseMessage.java
new file mode 100644
index 0000000..30c23fe
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CloseMessage.java
@@ -0,0 +1,48 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class CloseMessage {
+ // ----------------------------------------------------------
+ static LogicalByteArray marshal(int dialogueId, String stmtLabel, short freeResourceOpt, InterfaceConnection ic)
+ throws UnsupportedCharsetException, CharacterCodingException {
+ int wlength = Header.sizeOf();
+ LogicalByteArray buf;
+
+ byte[] stmtLabelBytes = ic.encodeString(stmtLabel, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+
+ wlength += TRANSPORT.size_int; // dialogueId
+ wlength += TRANSPORT.size_bytes(stmtLabelBytes);
+ wlength += TRANSPORT.size_short; // freeResourceOpt
+
+ buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
+
+ buf.insertInt(dialogueId);
+ buf.insertString(stmtLabelBytes);
+ buf.insertShort(freeResourceOpt);
+
+ return buf;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CloseReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CloseReply.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CloseReply.java
new file mode 100644
index 0000000..91bb2a7
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/CloseReply.java
@@ -0,0 +1,48 @@
+// @@@ 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 CloseReply {
+ odbc_SQLSvc_Close_exc_ m_p1;
+ int m_p2;
+ ERROR_DESC_LIST_def m_p3;
+
+ // -------------------------------------------------------------
+ CloseReply(LogicalByteArray buf, String addr, InterfaceConnection ic) throws CharacterCodingException,
+ UnsupportedCharsetException, SQLException {
+ buf.setLocation(Header.sizeOf());
+
+ m_p1 = new odbc_SQLSvc_Close_exc_();
+ m_p1.extractFromByteArray(buf, addr, ic);
+
+ if (m_p1.exception_nr != TRANSPORT.CEE_SUCCESS) {
+ m_p2 = buf.extractInt();
+
+ m_p3 = new ERROR_DESC_LIST_def();
+ m_p3.extractFromByteArray(buf, ic);
+ }
+ }
+}
[02/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4Statement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4Statement.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4Statement.java
deleted file mode 100644
index d0daff1..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4Statement.java
+++ /dev/null
@@ -1,1690 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.lang.ref.WeakReference;
-import java.math.BigDecimal;
-import java.nio.ByteBuffer;
-import java.sql.BatchUpdateException;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-/**
- * <p>
- * JDBC Type 4 TrafT4Statement class.
- * </p>
- * <p>
- * Description: The <code>TrafT4Statement</code> class is an implementation of
- * the <code>java.sql.Statement</code> interface.
- * </p>
- */
-public class TrafT4Statement extends HPT4Handle implements java.sql.Statement {
- // java.sql.Statement interface Methods
-
- public void addBatch(String sql) throws SQLException {
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("addBatch");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "addBatch", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("addBatch");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- if (batchCommands_ == null) {
- batchCommands_ = new ArrayList();
- }
-
-
- batchCommands_.add(sql);
- }
-
- public void cancel() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "cancel", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("cancel");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- // Donot clear warning, since the warning may pertain to
- // previous opertation and it is not yet seen by the application
- //
- // We must decide if this statement is currently being processed or
- // if it has a result set associated with it, and if that
- // result set is currently active (i.e. we are fetching rows).
- if ((ist_.t4statement_ != null && ist_.t4statement_.m_processing == true)
- || (resultSet_ != null && resultSet_[result_set_offset] != null
- && resultSet_[result_set_offset].irs_ != null
- && resultSet_[result_set_offset].irs_.t4resultSet_ != null && resultSet_[result_set_offset].irs_.t4resultSet_.m_processing == true))
- ist_.cancel();
- }
-
- public void clearBatch() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "clearBatch", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("clearBatch");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- batchCommands_.clear();
- }
-
- /**
- * Closes the statement object. Synchronized to prevent the same resource
- * issued free command twice on the server.
- *
- * @throws SQLException
- */
- synchronized public void close() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "close", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("close");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- if (isClosed_) {
- return;
- }
-
- try {
- if (connection_._isClosed() == false) {
- for (int i = 0; i < num_result_sets_; i++) {
- if (resultSet_[i] != null) {
- resultSet_[i].close(false);
- }
- }
- ist_.close();
- }
- } finally {
- isClosed_ = true;
- connection_.removeElement(pRef_);
- initResultSets();
- }
- }
-
- void initResultSets() {
- num_result_sets_ = 1;
- result_set_offset = 0;
- resultSet_[result_set_offset] = null;
- }
-
- // ------------------------------------------------------------------
- /**
- * This method will execute an operation.
- *
- * @return true
- *
- * @exception A
- * SQLException is thrown
- */
-
- public boolean execute() throws SQLException {
- try {
- ist_.executeDirect(queryTimeout_, this);
- } catch (SQLException se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- return true;
- } // end execute
-
- // ------------------------------------------------------------------
-
- public boolean execute(String sql) throws SQLException {
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("execute");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "execute", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("execute");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateExecDirectInvocation(sql);
- try {
- ist_.execute(TRANSPORT.SRVR_API_SQLEXECDIRECT, 0, 0, null, queryTimeout_, sql_, this);
-
- checkSQLWarningAndClose();
- } catch (SQLException se) {
- try {
- if (num_result_sets_ == 1 && resultSet_[result_set_offset] == null)
- ;
- {
- internalClose();
- }
- } catch (SQLException closeException) {
- se.setNextException(closeException);
- }
- performConnectionErrorChecks(se);
- throw se;
- }
- if (resultSet_[result_set_offset] != null) {
- return true;
- } else {
- return false;
- }
- }
-
- public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, autoGeneratedKeys);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "execute", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, autoGeneratedKeys);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("execute");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- boolean ret;
-
- if (autoGeneratedKeys == TrafT4Statement.NO_GENERATED_KEYS) {
- ret = execute(sql);
- } else {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "auto_generated_keys_not_supported", null);
- }
- return ret;
- }
-
- public boolean execute(String sql, int[] columnIndexes) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnIndexes);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "execute", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnIndexes);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("execute");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- boolean ret;
-
- if (columnIndexes == null) {
- ret = execute(sql);
- } else if (columnIndexes.length == 0) {
- ret = execute(sql);
- } else {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "auto_generated_keys_not_supported", null);
- }
- return ret;
- }
-
- public boolean execute(String sql, String[] columnNames) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnNames);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "execute", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnNames);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("execute");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- boolean ret;
-
- if (columnNames == null) {
- ret = execute(sql);
- } else if (columnNames.length == 0) {
- ret = execute(sql);
- } else {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "auto_generated_keys_not_supported", null);
- }
- return ret;
- }
-
- public int[] executeBatch() throws SQLException, BatchUpdateException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeBatch", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("executeBatch");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- try {
- int i = 0;
- SQLException se;
-
- validateExecDirectInvocation();
- if ((batchCommands_ == null) || (batchCommands_.isEmpty())) {
- return new int[]
-
- {};
- }
-
- batchRowCount_ = new int[batchCommands_.size()];
- for (i = 0; i < batchCommands_.size(); i++) {
- String sql = (String) batchCommands_.get(i);
-
- if (sql == null) {
- se = HPT4Messages.createSQLException(connection_.props_, this.ist_.ic_.getLocale(),
- "batch_command_failed", "Invalid SQL String");
- throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
- }
-
- sqlStmtType_ = ist_.getSqlStmtType(sql);
-
- if (sqlStmtType_ == TRANSPORT.TYPE_SELECT) {
- se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "select_in_batch_not_supported", null);
- throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
- } else if (sqlStmtType_ == TRANSPORT.TYPE_STATS) {
- se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "infostats_invalid_error", null);
- throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
- } else if (sqlStmtType_ == TRANSPORT.TYPE_CONFIG) {
- se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "config_cmd_invalid_error", null);
- throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
- }
- ist_.setTransactionStatus(connection_, sql);
- }
-
- Object[] commands = batchCommands_.toArray();
- int[] batchRowCount = new int[commands.length];
- String sql;
- int rowCount = 0;
-
- try {
- for (i = 0; i < commands.length; i++) {
- sql = String.valueOf(commands[i]);
-
- validateExecDirectInvocation(sql);
-
- ist_.execute(TRANSPORT.SRVR_API_SQLEXECDIRECT, 0, 0, null, queryTimeout_, sql_, this);
-
- checkSQLWarningAndClose();
-
- batchRowCount[i] = batchRowCount_[0]; // the member will
- // be set by
- // execute...keep
- // them in our local
- // array
- rowCount += ist_.getRowCount();
- }
- // CTS requirement.
- if (commands.length < 1) {
- batchRowCount = new int[] {};
- }
- } catch (SQLException e) {
- ist_.setRowCount(rowCount);
- batchRowCount_ = new int[i];
- System.arraycopy(batchRowCount, 0, batchRowCount_, 0, i);
-
- BatchUpdateException be;
-
- se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "batch_command_failed", null);
- be = new BatchUpdateException(se.getMessage(), se.getSQLState(), batchRowCount_);
- be.setNextException(e);
-
- try {
- if (resultSet_[result_set_offset] == null) {
- internalClose();
- }
- } catch (SQLException closeException) {
- be.setNextException(closeException);
- }
- performConnectionErrorChecks(e);
-
- throw be;
- }
-
- ist_.setRowCount(rowCount);
- batchRowCount_ = new int[i];
- System.arraycopy(batchRowCount, 0, batchRowCount_, 0, i);
- return batchRowCount_;
- } finally {
- clearBatch();
- }
-
- }
-
- public ResultSet executeQuery(String sql) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeQuery", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("executeQuery");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- validateExecDirectInvocation(sql);
- if (sqlStmtType_ != TRANSPORT.TYPE_SELECT && sqlStmtType_ != TRANSPORT.TYPE_STATS) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "non_select_invalid",
- null);
- }
- try {
- ist_.execute(TRANSPORT.SRVR_API_SQLEXECDIRECT, 0, 0, null, queryTimeout_, sql_, this);
-
- checkSQLWarningAndClose();
- } catch (SQLException se) {
- try {
- if (resultSet_[result_set_offset] == null) {
- internalClose();
- }
- } catch (SQLException closeException) {
- se.setNextException(closeException);
- }
- performConnectionErrorChecks(se);
- throw se;
- }
- return resultSet_[result_set_offset];
- }
-
- public int executeUpdate(String sql) throws SQLException {
- long count = executeUpdate64(sql);
-
- if (count > Integer.MAX_VALUE)
- this.setSQLWarning(null, "numeric_out_of_range", null);
-
- return (int) count;
- }
-
- public long executeUpdate64(String sql) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeUpdate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("executeUpdate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateExecDirectInvocation(sql);
- // 7708
- if (sqlStmtType_ == TRANSPORT.TYPE_SELECT && (ist_.stmtIsLock != true)) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "select_invalid", null);
- }
- try {
- ist_.execute(TRANSPORT.SRVR_API_SQLEXECDIRECT, 0, 0, null, queryTimeout_, sql_, this);
-
- checkSQLWarningAndClose();
- } catch (SQLException se) {
- try {
- if (resultSet_[result_set_offset] == null) {
- internalClose();
- }
- } catch (SQLException closeException) {
- se.setNextException(closeException);
- }
- performConnectionErrorChecks(se);
- throw se;
- }
- return ist_.getRowCount();
- }
-
- public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, autoGeneratedKeys);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeUpdate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, autoGeneratedKeys);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("executeUpdate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int ret;
-
- if (autoGeneratedKeys == TrafT4Statement.NO_GENERATED_KEYS) {
- ret = executeUpdate(sql);
- } else {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "auto_generated_keys_not_supported", null);
- }
- return ret;
- }
-
- public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnIndexes);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeUpdate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnIndexes);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("executeUpdate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int ret;
-
- if (columnIndexes == null) {
- ret = executeUpdate(sql);
- } else if (columnIndexes.length == 0) {
- ret = executeUpdate(sql);
- } else {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "auto_generated_keys_not_supported", null);
- }
- return ret;
- }
-
- public int executeUpdate(String sql, String[] columnNames) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnNames);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeUpdate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnNames);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("executeUpdate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int ret;
-
- if (columnNames == null) {
- ret = executeUpdate(sql);
- } else if (columnNames.length == 0) {
- ret = executeUpdate(sql);
- } else {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "auto_generated_keys_not_supported", null);
- }
- return ret;
- }
-
- public Connection getConnection() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getConnection", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("getConnection");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return connection_;
- }
-
- public int getFetchDirection() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getFetchDirection", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("getFetchDirection");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- return fetchDirection_;
- }
-
- public int getFetchSize() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getFetchSize", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("getFetchSize");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- return fetchSize_;
- }
-
- public ResultSet getGeneratedKeys() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getGeneratedKeys", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("getGeneratedKeys");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "auto_generated_keys_not_supported", null);
- }
-
- public int getMaxFieldSize() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getMaxFieldSize", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("getMaxFieldSize");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- return maxFieldSize_;
- }
-
- public int getMaxRows() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getMaxRows", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("getMaxRows");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- return maxRows_;
- }
-
- public boolean getMoreResults() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getMoreResults", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("getMoreResults");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- return getMoreResults(Statement.CLOSE_CURRENT_RESULT);
- }
-
- public boolean getMoreResults(int current) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, current);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getMoreResults", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, current);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("getMoreResults");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- switch (current) {
- case Statement.CLOSE_ALL_RESULTS:
- for (int i = 0; i <= result_set_offset; i++) {
- if (resultSet_[i] != null) {
- resultSet_[i].close();
- }
- }
- break;
- case Statement.KEEP_CURRENT_RESULT:
- break;
- case Statement.CLOSE_CURRENT_RESULT: // this is the default action
- default:
- if (resultSet_[result_set_offset] != null) {
- resultSet_[result_set_offset].close();
- }
- break;
- }
- ist_.setRowCount(-1);
- if (result_set_offset < num_result_sets_ - 1) {
- result_set_offset++;
- return true;
- }
- return false;
- }
-
- public int getQueryTimeout() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getQueryTimeout", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("getQueryTimeout");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- return queryTimeout_;
- }
-
- public ResultSet getResultSet() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getResultSet", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("getResultSet");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- return resultSet_[result_set_offset];
- }
-
- public int getResultSetConcurrency() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getResultSetConcurrency", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("getResultSetConcurrency");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- return resultSetConcurrency_;
- }
-
- public int getResultSetHoldability() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getResultSetHoldability", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("getResultSetHoldability");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- return resultSetHoldability_;
- }
-
- public int getResultSetType() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getResultSetType", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("getResultSetType");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- return resultSetType_;
- }
-
- public int getUpdateCount() throws SQLException {
- long count = getUpdateCount64();
-
- if (count > Integer.MAX_VALUE)
- this.setSQLWarning(null, "numeric_out_of_range", null);
-
- return (int) count;
- }
-
- public long getUpdateCount64() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getUpdateCount", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("getUpdateCount");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- if (ist_ == null) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_statement_handle", null);
- }
-
- // Spec wants -1 when the resultset is current and no more rows.
- long count = ist_.getRowCount();
- if ((count == 0) && resultSet_ != null && resultSet_[result_set_offset] != null) {
- count = -1;
- }
-
- return count;
- }
-
- // ------------------------------------------------------------------
- /**
- * This method will get the operation ID for this statement. -1 is returned
- * if the operation ID has not been set.
- *
- * @retrun The operation ID or -1 if the operation ID has not been set.
- *
- * @exception A
- * SQLException is thrown
- */
- public short getOperationID() throws SQLException {
- return operationID_;
- } // end getOperationID
-
- // ------------------------------------------------------------------
- /**
- * This method will get the operation buffer for this statement. Null is
- * returned if the operation buffer has not been set.
- *
- * @retrun The operation buffer or null if the operation ID has not been
- * set.
- *
- * @exception A
- * SQLException is thrown
- */
- public byte[] getOperationBuffer() throws SQLException {
- // System.out.println("in getOperation");
- return operationBuffer_;
- }
-
- // ------------------------------------------------------------------
- /**
- * This method will get the operation reply buffer for this statement. Null
- * is returned if the operation reply buffer has not been set.
- *
- * @retrun The operation reply buffer or null.
- *
- * @exception A
- * SQLException is thrown
- */
- public byte[] getOperationReplyBuffer() throws SQLException {
- // System.out.println("in getOperationReplyBuffer");
- return operationReply_;
- }
-
- // ------------------------------------------------------------------
-
- public void setCursorName(String name) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, name);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setCursorName", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, name);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("setCursorName");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- // TODO: May need to check the Statement STATE
- cursorName_ = name;
- }
-
- public void setEscapeProcessing(boolean enable) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, enable);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setEscapeProcessing", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, enable);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("setEscapeProcessing");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- escapeProcess_ = enable;
-
- }
-
- public void setFetchDirection(int direction) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, direction);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setFetchDirection", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, direction);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("setFetchDirection");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- switch (direction) {
- case ResultSet.FETCH_FORWARD:
- fetchDirection_ = direction;
- break;
- case ResultSet.FETCH_REVERSE:
- case ResultSet.FETCH_UNKNOWN:
- fetchDirection_ = ResultSet.FETCH_FORWARD;
- break;
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_fetch_direction", null);
- }
- }
-
- public void setFetchSize(int rows) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rows);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setFetchSize", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rows);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("setFetchSize");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- if (rows < 0) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_fetch_size",
- null);
- } else if (rows == 0) {
- fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
- } else {
- fetchSize_ = rows;
- }
- }
-
- public void setMaxFieldSize(int max) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, max);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setMaxFieldSize", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, max);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("setMaxFieldSize");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- if (max < 0) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_maxFieldSize_value", null);
- }
- maxFieldSize_ = max;
- }
-
- public void setMaxRows(int max) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, max);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setMaxRows", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, max);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("setMaxRows");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- if (max < 0) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_maxRows_value",
- null);
- }
- maxRows_ = max;
- }
-
- public void setQueryTimeout(int seconds) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, seconds);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setQueryTimeout", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, seconds);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("setQueryTimeout");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- //HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "setQueryTimeout()");
-
- if (seconds < 0) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_queryTimeout_value", null);
- }
- queryTimeout_ = seconds;
- }
-
- // ------------------------------------------------------------------
- /**
- * This method will set the operation ID for this statement.
- *
- * @param opID
- * the operation ID to associate with this statement.
- *
- * @exception A
- * SQLException is thrown
- */
- public void setOperationID(short opID) throws SQLException {
- operationID_ = opID;
- } // end setOperationID
-
- // ------------------------------------------------------------------
- /**
- * This method will set the operation buffer for this statement.
- *
- * @param The
- * operation buffer.
- *
- * @exception A
- * SQLException is thrown
- */
- public void setOperationBuffer(byte[] opBuffer) throws SQLException {
- operationBuffer_ = opBuffer;
- }
-
-
- void validateExecDirectInvocation(String sql) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "validateExecDirectInvocation", "", p);
- }
-
- validateExecDirectInvocation();
- sqlStmtType_ = ist_.getSqlStmtType(sql);
- ist_.setTransactionStatus(connection_, sql);
- sql_ = sql;
-
- }
-
- void validateExecDirectInvocation() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "validateExecDirectInvocation", "", p);
- }
- ist_.setRowCount(-1);
- clearWarnings();
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_statement",
- null);
- }
- try {
- // connection_.getServerHandle().isConnectionOpen();
- connection_.isConnectionOpen();
-
- // close the previous resultset, if any
- for (int i = 0; i < num_result_sets_; i++) {
- if (resultSet_[i] != null) {
- resultSet_[i].close();
- }
- }
- } catch (SQLException se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- }
-
- // This functions ensure that Database Resources are cleaned up,
- // but leave the java Statement object
- // intact.
- void internalClose() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "internalClose", "", p);
- }
- if (connection_._isClosed() == false) {
- ist_.close();
- }
- }
-
- private void setResultSet(HPT4Desc[] outputDesc) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, outputDesc);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "setResultSet", "", p);
- }
- initResultSets();
- if (outputDesc != null) {
- resultSet_[result_set_offset] = new TrafT4ResultSet(this, outputDesc);
- } else {
- resultSet_[result_set_offset] = null;
- }
- }
-
- public void setTransactionToJoin(byte[] txid) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, txid);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "setTransactionToJoin", "", p);
- }
-
- this.transactionToJoin = txid;
- }
-
- void setMultipleResultSets(int num_result_sets, HPT4Desc[][] output_descriptors, String[] stmt_labels,
- String[] proxySyntax) throws SQLException {
- if (num_result_sets < 1)
- return;
-
- resultSet_ = new TrafT4ResultSet[num_result_sets];
- num_result_sets_ = num_result_sets;
- for (int i = 0; i < num_result_sets; i++) {
- HPT4Desc[] desc = output_descriptors[i];
- if (desc == null) {
- resultSet_[i] = null;
- } else {
- resultSet_[i] = new TrafT4ResultSet(this, desc, stmt_labels[i], true);
- resultSet_[i].proxySyntax_ = proxySyntax[i];
- }
- }
- }
-
- // ----------------------------------------------------------------------------------
- void setExecute2Outputs(byte[] values, short rowsAffected, boolean endOfData, String[] proxySyntax, HPT4Desc[] desc)
- throws SQLException {
- num_result_sets_ = 1;
- result_set_offset = 0;
-
- // if NO DATA FOUND is returned from the server, desc = null but
- // we still want to save our descriptors from PREPARE
- if (desc != null)
- outputDesc_ = desc;
-
- resultSet_ = new TrafT4ResultSet[num_result_sets_];
-
- if (outputDesc_ != null) {
- resultSet_[result_set_offset] = new TrafT4ResultSet(this, outputDesc_);
- resultSet_[result_set_offset].proxySyntax_ = proxySyntax[result_set_offset];
-
- if (rowsAffected == 0) {
- if (endOfData == true) {
- resultSet_[result_set_offset].setFetchOutputs(new Row[0], 0, true);
- }
- } else {
- if(resultSet_[result_set_offset].keepRawBuffer_ == true)
- resultSet_[result_set_offset].rawBuffer_ = values;
-
- resultSet_[result_set_offset].irs_.setExecute2FetchOutputs(resultSet_[result_set_offset], 1, true,
- values);
- }
- } else {
- resultSet_[result_set_offset] = null;
- }
- }
-
- // Constructors with access specifier as "default"
- TrafT4Statement() {
- if (T4Properties.t4GlobalLogger.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null);
- T4Properties.t4GlobalLogger.logp(Level.FINE, "TrafT4Statement", "<init>", "", p);
- }
- resultSet_ = new TrafT4ResultSet[1];
- initResultSets();
- }
-
- /*
- * * For closing statements using label.
- */
- TrafT4Statement(TrafT4Connection connection, String stmtLabel) throws SQLException {
- if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, stmtLabel);
- connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>", "", p);
- }
- if (connection.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("Note, this constructor was called before the previous constructor");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection.props_.getLogWriter().println(temp);
- }
- int hashcode;
-
- connection_ = connection;
- operationID_ = -1;
-
- resultSetType_ = ResultSet.TYPE_FORWARD_ONLY;
- resultSetConcurrency_ = ResultSet.CONCUR_READ_ONLY;
- resultSetHoldability_ = TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT;
- queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
-
- stmtLabel_ = stmtLabel;
- fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
- maxRows_ = 0;
- fetchDirection_ = ResultSet.FETCH_FORWARD;
- pRef_ = new WeakReference(this, connection_.refStmtQ_);
- ist_ = new InterfaceStatement(this);
- connection_.addElement(pRef_, stmtLabel_);
-
- resultSet_ = new TrafT4ResultSet[1];
- initResultSets();
- }
-
- TrafT4Statement(TrafT4Connection connection) throws SQLException {
- this(connection, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT);
- if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection);
- connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>",
- "Note, this constructor was called before the previous constructor", p);
- }
- if (connection.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("<init>");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection.props_.getLogWriter().println(temp);
- }
- resultSet_ = new TrafT4ResultSet[1];
- roundingMode_ = connection_.props_.getRoundingMode();
- initResultSets();
- }
-
- TrafT4Statement(TrafT4Connection connection, int resultSetType, int resultSetConcurrency) throws SQLException {
- this(connection, resultSetType, resultSetConcurrency, TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT);
- if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
- resultSetConcurrency);
- connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>",
- "Note, this constructor was called before the previous constructor", p);
- }
- if (connection.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
- resultSetConcurrency);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("<init>");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection.props_.getLogWriter().println(temp);
- }
- resultSet_ = new TrafT4ResultSet[1];
- roundingMode_ = connection_.props_.getRoundingMode();
- initResultSets();
- }
- TrafT4Statement(TrafT4Connection connection, int resultSetType, int resultSetConcurrency, int resultSetHoldability,
- String stmtLabel) throws SQLException {
- if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
- resultSetConcurrency, resultSetHoldability);
- connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>", "", p);
- }
- if (connection.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
- resultSetConcurrency, resultSetHoldability);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("<init>");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection.props_.getLogWriter().println(temp);
- }
- int hashcode;
-
- connection_ = connection;
- operationID_ = -1;
-
- if (resultSetType != ResultSet.TYPE_FORWARD_ONLY && resultSetType != ResultSet.TYPE_SCROLL_INSENSITIVE
- && resultSetType != ResultSet.TYPE_SCROLL_SENSITIVE) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_resultset_type", null);
- }
-
- if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) {
- resultSetType_ = ResultSet.TYPE_SCROLL_INSENSITIVE;
- connection_.setSQLWarning(null, "scrollResultSetChanged", null);
- //setSQLWarning(null, "scrollResultSetChanged", null);
- } else {
- resultSetType_ = resultSetType;
- }
- if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY && resultSetConcurrency != ResultSet.CONCUR_UPDATABLE) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_resultset_concurrency", null);
- }
-
- if ((resultSetHoldability != 0) && (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT)
- && (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_holdability",
- null);
- }
-
- resultSetConcurrency_ = resultSetConcurrency;
- resultSetHoldability_ = resultSetHoldability;
- queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
-
- stmtLabel_ = stmtLabel;
- fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
- maxRows_ = 0;
- fetchDirection_ = ResultSet.FETCH_FORWARD;
-
- connection_.gcStmts();
- pRef_ = new WeakReference(this, connection_.refStmtQ_);
- ist_ = new InterfaceStatement(this);
- connection_.addElement(pRef_, stmtLabel_);
- roundingMode_ = connection_.props_.getRoundingMode();
-
- resultSet_ = new TrafT4ResultSet[1];
- }
-
- TrafT4Statement(TrafT4Connection connection, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
- throws SQLException {
- if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
- resultSetConcurrency, resultSetHoldability);
- connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>", "", p);
- }
- if (connection.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
- resultSetConcurrency, resultSetHoldability);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Statement");
- lr.setSourceMethodName("<init>");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection.props_.getLogWriter().println(temp);
- }
- int hashcode;
-
- connection_ = connection;
- operationID_ = -1;
-
- if (resultSetType != ResultSet.TYPE_FORWARD_ONLY && resultSetType != ResultSet.TYPE_SCROLL_INSENSITIVE
- && resultSetType != ResultSet.TYPE_SCROLL_SENSITIVE) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_resultset_type", null);
- }
-
- if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) {
- resultSetType_ = ResultSet.TYPE_SCROLL_INSENSITIVE;
- connection_.setSQLWarning(null, "scrollResultSetChanged", null);
- //setSQLWarning(null, "scrollResultSetChanged", null);
- } else {
- resultSetType_ = resultSetType;
- }
- if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY && resultSetConcurrency != ResultSet.CONCUR_UPDATABLE) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_resultset_concurrency", null);
- }
-
- if ((resultSetHoldability != 0) && (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT)
- && (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_holdability",
- null);
- }
-
- resultSetConcurrency_ = resultSetConcurrency;
- resultSetHoldability_ = resultSetHoldability;
- queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
-
- stmtLabel_ = generateStmtLabel();
- fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
- maxRows_ = 0;
- fetchDirection_ = ResultSet.FETCH_FORWARD;
-
- connection_.gcStmts();
- pRef_ = new WeakReference(this, connection_.refStmtQ_);
- ist_ = new InterfaceStatement(this);
- connection_.addElement(pRef_, stmtLabel_);
-
- resultSet_ = new TrafT4ResultSet[1];
- roundingMode_ = connection_.props_.getRoundingMode();
- initResultSets();
- }
-
- //max length for a label is 32 characters.
- String generateStmtLabel() {
- String id = String.valueOf(this.connection_.ic_.getSequenceNumber());
- if(id.length() > 24) {
- id = id.substring(id.length()-24);
- }
-
- return "SQL_CUR_" + id;
- }
-
- // Database statement are not deallocated when there is a
- // SQLWarning or SQLException or when a resultSet is produced
- void checkSQLWarningAndClose() {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "checkSQLWarningAndClose", "", p);
- }
- if (sqlWarning_ != null) {
- if (resultSet_[result_set_offset] == null) {
- try {
- internalClose();
- } catch (SQLException closeException1) {
- }
- }
- }
- }
-
- public void setRoundingMode(int roundingMode) {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, roundingMode);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setRoundingMode", "", p);
- }
- roundingMode_ = Utility.getRoundingMode(roundingMode);
- }
-
- public void setRoundingMode(String roundingMode) {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, roundingMode);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setRoundingMode", "", p);
- }
- roundingMode_ = Utility.getRoundingMode(roundingMode);
- }
-
- void closeErroredConnection(HPT4Exception sme) {
- connection_.closeErroredConnection(sme);
- }
-
- /**
- * Use this method to retrieve the statement-label name that was used when
- * creating the statement through the Trafodion connectivity service. You can
- * subsequently use the name retrieved as the cursor name when invoking
- * INFOSTATS to gather resource statistics through either the
- * <code>executeQuery(String sql)</code> or
- * <code>execute(String sql)</code> methods.
- */
- public String getStatementLabel() {
- return new String(stmtLabel_);
- }
-
- /**
- * Returns the raw SQL associated with the statement
- *
- * @return the SQL text
- */
- public String getSQL() {
- return this.sql_;
- }
-
- /**
- * Returns the MXCS statement handle
- *
- * @return the MXCS statement handle
- */
- public int getStmtHandle() {
- return this.ist_.stmtHandle_;
- }
-
- // static fields
- public static final int NO_GENERATED_KEYS = 2;
- // Fields
- TrafT4Connection connection_;
- int resultSetType_;
- int resultSetConcurrency_;
- String sql_;
- int queryTimeout_;
- int maxRows_;
- int maxFieldSize_;
- int fetchSize_;
- int fetchDirection_;
- boolean escapeProcess_;
- String cursorName_ = "";
- TrafT4ResultSet[] resultSet_; // Added for SPJ RS - SB 11/21/2005
- int num_result_sets_; // Added for SPJ RS - SB 11/21/2005
- int result_set_offset; // Added for SPJ RS - SB 11/21/2005
- String stmtLabel_;
- short sqlStmtType_;
- boolean isClosed_;
- ArrayList batchCommands_;
- int[] batchRowCount_;
- WeakReference pRef_;
- int resultSetHoldability_;
- InterfaceStatement ist_;
-
- int inputParamsLength_;
- int outputParamsLength_;
- int inputDescLength_;
- int outputDescLength_;
-
- int inputParamCount_;
- int outputParamCount_;
-
- int roundingMode_ = BigDecimal.ROUND_HALF_EVEN;
-
- HPT4Desc[] inputDesc_, outputDesc_;
-
- short operationID_;
- byte[] operationBuffer_;
- byte[] operationReply_;
-
- boolean usingRawRowset_;
- ByteBuffer rowwiseRowsetBuffer_;
-
- byte[] transactionToJoin;
-
- int _lastCount = -1;
-
- /**
- * @return the inputParamsLength_
- */
- public int getInputParamsLength_() {
- return inputParamsLength_;
- }
-
- /**
- * @return the outputParamsLength_
- */
- public int getOutputParamsLength_() {
- return outputParamsLength_;
- }
-
- public Object unwrap(Class iface) throws SQLException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean isWrapperFor(Class iface) throws SQLException {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean isClosed() throws SQLException {
- // TODO Auto-generated method stub
- return isClosed_;
- }
-
- public void setPoolable(boolean poolable) throws SQLException {
- // TODO Auto-generated method stub
-
- }
-
- public boolean isPoolable() throws SQLException {
- // TODO Auto-generated method stub
- return false;
- }
-
- public void closeOnCompletion() throws SQLException {
- // TODO Auto-generated method stub
-
- }
-
- public boolean isCloseOnCompletion() throws SQLException {
- // TODO Auto-generated method stub
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/USER_DESC_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/USER_DESC_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/USER_DESC_def.java
deleted file mode 100644
index d67aa96..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/USER_DESC_def.java
+++ /dev/null
@@ -1,61 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class USER_DESC_def {
- int userDescType;
- byte[] userSid;
- String domainName;
- String userName;
- byte[] password;
-
- byte[] domainNameBytes;
- byte[] userNameBytes;
-
- int sizeOf(InterfaceConnection ic) throws CharacterCodingException, UnsupportedCharsetException {
- int size = 0;
-
- domainNameBytes = ic.encodeString(domainName, 1);
- userNameBytes = ic.encodeString(userName, 1);
-
- size += TRANSPORT.size_int; // descType
-
- size += TRANSPORT.size_bytes(userSid);
- size += TRANSPORT.size_bytes(domainNameBytes);
- size += TRANSPORT.size_bytes(userNameBytes);
- size += TRANSPORT.size_bytes(password);
-
- return size;
- }
-
- void insertIntoByteArray(LogicalByteArray buf) {
- buf.insertInt(userDescType);
-
- buf.insertString(userSid);
- buf.insertString(domainNameBytes);
- buf.insertString(userNameBytes);
- buf.insertString(password);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Utility.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Utility.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Utility.java
deleted file mode 100644
index a3224d7..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Utility.java
+++ /dev/null
@@ -1,636 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.io.UnsupportedEncodingException;
-import java.math.BigDecimal;
-import java.sql.DataTruncation;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-/**
- * This class contains a variety of methods for doing all sorts of things.
- * @version 1.0
- */
-
-class Utility {
-
- private static final byte key[] = Utility.UnicodeToAscii("ci4mg04-3;" + "b,hl;y'd1q" + "x8ngp93nGp" + "oOp4HlD7vm"
- + ">o(fHoPdkd" + "khp1`gl0hg" + "qERIFdlIFl" + "w48fgljksg" + "3oi5980rfd" + "4t8u9dfvkl");
-
- // -------------------------------------------------------------
- /**
- * This method will translate a double byte Unicode string into a single
- * byte ASCII array.
- *
- * @param original
- * the original string
- *
- * @return a byte array containing the translated string
- *
- * @exception An
- * UnsupportedEncodingException is thrown
- */
- static byte[] UnicodeToAscii(String original) {
- try {
- byte[] utf8Bytes = original.getBytes("UTF8");
- return utf8Bytes;
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- return null;
- } // end UnicodeToAscii
-
- // -------------------------------------------------------------
- /**
- * This method will encrypt a byte buffer according to the encryption
- * algorithm used by the ODBC server.
- *
- * @param original
- * the original string
- *
- * @return a byte array containing the translated string
- *
- */
- static boolean Encryption(byte inBuffer[], byte outBuffer[], int inLength) {
- // Use simple encryption/decryption
-
- if (outBuffer != inBuffer) {
- System.arraycopy(outBuffer, 0, inBuffer, 0, inLength);
- } // end if
-
- for (int i = 0; i < inLength; ++i) {
- int j = i % 100;
- outBuffer[i] ^= key[j];
- }
-
- return true;
- } // end Encryption
-
- // -------------------------------------------------------------
- /**
- * This method will check a float value according to the MAX_FLOAT and
- * MIN_FLOAT values in the Java language.
- *
- * @param the
- * original double value to check
- * @Locale the Locale to print the error message in
- *
- * @return none
- *
- */
- static void checkFloatBoundary(Locale locale, BigDecimal inbd) throws SQLException {
- double indbl = inbd.doubleValue();
- // double abdbl = inbd.abs().doubleValue(); Need to do MIN check as well
- if (indbl > (double) Float.MAX_VALUE) {
- throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", inbd.toString());
- }
- } // end checkFloatBoundary
-
- // -------------------------------------------------------------
- /**
- * This method will check a double value according to the MAX_VALUE and
- * MIN_VALUE values in the Double class.
- *
- * @param the
- * original double value to check
- * @Locale the Locale to print the error message in
- *
- * @return none
- *
- */
- static void checkDoubleBoundary(Locale locale, BigDecimal inbd) throws SQLException {
- BigDecimal maxbd = new BigDecimal(Double.MAX_VALUE);
- // need to check min as well
- // BigDecimal minbd = new BigDecimal(Double.MIN_VALUE);
- if ((inbd.compareTo(maxbd) > 0)) {
- throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", inbd.toString());
- }
-
- } // end checkDoubleBoundary
-
- // -------------------------------------------------------------
- /**
- * This method will check a Integer value according to the
- * Interger.MAX_VALUE and Integer.MIN_VALUE values.
- *
- * @param the
- * original long value to check
- * @Locale the Locale to print the error message in
- *
- * @return none
- *
- */
- static void checkIntegerBoundary(Locale locale, BigDecimal inbd) throws SQLException {
- long inlong = inbd.longValue();
- if ((inlong > Integer.MAX_VALUE) || (inlong < Integer.MIN_VALUE)) {
- throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
- }
- } // end checkIntegerBoundary
-
- // -------------------------------------------------------------
- /**
- * This method will check a Long value according to the Long.MAX_VALUE*2 and
- * 0 values.
- *
- * @param the
- * original BigDecimal value to check
- * @Locale the Locale to print the error message in
- *
- * @return none
- *
- */
- static void checkSignedLongBoundary(Locale locale, BigDecimal inbd) throws SQLException {
- long inlong = inbd.longValue();
- BigDecimal maxbd = new BigDecimal(Long.MAX_VALUE);
- maxbd = maxbd.add(maxbd);
- if ((inlong < 0) || (inbd.compareTo(maxbd) > 0)) {
- throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
- }
- } // end checkIntegerBoundary
-
- // -------------------------------------------------------------
- /**
- * This method will check a unsigned Short value according to the
- * Short.MAX_VALUE*2 and 0 values.
- *
- * @param the
- * original BigDecimal value to check
- * @Locale the Locale to print the error message in
- *
- * @return none
- *
- */
- static void checkSignedShortBoundary(Locale locale, BigDecimal inbd) throws SQLException {
- long inlong = inbd.longValue();
- long maxushort = (Short.MAX_VALUE * 2) + 1;
- if ((inlong < 0) || (inlong > maxushort)) {
- throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
- }
- } // end checkIntegerBoundary
-
- // -------------------------------------------------------------
- /**
- * This method will check a unsigned Int value according to the
- * Integer.MAX_VALUE*2 and 0 values.
- *
- * @param the
- * original BigDecimal value to check
- * @Locale the Locale to print the error message in
- *
- * @return none
- *
- */
- static void checkUnsignedIntegerBoundary(Locale locale, BigDecimal inbd) throws SQLException {
- long inlong = inbd.longValue();
- long maxuint = ((long) Integer.MAX_VALUE * 2L) + 1L;
- if ((inlong < 0) || (inlong > maxuint)) {
- throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
- }
- } // end checkIntegerBoundary
-
- // -------------------------------------------------------------
- /**
- * This method will check a Tinyint value according to the Byte.MAX_VALUE
- * and Byte.MIN_VALUE values.
- *
- * @param the
- * original long value to check
- * @Locale the Locale to print the error message in
- *
- * @return none
- *
- */
- static void checkTinyintBoundary(Locale locale, BigDecimal inbd) throws SQLException {
- long inlong = inbd.longValue();
- if ((inlong > Byte.MAX_VALUE) || (inlong < Byte.MIN_VALUE)) {
- throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
- }
- } // end checkTinyintBoundary
-
- // -------------------------------------------------------------
- /**
- * This method will check a Short value according to the Short.MAX_VALUE and
- * Short.MIN_VALUE values.
- *
- * @param the
- * original long value to check
- * @Locale the Locale to print the error message in
- *
- * @return none
- *
- */
- static void checkShortBoundary(Locale locale, BigDecimal inbd) throws SQLException {
- long inlong = inbd.longValue();
- if ((inlong > Short.MAX_VALUE) || (inlong < Short.MIN_VALUE)) {
- throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
- }
- } // end checkShortBoundary
-
- // -------------------------------------------------------------
- /**
- * This method will extract the BigDecimal value.
- *
- * @param the
- * Locale to print the error message in
- * @param the
- * original object value to extract
- *
- * @return constructed BigDecimal value
- *
- */
- static BigDecimal getBigDecimalValue(Locale locale, Object paramValue) throws SQLException {
- BigDecimal tmpbd;
-
- if (paramValue instanceof Long) {
- tmpbd = BigDecimal.valueOf(((Long) paramValue).longValue());
- } else if (paramValue instanceof Integer) {
- tmpbd = BigDecimal.valueOf(((Integer) paramValue).longValue());
- } else if (paramValue instanceof BigDecimal) {
- tmpbd = (BigDecimal) paramValue;
- } else if (paramValue instanceof String) {
- String sVal = (String) paramValue;
- if (sVal.equals("true") == true) {
- sVal = "1";
- } else if (sVal.equals("false") == true) {
- sVal = "0";
- }
- tmpbd = new BigDecimal(sVal);
- } else if (paramValue instanceof Float) {
- tmpbd = new BigDecimal(paramValue.toString());
- } else if (paramValue instanceof Double) {
- tmpbd = new BigDecimal(((Double) paramValue).toString());
- } else if (paramValue instanceof Boolean) {
- tmpbd = BigDecimal.valueOf(((((Boolean) paramValue).booleanValue() == true) ? 1 : 0));
- } else if (paramValue instanceof Byte) {
- tmpbd = BigDecimal.valueOf(((Byte) paramValue).longValue());
- } else if (paramValue instanceof Short) {
- tmpbd = BigDecimal.valueOf(((Short) paramValue).longValue());
- } else if (paramValue instanceof Integer) {
- tmpbd = BigDecimal.valueOf(((Integer) paramValue).longValue());
- // For LOB Support SB: 10/25/2004
- /*
- * else if (paramValue instanceof DataWrapper) tmpbd =
- * BigDecimal.valueOf(((DataWrapper)paramValue).longValue);
- */
- } else {
- throw HPT4Messages.createSQLException(null, locale, "object_type_not_supported", paramValue);
- }
- return tmpbd;
- } // end getBigDecimalValue
-
- // -------------------------------------------------------------
- /**
- * This method will check a Decimal value according to the precision in the
- * Database table.
- *
- * @param the
- * original BigDecimal value to check
- * @param the
- * Locale to print the error message in
- *
- * @return none
- *
- */
- static void checkDecimalBoundary(Locale locale, BigDecimal inbd, int precision) throws SQLException {
- if (precision > 0) {
- BigDecimal maxbd = new BigDecimal(Math.pow(10, precision));
- BigDecimal minbd = maxbd.negate();
- if ((inbd.compareTo(maxbd) >= 0) || (inbd.compareTo(minbd) < 0)) {
- throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", inbd.toString());
- }
- }
- } // end checkBigDecimalBoundary
- //---------------------------------------------------------------
- /*code change starts
- * MR Description: Warnings not being displayed when numeric overflow occurs
- */
-
- /**
- * This method will check a scale value with the column in the
- * Database table.
- *
- * @param the
- * BigDecimal value to check
- * @param the
- * scale to check with the BigDecimal's scale
- *
- * @return none
- *
- */
- static void checkScale(BigDecimal tmpbd, int scale) throws SQLException
- {
- if (tmpbd.scale() > scale)
- if (!((tmpbd.scale() == 1) && (tmpbd.toString().endsWith("0"))))
- {
- try
- {
- Object[] messageArguments = new Object[1];
- messageArguments[0] = new String("A numeric overflow occurred during an arithmetic computation " +
- "or data conversion.");
- throw HPT4Messages.createSQLWarning(null, "8411", messageArguments);
- }
- catch (SQLWarning e)
- {
- e.printStackTrace();
- }
- }
- }
-
- //code change ends
-
- // Fix_LeadingZero - AM 08/07/2006
- private static int getExtraLen(String s) {
- int extra = 0;
-
- // count the trailing zero
- int inx = s.indexOf(".");
- if (inx != -1) {
- int len = s.length();
- for (int i = len - 1; i > inx; i--) {
- char ch = s.charAt(i);
- if (ch != '0') {
- break;
- }
- extra++;
- }
- }
- // count for leading zero
- if (s.startsWith("0.") || s.startsWith("-0.")) {
- extra++;
- }
-
- return extra;
- }
-
- // -------------------------------------------------------------
- /**
- * This method will check a Decimal value according to the precision in the
- * Database table.
- *
- * @param the
- * original BigDecimal value to check
- * @param the
- * Locale to print the error message in
- *
- * @return none
- *
- */
- static void checkDecimalTruncation(int parameterIndex, Locale locale, BigDecimal inbd, int precision, int scale)
- throws SQLException {
- if (precision <= 0)
- return;
-
- int expectedLen = precision;
-
- if (scale > 0)
- expectedLen = precision + 1;
-
- if (inbd.signum() == -1)
- expectedLen++;
- int actualLen = 0;
-
- // Fix_LeadingZero - AM 08/07/2006
- expectedLen += getExtraLen(inbd.toString());
- /*
- * if( (actualLen = inbd.toString().length()) > expectedLen ){
- * //System.out.println("Length of " + inbd.toString() + " is greater
- * than " + precision); throw new DataTruncation(parameterIndex, true,
- * false, actualLen, expectedLen); }
- */
- actualLen = inbd.toString().length();
- if (precision > 0) {
- BigDecimal maxbd = new BigDecimal(Math.pow(10, precision - scale));
- BigDecimal minbd = maxbd.negate();
- if ((inbd.compareTo(maxbd) >= 0) || (inbd.compareTo(minbd) < 0)) {
- // System.out.println("Max = " + maxbd.toString() + "\nMin = " +
- // minbd + "\nInputted Val: " + inbd.toString());
- // throw new DataTruncation(parameterIndex, true, false,
- // actualLen, expectedLen);
- throw new SQLException("*** ERROR[29188] Numeric value " + inbd.doubleValue() + " is out of range [" + minbd.doubleValue() + ", " + maxbd.doubleValue() + "]; Parameter index: " + (parameterIndex) +". ["+new SimpleDateFormat("yyyy-MM-dd HH:mm:s").format(new Date())+"]", "22003", -8411);
- }
- }
- } // end checkDecimalTruncation
-
- // -------------------------------------------------------------
- /**
- * This method will check a Long value according to the Long.MAX_VALUE and
- * Long.MIN_VALUE values.
- *
- * @param the
- * original long value to check
- * @param the
- * Locale to print the error message in
- *
- * @return none
- *
- */
- static void checkLongBoundary(Locale locale, BigDecimal inbd) throws SQLException {
- if ((inbd.compareTo(long_maxbd) > 0) || (inbd.compareTo(long_minbd) < 0)) {
- throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", inbd.toString());
- }
- } // end checkBigDecimalBoundary
-
- // -------------------------------------------------------------
- /**
- * This method will check a Double and long value are the same.
- *
- * @param the
- * original double value to check
- * @param the
- * original long value to check
- * @param the
- * Locale to print the error message in
- *
- * @return none
- *
- */
- static void checkLongTruncation(int parameterindex, BigDecimal inbd) throws SQLException {
- long inlong = inbd.longValue();
- double indbl = inbd.doubleValue();
-
- if ((double) inlong != indbl) {
- int sizeLong = String.valueOf(inlong).length();
- int sizeDbl = String.valueOf(indbl).length();
- // throw new DataTruncation(parameterindex, true, false,
- // sizeLong, sizeDbl);
-
- DataTruncation dt = new DataTruncation(parameterindex, true, false, sizeLong, sizeDbl);
- dt.setNextException(new SQLException("DataTruncation", "22003", -8411));
- throw dt;
- }
- } // end checkLongTruncation
-
- /**
- * This method sets the round mode behaviour for the driver. Accepted values
- * are: static int ROUND_CEILING Rounding mode to round towards positive
- * infinity. static int ROUND_DOWN Rounding mode to round towards zero.
- * static int ROUND_FLOOR Rounding mode to round towards negative infinity.
- * static int ROUND_HALF_DOWN Rounding mode to round towards "nearest
- * neighbor" unless both neighbors are equidistant, in which case round
- * down. static int ROUND_HALF_EVEN Rounding mode to round towards the
- * "nearest neighbor" unless both neighbors are equidistant, in which case,
- * round towards the even neighbor. static int ROUND_HALF_UP Rounding mode
- * to round towards "nearest neighbor" unless both neighbors are
- * equidistant, in which case round up. static int ROUND_UNNECESSARY
- * Rounding mode to assert that the requested operation has an exact result,
- * hence no rounding is necessary. static int ROUND_UP Rounding mode to
- * round away from zero. The default behaviour is to do ROUND_DOWN.
- *
- * @param ref
- * roundMode
- */
- static int getRoundingMode(String roundMode) {
- int op_roundMode = BigDecimal.ROUND_DOWN;
- if (roundMode == null) {
- op_roundMode = BigDecimal.ROUND_DOWN;
- } else if (roundMode.equals("ROUND_CEILING")) {
- op_roundMode = BigDecimal.ROUND_CEILING;
- } else if (roundMode.equals("ROUND_DOWN")) {
- op_roundMode = BigDecimal.ROUND_DOWN;
- } else if (roundMode.equals("ROUND_FLOOR")) {
- op_roundMode = BigDecimal.ROUND_FLOOR;
- } else if (roundMode.equals("ROUND_HALF_UP")) {
- op_roundMode = BigDecimal.ROUND_HALF_UP;
- } else if (roundMode.equals("ROUND_UNNECESSARY")) {
- op_roundMode = BigDecimal.ROUND_UNNECESSARY;
- } else if (roundMode.equals("ROUND_HALF_EVEN")) {
- op_roundMode = BigDecimal.ROUND_HALF_EVEN;
- } else if (roundMode.equals("ROUND_HALF_DOWN")) {
- op_roundMode = BigDecimal.ROUND_HALF_DOWN;
- } else if (roundMode.equals("ROUND_UP")) {
- op_roundMode = BigDecimal.ROUND_UP;
- } else {
- try {
- op_roundMode = getRoundingMode(Integer.parseInt(roundMode));
- } catch (Exception ex) {
- op_roundMode = BigDecimal.ROUND_DOWN;
- }
-
- }
- return op_roundMode;
- }
-
- /**
- * This method sets the round mode behaviour for the driver. Accepted values
- * are: static int ROUND_CEILING Rounding mode to round towards positive
- * infinity. static int ROUND_DOWN Rounding mode to round towards zero.
- * static int ROUND_FLOOR Rounding mode to round towards negative infinity.
- * static int ROUND_HALF_DOWN Rounding mode to round towards "nearest
- * neighbor" unless both neighbors are equidistant, in which case round
- * down. static int ROUND_HALF_EVEN Rounding mode to round towards the
- * "nearest neighbor" unless both neighbors are equidistant, in which case,
- * round towards the even neighbor. static int ROUND_HALF_UP Rounding mode
- * to round towards "nearest neighbor" unless both neighbors are
- * equidistant, in which case round up. static int ROUND_UNNECESSARY
- * Rounding mode to assert that the requested operation has an exact result,
- * hence no rounding is necessary. static int ROUND_UP Rounding mode to
- * round away from zero. The default behaviour is to do ROUND_DOWN.
- *
- * @param ref
- * roundMode
- */
- static int getRoundingMode(int roundMode) {
- if ((roundMode == BigDecimal.ROUND_CEILING) || (roundMode == BigDecimal.ROUND_DOWN)
- || (roundMode == BigDecimal.ROUND_UP) || (roundMode == BigDecimal.ROUND_FLOOR)
- || (roundMode == BigDecimal.ROUND_HALF_UP) || (roundMode == BigDecimal.ROUND_UNNECESSARY)
- || (roundMode == BigDecimal.ROUND_HALF_EVEN) || (roundMode == BigDecimal.ROUND_HALF_DOWN)) {
- return roundMode;
- } else {
- return BigDecimal.ROUND_DOWN;
- }
- }
-
- static BigDecimal setScale(BigDecimal tmpbd, int scale, int roundingMode) throws SQLException {
- try {
- if (scale > -1) {
- tmpbd = tmpbd.setScale(scale, roundingMode);
- }
- } catch (ArithmeticException aex) {
- throw new SQLException(aex.getMessage());
- }
- return tmpbd;
- }
-
- static final BigDecimal long_maxbd = BigDecimal.valueOf(Long.MAX_VALUE);
- static final BigDecimal long_minbd = BigDecimal.valueOf(Long.MIN_VALUE);
-
- static private final char DEFAULT_TRIM_WHITESPACE = ' ';
-
- static public String trimRight(final String string)
- {
- return trimRight(string, DEFAULT_TRIM_WHITESPACE);
- }
-
- static public String trimRight(final String string, final char trimChar)
- {
- final int lastChar = string.length() - 1;
- int i;
-
- for (i = lastChar; i >= 0 && string.charAt(i) == trimChar; i--) {
- /* Decrement i until it is equal to the first char that does not
- * match the trimChar given. */
- }
-
- if (i < lastChar) {
- // the +1 is so we include the char at i
- return string.substring(0, i+1);
- } else {
- return string;
- }
- }
- static public String trimLeft(String string)
- {
- return trimLeft( string, DEFAULT_TRIM_WHITESPACE );
- }
-
- static public String trimLeft(final String string, final char trimChar)
- {
- final int stringLength = string.length();
- int i;
-
- for (i = 0; i < stringLength && string.charAt(i) == trimChar; i++) {
- /* increment i until it is at the location of the first char that
- * does not match the trimChar given. */
- }
-
- if (i == 0) {
- return string;
- } else {
- return string.substring(i);
- }
- }
- static public String trimRightZeros(String x) {
- byte[] input = x.getBytes();
- int i = input.length;
-
- while (i-- > 0 && input[i] == 0) {}
-
- byte[] output = new byte[i+1];
- System.arraycopy(input, 0, output, 0, i+1);
- return new String(output);
- }
-
-} // end class Utility
[03/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4ResultSet.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4ResultSet.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4ResultSet.java
deleted file mode 100644
index c181bee..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4ResultSet.java
+++ /dev/null
@@ -1,5389 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.URL;
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.Connection;
-import java.sql.DataTruncation;
-import java.sql.DatabaseMetaData;
-import java.sql.Date;
-import java.sql.NClob;
-import java.sql.PreparedStatement;
-import java.sql.Ref;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.RowId;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-import java.sql.Statement;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.Calendar;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-public class TrafT4ResultSet extends HPT4Handle implements java.sql.ResultSet {
-
- // java.sql.ResultSet interface methods
- public boolean absolute(int row) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, row);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "absolute", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, row);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("absolute");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- boolean flag = false;
- int absRow;
-
- clearWarnings();
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- if (getType() == ResultSet.TYPE_FORWARD_ONLY) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "forward_only_cursor",
- null);
- }
- if (row == 0) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_row_number",
- null);
- }
-
-
- if (row > 0) {
- if (row <= numRows_) {
- currentRow_ = row;
- isBeforeFirst_ = false;
- isAfterLast_ = false;
- onInsertRow_ = false;
- flag = true;
- } else {
- do {
- flag = next();
- if (!flag) {
- break;
- }
- } while (currentRow_ < row);
- }
- } else {
- absRow = -row;
- afterLast();
- if (absRow <= numRows_) {
- currentRow_ = numRows_ - absRow + 1;
- isAfterLast_ = false;
- isBeforeFirst_ = false;
- onInsertRow_ = false;
- flag = true;
- } else {
- beforeFirst();
- }
- }
- return flag;
- }
-
- public void afterLast() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "afterLast", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("afterLast");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- clearWarnings();
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- if (getType() == ResultSet.TYPE_FORWARD_ONLY) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "forward_only_cursor",
- null);
- }
- last();
- // currentRow_++;
- isAfterLast_ = true;
- isBeforeFirst_ = false;
- }
-
- public void beforeFirst() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "beforeFirst", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("beforeFirst");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- clearWarnings();
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- if (getType() == ResultSet.TYPE_FORWARD_ONLY) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "forward_only_cursor",
- null);
- }
-
-
- currentRow_ = 0;
- isBeforeFirst_ = true;
- isAfterLast_ = false;
- onInsertRow_ = false;
- }
-
- public void cancelRowUpdates() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "cancelRowUpdates", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("cancelRowUpdates");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- clearWarnings();
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- if (getConcurrency() == ResultSet.CONCUR_READ_ONLY) {
- throw HPT4Messages
- .createSQLException(connection_.props_, connection_.getLocale(), "read_only_concur", null);
- }
- if (onInsertRow_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cursor_position", null);
- }
- Row row = (Row) getCurrentRow();
- if (!row.getUpdated()) {
- row.clearUpdated();
- }
- }
-
- /**
- * Close the resultSet. This method is synchronized to prevent many threads
- * talking to the same server after close().
- *
- * @throws SQLException
- */
- synchronized public void close() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "close", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("close");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- clearWarnings();
- if (isClosed_) {
- return;
- }
- if (connection_._isClosed()) {
- connection_.closeErroredConnection(null);
- return;
- }
-
-
- if (stmt_ instanceof org.trafodion.jdbc.t4.TrafT4PreparedStatement) {
- close(false);
- } else {
- close(true);
- }
- }
-
- public void deleteRow() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "deleteRow", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("deleteRow");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- clearWarnings();
-
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- if (getConcurrency() == ResultSet.CONCUR_READ_ONLY) {
- throw HPT4Messages
- .createSQLException(connection_.props_, connection_.getLocale(), "read_only_concur", null);
- }
- if (onInsertRow_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cursor_position", null);
- }
-
-
- try {
- prepareDeleteStmt();
- Row row = (Row) getCurrentRow();
- // Remove the row from database
- row.deleteRow(connection_.getLocale(), deleteStmt_, paramCols_);
- // Remove the row from the resultSet
- cachedRows_.remove(--currentRow_);
- --numRows_;
-
- if ((getType() == ResultSet.TYPE_FORWARD_ONLY) && (getConcurrency() == ResultSet.CONCUR_UPDATABLE)) {
- int temp;
- temp = currentRowCount_;
-
- if (!next()) {
- if (temp == 1) {
- isBeforeFirst_ = true;
- }
- currentRowCount_ = 0;
- } else {
- --currentRowCount_;
- }
- } else {
- if (currentRow_ == 0) {
- isBeforeFirst_ = true;
- }
- }
- } catch (SQLException e) {
- performConnectionErrorChecks(e);
- throw e;
- }
- }
-
- public int findColumn(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "findColumn", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("findColumn");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int i;
-
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- for (i = 0; i < outputDesc_.length; i++) {
- if (columnName.equalsIgnoreCase(outputDesc_[i].name_)) {
- return i + 1;
- }
- }
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_column_name", null);
- }
-
- public boolean first() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "first", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("first");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- boolean flag = true;
-
- clearWarnings();
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- if (getType() == ResultSet.TYPE_FORWARD_ONLY) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "forward_only_cursor",
- null);
- }
-
-
- if (isBeforeFirst_) {
- flag = next();
- }
- if (numRows_ > 0) {
- currentRow_ = 1;
- isAfterLast_ = false;
- isBeforeFirst_ = false;
- onInsertRow_ = false;
- }
- return flag;
- }
-
- // JDK 1.2
- public Array getArray(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getArray", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getArray");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateGetInvocation(columnIndex);
- HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getArray()");
- return null;
- }
-
- // JDK 1.2
- public Array getArray(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getArray", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getArray");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getArray(columnIndex);
- }
-
- public InputStream getAsciiStream(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getAsciiStream", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getAsciiStream");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
- // For LOB Support - SB 10/8/2004
- int dataType;
-
-
- dataType = outputDesc_[columnIndex - 1].dataType_;
- switch (dataType) {
-
-
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.LONGVARBINARY:
- case Types.BLOB:
- case Types.CLOB:
- data = getLocalString(columnIndex);
- if (data != null) {
- try {
- return new java.io.DataInputStream(new java.io.ByteArrayInputStream(data.getBytes("ASCII")));
- } catch (java.io.UnsupportedEncodingException e) {
- Object[] messageArguments = new Object[1];
- messageArguments[0] = e.getMessage();
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "unsupported_encoding", messageArguments);
- }
- } else {
- return null;
- }
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
-
- }
-
- public InputStream getAsciiStream(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getAsciiStream", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getAsciiStream");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getAsciiStream(columnIndex);
- }
-
- public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBigDecimal", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getBigDecimal");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
-
- String data;
- BigDecimal retValue;
- Double d;
-
- validateGetInvocation(columnIndex);
- outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
- // String returned may not be numeric in case of SQL_CHAR, SQL_VARCHAR
- // and SQL_LONGVARCHAR
- // fields. Hoping that java might throw invalid value exception
- data = getLocalString(columnIndex);
- if (data != null) {
- data = data.trim();
- try {
- retValue = new BigDecimal(data);
- } catch (NumberFormatException e) {
- try {
- d = new Double(data);
- } catch (NumberFormatException e1) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
- retValue = new BigDecimal(d.doubleValue());
- }
- return retValue;
- } else {
- return null;
- }
- }
-
- public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, scale);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBigDecimal", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, scale);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getBigDecimal");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- BigDecimal retValue;
-
- retValue = getBigDecimal(columnIndex);
- if (retValue != null) {
- return retValue.setScale(scale);
- } else {
- return null;
- }
- }
-
- public BigDecimal getBigDecimal(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBigDecimal", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getBigDecimal");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getBigDecimal(columnIndex);
- }
-
- public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, scale);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBigDecimal", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, scale);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getBigDecimal");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getBigDecimal(columnIndex, scale);
- }
-
- public InputStream getBinaryStream(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBinaryStream", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getBinaryStream");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateGetInvocation(columnIndex);
- byte[] data;
-
- // For LOB Support - SB 10/8/2004
- int dataType;
-
-
- dataType = outputDesc_[columnIndex - 1].dataType_;
- switch (dataType) {
-
-
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.LONGVARBINARY:
- case Types.BLOB:
- case Types.CLOB:
- data = getBytes(columnIndex);
- if (data != null) {
- return new java.io.ByteArrayInputStream(data);
- } else {
- return null;
- }
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
- }
-
- public InputStream getBinaryStream(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBinaryStream", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getBinaryStream");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getBinaryStream(columnIndex);
- }
-
-
- public boolean getBoolean(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBoolean", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getBoolean");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
- short shortValue;
-
- validateGetInvocation(columnIndex);
- outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
- data = getLocalString(columnIndex);
- if (data != null) {
- data = data.trim();
- if ((data.equalsIgnoreCase("true")) || (data.equalsIgnoreCase("1"))) {
- return true;
- } else if ((data.equalsIgnoreCase("false")) || (data.equalsIgnoreCase("false"))) {
- return false;
- } else {
- try {
- shortValue = getShort(columnIndex);
- } catch (NumberFormatException e) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
- switch (shortValue) {
- case 0:
- return false;
- case 1:
- return true;
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "numeric_out_of_range", null);
- }
- }
- } else {
- return false;
- }
- }
-
- public boolean getBoolean(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBoolean", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getBoolean");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getBoolean(columnIndex);
- }
-
- public byte getByte(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getByte", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getByte");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
- byte retValue;
- Double d;
- double d1;
-
- validateGetInvocation(columnIndex);
- outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
- data = getLocalString(columnIndex);
- if (data != null) {
- try {
- retValue = Byte.parseByte(data);
- } catch (NumberFormatException e) {
- try {
- d = new Double(data);
- } catch (NumberFormatException e1) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
- d1 = d.doubleValue();
- // To allow -128.999.. and 127.999...
- if (d1 > (double) Byte.MIN_VALUE - 1 && d1 < (double) Byte.MAX_VALUE + 1) {
- retValue = d.byteValue();
- if ((double) retValue != d1) {
- setSQLWarning(null, "data_truncation", null);
- }
- } else {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "numeric_out_of_range", null);
- }
- }
- return retValue;
- } else {
- return 0;
- }
- }
-
- public byte getByte(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getByte", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getByte");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getByte(columnIndex);
- }
-
- public byte[] getBytes(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBytes", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getBytes");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateGetInvocation(columnIndex);
- int dataType;
-
-
- dataType = outputDesc_[columnIndex - 1].dataType_;
-
- switch (dataType) {
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.LONGVARBINARY:
- case Types.CHAR:
- case Types.VARCHAR: // Extension allows varchar and
- case Types.LONGVARCHAR: // longvarchar data types
- case Types.BLOB:
- case Types.CLOB:
-
- Object x = getCurrentRow().getColumnObject(columnIndex);
- if (x == null) {
- wasNull_ = true;
- return null;
- } else {
- wasNull_ = false;
- if (x instanceof byte[]) {
- return (byte[]) x;
- } else if (x instanceof String) {
- return ((String) x).getBytes();
- } else {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
- }
-
-
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
- }
-
- public byte[] getBytes(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBytes", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getBytes");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getBytes(columnIndex);
- }
-
- public Reader getCharacterStream(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getCharacterStream", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getCharacterStream");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
- int dataType;
-
-
- validateGetInvocation(columnIndex);
- dataType = outputDesc_[columnIndex - 1].dataType_;
- switch (dataType) {
-
-
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.LONGVARBINARY:
- case Types.BLOB:
- case Types.CLOB:
- data = getString(columnIndex);
- if (data != null) {
- return new java.io.StringReader(data);
- } else {
- return null;
- }
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
-
- }
-
- public Reader getCharacterStream(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getCharacterStream", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getCharacterStream");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getCharacterStream(columnIndex);
- }
-
- public int getConcurrency() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getConcurrency", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getConcurrency");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- if (stmt_ != null) {
- return stmt_.resultSetConcurrency_;
- } else {
- return ResultSet.CONCUR_READ_ONLY;
- }
- }
-
- public String getCursorName() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getCursorName", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getCursorName");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- if (spj_rs_ && stmtLabel_ != null) {
- return stmtLabel_;
- } else if (stmt_ != null) {
- String cursorName;
- cursorName = stmt_.cursorName_;
- if (cursorName == null) {
- cursorName = stmt_.stmtLabel_;
- }
- return cursorName;
- } else {
- return null;
- }
- }
-
- // wm_merge - AM
- static String convertDateFormat(String dt) {
- String tokens[] = dt.split("[/]", 3);
-
- if (tokens.length != 3) {
- return dt;
- }
- StringBuffer sb = new StringBuffer();
- sb.append(tokens[0]).append("-").append(tokens[1]).append("-").append(tokens[2]);
- return sb.toString();
- }
-
- public Date getDate(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getDate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- String data;
- Date retValue;
- int endIndex;
-
- validateGetInvocation(columnIndex);
- dataType = outputDesc_[columnIndex - 1].dataType_;
- if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
- && dataType != Types.DATE && dataType != Types.TIMESTAMP) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
-
- data = getLocalString(columnIndex);
- if (data != null) {
- try {
- boolean convertDate = connection_.getDateConversion();
-
- if (connection_.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- String temp = "Convert Date=" + convertDate;
- connection_.props_.t4Logger_.logp(Level.FINEST, "TrafT4ResultSet", "getDate", temp, p);
- }
- if (convertDate) {
- String dt = convertDateFormat(data);
- retValue = valueOf(dt);
- } else {
- retValue = Date.valueOf(data);
- }
- } catch (IllegalArgumentException e) {
- data = data.trim();
- if ((endIndex = data.indexOf(' ')) != -1) {
- data = data.substring(0, endIndex);
- }
- try {
- retValue = Date.valueOf(data);
- setSQLWarning(null, "data_truncation", null);
-
- } catch (IllegalArgumentException ex) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
- }
- return retValue;
- } else {
- return null;
- }
- }
-
- /* TODO: this is a horrible hack but what else can be done with random 2 digit/4 digit years for dates?
- * Note: The date constructor wants (year-1900) as a parameter
- * We use the following table for conversion:
- *
- * Year Value Assumed Year Action
- * <50 Value + 2000 must add 100
- * >=100 Value must subtract 1900
- * >=50 Value + 1900 no change in value needed
- *
- */
- static Date valueOf(String s) {
- int year;
- int month;
- int day;
- int firstDash;
- int secondDash;
-
- if (s == null)
- throw new java.lang.IllegalArgumentException();
-
- firstDash = s.indexOf('-');
- secondDash = s.indexOf('-', firstDash + 1);
- if ((firstDash > 0) & (secondDash > 0) & (secondDash < s.length() - 1)) {
- year = Integer.parseInt(s.substring(0, firstDash));
-
- if (year < 50) {//handles 2 digit years: <50 assume 2000, >=50 assume 1900
- year += 100;
- }
- else if(year >= 100) { //handles 4 digit years
- year -= 1900;
- }
-
- month = Integer.parseInt(s.substring(firstDash + 1, secondDash)) - 1;
- day = Integer.parseInt(s.substring(secondDash + 1));
- } else {
- throw new java.lang.IllegalArgumentException();
- }
-
- return new Date(year, month, day);
- }
-
- public Date getDate(int columnIndex, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getDate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- Date sqlDate;
- java.util.Date d;
-
- sqlDate = getDate(columnIndex);
- if (sqlDate != null) {
- if (cal != null) {
- cal.setTime(sqlDate);
- d = cal.getTime();
- sqlDate = new Date(d.getTime());
- }
- return sqlDate;
- } else {
- return (sqlDate);
- }
- }
-
- public Date getDate(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getDate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getDate(columnIndex);
- }
-
- public Date getDate(String columnName, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getDate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getDate(columnIndex, cal);
- }
-
- public double getDouble(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDouble", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getDouble");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
-
- validateGetInvocation(columnIndex);
- outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
- data = getLocalString(columnIndex);
- if (data != null) {
- try {
- return Double.parseDouble(data);
- } catch (NumberFormatException e1) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
- } else {
- return 0;
- }
- }
-
- public double getDouble(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDouble", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getDouble");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getDouble(columnIndex);
- }
-
- public int getFetchDirection() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getFetchDirection", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getFetchDirection");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- return fetchDirection_;
- }
-
- public int getFetchSize() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getFetchSize", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getFetchSize");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- return fetchSize_;
- }
-
- public float getFloat(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getFloat", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getFloat");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- double data;
- validateGetInvocation(columnIndex);
-
- outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
- // parseFloat doesn't return error when
- // the value exceds the float max
- data = getDouble(columnIndex);
- if (data >= Float.NEGATIVE_INFINITY && data <= Float.POSITIVE_INFINITY) {
- return (float) data;
- } else {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "numeric_out_of_range",
- null);
- }
- }
-
- public float getFloat(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getFloat", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getFloat");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getFloat(columnIndex);
- }
-
- public int getInt(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getInt", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getInt");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
- int retValue;
- double d;
-
- validateGetInvocation(columnIndex);
- outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
- data = getLocalString(columnIndex);
- if (data != null) {
- try {
- retValue = Integer.parseInt(data);
- } catch (NumberFormatException e) {
- try {
- d = new Double(data).doubleValue();
- } catch (NumberFormatException e1) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
-
- if (d > (double) Integer.MIN_VALUE - 1 && d < (double) Integer.MAX_VALUE + 1) {
- retValue = (int) d;
- if ((double) retValue != d) {
- setSQLWarning(null, "data_truncation", null);
- }
- } else {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "numeric_out_of_range", null);
- }
- }
- } else {
- retValue = 0;
- }
-
- return retValue;
- }
-
- public int getInt(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getInt", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getInt");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getInt(columnIndex);
- }
-
- public long getLong(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getLong", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getLong");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
- long retValue;
- double d;
-
- BigDecimal bd;
-
- validateGetInvocation(columnIndex);
- outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
- data = getLocalString(columnIndex);
-
- if (data != null) {
- try {
- retValue = Long.parseLong(data);
- } catch (NumberFormatException e) {
- try {
- bd = new BigDecimal(data);
- retValue = bd.longValue();
- if (bd.compareTo(BigDecimal.valueOf(Long.MAX_VALUE)) <= 0
- && bd.compareTo(BigDecimal.valueOf(Long.MIN_VALUE)) >= 0) {
-
- if (bd.compareTo(BigDecimal.valueOf(retValue)) != 0) {
- setSQLWarning(null, "data_truncation", null);
- }
- } else {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "numeric_out_of_range", null);
- }
- } catch (NumberFormatException e2) {
-
- try {
- d = new Double(data).doubleValue();
- } catch (NumberFormatException e1) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
-
- if (d >= Long.MIN_VALUE && d <= Long.MAX_VALUE) {
- retValue = (long) d;
-
- if ((double) retValue != d) {
- setSQLWarning(null, "data_truncation", null);
- }
- } else {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "numeric_out_of_range", null);
- }
- }
- }
- } else {
- retValue = 0;
- }
-
- return retValue;
- }
-
- public long getLong(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getLong", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getLong");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getLong(columnIndex);
- }
-
- public ResultSetMetaData getMetaData() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getMetaData", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getMetaData");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- return new HPT4ResultSetMetaData(this, outputDesc_);
- }
-
- public Object getObject(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getObject", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getObject");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- int precision;
- byte byteValue;
- short shortValue;
- int intValue;
- long longValue;
- float floatValue;
- double doubleValue;
- boolean booleanValue;
-
- validateGetInvocation(columnIndex);
- dataType = outputDesc_[columnIndex - 1].dataType_;
- precision = outputDesc_[columnIndex - 1].sqlPrecision_;
- switch (dataType) {
- case Types.TINYINT:
- byteValue = getByte(columnIndex);
- if (wasNull_) {
- return null;
- } else {
- return new Byte(byteValue);
- }
- case Types.SMALLINT:
- shortValue = getShort(columnIndex);
- if (wasNull_) {
- return null;
- } else {
- return new Short(shortValue);
- }
- case Types.INTEGER:
- intValue = getInt(columnIndex);
- if (wasNull_) {
- return null;
- } else {
- return new Integer(intValue);
- }
- case Types.BIGINT:
- longValue = getLong(columnIndex);
- if (wasNull_) {
- return null;
- } else {
- return new Long(longValue);
- }
- case Types.REAL:
- floatValue = getFloat(columnIndex);
- if (wasNull_) {
- return null;
- } else {
- return new Float(floatValue);
- }
- case Types.FLOAT:
- case Types.DOUBLE:
- doubleValue = getDouble(columnIndex);
- if (wasNull_) {
- return null;
- } else {
- return new Double(doubleValue);
- }
- case Types.DECIMAL:
- case Types.NUMERIC:
- return getBigDecimal(columnIndex);
- case Types.BIT:
- booleanValue = getBoolean(columnIndex);
- if (wasNull_) {
- return null;
- } else {
- return new Boolean(booleanValue);
- }
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.BLOB:
- case Types.CLOB:
- return getString(columnIndex);
- case Types.BINARY:
- case Types.VARBINARY:
- return getBytes(columnIndex);
- case Types.LONGVARBINARY:
- return getBinaryStream(columnIndex);
- case Types.DATE:
- return getDate(columnIndex);
- case Types.TIME:
- if (precision > 0)
- return getString(columnIndex);
-
- return getTime(columnIndex);
- case Types.TIMESTAMP:
- return getTimestamp(columnIndex);
- // For LOB Support - SB 10/8/2004
-
-
- case Types.OTHER:
- return getString(columnIndex);
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
- }
-
- // JDK 1.2
- public Object getObject(int columnIndex, Map map) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getObject", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getObject");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateGetInvocation(columnIndex);
- HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getObject()");
- return null;
- }
-
- public Object getObject(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getObject", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getObject");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getObject(columnIndex);
- }
-
- // JDK 1.2
- public Object getObject(String columnName, Map map) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, map);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getObject", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, map);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getObject");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getObject(columnIndex, map);
- }
-
- // JDK 1.2
- public Ref getRef(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getRef", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getRef");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateGetInvocation(columnIndex);
- HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getRef()");
- return null;
- }
-
- // JDK 1.2
- public Ref getRef(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getRef", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getRef");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getRef(columnIndex);
- }
-
- public int getRow() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getRow", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getRow");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- clearWarnings();
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- if (isBeforeFirst_ || isAfterLast_ || onInsertRow_) {
- return 0;
- }
-
- if ((getType() == ResultSet.TYPE_FORWARD_ONLY) && (getConcurrency() == ResultSet.CONCUR_UPDATABLE)) {
- return currentRowCount_;
- }
- return currentRow_;
- }
-
- public short getShort(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getShort", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getShort");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- String data;
- short retValue;
- double d;
-
- validateGetInvocation(columnIndex);
- outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
-
- data = getLocalString(columnIndex);
- if (data != null) {
- try {
- retValue = Short.parseShort(data);
- } catch (NumberFormatException e) {
- try {
- d = new Double(data).doubleValue();
- } catch (NumberFormatException e1) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
-
- if (d > (double) Short.MIN_VALUE - 1 && d < (double) Short.MAX_VALUE + 1) {
- retValue = (short) d;
- if ((double) retValue != d)
-
- {
- setSQLWarning(null, "data_truncation", null);
- }
- } else {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "numeric_out_of_range", null);
- }
- }
-
- } else {
- retValue = 0;
- }
-
- return retValue;
- }
-
- public short getShort(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getShort", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getShort");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getShort(columnIndex);
- }
-
- public Statement getStatement() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getStatement", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getStatement");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- return stmt_;
- }
-
- public String getString(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getString", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getString");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
- int targetSqlType;
- int precision;
- Object x;
- BaseRow currentRow;
-
- validateGetInvocation(columnIndex);
- currentRow = getCurrentRow();
- x = currentRow.getColumnObject(columnIndex);
-
- if (x == null) {
- wasNull_ = true;
- return null;
- }
-
- wasNull_ = false;
- targetSqlType = outputDesc_[columnIndex - 1].dataType_;
- precision = outputDesc_[columnIndex - 1].sqlPrecision_;
- switch (targetSqlType) {
-
-
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.BLOB:
- case Types.CLOB:
- data = getLocalString(columnIndex);
- if (stmt_ != null && stmt_.maxFieldSize_ != 0) {
- if (data.length() > stmt_.maxFieldSize_) {
- data = data.substring(0, stmt_.maxFieldSize_);
- }
- }
- break;
- case Types.VARBINARY:
- case Types.BINARY:
- case Types.LONGVARBINARY:
- data = String.valueOf(getBytes(columnIndex));
- break;
- case Types.TIMESTAMP:
- Timestamp t = getTimestamp(columnIndex);
- data = "" + t.getNanos();
- int l = data.length();
- data = t.toString();
-
- if(precision > 0) {
- for(int i=0;i<precision-l;i++)
- data += '0';
- } else {
- data = data.substring(0,data.lastIndexOf('.'));
- }
-
- break;
- case Types.TIME:
- if (precision > 0)
- data = x.toString();
- else
- data = String.valueOf(getTime(columnIndex));
- break;
- case Types.DATE:
- data = String.valueOf(getDate(columnIndex));
- break;
- case Types.BOOLEAN:
- data = String.valueOf(getBoolean(columnIndex));
- break;
- case Types.SMALLINT:
- data = String.valueOf(getShort(columnIndex));
- break;
- case Types.TINYINT:
- data = String.valueOf(getByte(columnIndex));
- break;
- case Types.REAL:
- data = String.valueOf(getFloat(columnIndex));
- break;
- case Types.DOUBLE:
- case Types.FLOAT:
- data = String.valueOf(getDouble(columnIndex));
- break;
- case Types.DECIMAL:
- case Types.NUMERIC:
- BigDecimal bd = getBigDecimal(columnIndex);
- if (_javaVersion >= 1.5) {
- // as of Java 5.0 and above, BigDecimal.toPlainString() should be used.
- try {
- data = (String) _toPlainString.invoke(bd, (Object[]) null);
- } catch (Exception e) {
- data = bd.toString();
- }
- } else {
- data = bd.toString();
- }
- break;
- case Types.BIGINT:
- data = String.valueOf(getLong(columnIndex));
- break;
- case Types.INTEGER:
- data = String.valueOf(getInt(columnIndex));
- break;
- case Types.OTHER: {
- if (x instanceof byte[]) {
- try {
- data = new String((byte[]) x, "ASCII");
- } catch (Exception e) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "unsupported_encoding", "ASCII");
- }
- } else {
- data = x.toString();
- }
- // only 2 supported today
- // 1. SQLTYPECODE_INTERVAL
- // 2. SQLTYPECODE_DATETIME
- // Within DATETIME we check for only the SQL/MP specific data types
- // in another switch-case statement
- switch (outputDesc_[columnIndex - 1].fsDataType_) {
- case InterfaceResultSet.SQLTYPECODE_INTERVAL: {
- // if data does no start with a hyphen (representing a negative
- // sign)
- // then send back data without the byte that holds the hyphen
- // Reason: for Interval data types first byte is holding either
- // the
- // a negative sign or if number is positive, it is just an extra
- // space
- data = Utility.trimRightZeros(data);
- if (!data.startsWith(hyphen_string)) {
- data = data.substring(1);
- }
- }
- break;
- case InterfaceResultSet.SQLTYPECODE_DATETIME: {
- switch (outputDesc_[columnIndex - 1].sqlDatetimeCode_) {
- case HPT4Desc.SQLDTCODE_YEAR:
- case HPT4Desc.SQLDTCODE_YEAR_TO_MONTH:
- case HPT4Desc.SQLDTCODE_MONTH:
- case HPT4Desc.SQLDTCODE_MONTH_TO_DAY:
- case HPT4Desc.SQLDTCODE_DAY:
- case HPT4Desc.SQLDTCODE_HOUR:
- case HPT4Desc.SQLDTCODE_HOUR_TO_MINUTE:
- case HPT4Desc.SQLDTCODE_MINUTE:
- case HPT4Desc.SQLDTCODE_MINUTE_TO_SECOND:
- // case HPT4Desc.SQLDTCODE_MINUTE_TO_FRACTION:
- case HPT4Desc.SQLDTCODE_SECOND:
- // case HPT4Desc.SQLDTCODE_SECOND_TO_FRACTION:
- case HPT4Desc.SQLDTCODE_YEAR_TO_HOUR:
- case HPT4Desc.SQLDTCODE_YEAR_TO_MINUTE:
- case HPT4Desc.SQLDTCODE_MONTH_TO_HOUR:
- case HPT4Desc.SQLDTCODE_MONTH_TO_MINUTE:
- case HPT4Desc.SQLDTCODE_MONTH_TO_SECOND:
- // case HPT4Desc.SQLDTCODE_MONTH_TO_FRACTION:
- case HPT4Desc.SQLDTCODE_DAY_TO_HOUR:
- case HPT4Desc.SQLDTCODE_DAY_TO_MINUTE:
- case HPT4Desc.SQLDTCODE_DAY_TO_SECOND:
- // case HPT4Desc.SQLDTCODE_DAY_TO_FRACTION:
- case HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION:
- break;
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "object_type_not_supported", null);
- }
- }
- break;
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "object_type_not_supported", null);
- }
- }
- break;
- case Types.ARRAY:
- case Types.BIT:
- case Types.REF:
- case Types.DATALINK:
- case Types.DISTINCT:
- case Types.JAVA_OBJECT:
- case Types.STRUCT:
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "object_type_not_supported", null);
- }
- return data;
- }
-
- public String getString(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getString", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getString");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getString(columnIndex);
- }
-
- public Time getTime(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTime", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getTime");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- String data;
- Time retValue;
- Timestamp timestamp;
-
- validateGetInvocation(columnIndex);
- dataType = outputDesc_[columnIndex - 1].dataType_;
- if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
- && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
- data = getLocalString(columnIndex);
- if (data != null) {
- switch (dataType) {
- case Types.TIMESTAMP:
- try {
- timestamp = Timestamp.valueOf(data);
- retValue = new Time(timestamp.getTime());
- } catch (IllegalArgumentException e) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
- break;
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.BLOB:
- case Types.CLOB:
- data = data.trim(); // Fall Thru
- case Types.TIME:
- try {
- retValue = Time.valueOf(data);
- } catch (IllegalArgumentException e) {
- try {
- timestamp = Timestamp.valueOf(data);
- retValue = new Time(timestamp.getTime());
- } catch (IllegalArgumentException ex) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
- }
- break;
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "restricted_data_type", null);
- }
- return retValue;
- } else {
- return null;
- }
- }
-
- public Time getTime(int columnIndex, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTime", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getTime");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- Time sqlTime;
- java.util.Date d;
-
- sqlTime = getTime(columnIndex);
- if (sqlTime != null) {
- if (cal != null) {
- cal.setTime(sqlTime);
- d = cal.getTime();
- sqlTime = new Time(d.getTime());
- }
- return sqlTime;
- } else {
- return (sqlTime);
- }
- }
-
- public Time getTime(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTime", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getTime");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getTime(columnIndex);
- }
-
- public Time getTime(String columnName, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTime", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getTime");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getTime(columnIndex, cal);
- }
-
- public Timestamp getTimestamp(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTimestamp", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getTimestamp");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- String data;
- Timestamp retValue;
- Date dateValue;
- Time timeValue;
-
- validateGetInvocation(columnIndex);
- dataType = outputDesc_[columnIndex - 1].dataType_;
- if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
- && dataType != Types.DATE && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
- data = getLocalString(columnIndex);
- if (data != null) {
- switch (dataType) {
- case Types.DATE:
- try {
- dateValue = Date.valueOf(data);
- retValue = new Timestamp(dateValue.getTime());
- } catch (IllegalArgumentException e) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
- break;
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.BLOB:
- case Types.CLOB:
- data = data.trim();
- case Types.TIMESTAMP:
- case Types.TIME:
- try {
- retValue = Timestamp.valueOf(data);
- } catch (IllegalArgumentException e) {
- try {
- dateValue = Date.valueOf(data);
- retValue = new Timestamp(dateValue.getTime());
- } catch (IllegalArgumentException e1) {
- try {
- int nano = 0;
- if (outputDesc_[columnIndex - 1].sqlPrecision_ > 0) {
- nano = Integer.parseInt(data.substring(data.indexOf(".") + 1));
- nano *= Math.pow(10, 9 - outputDesc_[columnIndex - 1].sqlPrecision_);
- data = data.substring(0, data.indexOf("."));
- }
-
- timeValue = Time.valueOf(data);
- retValue = new Timestamp(timeValue.getTime());
- retValue.setNanos(nano);
- } catch (IllegalArgumentException e2) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
-
- }
- }
- break;
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "restricted_data_type", null);
- }
- return retValue;
- } else {
- return null;
- }
- }
-
- public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTimestamp", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getTimestamp");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- Timestamp sqlTimestamp;
- java.util.Date d;
- int nanos;
-
- sqlTimestamp = getTimestamp(columnIndex);
- if (sqlTimestamp != null) {
- if (cal != null) {
- nanos = sqlTimestamp.getNanos();
- cal.setTime(sqlTimestamp);
- d = cal.getTime();
- sqlTimestamp = new Timestamp(d.getTime());
- sqlTimestamp.setNanos(nanos);
- }
- return sqlTimestamp;
- } else {
- return (sqlTimestamp);
- }
- }
-
- public Timestamp getTimestamp(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTimestamp", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getTimestamp");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getTimestamp(columnIndex);
- }
-
- public Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTimestamp", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getTimestamp");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getTimestamp(columnIndex, cal);
- }
-
- public int getType() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getType", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getType");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
- null);
- }
- if (stmt_ != null) {
- return stmt_.resultSetType_;
- } else {
- return ResultSet.TYPE_FORWARD_ONLY;
- }
-
- }
-
- public InputStream getUnicodeStream(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getUnicodeStream", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getUnicodeStream");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
-
- validateGetInvocation(columnIndex);
- data = getLocalString(columnIndex);
- if (data != null) {
- try {
- return new java.io.ByteArrayInputStream(data.getBytes((String) InterfaceUtilities
- .getCharsetName(InterfaceUtilities.SQLCHARSETCODE_UNICODE)));
- } catch (java.io.UnsupportedEncodingException e) {
- Object[] messageArguments = new Object[1];
- messageArguments[0] = e.getMessage();
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "unsupported_encoding", messageArguments);
- }
- } else {
- return null;
- }
-
- }
-
- public InputStream getUnicodeStream(String columnName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getUnicodeStream", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4ResultSet");
- lr.setSourceMethodName("getUnicodeStream");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int columnIndex = validateGetInvocation(columnName);
- return getUnicodeStream(columnIndex);
- }
-
- public URL getURL(int columnIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
- connection_.props_.t4Log
<TRUNCATED>
[23/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Connection.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Connection.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Connection.java
new file mode 100644
index 0000000..f1d34f9
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Connection.java
@@ -0,0 +1,1987 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.DatabaseMetaData;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.Statement;
+import java.sql.Struct;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.Executor;
+import java.util.logging.FileHandler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+import javax.sql.PooledConnection;
+
+/**
+ * <p>
+ * JDBC Type 4 TrafT4Connection class.
+ * </p>
+ * <p>
+ * Description: The <code>TrafT4Connection</code> class is an implementation of
+ * the <code>java.sql.Connection</code> interface.
+ * </p>
+ *
+ */
+public class TrafT4Connection extends PreparedStatementManager implements java.sql.Connection {
+
+ /**
+ * Validates the connection by clearing warnings and verifying that the
+ * Connection is still open.
+ *
+ * @throws SQLException
+ * If the Connection is not valid
+ */
+ private void validateConnection() throws SQLException {
+ clearWarnings();
+
+ if (this.ic_ == null || this.ic_.isClosed()) {
+ throw HPT4Messages.createSQLException(this.props_, this.getLocale(), "invalid_connection", null);
+ }
+ }
+
+ public String getRemoteProcess() throws SQLException {
+ return this.ic_.getRemoteProcess();
+ }
+
+ synchronized public void close() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "close", "", p);
+ }
+
+ if (this.ic_ == null || this.ic_.isClosed())
+ return;
+
+ // only hard-close if no pooled connection exists
+ close((pc_ == null), true);
+ }
+
+ public void commit() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "commit", "", p);
+ }
+
+ validateConnection();
+
+ try {
+ ic_.commit();
+ } catch (SQLException se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ }
+
+ public void resetServerIdleTimer() throws SQLException {
+ clearWarnings();
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+
+ this.setConnectionAttr(InterfaceConnection.RESET_IDLE_TIMER, 0, "0");
+ }
+
+ public String getApplicationName() throws SQLException {
+ validateConnection();
+
+ return this.ic_.getApplicationName();
+ }
+
+ public String getServerDataSource() throws SQLException {
+ validateConnection();
+
+ return this.ic_.getServerDataSource();
+ }
+
+ public boolean getEnforceISO() throws SQLException {
+ validateConnection();
+
+ return this.ic_.getEnforceISO();
+ }
+
+ public int getISOMapping() throws SQLException {
+ validateConnection();
+
+ return this.ic_.getISOMapping();
+ }
+
+ public String getRoleName() throws SQLException {
+ validateConnection();
+
+ return this.ic_.getRoleName();
+ }
+
+ public int getTerminalCharset() throws SQLException {
+ validateConnection();
+
+ return this.ic_.getTerminalCharset();
+ }
+
+ public T4Properties getT4Properties() throws SQLException {
+ validateConnection();
+
+ return this.ic_.t4props_;
+ }
+
+ public String getSessionName() throws SQLException {
+ validateConnection();
+
+ return this.ic_.getSessionName();
+ }
+
+ public Statement createStatement() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "createStatement", "", p);
+ }
+
+ validateConnection();
+
+ try {
+ return new TrafT4Statement(this);
+ } catch (SQLException se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ }
+
+ public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, resultSetType, resultSetConcurrency);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "createStatement", "", p);
+ }
+
+ validateConnection();
+
+ try {
+ return new TrafT4Statement(this, resultSetType, resultSetConcurrency);
+ } catch (SQLException se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ }
+
+ public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, resultSetType, resultSetConcurrency,
+ resultSetHoldability);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "createStatement", "", p);
+ }
+
+ validateConnection();
+
+ try {
+ return new TrafT4Statement(this, resultSetType, resultSetConcurrency, resultSetHoldability);
+ } catch (SQLException se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ }
+
+ Locale getLocale() {
+ if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "getLocale", "", p);
+ }
+ if (ic_ != null) {
+ return ic_.getLocale();
+ } else {
+ return null;
+ }
+ }
+
+ public boolean getAutoCommit() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getAutoCommit", "getAutoCommit", p);
+ }
+
+ validateConnection();
+
+ return ic_.getAutoCommit();
+ }
+
+ public String getCatalog() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getCatalog", "", p);
+ }
+
+ validateConnection();
+
+ return ic_.getCatalog();
+ }
+
+ public String getSchema() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getSchema", "", p);
+ }
+
+ Statement s = null;
+ ResultSet rs = null;
+ String sch = null;
+
+ try {
+ s = this.createStatement();
+ rs = s.executeQuery("SHOWCONTROL DEFAULT SCHEMA, match full, no header");
+ rs.next();
+ sch = rs.getString(1);
+ if(sch.charAt(0) != '\"' && sch.indexOf('.') != -1) {
+ sch = sch.substring(sch.indexOf('.') + 1);
+ }
+ }catch(SQLException e) {
+ sch = ic_.getSchema();
+ }finally {
+ if(rs != null)
+ rs.close();
+ if(s != null)
+ s.close();
+ }
+
+ return sch;
+ }
+
+ public int getHoldability() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getHoldability", "", p);
+ }
+
+ validateConnection();
+
+ return holdability_;
+ }
+
+ public DatabaseMetaData getMetaData() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getMetaData", "getMetaData", p);
+ }
+
+ validateConnection();
+
+ return new T4DatabaseMetaData(this);
+ }
+
+ public int getTransactionIsolation() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getTransactionIsolation", "", p);
+ }
+
+ validateConnection();
+
+ return ic_.getTransactionIsolation();
+ }
+
+ public Map getTypeMap() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getTypeMap", "", p);
+ }
+
+ validateConnection();
+
+ return userMap_;
+ }
+
+ void isConnectionOpen() throws SQLException {
+ validateConnection();
+ }
+
+ public boolean isClosed() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "isClosed", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("isClosed");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+
+ boolean rv = true;
+
+ if (ic_ == null) {
+ rv = true;
+ // return true;
+ } else {
+ clearWarnings();
+ rv = ic_.getIsClosed();
+ }
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "isClosed", "At exit return = " + rv, p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("isClosed");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+
+ return rv;
+ // return ic_.get_isClosed();
+ }
+
+ // New method that checks if the connection is closed
+ // However, this is to be used only be internal classes
+ // It does not clear any warnings associated with the current connection
+ // Done for CASE 10_060123_4011 ; Swastik Bihani
+ boolean _isClosed() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "_isClosed", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("_isClosed");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+
+ boolean rv = true;
+
+ if (ic_ == null) {
+ rv = true;
+ } else {
+ rv = ic_.getIsClosed();
+ }
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "_isClosed", "At exit return = " + rv, p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("_isClosed");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+
+ return rv;
+ }
+
+ /**
+ * @deprecated
+ */
+ public String getServiceName() throws SQLException {
+ return "";
+ }
+
+ /**
+ * @deprecated
+ */
+ public void setServiceName(String serviceName) throws SQLException {
+
+ }
+
+ public boolean isReadOnly() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "isReadOnly", "", p);
+ }
+
+ validateConnection();
+
+ return ic_.isReadOnly();
+ }
+
+ public String nativeSQL(String sql) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "nativeSQL", "", p);
+ }
+
+ validateConnection();
+
+ return sql;
+ }
+
+ public CallableStatement prepareCall(String sql) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "prepareCall", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("prepareCall");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+
+ TrafT4CallableStatement stmt;
+
+ clearWarnings();
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+
+ try {
+ if (isStatementCachingEnabled()) {
+ stmt = (TrafT4CallableStatement) getPreparedStatement(this, sql, ResultSet.TYPE_FORWARD_ONLY,
+ ResultSet.CONCUR_READ_ONLY, holdability_);
+
+ if (stmt != null) {
+ return stmt;
+ }
+ }
+
+ stmt = new TrafT4CallableStatement(this, sql);
+ stmt.prepareCall(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
+
+ if (isStatementCachingEnabled()) {
+ addPreparedStatement(this, sql, stmt, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
+ holdability_);
+ }
+ } catch (HPT4Exception se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ return stmt;
+ }
+
+ public CallableStatement prepareCall(String sql, String stmtLabel) throws SQLException {
+ final String QUOTE = "\"";
+
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "prepareCall", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("prepareCall");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+
+ if (stmtLabel == null || stmtLabel.length() == 0) {
+ throw HPT4Messages.createSQLException(props_, null, "null_data", null);
+ }
+
+ if (stmtLabel.startsWith(QUOTE) && stmtLabel.endsWith(QUOTE)) {
+ int len = stmtLabel.length();
+ if (len == 2) {
+ throw HPT4Messages.createSQLException(props_, null, "null_data", null);
+ } else {
+ stmtLabel = stmtLabel.substring(1, len - 1);
+ }
+ } else {
+ stmtLabel = stmtLabel.toUpperCase();
+ }
+
+ TrafT4CallableStatement stmt;
+
+ clearWarnings();
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+
+ try {
+ if (isStatementCachingEnabled()) {
+ stmt = (TrafT4CallableStatement) getPreparedStatement(this, sql, ResultSet.TYPE_FORWARD_ONLY,
+ ResultSet.CONCUR_READ_ONLY, holdability_);
+
+ if (stmt != null) {
+ return stmt;
+ }
+ }
+
+ stmt = new TrafT4CallableStatement(this, sql, stmtLabel);
+ stmt.prepareCall(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
+
+ if (isStatementCachingEnabled()) {
+ addPreparedStatement(this, sql, stmt, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
+ holdability_);
+ }
+ } catch (HPT4Exception se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ return stmt;
+ }
+
+ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql, resultSetType, resultSetConcurrency);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "prepaseCall", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql, resultSetType, resultSetConcurrency);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("prepaseCall");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ TrafT4CallableStatement stmt;
+
+ clearWarnings();
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+
+ try {
+ if (isStatementCachingEnabled()) {
+ stmt = (TrafT4CallableStatement) getPreparedStatement(this, sql, resultSetType, resultSetConcurrency,
+ holdability_);
+ if (stmt != null) {
+ return stmt;
+ }
+ }
+
+ stmt = new TrafT4CallableStatement(this, sql, resultSetType, resultSetConcurrency);
+ stmt.prepareCall(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
+
+ if (isStatementCachingEnabled()) {
+ addPreparedStatement(this, sql, stmt, resultSetType, resultSetConcurrency, holdability_);
+ }
+ } catch (HPT4Exception se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ return stmt;
+ }
+
+ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql, resultSetType, resultSetConcurrency,
+ resultSetHoldability);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "prepareCall", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql, resultSetType, resultSetHoldability);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("prepareCall");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ TrafT4CallableStatement stmt;
+
+ clearWarnings();
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+ try {
+ if (isStatementCachingEnabled()) {
+ stmt = (TrafT4CallableStatement) getPreparedStatement(this, sql, resultSetType, resultSetConcurrency,
+ resultSetHoldability);
+ if (stmt != null) {
+ return stmt;
+ }
+ }
+
+ stmt = new TrafT4CallableStatement(this, sql, resultSetType, resultSetConcurrency, resultSetHoldability);
+
+ stmt.prepareCall(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
+
+ if (isStatementCachingEnabled()) {
+ addPreparedStatement(this, sql, stmt, resultSetType, resultSetConcurrency, resultSetHoldability);
+ }
+ } catch (HPT4Exception se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ return stmt;
+ }
+
+ /**
+ * Creates a <code>PreparedStatement</code> object for sending
+ * parameterized SQL statements to the database.
+ *
+ * @param sql
+ * SQL statement that might contain one or more '?' IN parameter
+ * placeholders
+ * @param stmtLabel
+ * SQL statement label that can be passed to the method instead
+ * of generated by the database system.
+ * @returns a new default PreparedStatement object containing the
+ * pre-compiled SQL statement
+ * @throws SQLException
+ * if a database access error occurs
+ */
+ public PreparedStatement prepareStatement(String sql, String stmtLabel) throws SQLException {
+ final String QUOTE = "\"";
+
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "prepareStatement", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("prepareStatement");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+
+ if (stmtLabel == null || stmtLabel.length() == 0) {
+ throw HPT4Messages.createSQLException(props_, null, "null_data", null);
+ }
+
+ if (stmtLabel.startsWith(QUOTE) && stmtLabel.endsWith(QUOTE)) {
+ int len = stmtLabel.length();
+ if (len == 2) {
+ throw HPT4Messages.createSQLException(props_, null, "null_data", null);
+ } else {
+ stmtLabel = stmtLabel.substring(1, len - 1);
+ }
+ } else {
+ stmtLabel = stmtLabel.toUpperCase();
+ }
+
+ TrafT4PreparedStatement stmt;
+
+ clearWarnings();
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+ try {
+ if (isStatementCachingEnabled()) {
+ stmt = (TrafT4PreparedStatement) getPreparedStatement(this, sql, ResultSet.TYPE_FORWARD_ONLY,
+ ResultSet.CONCUR_READ_ONLY, holdability_);
+ if (stmt != null) {
+ return stmt;
+ }
+ }
+
+ stmt = new TrafT4PreparedStatement(this, sql, stmtLabel);
+
+ stmt.prepare(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
+
+ if (isStatementCachingEnabled()) {
+ addPreparedStatement(this, sql, stmt, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
+ holdability_);
+ }
+ } catch (HPT4Exception se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ return stmt;
+ }
+
+ public PreparedStatement prepareStatement(String sql) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "prepareStatement", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("prepareStatement");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+
+ TrafT4PreparedStatement stmt;
+
+ clearWarnings();
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+ try {
+ if (isStatementCachingEnabled()) {
+ stmt = (TrafT4PreparedStatement) getPreparedStatement(this, sql, ResultSet.TYPE_FORWARD_ONLY,
+ ResultSet.CONCUR_READ_ONLY, holdability_);
+ if (stmt != null) {
+ return stmt;
+ }
+ }
+
+ stmt = new TrafT4PreparedStatement(this, sql);
+
+ stmt.prepare(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
+
+ if (isStatementCachingEnabled()) {
+ addPreparedStatement(this, sql, stmt, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
+ holdability_);
+ }
+ } catch (HPT4Exception se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ return stmt;
+ }
+
+ // SB 12/02/2004 - only for LOB statements - these will be not added to the
+ // statement cache
+ PreparedStatement prepareLobStatement(String sql) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "prepareLobStatement", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("prepareLobStatement");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+
+ TrafT4PreparedStatement stmt;
+
+ clearWarnings();
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+
+ try {
+ stmt = new TrafT4PreparedStatement(this, sql);
+ stmt.prepare(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
+ } catch (HPT4Exception se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ return stmt;
+
+ }
+
+ public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql, autoGeneratedKeys);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "prepareStatement", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql, autoGeneratedKeys);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("prepareStatement");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+
+ if (autoGeneratedKeys == TrafT4Statement.NO_GENERATED_KEYS) {
+ return prepareStatement(sql);
+ } else {
+ throw HPT4Messages.createSQLException(props_, getLocale(), "auto_generated_keys_not_supported", null);
+ }
+ }
+
+ public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql, columnIndexes);
+ props_.t4Logger_.logp(Level.FINE, "SQLConnection", "prepareStatement", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql, columnIndexes);
+ lr.setParameters(p);
+ lr.setSourceClassName("SQLConnection");
+ lr.setSourceMethodName("prepareStatement");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+
+ if (columnIndexes != null && columnIndexes.length > 0) {
+ throw HPT4Messages.createSQLException(props_, getLocale(), "auto_generated_keys_not_supported", null);
+ } else {
+ return prepareStatement(sql);
+ }
+ }
+
+ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
+ throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql, resultSetType, resultSetConcurrency);
+ props_.t4Logger_.logp(Level.FINE, "SQLConnection", "prepareStatement", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql, resultSetType, resultSetConcurrency);
+ lr.setParameters(p);
+ lr.setSourceClassName("SQLConnection");
+ lr.setSourceMethodName("prepareStatement");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ TrafT4PreparedStatement stmt;
+
+ clearWarnings();
+
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+
+ try {
+ if (isStatementCachingEnabled()) {
+ stmt = (TrafT4PreparedStatement) getPreparedStatement(this, sql, resultSetType, resultSetConcurrency,
+ holdability_);
+ if (stmt != null) {
+ return stmt;
+ }
+ }
+
+ stmt = new TrafT4PreparedStatement(this, sql, resultSetType, resultSetConcurrency);
+ stmt.prepare(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
+
+ if (isStatementCachingEnabled()) {
+ addPreparedStatement(this, sql, stmt, resultSetType, resultSetConcurrency, holdability_);
+ }
+ } catch (HPT4Exception se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ return stmt;
+ }
+
+ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql, resultSetType, resultSetConcurrency,
+ resultSetHoldability);
+ props_.t4Logger_.logp(Level.FINE, "SQLConnection", "prepareStatement", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql, resultSetType, resultSetHoldability);
+ lr.setParameters(p);
+ lr.setSourceClassName("SQLConnection");
+ lr.setSourceMethodName("prepareStatement");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ TrafT4PreparedStatement stmt;
+
+ clearWarnings();
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+
+ try {
+ if (isStatementCachingEnabled()) {
+ stmt = (TrafT4PreparedStatement) getPreparedStatement(this, sql, resultSetType, resultSetConcurrency,
+ resultSetHoldability);
+ if (stmt != null) {
+ return stmt;
+ }
+ }
+
+ stmt = new TrafT4PreparedStatement(this, sql, resultSetType, resultSetConcurrency, resultSetHoldability);
+ stmt.prepare(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
+
+ if (isStatementCachingEnabled()) {
+ addPreparedStatement(this, sql, stmt, resultSetType, resultSetConcurrency, resultSetHoldability);
+ }
+ } catch (HPT4Exception se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ return stmt;
+ }
+
+ public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql, columnNames);
+ props_.t4Logger_.logp(Level.FINE, "SQLConnection", "prepareStatement", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, sql, columnNames);
+ lr.setParameters(p);
+ lr.setSourceClassName("SQLConnection");
+ lr.setSourceMethodName("prepareStatement");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ if (columnNames != null && columnNames.length > 0) {
+ throw HPT4Messages.createSQLException(props_, getLocale(), "auto_generated_keys_not_supported", null);
+ } else {
+ return prepareStatement(sql);
+ }
+ }
+
+ public void releaseSavepoint(Savepoint savepoint) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, savepoint);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "releaseSavepoint", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, savepoint);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("releaseSavepoint");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ HPT4Messages.throwUnsupportedFeatureException(props_, getLocale(), "releaseSavepoint()");
+ }
+
+ public void rollback() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "rollback", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("rollback");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+
+ // if (ic_.getTxid() == 0) - XA
+ // return;
+
+ // commit the Transaction
+ try {
+ ic_.rollback();
+ } catch (HPT4Exception se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ // ic_.setTxid(0); - XA
+ }
+
+ public void rollback(Savepoint savepoint) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, savepoint);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "rollback", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, savepoint);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("rollback");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ HPT4Messages.throwUnsupportedFeatureException(props_, getLocale(), "rollback(Savepoint)");
+ }
+
+ public void setAutoCommit(boolean autoCommit) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, autoCommit);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "setAutoCommit", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, autoCommit);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("setAutoCommit");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+
+ clearWarnings();
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+ try {
+ ic_.setAutoCommit(this, autoCommit);
+ } catch (HPT4Exception se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ }
+
+ public void setCatalog(String catalog) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, catalog);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "setCalalog", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, catalog);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("setCalalog");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+ if (catalog != null) {
+ try {
+ ic_.setCatalog(this, catalog);
+ } catch (HPT4Exception se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ }
+ }
+
+ public void setHoldability(int holdability) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, holdability);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "setHoldability", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, holdability);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("setHoldability");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+
+ if (holdability != TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT)
+
+ {
+ throw HPT4Messages.createSQLException(props_, getLocale(), "invalid_holdability", null);
+ }
+ holdability_ = holdability;
+ }
+
+ public void setReadOnly(boolean readOnly) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, readOnly);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "setReadOnly", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, readOnly);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("setReadOnly");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+ try {
+ // ic_.setReadOnly(readOnly);
+ ic_.setReadOnly(this, readOnly);
+ } catch (HPT4Exception se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ }
+
+ public void setConnectionAttr(short attr, int valueNum, String valueString) throws SQLException {
+ ic_.setConnectionAttr(this, attr, valueNum, valueString);
+ }
+
+ //3196 - NDCS transaction for SPJ
+ public void joinUDRTransaction(long transId) throws SQLException {
+ String sTransid = String.valueOf(transId);
+ ic_.setConnectionAttr(this, InterfaceConnection.SQL_ATTR_JOIN_UDR_TRANSACTION, 0, sTransid);
+ }
+
+ //3196 - NDCS transaction for SPJ
+ public void suspendUDRTransaction() throws SQLException {
+ String sTransid = String.valueOf(ic_.transId_);
+ ic_.setConnectionAttr(this, InterfaceConnection.SQL_ATTR_SUSPEND_UDR_TRANSACTION, 0, sTransid);
+ }
+
+ public Savepoint setSavepoint(String name) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, name);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "setSavepoint", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, name);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("setSavepoint");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ HPT4Messages.throwUnsupportedFeatureException(props_, getLocale(), "setSavepoint");
+ return null;
+ }
+
+ public Savepoint setSavepoint() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "setSavepoint", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("setSavepoint");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ HPT4Messages.throwUnsupportedFeatureException(props_, getLocale(), "setSavepoint");
+ return null;
+ }
+
+ public void setTransactionIsolation(int level) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, level);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "setTransactionIsolation", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, level);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("setTransactionIsolation");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+ try {
+ ic_.setTransactionIsolation(this, level);
+ } catch (HPT4Exception se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ }
+
+ // JDK 1.2
+ public void setTypeMap(java.util.Map map) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, map);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "setTypeMap", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, map);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("setTypeMap");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ userMap_ = map;
+ }
+
+ public void begintransaction() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "begintransaction", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("begintransaction");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+ try {
+ ic_.beginTransaction();
+
+ if (ic_.beginTransaction() == 0) {
+ return;
+ } else {
+ setAutoCommit(false);
+ }
+ } catch (HPT4Exception se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ }
+
+ public long getCurrentTransaction() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getTxid", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("getTxid");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+ return ic_.getTxid();
+ }
+
+ public void setTxid(long txid) throws SQLException {
+ setTransactionToJoin(Bytes.createLongBytes(txid, this.ic_.getByteSwap()));
+ }
+
+ public void setTransactionToJoin(byte[] txid) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, txid);
+ props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "setTxid", "", p);
+ }
+ if (_isClosed() == true) {
+ throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
+ }
+
+ transactionToJoin = txid;
+ }
+
+ void gcStmts() {
+ if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "gcStmt", "", p);
+ }
+ Reference pRef;
+ String stmtLabel;
+
+ while ((pRef = refStmtQ_.poll()) != null) {
+ stmtLabel = (String) refToStmt_.get(pRef);
+ // All PreparedStatement objects are added to Hashtable
+ // Only Statement objects that produces ResultSet are added to
+ // Hashtable
+ // Hence stmtLabel could be null
+ if (stmtLabel != null) {
+ try {
+ TrafT4Statement stmt = new TrafT4Statement(this, stmtLabel);
+ stmt.close();
+ stmt = null;
+ } catch (SQLException e) {
+ performConnectionErrorChecks(e);
+ } finally {
+ refToStmt_.remove(pRef);
+ }
+ }
+ }
+ }
+
+ void removeElement(Reference pRef) {
+ if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, pRef);
+ props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "removeElement", "", p);
+ }
+
+ refToStmt_.remove(pRef);
+ pRef.clear();
+ }
+
+ void addElement(Reference pRef, String stmtLabel) {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, stmtLabel);
+ props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "addElement", "", p);
+ }
+ refToStmt_.put(pRef, stmtLabel);
+ }
+
+ private void physicalCloseStatements() {
+ if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "physicalCloseStatement", "", p);
+ }
+ // close all the statements
+ ArrayList stmts = new ArrayList(refToStmt_.values());
+ int size = stmts.size();
+ for (int i = 0; i < size; i++) {
+ try {
+ String stmtLabel = (String) stmts.get(i);
+ TrafT4Statement stmt = new TrafT4Statement(this, stmtLabel);
+ stmt.close();
+ stmt = null;
+ } catch (SQLException se) {
+ // Ignore any exception and proceed to the next statement
+ }
+ }
+ refToStmt_.clear();
+
+
+ }
+
+ private void rollbackAndIgnoreError() {
+ if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "rollbackAndIgnoreError", "", p);
+ }
+ // Rollback the Transaction when autoCommit mode is OFF
+ try {
+ if (getAutoCommit() == false || isBeginTransaction) {
+ rollback();
+ }
+ } catch (SQLException sqex) {
+ if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "rollbackAndIgnoreError", "warning: "+sqex.getMessage(), p);
+ }
+ }
+ }
+
+
+ synchronized void close(boolean hardClose, boolean sendEvents) throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, hardClose, sendEvents);
+ props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "close", "", p);
+ }
+ clearWarnings();
+ try {
+ if (!hardClose) {
+ if (this.ic_ != null && this.ic_.getIsClosed()) {
+ return;
+ }
+ if (isStatementCachingEnabled()) {
+ closePreparedStatementsAll();
+ } else {
+ physicalCloseStatements();
+ }
+ rollbackAndIgnoreError();
+
+ /*
+ * //inform the NCS server to disregard the T4 ConnectionTimeout
+ * value try{ if (ic_ != null) {
+ * ic_.disregardT4ConnectionTimeout(this); } }catch(SQLException
+ * e){ //ignore - new property from old MXCS ABD version (now
+ * known as NCS) //ignored for backward compatibility }
+ */
+
+ // Need to logicallcally close the statement
+ pc_.logicalClose(sendEvents);
+ if (ic_ != null) {
+ ic_.setIsClosed(true);
+ }
+ } else {
+ if (getServerHandle() == null) {
+ return;
+ }
+
+ // close all the statements
+ physicalCloseStatements();
+
+ // Need to logicallcally close the statement
+ // Rollback the Transaction when autoCommit mode is OFF
+ rollbackAndIgnoreError();
+
+ if (isStatementCachingEnabled()) {
+ clearPreparedStatementsAll();
+ }
+
+ // Close the connection
+ try {
+ ic_.close();
+ } finally {
+ if (ic_ != null) {
+ ic_.removeElement(this);
+ }
+ ic_ = null;
+ }
+ }
+ } catch (SQLException e) {
+ performConnectionErrorChecks(e);
+ throw e;
+ } finally {
+ // close the timer thread
+ if (ic_ != null && ic_.getT4Connection() != null) {
+ ic_.getT4Connection().closeTimers();
+ }
+ }
+ }
+
+ protected void finalize() {
+ if (ic_ != null && ic_.getT4Connection() != null) {
+ ic_.getT4Connection().closeTimers();
+ }
+ }
+
+ void reuse() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "resue", "", p);
+ }
+ ic_.reuse();
+ /*
+ * try { ic_.enforceT4ConnectionTimeout(this); } catch (HPT4Exception
+ * se) { //performConnectionErrorChecks(se); //throw se; //ignore - new
+ * property from old MXCS ABD version (now known as NCS) //ignored for
+ * backward compatibility }
+ */
+ }
+
+
+ // Extension method for WLS, this method gives the pooledConnection object
+ // associated with the given connection object.
+ public PooledConnection getPooledConnection() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getPooledConnection", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("getPooledConnection");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ if (pc_ != null) {
+ return pc_;
+ } else {
+ throw HPT4Messages.createSQLException(props_, getLocale(), "null_pooled_connection", null);
+ }
+ }
+
+ TrafT4Connection(HPT4DataSource ds, T4Properties t4props) throws SQLException {
+ super(t4props);
+
+ t4props.setConnectionID(Integer.toString(this.hashCode()));
+ setupLogging(t4props);
+
+ if (t4props.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, ds, t4props);
+ t4props.t4Logger_.logp(Level.FINE, "TrafT4Connection", "<init>", "", p);
+ }
+ if (t4props.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, ds, t4props);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("<init>");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ t4props.getLogWriter().println(temp);
+ }
+ ds_ = ds;
+
+
+ makeConnection(t4props);
+ holdability_ = TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT;
+ }
+
+ TrafT4Connection(HPT4PooledConnection poolConn, T4Properties t4props) throws SQLException {
+ super(t4props);
+
+ t4props.setConnectionID(Integer.toString(this.hashCode()));
+ setupLogging(t4props);
+
+ if (t4props.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, poolConn, t4props);
+ t4props.t4Logger_.logp(Level.FINE, "TrafT4Connection", "<init>", "", p);
+ }
+ if (t4props.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_, poolConn, t4props);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("<init>");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ t4props.getLogWriter().println(temp);
+ }
+
+ pc_ = poolConn;
+
+
+ makeConnection(t4props);
+ holdability_ = TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT;
+ }
+
+ private void makeConnection(T4Properties t4props) throws SQLException {
+ if (t4props.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_, t4props);
+ t4props.t4Logger_.logp(Level.FINER, "TrafT4Connection", "makeConnection", "", p);
+ }
+
+ ArrayList<String> addresses = createAddressList(t4props);
+ SQLException eList = null;
+ boolean success = false;
+
+ for(int i=0;i<addresses.size();i++) {
+ clearWarnings();
+ t4props.setUrl(addresses.get(i));
+
+ try {
+ ic_ = new InterfaceConnection(this, t4props);
+ success = true;
+ break;
+ } catch (SQLException se) {
+ boolean connectionError = performConnectionErrorChecks(se);
+ if(addresses.size() == 1 || !connectionError) {
+ throw se;
+ }
+ if(eList == null) {
+ eList = se;
+ }
+ else {
+ eList.setNextException(se);
+ }
+ }
+ }
+
+ if(!success) {
+ throw eList;
+ }
+
+ if (ic_.sqlwarning_ != null) {
+ setSqlWarning(ic_.sqlwarning_);
+ }
+
+ refStmtQ_ = new ReferenceQueue();
+ refToStmt_ = new Hashtable();
+ pRef_ = new WeakReference(this, ic_.refQ_);
+ ic_.refTosrvrCtxHandle_.put(pRef_, ic_);
+ props_ = t4props;
+
+ ic_.enableNARSupport(this, props_.getBatchRecovery());
+
+ if (props_.getSPJEnv()) {
+ ic_.enableProxySyntax(this);
+ }
+ }
+
+ private ArrayList<String> createAddressList(T4Properties t4props) {
+ ArrayList<String> addresses = new ArrayList<String>(); //10 addresses by default
+ addresses.add(t4props.getUrl());
+ String os = System.getProperty("os.name");
+ String enable = System.getProperty("t4jdbc.redirectaddr");
+
+ if(enable != null && enable.equals("true") && os != null && os.equals("NONSTOP_KERNEL")) { // TODO get real name
+ String providedUrl = t4props.getUrl();
+ String providedHost = providedUrl.substring(16).toLowerCase();
+ String hostPrefix = null;
+ try {
+ hostPrefix = java.net.InetAddress.getLocalHost().getHostName().substring(0, 5).toLowerCase();
+ }catch(Exception e) {
+ }
+
+ if(hostPrefix != null && providedHost.startsWith(hostPrefix)) {
+ File f = new File("/E/" + hostPrefix + "01/usr/t4jdbc/jdbcaddr.txt");
+ if(f.exists()) {
+ addresses.clear();
+
+ String urlSuffix = providedUrl.substring(providedUrl.indexOf("/:"));
+
+ try {
+ BufferedReader in = new BufferedReader(new FileReader(f));
+ String host;
+ while ((host = in.readLine()) != null) {
+ if(host.indexOf(':') == -1) {
+ host += ":18650";
+ }
+ addresses.add(String.format("jdbc:t4jdbc://" + host + urlSuffix));
+ }
+ in.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
+
+ return addresses;
+ }
+
+
+
+ // --------------------------------------------------------
+ private void setupLogging(T4Properties t4props) {
+
+ String ID = T4LoggingUtilities.getUniqueID();
+ String name = T4LoggingUtilities.getUniqueLoggerName(ID);
+
+ if (t4props.getT4LogLevel() == Level.OFF) {
+ if (dummyLogger_ == null) {
+ dummyLogger_ = Logger.getLogger(name);
+ }
+ t4props.t4Logger_ = dummyLogger_;
+ } else {
+ t4props.t4Logger_ = Logger.getLogger(name);
+ }
+
+ // t4props.t4Logger_ = Logger.getLogger(name);
+ t4props.t4Logger_.setUseParentHandlers(false);
+ t4props.t4Logger_.setLevel(t4props.getT4LogLevel());
+
+ if (t4props.getT4LogLevel() != Level.OFF) {
+ FileHandler fh1 = t4props.getT4LogFileHandler();
+ t4props.t4Logger_.addHandler(fh1);
+ }
+ } // end setupLogging
+
+ // --------------------------------------------------------
+
+ // Interface Methods
+ InterfaceConnection getServerHandle() {
+ if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "getServerHandle", "", p);
+ }
+ return ic_;
+ }
+
+ // Interface Methods
+ public int getDialogueId() throws SQLException {
+ if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getDialogueId", "", p);
+ }
+ if (props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Connection");
+ lr.setSourceMethodName("getDialogueId");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ props_.getLogWriter().println(temp);
+ }
+ return getServerHandle().getDialogueId();
+ }
+
+ /**
+ * Returns true if the data format needs to be converted. Used by the
+ * <CODE>TrafT4ResultSet</CODE> class.
+ *
+ * @return true if conversion is needed; otherwise, false.
+ */
+ public boolean getDateConversion() throws SQLException {
+ validateConnection();
+
+ return ic_.getDateConversion();
+ }
+
+ int getServerMajorVersion() throws SQLException {
+ validateConnection();
+
+ return ic_.getServerMajorVersion();
+ }
+
+ int getServerMinorVersion() throws SQLException {
+ validateConnection();
+
+ return ic_.getServerMinorVersion();
+ }
+
+
+ void closeErroredConnection(HPT4Exception se) {
+ try {
+ if (!erroredConnection) { // don't issue close repeatedly
+ erroredConnection = true;
+ if (pc_ != null) {
+ pc_.sendConnectionErrorEvent(se);
+ } else {
+ // hardclose
+ close(true, true);
+ }
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+
+ boolean erroredConnection = false;
+
+ PreparedStatement[] LobPreparedStatements = new PreparedStatement[14];
+
+ // boolean reserveEmptyDataLocator_ = false;
+ // public static final int EMPTY_DATA_LOCATOR_UPDATE = 0;
+
+ String clobTableName_;
+ String blobTableName_;
+ // String preparedClobTableName_;
+ // String preparedBlobTableName_;
+
+ static final int CLOB_INS_LOB_DATA_STMT = 0;
+ static final int CLOB_GET_LOB_DATA_STMT = 1;
+ static final int CLOB_GET_LOB_LEN_STMT = 2;
+ static final int CLOB_DEL_LOB_DATA_STMT = 3;
+ static final int CLOB_TRUN_LOB_DATA_STMT = 4;
+ static final int CLOB_UPD_LOB_DATA_STMT = 5;
+ static final int CLOB_GET_STRT_DATA_LOC_STMT = 6;
+ static final int BLOB_INS_LOB_DATA_STMT = 7;
+ static final int BLOB_GET_LOB_DATA_STMT = 8;
+ static final int BLOB_GET_LOB_LEN_STMT = 9;
+ static final int BLOB_DEL_LOB_DATA_STMT = 10;
+ static final int BLOB_TRUN_LOB_DATA_STMT = 11;
+ static final int BLOB_UPD_LOB_DATA_STMT = 12;
+ static final int BLOB_GET_STRT_DATA_LOC_STMT = 13;
+
+ static Logger dummyLogger_ = null;
+
+ boolean[] bLobStatementPrepared = new boolean[14]; // initialized to false,
+ // one each for the
+ // BLOB/CLOB statements
+ // listed above
+
+ // Fields
+ InterfaceConnection ic_;
+
+ // Connection
+ Map userMap_;
+ ReferenceQueue refStmtQ_;
+ Hashtable refToStmt_;
+ Hashtable refToRS_;
+ int holdability_;
+ HPT4DataSource ds_;
+ HPT4PooledConnection pc_;
+ T4Driver driver_;
+ WeakReference pRef_;
+ T4Properties props_;
+
+ byte[] transactionToJoin;
+
+ private boolean isBeginTransaction = false;
+
+ protected boolean isBeginTransaction() {
+ return isBeginTransaction;
+ }
+
+ protected void setBeginTransaction(boolean isBeginTransaction) {
+ this.isBeginTransaction = isBeginTransaction;
+ }
+
+
+ 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 Clob createClob() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Blob createBlob() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NClob createNClob() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public SQLXML createSQLXML() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isValid(int timeout) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setClientInfo(String name, String value)
+ throws SQLClientInfoException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setClientInfo(Properties properties)
+ throws SQLClientInfoException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public String getClientInfo(String name) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Properties getClientInfo() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Array createArrayOf(String typeName, Object[] elements)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Struct createStruct(String typeName, Object[] attributes)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setSchema(String schema) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void abort(Executor executor) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setNetworkTimeout(Executor executor, int milliseconds)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public int getNetworkTimeout() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /*
+ * JDK 1.6 functions public Clob createClob() throws SQLException { return
+ * null; }
+ *
+ *
+ * public Blob createBlob() throws SQLException { return null; }
+ *
+ *
+ * public NClob createNClob() throws SQLException { return null; }
+ *
+ *
+ * public SQLXML createSQLXML() throws SQLException { return null; }
+ *
+ *
+ * public boolean isValid(int _int) throws SQLException { return false; }
+ *
+ *
+ * public void setClientInfo(String string, String string1) throws
+ * SQLClientInfoException { }
+ *
+ *
+ * public void setClientInfo(Properties properties) throws
+ * SQLClientInfoException { }
+ *
+ *
+ * public String getClientInfo(String string) throws SQLException { return
+ * ""; }
+ *
+ *
+ * public Properties getClientInfo() throws SQLException { return null; }
+ *
+ *
+ * public Array createArrayOf(String string, Object[] objectArray) throws
+ * SQLException { return null; }
+ *
+ *
+ * public Struct createStruct(String string, Object[] objectArray) throws
+ * SQLException { return null; }
+ *
+ *
+ * public Object unwrap(Class _class) throws SQLException { return null; }
+ *
+ *
+ * public boolean isWrapperFor(Class _class) throws SQLException { return
+ * false; }
+ */
+}
[30/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecPwd.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecPwd.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecPwd.java
new file mode 100644
index 0000000..60da5da
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecPwd.java
@@ -0,0 +1,274 @@
+/**********************************************************************
+// @@@ 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 @@@
+ //
+ **********************************************************************/
+
+/**
+ * class SecPwd - builds the password key, encrypts password,
+ * creates HMAC message based on password, rolename
+ * process info and time stamp. It also gets expiration
+ * date of a certificate.
+ *
+ */
+
+package org.trafodion.jdbc.t4;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.sql.Connection;
+
+
+public class SecPwd {
+ /**
+ *
+ *
+ * @return SecPwd
+ */
+ public static SecPwd getInstance(Connection con, String directory, String fileName,
+ String serverName, boolean spjMode, byte[] procInfo) throws SecurityException
+ {
+ if (con == null)
+ throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"connection"});
+ SecPwd secpwd = new SecPwd(directory, fileName, serverName, spjMode, procInfo);
+
+ SymCrypto.insert(con, secpwd);
+
+
+ return secpwd;
+ }
+
+ public static void removeInstance(Connection con)
+ {
+ SymCrypto.remove(con);
+ }
+
+ /**
+ * Ctor for the SecPwd. There are two possible certificates: active
+ * certificate and certificate that is going to be active.
+ *
+ * If autodownload is true, certificate will always come from the
+ * server. In this case, only active certificate is used.
+ *
+ * If autodownload is false, active certificate is used to encrypt the
+ * password. When there is a new certificate, it will be stored in
+ * "certificate". As soon as this new certificate is activated on the
+ * server, the current active certificate will become stale, and the new
+ * certificate will be copied over and becomes the active certificate.
+ *
+ * If spjMode is true, the OS name is NONSTOP_KERNEL and the host name
+ * is the same as the server name then just setSpj mode to true
+ * and does nothing.
+ *
+ * @param directory
+ * specifies the directory to locate the certificate. The default
+ * value is %HOME% if set else %HOMEDRIVE%%HOMEPATH%.
+ * @param fileName
+ * specifies the certificate that is in waiting. The default
+ * value is the first 5 characters of server name.
+ * @param activeFileName
+ * specifies the current certificate in use. The default value is
+ * the first 5 character of server name + Active
+ * @param spjMode
+ * true - and if os.name == NSK and the host name
+ * matches the local host - token case. Certificate is not
+ * handled in this case.
+ * false - handles certificate
+ * @param serverName
+ * server name for this certificate.
+ * @throws SecurityException
+ */
+ private SecPwd(String directory, String fileName,
+ String serverName, boolean spjMode, byte[] procInfo) throws SecurityException {
+ String hostName = null;
+
+ try {
+ hostName = java.net.InetAddress.getLocalHost().getHostName();
+ } catch (java.net.UnknownHostException ex) {
+ throw new SecurityException(
+ SecClientMsgKeys.GET_LOCAL_HOST_NAME_FAILED, null);
+ }
+
+ // check USERID env variable for MXCI testing of SPJs. If set use normal password
+ // encryption
+ if ((spjMode == true) &&
+ // ((hostName.substring(0, 5)).compareToIgnoreCase(serverName.substring(0, 5)) == 0) &&
+ (System.getenv("USERID") == null))// token
+ {
+ m_spjMode = spjMode;
+ }
+ else // password
+ {
+ if (procInfo == null)
+ throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"procInfo"});
+ // Stores procInfo with the time stamp for data message encryption used
+ m_procInfo = new byte [SecdefsCommon.PROCINFO_SIZE + SecdefsCommon.TIMESTAMP_SIZE];
+ System.arraycopy(procInfo, 0, m_procInfo, 0, (SecdefsCommon.PROCINFO_SIZE + SecdefsCommon.TIMESTAMP_SIZE));
+ directory = (directory != null) ? directory : System.getenv("HOME");
+ if (directory == null)
+ {
+ String hmdrive = System.getenv("HOMEDRIVE");
+ String hmpath = System.getenv("HOMEPATH");
+ if (hmdrive != null && hmpath != null)
+ {
+ directory = hmdrive + File.separator + hmpath;
+ }
+ else
+ {
+ directory = System.getProperty("user.home");
+ if (directory == null)
+ throw new SecurityException (SecClientMsgKeys.HOME_ENVIRONMENT_VAR_IS_NULL, null);
+ }
+ }
+ fileName = (fileName != null) ? fileName : serverName + ".cer";
+
+ File dir = new File(directory);
+ if (dir.isDirectory() == false)
+ throw new SecurityException(SecClientMsgKeys.DIR_NOTFOUND, new Object[]{dir.getPath()});
+
+ certFile = new File(directory, fileName);
+ }
+ }
+
+ /**
+ * Processes the active certificate when spjMode is false
+ * else does nothing. The certificate is processed by calling
+ * the Security ctor to creates the password key and initializes it
+ * with password id. Gets public key and the length of the public
+ * key from the certificate file. Generates nonce and session key.
+ * @throws SecurityException
+ */
+ public void openCertificate() throws SecurityException {
+ if (m_spjMode == false) // do nothing for the token case
+ m_sec = new Security(certFile);
+ }
+
+ /** This method builds the password key which consists 4 bytes of password id,
+ * 128 bytes of role name which would be 128 spaces when role name is null,
+ * 32 bytes of the digest message calculated using the session key on the data made up of
+ * the procInfo and the encrypted data and 256 bytes (if the 2048 public key is used) or
+ * 128 bytes (if the1024 public key is used) encrypted data calculated using the public key
+ * on the plain text made up of the session key, the nonce and the password.
+ * The password key is generated only when the spjMode is false. When
+ * the spjMode is true, 26 bytes of the token is returned instead.
+ * Builds password key
+ * @param pwd
+ * password to be encrypted
+ * @param rolename
+ * role name to build password key
+ * @param procInfo
+ * process information (PIN, CPU, segment name and time stamp)
+ * @return pwdkey
+ * returns the password key if spjMode is false
+ * returns the token when spjMode is true
+ * @throws SecurityException
+ */
+
+ public void encryptPwd(byte[] pwd, byte[] rolename, byte[] pwdkey) throws SecurityException {
+ // rolename is optional so can be NULL
+ if (pwd == null)
+ throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"password"});
+ if (pwdkey == null)
+ throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"password key"});
+ if (m_spjMode == true) // token
+ {
+ if (pwd.length != SecdefsCommon.TOKENSIZE)
+ throw new SecurityException(SecClientMsgKeys.BAD_TOKEN_LEN, null);
+ if ((pwd[0] != SecdefsCommon.USERTOKEN_ID_1)
+ || (pwd[1] != SecdefsCommon.USERTOKEN_ID_2))
+ throw new SecurityException(
+ SecClientMsgKeys.INCORRECT_TOKEN_FORMAT, null);
+ ByteBuffer.wrap(pwd).get(pwdkey, 0, SecdefsCommon.TOKENSIZE);
+ }
+ else
+ {
+ m_sec.encryptPwd(pwd, rolename, m_procInfo, pwdkey);
+ }
+ }
+
+ /** Gets length of buffer for password encryption (public)
+ * or the length of the token if it is the SPJ mode
+ * @returns
+ * If the spjMode is false
+ * the length of the password key is returnd if success
+ * 0 if failed
+ * If spjMode is true
+ * the length of the token is returned
+ * @throws SecurityException
+ */
+ public int getPwdEBufferLen() throws SecurityException {
+ if (m_spjMode == true)
+ return SecdefsCommon.TOKENSIZE;
+ else
+ return m_sec.getPwdEBufferLen();
+ }
+
+ /** Gets the expiration date of the certificate
+ * @return an array of bytes
+ * presents the certificate's
+ * expiration day in the format YYMMDDHHMMSS
+ * or a zero length byte array if the it is in the SPJ mode
+ */
+ public byte[] getCertExpDate() {
+ if (m_spjMode == false)
+ return m_sec.getCertExpDate();
+ else
+ return new byte[0];
+ }
+
+ /**
+ * When autodownload is on, client will download the certificate from server
+ * when there is no certificate or certificate is stale.
+ *
+ * @param buf
+ * content of the certificate pushed from server.
+ */
+ public void switchCertificate(byte[] buf) throws SecurityException {
+ FileChannel outChannel = null;
+ try {
+ outChannel = new FileOutputStream(certFile).getChannel();
+ outChannel.write(ByteBuffer.wrap(buf));
+ } catch (Exception e) {
+ throw new SecurityException(SecClientMsgKeys.ERR_WRITE_CERT_FILE, new Object[]{certFile});
+ } finally {
+ try {
+ if (outChannel != null)
+ outChannel.close();
+ } catch (Exception e) {
+ }
+ }
+ m_sec = new Security(certFile);
+ }
+
+ public byte[] getProcInfo()
+ {
+ return m_procInfo;
+ }
+
+ private Security m_sec;
+ private File certFile;
+ private boolean m_spjMode;
+ private byte[] m_procInfo; //stores only 4 bytes pid + 4 bytes nid
+
+
+};
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecResourceBundle.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecResourceBundle.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecResourceBundle.java
new file mode 100644
index 0000000..5400d55
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecResourceBundle.java
@@ -0,0 +1,57 @@
+/**********************************************************************
+// @@@ 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.ResourceBundle;
+import java.text.MessageFormat;
+
+public class SecResourceBundle
+{
+
+ private static ResourceBundle rb = ResourceBundle.getBundle("secClient");
+
+ /**
+ * This method is used to obtain parameterized message text
+ *
+ */
+ static String obtainMessageText (String key, Object[] params) {
+ String pattern;
+ try {
+ pattern = rb.getString(key);
+ } catch (Exception e) {
+ return key;
+ }
+ if(pattern == null) {
+ return key;
+ }
+ String message;
+ try {
+ message = MessageFormat.format(pattern, params);
+ } catch (Exception e) {
+ return pattern;
+ }
+ return message;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecdefsCommon.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecdefsCommon.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecdefsCommon.java
new file mode 100644
index 0000000..f003588
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecdefsCommon.java
@@ -0,0 +1,84 @@
+/**********************************************************************
+// @@@ 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;
+
+/**
+ * This class contains defines
+ *
+ */
+
+public class SecdefsCommon {
+
+ public static final int NONCE_RANDOM = 24;
+ public static final int NONCE_SEQNUM = 8;
+ public static final int NONCE_SIZE = (NONCE_RANDOM+NONCE_SEQNUM);
+ public static final int SESSION_KEYLEN = 32;
+ public static final int DIGEST_LENGTH = 32;
+ // AES block size used in data encryption
+ public static final int AES_BLOCKSIZE = 16;
+ public static final int KEY_REFRESH = 30;
+ public static final int TIMESTAMP_SIZE = 8;
+ public static final int ROLENAME_SIZE = 128;
+ public static final int PROCINFO_SIZE = 8;
+ public static final int PWDID_SIZE = 4;
+ public static final int EXPDATESIZE = 12;
+ public static final int PWDKEY_SIZE_LESS_LOGINDATA = (PWDID_SIZE + ROLENAME_SIZE + DIGEST_LENGTH + TIMESTAMP_SIZE);
+ // For public key encryption, the number of bytes
+ // to be encrypted is 11 bytes less than the public key length
+ public static final int UNUSEDBYTES = 11;
+ public static final int TOKENSIZE = 68;
+ // User tokens begin with byte values 3,4.
+ public static final byte USERTOKEN_ID_1 = '\3'; // User token identifier, must be a sequence
+ public static final byte USERTOKEN_ID_2 = '\4'; // not allowed in password
+ public static final int DATA_BLOCK_BIT_SIZE = 128; // data encryption block size in bits. Java
+ // supports block size of 128 bits for AES
+ // algorithm using cryptographic key of 256 bits only.
+
+
+ // Structure used to describe layout of Encrypted data
+ // in login message
+ public static class LoginData {
+ //000 Session key
+ byte[] session_key = new byte[SecdefsCommon.SESSION_KEYLEN];
+ //032 Nonce
+ byte[] nonce = new byte[SecdefsCommon.NONCE_SIZE];
+ Byte password; // 064 User's password
+ } // 128 for 1024 or 256 for 2048
+
+// Structure used to describe layout of password key
+
+ public static class PwdKey {
+ //000 Key identifier, binary values 1,2,3,4
+ //or 1,2,2,4 keys, optional mode only
+ byte[] id= new byte[SecdefsCommon.PWDID_SIZE];
+ //004 RolenameA
+ byte[] rolename = new byte[SecdefsCommon.ROLENAME_SIZE];
+ //132 Digest of server id and encrypted data
+ byte[] digest = new byte[SecdefsCommon.DIGEST_LENGTH];
+ // 164 time stamp
+ byte[] ts = new byte[SecdefsCommon.TIMESTAMP_SIZE];
+ LoginData data; //172 Encrypted data
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Security.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Security.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Security.java
new file mode 100644
index 0000000..1a02021
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Security.java
@@ -0,0 +1,319 @@
+/**********************************************************************
+// @@@ 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.ByteBuffer;
+import java.security.SecureRandom;
+import java.util.Date;
+import java.security.NoSuchAlgorithmException;
+import java.io.File;
+import javax.crypto.SecretKey;
+
+
+
+class Security
+{
+ public static final Cipher cipher = org.trafodion.jdbc.t4.Cipher.getInstance();
+ public static final MessageDigest msgDigest = MessageDigest.getInstance();
+
+ /** Ctor - Creates the password key and initializes it with
+ * password id. Gets public key and the length of the public key
+ * from the certificate file. Generates nonce and session key.
+ * @param cert_file - fully qualified name of certificate file
+ * @throw SecurityException
+ */
+ public Security(File certFile) throws SecurityException
+ {
+ // m_encrypted = 0;
+ m_pwdkey = new SecdefsCommon.PwdKey();
+ m_pwdkey.data = new SecdefsCommon.LoginData();
+ m_pwdkey.id[0] = '\1';
+ m_pwdkey.id[1] = '\2';
+ m_pwdkey.id[2] = '\3';
+ m_pwdkey.id[3] = '\4';
+
+ try {
+ m_keyObj = new Key();
+ m_cert = new Certificate(certFile);
+ m_keyObj.getPubKeyFromFile(m_cert.getCert());
+ generateSessionKey();
+ }catch (SecurityException se) {
+ throw se;
+ }
+ }
+
+ /** This method builds the password key which consists 4 bytes of password id,
+ * 128 bytes of role name which would be 128 spaces when role name is null,
+ * 32 bytes of the digest message calculated using the session key on the data made up of
+ * the procInfo and the encrypted data and 256 bytes (if the 2048 public key is used) or
+ * 128 bytes (if the1024 public key is used) encrypted data calculated using the public key
+ * on the plain text made up of the session key, the nonce and the password.
+ * Builds password key
+ * @param pwd
+ * password to be encrypted
+ * @param rolename
+ * role name to build password key
+ * @param procInfo
+ * process information (PIN, CPU, segment name and time stamp)
+ * @return pwdkey
+ * returned password key
+ * @throws SecurityException
+ */
+ public void encryptPwd(byte[] pwd, byte[] rolename, byte[] procInfo,
+ byte[] pwdkey)
+ throws SecurityException
+ {
+ // Get public key length
+ int pubKeyLen = m_keyObj.getPubKeyLen();
+ int maxPlainTextLen = pubKeyLen - SecdefsCommon.UNUSEDBYTES;
+
+ // Password + nonce + session key can't be longer than the public
+ // key's length
+ if ((SecdefsCommon.NONCE_SIZE + SecdefsCommon.SESSION_KEYLEN
+ + pwd.length) > maxPlainTextLen)
+ throw new SecurityException(SecClientMsgKeys.
+ PWD_LENGTH_TOO_LONG, null);
+
+ byte[] to_encrypt = new byte[SecdefsCommon.SESSION_KEYLEN +
+ SecdefsCommon.NONCE_SIZE + pwd.length];
+ byte[] cipherText = new byte[pubKeyLen];
+ byte[] to_digest = new byte[SecdefsCommon.PROCINFO_SIZE +
+ SecdefsCommon.TIMESTAMP_SIZE + pubKeyLen];
+ byte[] digestedMsg = new byte[SecdefsCommon.DIGEST_LENGTH];
+
+ try {
+ // Build password key
+ // Copy 4 bytes of id
+ System.arraycopy(m_pwdkey.id, 0, pwdkey, 0, SecdefsCommon.PWDID_SIZE);
+ // Copy rolename
+ if (rolename != null)
+ System.arraycopy(rolename, 0, pwdkey, SecdefsCommon.PWDID_SIZE,
+ rolename.length);
+ // Copy 12 bytes of procInfo and 8 bytes of timestamp to
+ // password key store procInfo in the digest starting from
+ // digest[20]
+ System.arraycopy(procInfo, 0, pwdkey, (SecdefsCommon.PWDID_SIZE +
+ SecdefsCommon.ROLENAME_SIZE + SecdefsCommon.DIGEST_LENGTH -
+ SecdefsCommon.PROCINFO_SIZE), (SecdefsCommon.PROCINFO_SIZE +
+ SecdefsCommon.TIMESTAMP_SIZE));
+
+ // Build plain text to encrypt
+ System.arraycopy(m_pwdkey.data.session_key, 0, to_encrypt, 0,
+ SecdefsCommon.SESSION_KEYLEN);
+ System.arraycopy(m_pwdkey.data.nonce, 0, to_encrypt,
+ SecdefsCommon.SESSION_KEYLEN, SecdefsCommon.NONCE_SIZE);
+ System.arraycopy(pwd, 0, to_encrypt,
+ (SecdefsCommon.SESSION_KEYLEN + SecdefsCommon.NONCE_SIZE), pwd.length);
+
+ // Encrypt the data
+ int cipherTextLen = cipher.encrypt(to_encrypt, cipherText,
+ (java.security.Key)(m_keyObj.getPubKey()));
+
+ if(cipherTextLen != pubKeyLen)
+ throw new SecurityException(SecClientMsgKeys.
+ CIPHER_TEXT_LEN_NOT_EQUAL_KEY_LEN, null);
+
+ // Copy cipherText to pwdkey
+ System.arraycopy(cipherText, 0, pwdkey,
+ SecdefsCommon.PWDKEY_SIZE_LESS_LOGINDATA, cipherTextLen);
+
+ // Create digest
+ // Get bytes from digest[20] on
+ System.arraycopy(pwdkey, (SecdefsCommon.PWDKEY_SIZE_LESS_LOGINDATA -
+ SecdefsCommon.TIMESTAMP_SIZE - SecdefsCommon.PROCINFO_SIZE),
+ to_digest, 0, (SecdefsCommon.PROCINFO_SIZE +
+ SecdefsCommon.TIMESTAMP_SIZE + cipherTextLen));
+
+ int mdLen = msgDigest.digest(m_pwdkey.data.session_key,
+ to_digest, digestedMsg);
+
+ if (mdLen != SecdefsCommon.DIGEST_LENGTH)
+ throw new SecurityException(SecClientMsgKeys.
+ BAD_MESSAGE_DIGEST_LEN, null);
+
+ // copy digestedMsg into pwdkey
+ System.arraycopy(digestedMsg, 0, pwdkey,
+ (SecdefsCommon.PWDKEY_SIZE_LESS_LOGINDATA
+ - SecdefsCommon.TIMESTAMP_SIZE - SecdefsCommon.DIGEST_LENGTH), mdLen );
+
+ }catch (SecurityException se) {
+ throw se;
+ }catch (Exception e) {
+ throw new SecurityException(SecClientMsgKeys.FAILED_BUILDING_PWDKEY, null);
+ }finally {
+ if (to_digest != null)
+ to_digest = null;
+ if (digestedMsg != null)
+ digestedMsg = null;
+ if (to_encrypt != null)
+ to_encrypt = null;
+ }
+ }
+
+ /** Encrypts the data using AES256 algorithm.
+ *
+ * @param data - data to be encrypted
+ * @return array of bytes of 2 bytes PIN,
+ * 2 bytes of CPU, 8 bytes of seg_name
+ * and the encrypted data
+ * @throw SecurityException
+ */
+
+ public byte[] encryptData(byte[] data) throws SecurityException
+ {
+ //Creates a secret key from the session key
+ byte[] skey = new byte[SecdefsCommon.AES_BLOCKSIZE];
+ System.arraycopy(m_pwdkey.data.session_key, SecdefsCommon.AES_BLOCKSIZE,
+ skey, 0, SecdefsCommon.AES_BLOCKSIZE);
+ SecretKey seckey = Key.generateSymmetricKey(skey);
+ byte [] iv = new byte [SecdefsCommon.AES_BLOCKSIZE];
+ System.arraycopy(m_pwdkey.data.nonce, SecdefsCommon.AES_BLOCKSIZE,
+ iv, 0, SecdefsCommon.AES_BLOCKSIZE);
+ m_cipher = Cipher.getEASInstance("AES/CBC/PKCS5Padding");
+ return Cipher.encryptData(data, seckey, iv, m_cipher);
+ }
+
+ // Currently not implemented
+ // Generate message digest
+ // str - message to digest
+ // hmacMsg - Hashed message in bytes
+ // hmacMsgLen - Length of hashed message
+ public void HMAC_Message_Generate(byte[] str, byte[] hmacMsg,
+ int hmacMsgLen) throws SecurityException
+ {
+ // Not implemented yet
+ }
+
+ // Currently not implemented
+ // Verify message digest
+ // str - message digest
+ // length - message digest length
+ public boolean HMAC_Message_Verify(byte[] str) throws SecurityException
+ {
+ // Not implemented yet
+ return false;
+ }
+
+ /** increment the nonce sequence
+ *
+ */
+ public void incrementNonceSeq ()
+ {
+ m_nonceSeq++;
+ }
+
+ /** Gets length of buffer for password encryption (public)
+ * @Return pass word key length if success and 0 if failed
+ * @throw SecurityException
+ */
+ public int getPwdEBufferLen() throws SecurityException
+ {
+ int pubKLen = m_keyObj.getPubKeyLen();
+ if(pubKLen <= 0)
+ throw new SecurityException(SecClientMsgKeys.
+ PUBKEY_LENGTH_IS_ZERO, null);
+ else
+ return (pubKLen + SecdefsCommon.PWDKEY_SIZE_LESS_LOGINDATA);
+ }
+
+ /** Gets certificate's expiration date
+ * @Return an array of bytes represents the certificate's
+ * expiration day in the string format YYMMDDHHMMSS
+ */
+ public byte[] getCertExpDate()
+ {
+ return m_cert.getCertExpDate();
+ }
+
+ // Generates session key and nonce
+ private void generateSessionKey() throws SecurityException
+ {
+ //try {
+ SecureRandom random = new SecureRandom();
+ try {
+ random.setSeed(System.currentTimeMillis());
+
+ random.setSeed(Runtime.getRuntime().freeMemory());
+ random.setSeed(Runtime.getRuntime().totalMemory());
+ random.setSeed(Runtime.getRuntime().maxMemory());
+
+ String p = null;
+
+ p = System.getProperty("java.version", "unknown java version");
+ random.setSeed(p.getBytes());
+ p = System.getProperty("java.vendor", "unknown vendor");
+ random.setSeed(p.getBytes());
+ p = System.getProperty("os.name", "unknown os");
+ random.setSeed(p.getBytes());
+ p = System.getProperty("os.version", "unknown os version");
+ random.setSeed(p.getBytes());
+
+ // Add current time again
+
+ random.setSeed(System.currentTimeMillis());
+ }
+ catch(Exception e ) {
+ // Ignore
+ }
+ byte bytes[] = new byte[SecdefsCommon.SESSION_KEYLEN +
+ SecdefsCommon.NONCE_SIZE];
+ synchronized(random) {
+ random.nextBytes(bytes);
+ }
+
+ // Assign bytes to members m_pwdkey.data.session_key
+ // and m_pwdkey.data.nonce
+
+ System.arraycopy(bytes, 0, m_pwdkey.data.session_key, 0, SecdefsCommon.SESSION_KEYLEN);
+ System.arraycopy(bytes, SecdefsCommon.SESSION_KEYLEN, m_pwdkey.data.nonce, 0, SecdefsCommon.NONCE_SIZE);
+
+ m_nonceSeq = (ByteBuffer.wrap(m_pwdkey.data.nonce)).getLong(
+ SecdefsCommon.SESSION_KEYLEN -
+ SecdefsCommon.NONCE_SEQNUM);
+
+ // Set time when session key is generated
+ m_keyTime = (new Date()).getTime();
+ /*}catch (NoSuchAlgorithmException nae) {
+ throw new SecurityException(SecClientMsgKeys.SESSION_KEY_GENERATION_FAILED, null);
+ }*/
+ }
+
+ // encryption is required or not for replied message 0-yes, 1-no
+ //int m_encrypted;
+ // security option - mandatory - 1 or undocumented option - 0
+ // Time when session key is generated
+ private long m_keyTime;
+ // sequence nonce used in nonce increment
+ // Need to use 64 bit number type here
+ private long m_nonceSeq;
+ // certificate
+ private Certificate m_cert;
+ // key
+ private Key m_keyObj;
+ // password key
+ private SecdefsCommon.PwdKey m_pwdkey;
+ private javax.crypto.Cipher m_cipher;
+
+};
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecurityException.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecurityException.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecurityException.java
new file mode 100644
index 0000000..64d1a3d
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecurityException.java
@@ -0,0 +1,47 @@
+/**********************************************************************
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+//
+ **********************************************************************/
+package org.trafodion.jdbc.t4;
+
+import java.lang.String;
+import java.lang.Integer;
+import java.sql.SQLException;
+
+public class SecurityException extends SQLException
+{
+ private static final String SQLState = "38001";
+
+ public SecurityException(String key, Object[] params)
+ {
+ // Get the text message from the file secClient.properties.
+ // Parse the message for the error message and error number.
+ this((SecResourceBundle.obtainMessageText(key, params)).substring(6),
+ Integer.parseInt((SecResourceBundle.obtainMessageText(key, params)).substring(0, 5)));
+ }
+
+ public SecurityException(String errMsg, int errNum)
+ {
+ super(errMsg, SQLState, errNum);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SetConnectionOptionMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SetConnectionOptionMessage.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SetConnectionOptionMessage.java
new file mode 100644
index 0000000..8ee7c6c
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SetConnectionOptionMessage.java
@@ -0,0 +1,50 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class SetConnectionOptionMessage {
+ // ----------------------------------------------------------
+ static LogicalByteArray marshal(int dialogueId, short connectionOption, int optionValueNum, String optionValueStr,
+ InterfaceConnection ic) throws CharacterCodingException, UnsupportedCharsetException {
+ int wlength = Header.sizeOf();
+ LogicalByteArray buf;
+
+ byte[] optionValueBytes = ic.encodeString(optionValueStr, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+
+ wlength += TRANSPORT.size_int; // dialogueId
+ wlength += TRANSPORT.size_short; // connectionOption
+ wlength += TRANSPORT.size_int; // optionValueNum
+ wlength += TRANSPORT.size_bytes(optionValueBytes); // optionValueStr
+
+ buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
+
+ buf.insertInt(dialogueId);
+ buf.insertShort(connectionOption);
+ buf.insertInt(optionValueNum);
+ buf.insertString(optionValueBytes);
+
+ return buf;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SetConnectionOptionReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SetConnectionOptionReply.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SetConnectionOptionReply.java
new file mode 100644
index 0000000..fa3ecc0
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SetConnectionOptionReply.java
@@ -0,0 +1,45 @@
+// @@@ 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 SetConnectionOptionReply {
+ odbc_SQLSvc_SetConnectionOption_exc_ m_p1;
+ ERROR_DESC_LIST_def m_p2;
+
+ // -------------------------------------------------------------
+ SetConnectionOptionReply(LogicalByteArray buf, String addr, InterfaceConnection ic)
+ throws CharacterCodingException, UnsupportedCharsetException, SQLException {
+ buf.setLocation(Header.sizeOf());
+
+ m_p1 = new odbc_SQLSvc_SetConnectionOption_exc_();
+ m_p1.extractFromByteArray(buf, addr, ic);
+
+ if (m_p1.exception_nr == TRANSPORT.CEE_SUCCESS) {
+ m_p2 = new ERROR_DESC_LIST_def();
+ m_p2.extractFromByteArray(buf, ic);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SymCrypto.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SymCrypto.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SymCrypto.java
new file mode 100644
index 0000000..a0e10ad
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SymCrypto.java
@@ -0,0 +1,87 @@
+/**********************************************************************
+// @@@ 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 @@@
+ //
+ **********************************************************************/
+
+/**
+ * class SymCrypto - Stores connections and correspondence SecPwd
+ * objects.
+ */
+
+package org.trafodion.jdbc.t4;
+
+import java.util.HashMap;
+import java.sql.Connection;
+
+public class SymCrypto
+{
+ static HashMap<Connection, SymCrypto> storage = new HashMap<Connection, SymCrypto> ();
+
+ /**
+ * Ctor -
+ * @param secpwd
+ */
+ private SymCrypto(SecPwd secpwd)
+ {
+ m_secPwd = secpwd;
+ }
+
+ /**
+ * Returns the SymCrypto object correspondence to the connection passed in
+ * @param con
+ * @return the value to which the SymCrypto object maps the connection passed in or
+ * null if the map contains no mapping for the connection.
+ * @throws SecurityException
+ */
+ public static SymCrypto getInstance(Connection con) throws SecurityException
+ {
+ if (con == null)
+ throw new SecurityException (SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"connection"});
+ return storage.get(con);
+ }
+
+ /**
+ * Creates and SymCrypto object from the SecPwd object and inserts the connection
+ * and the equivalent SymCRypto object into the hash table storage. If the table previously
+ * contained a mapping for the connection, the old value is replaced.
+ * @param con - the JDBC connection
+ * @param secpwd - the SecPwd object associated with the JDBC connection
+ */
+ public static void insert(Connection con, SecPwd secpwd)
+ {
+ SymCrypto symcrypto = new SymCrypto(secpwd);
+ storage.put(con, symcrypto);
+ }
+
+ /**
+ * Removed the mapping of this JDBC connection from the hash table if present
+ * @param con - JDBC connection whose entry is to be removed from the hash table storage
+ */
+ public static void remove(Connection con)
+ {
+ if (con != null)
+ storage.remove(con);
+ }
+
+ private SecPwd m_secPwd;
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Address.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Address.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Address.java
new file mode 100644
index 0000000..6cc2085
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Address.java
@@ -0,0 +1,315 @@
+// @@@ 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;
+
+/**********************************************************
+ * This class represents an address reference.
+ *
+ * @version 1.0
+ **********************************************************/
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.Locale;
+import java.util.Properties;
+
+final class T4Address extends Address {
+
+ private static final String t4ConnectionPrefix = "jdbc:t4jdbc:";
+ private static final String urlPrefix = t4ConnectionPrefix + "//";
+ private static final int minT4ConnectionAddrLen = t4ConnectionPrefix.length() + 4;
+ private static final int AS_type = 1; // jdbc:subprotocol:subname
+
+ /**
+ * The constructor.
+ *
+ * @param addr
+ * The addr has two forms:
+ *
+ * DriverManager getConnection addr parameter format for connecting via the
+ * Fast JDBC Type 4 driver.
+ *
+ * jdbc:subprotocol:subname
+ *
+ * Where:
+ *
+ * subprotocol = t4jdbc
+ *
+ * subname = //<{IP Address|Machine Name}[:port]>/<properties>
+ *
+ * Example: jdbc:t4jdbc://130.168.200.30:1433/database1
+ *
+ */
+
+ // ----------------------------------------------------------
+ T4Address(T4Properties t4props, Locale locale, String addr) throws SQLException {
+ super(t4props, locale, addr);
+
+ if (addr == null) {
+ SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_null_error", null);
+ throw se;
+ }
+
+ //
+ // We are now expecting addr = "//<{IP Address|Machine
+ // Name}[:port]>/<properties>"
+ //
+ m_type = AS_type;
+
+ //
+ // We don't recognize this address syntax
+ //
+ if (acceptsURL(addr) == false) {
+ SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", addr);
+ SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "unknown_prefix_error", null);
+
+ se.setNextException(se2);
+ throw se;
+ }
+
+ //
+ // We are now expecting addr = "<{IP Address|Machine Name}[:port]>"
+ // Get the IP or Name
+ //
+ String IPorName = extractHostFromUrl(addr);
+ if (isIPAddress(IPorName)) {
+ m_ipAddress = IPorName;
+ } else {
+ m_machineName = IPorName;
+
+ //
+ // Get the port number if there is one.
+ //
+ }
+ m_portNumber = new Integer(extractPortFromUrl(addr));
+ m_properties = extractPropertiesFromString(addr);
+
+ m_url = recreateAddress();
+
+ validateAddress();
+ setInputOutput();
+ }
+
+ String recreateAddress() {
+ String addr = null;
+
+ addr = t4ConnectionPrefix + "//";
+
+ if (m_machineName != null) {
+ addr = addr + m_machineName;
+ } else if (m_ipAddress != null) {
+ addr = addr + m_ipAddress;
+
+ }
+ if (m_portNumber != null) {
+ addr = addr + ":" + m_portNumber;
+
+ }
+ addr = addr + "/";
+
+ return addr;
+ } // end recreateAddress
+
+ static boolean acceptsURL(String url) throws SQLException {
+ try {
+ return url.toLowerCase().startsWith(t4ConnectionPrefix);
+ } catch (Exception ex) {
+ throw new SQLException(ex.toString());
+ }
+ }
+
+ // ----------------------------------------------------------
+ String getUrl() {
+ return urlPrefix + getIPorName() + ':' + getPort().toString() + "/:";
+ } // end getProps()
+
+ // ----------------------------------------------------------
+ Properties getProps() {
+ return m_properties;
+ } // end getProps()
+
+ /**
+ * Return the host value
+ *
+ * @param url
+ * of format jdbc:t4jdbc://host:port/:[prop-name=prop-value]..
+ * @return host string
+ */
+ private String extractHostFromUrl(String url) throws SQLException {
+ if (url.length() < minT4ConnectionAddrLen) {
+ SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", url);
+ SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "min_address_length_error", null);
+
+ se.setNextException(se2);
+ throw se;
+ }
+
+ int hostStartIndex = urlPrefix.length();
+ int hostEndIndex = -1;
+ if (isIPV6(url)) {
+ hostEndIndex = url.lastIndexOf(']', hostStartIndex); // IP6
+ } else {
+ hostEndIndex = url.indexOf(':', hostStartIndex); // IP4
+
+ }
+ if (hostEndIndex < 0) {
+ SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", url);
+ SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "address_format_error", url);
+
+ se.setNextException(se2);
+ throw se;
+ }
+
+ String host = url.substring(hostStartIndex, hostEndIndex);
+ if ((host == null) || (host.length() == 0)) {
+ SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", url);
+ SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "address_format_error", null);
+ SQLException se3 = HPT4Messages.createSQLException(m_t4props, m_locale, "missing_ip_or_name_error", null);
+ se.setNextException(se2);
+ se2.setNextException(se3);
+ throw se;
+ }
+
+ return host;
+ }
+
+ /**
+ * Return the port value
+ *
+ * @param url
+ * of format jdbc:t4jdbc://host:port/:[prop-name=prop-value]..
+ * @return port string
+ */
+ private String extractPortFromUrl(String url) throws SQLException {
+ int portStartIndex = url.indexOf(':', urlPrefix.length()) + 1;
+ int portEndIndex = url.indexOf('/', portStartIndex);
+ if (portEndIndex < 0) {
+ portEndIndex = url.length();
+
+ }
+ String port = url.substring(portStartIndex, portEndIndex);
+ if (port.length() < 1) {
+ throw new SQLException("Incorrect port value in the URL.");
+ }
+ ;
+
+ int asPort;
+ try {
+ asPort = Integer.parseInt(port);
+ } catch (Exception e) {
+ throw new SQLException("Incorrect port value in the URL.");
+ }
+
+ if ((asPort < 0) || (asPort > 65535)) {
+ throw new SQLException("Port value out of range in the URL.");
+ }
+
+ return port;
+ }
+
+ /**
+ * Checks if the url is of IP6 protocol
+ */
+ private boolean isIPV6(String url) throws SQLException {
+ if (url == null) {
+ SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", url);
+ SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "address_format_2_error", null);
+ se.setNextException(se2);
+ throw se;
+
+ }
+ int hostStartIndex = urlPrefix.length();
+ return (url.charAt(hostStartIndex) == '[');
+ }
+
+ /**
+ * Extracts the property name, value pair from a url String, seperated by ;
+ *
+ * @param url
+ * of format jdbc:t4jdbc://host:port/:[prop-name=prop-value]..
+ * @return Propeties object
+ * @throws IOException
+ */
+ private Properties extractPropertiesFromString(String url) throws SQLException {
+ int urLength = url.length();
+ int hostStartIndex = urlPrefix.length();
+ int propStartIndex = url.indexOf('/', hostStartIndex);
+ if (propStartIndex < 0) {
+ return null;
+ }
+
+ if (propStartIndex == urLength) {
+ return null;
+ }
+
+ if (url.charAt(propStartIndex) == '/') {
+ propStartIndex++;
+
+ }
+ if (propStartIndex == urLength) {
+ return null;
+ }
+
+ if (url.charAt(propStartIndex) == ':') {
+ propStartIndex++;
+
+ }
+ if (propStartIndex == urLength) {
+ return null;
+ }
+
+ String propStr = url.substring(propStartIndex);
+ if ((propStr == null) || (propStr.length() == 0)) {
+ return null;
+ }
+
+ Properties props = new Properties();
+ propStr = propStr.replace(';', '\n');
+ ByteArrayInputStream byteArrIPStream = new ByteArrayInputStream(propStr.getBytes());
+
+ try {
+ props.load(byteArrIPStream);
+ } catch (IOException ioex) {
+ throw new SQLException(ioex.getMessage());
+ }
+
+ return props;
+ }
+
+ /**
+ * Checks the string is host or port.
+ *
+ * @param IPorName
+ * @return true if the address is a IP address
+ */
+ private boolean isIPAddress(String IPorName) {
+ // Minimum length = 7; 1.1.1.1
+ if (IPorName.length() < 7)
+ return false;
+ //
+ // If first letter is a digit or ":" (i.e. IPv6), I'll assume it is an
+ // IP address
+ //
+ return (Character.isDigit(IPorName.charAt(0)) || (IPorName.charAt(1) == ':'));
+ }
+} // end class Address
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Connection.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Connection.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Connection.java
new file mode 100644
index 0000000..d1ce34f
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Connection.java
@@ -0,0 +1,505 @@
+// @@@ 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;
+import java.util.logging.Level;
+
+class T4Connection {
+ protected Locale m_locale;
+ protected int m_dialogueId;
+ protected NCSAddress m_ncsAddress;
+ private InputOutput m_io;
+ private USER_DESC_def m_userDesc;
+ private CONNECTION_CONTEXT_def m_inContext;
+ private String m_sessionName;
+ InterfaceConnection m_ic;
+
+ static final int INCONTEXT_OPT1_SESSIONNAME = 0x80000000; // (2^31)
+ static final int INCONTEXT_OPT1_FETCHAHEAD = 0x40000000; // (2^30)
+ static final int INCONTEXT_OPT1_CERTIFICATE_TIMESTAMP = 0x20000000; //(2^29)
+ static final int INCONTEXT_OPT1_CLIENT_USERNAME = 0x10000000; //(2^28)
+
+ T4Connection(InterfaceConnection ic) throws SQLException {
+ if (ic == null) {
+ throwInternalException();
+
+ }
+ m_ic = ic;
+ m_locale = ic.getLocale();
+ m_dialogueId = ic.getDialogueId();
+ m_ncsAddress = ic.getNCSAddress();
+ m_userDesc = ic.getUserDescription();
+ m_inContext = ic.getInContext();
+ m_sessionName = ic.getSessionName();
+
+ if (m_dialogueId < 1 || m_ncsAddress == null || m_userDesc == null || m_inContext == null) {
+ throwInternalException();
+
+ }
+ m_io = m_ncsAddress.getInputOutput();
+ if (m_io == null) {
+ throwInternalException();
+ }
+ m_io.setDialogueId(m_dialogueId);
+ m_io.setConnectionIdleTimeout(ic.getConnectionTimeout());
+ // trace_connection - AM
+ m_io.setT4Connection(this);
+ m_io.openIO();
+ getInputOutput().setTimeout(ic.getLoginTimeout());
+ checkConnectionIdleTimeout();
+ resetConnectionIdleTimeout();
+ }
+
+ public void finalizer() {
+ closeTimers();
+ }
+
+ protected int getDialogueId() {
+ return m_dialogueId;
+ }
+
+ protected Locale getLocale() {
+ return m_locale;
+ }
+
+ protected String getSessionName() {
+ return this.m_sessionName;
+ }
+
+ protected NCSAddress getNCSAddress() {
+ return m_ncsAddress;
+ }
+
+ void closeTimers() {
+ if (m_io != null) {
+ m_io.closeTimers();
+ }
+ }
+
+ protected void reuse() {
+ resetConnectionIdleTimeout();
+ }
+
+ private void setConnectionIdleTimeout() {
+ m_io.startConnectionIdleTimeout();
+ }
+
+ private void resetConnectionIdleTimeout() {
+ m_io.resetConnectionIdleTimeout();
+ }
+
+ private void checkConnectionIdleTimeout() throws SQLException {
+ if (m_io.checkConnectionIdleTimeout()) {
+ try {
+ m_ic.close();
+ } catch (SQLException sqex) {
+ // ignores
+ }
+ throw HPT4Messages.createSQLException(m_ic.t4props_, m_locale, "ids_s1_t00", null);
+ }
+ }
+
+ protected boolean connectionIdleTimeoutOccured() {
+ return m_io.checkConnectionIdleTimeout();
+ }
+
+ protected InputOutput getInputOutput() throws SQLException {
+ checkConnectionIdleTimeout();
+ resetConnectionIdleTimeout();
+ return m_io;
+ }
+
+ protected void throwInternalException() throws SQLException {
+ T4Properties tempP = null;
+
+ if (m_ic != null) {
+ tempP = m_ic.t4props_;
+
+ }
+ SQLException se = HPT4Messages.createSQLException(tempP, m_locale, "internal_error", null);
+ SQLException se2 = HPT4Messages.createSQLException(tempP, m_locale, "contact_hp_error", null);
+
+ se.setNextException(se2);
+ throw se;
+ }
+
+ // --------------------------------------------------------------------------------
+ protected LogicalByteArray getReadBuffer(short odbcAPI, LogicalByteArray wbuffer) throws SQLException {
+ // trace_connection - AM
+ if (m_ic.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(m_ic.t4props_);
+ String temp = "LogicalByteArray";
+ m_ic.t4props_.t4Logger_.logp(Level.FINEST, "T4Connection", "getReadBuffer", temp, p);
+ }
+ LogicalByteArray rbuffer = m_io.doIO(odbcAPI, wbuffer);
+
+ return rbuffer;
+ }
+
+ // --------------------------------------------------------------------------------
+ /**
+ * This class corresponds to the ODBC client driver function
+ * odbc_SQLSvc_InitializeDialogue_pst_ as taken from odbccs_drvr.cpp.
+ * @version 1.0
+ *
+ * This method will make a connection to an ODBC server. The ODBC server's
+ * locaiton This method will make a connection to an ODBC server. The ODBC
+ * server's locaiton (i.e. ip address and port number), were provided by an
+ * earlier call to the ODBC association server.
+ *
+ * @param inContext
+ * a CONNETION_CONTEXT_def object containing connection
+ * information
+ * @param userDesc
+ * a USER_DESC_def object containing user information
+ * @param inContext
+ * a CONNECTION_CONTEXT_def object containing information for
+ * this connection
+ * @param dialogueId
+ * a unique id identifing this connection as supplied by an
+ * earlier call to the association server
+ *
+ * @retrun a InitializeDialogueReply class representing the reply from the
+ * ODBC server is returned
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+
+ InitializeDialogueReply InitializeDialogue(boolean setTimestamp, boolean downloadCert) throws SQLException {
+ try {
+ int optionFlags1 = INCONTEXT_OPT1_CLIENT_USERNAME;
+ int optionFlags2 = 0;
+
+ if(setTimestamp) {
+ optionFlags1 |= INCONTEXT_OPT1_CERTIFICATE_TIMESTAMP;
+ }
+
+ if (m_sessionName != null && m_sessionName.length() > 0) {
+ optionFlags1 |= INCONTEXT_OPT1_SESSIONNAME;
+ }
+
+ if (this.m_ic.t4props_.getFetchAhead()) {
+ optionFlags1 |= INCONTEXT_OPT1_FETCHAHEAD;
+ }
+
+ // trace_connection - AM
+ if (m_ic.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(m_ic.t4props_);
+ String temp = "m_dialogueId=" + m_dialogueId;
+ m_ic.t4props_.t4Logger_.logp(Level.FINEST, "T4Connection", "InitializeDialogue", temp, p);
+ }
+ LogicalByteArray wbuffer = InitializeDialogueMessage.marshal(m_userDesc, m_inContext, m_dialogueId,
+ optionFlags1, optionFlags2, m_sessionName, m_ic);
+
+ getInputOutput().setTimeout(m_ic.t4props_.getLoginTimeout());
+
+ LogicalByteArray rbuffer = getReadBuffer(TRANSPORT.SRVR_API_SQLCONNECT, wbuffer);
+
+ //
+ // Process output parameters
+ //
+ InitializeDialogueReply idr1 = new InitializeDialogueReply(rbuffer, m_ncsAddress.getIPorName(), m_ic, downloadCert);
+
+ return idr1;
+ } catch (SQLException se) {
+ throw se;
+ } catch (CharacterCodingException e) {
+ SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale,
+ "translation_of_parameter_failed", "InitializeDialogueMessage", 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,
+ "initialize_dialogue_message_error", e.getMessage());
+
+ se.initCause(e);
+ throw se;
+ } // end catch
+ } // end InitializeDialogue
+
+ /**
+ * This method will end a connection to an ODBC server. The ODBC server's
+ * locaiton (i.e. ip address and port number), were provided by an earlier
+ * call to the ODBC association server.
+ *
+ * @retrun a TerminateDialogueReply class representing the reply from the
+ * ODBC server is returned
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+ TerminateDialogueReply TerminateDialogue() throws SQLException {
+ try {
+ // trace_connection - AM
+ if (m_ic.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(m_ic.t4props_);
+ String temp = "m_dialogueId=" + m_dialogueId;
+ m_ic.t4props_.t4Logger_.logp(Level.FINEST, "T4Connection", "TerminateDialogue", temp, p);
+ }
+ LogicalByteArray wbuffer = TerminateDialogueMessage.marshal(m_dialogueId, this.m_ic);
+
+ //
+ // used m_ic instead of getInputOutput, because getInputOutput
+ // implicitly calls close at timeout, which will call
+ // TerminateDialogue
+ // which causes recursion.
+ //
+ // m_io.setTimeout(m_ic.t4props_.getCloseConnectionTimeout());
+ m_io.setTimeout(m_ic.t4props_.getLoginTimeout());
+
+ LogicalByteArray rbuffer = getReadBuffer(TRANSPORT.SRVR_API_SQLDISCONNECT, wbuffer);
+
+ //
+ // Process output parameters
+ //
+ TerminateDialogueReply tdr1 = new TerminateDialogueReply(rbuffer, m_ncsAddress.getIPorName(), m_ic);
+
+ //
+ // Send a close message and close the port if we don't have an
+ // error.
+ // If there is an error, it's up to the calling routine to decide
+ // what to do.
+ //
+ if (tdr1.m_p1.exception_nr == TRANSPORT.CEE_SUCCESS) {
+ m_io.CloseIO(wbuffer); // note, I'm re-using wbuffer
+
+ }
+
+ closeTimers();
+
+ return tdr1;
+ } // end try
+ catch (SQLException se) {
+ throw se;
+ } catch (CharacterCodingException e) {
+ SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale,
+ "translation_of_parameter_failed", "TerminateDialogMessage", 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,
+ "terminate_dialogue_message_error", e.getMessage());
+
+ se.initCause(e);
+ throw se;
+ } // end catch
+ } // end TerminateDialogue
+
+ /**
+ * This method will send a set connection option command to the server.
+ *
+ * @param connetionOption
+ * The connection option to be set
+ * @param optionValueNum
+ * The number value of the option
+ * @param optionValueStr
+ * The string value of the option
+ *
+ * @retrun a SetConnectionOptionReply class representing the reply from the
+ * ODBC server is returned
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+ SetConnectionOptionReply SetConnectionOption(short connectionOption, int optionValueNum, String optionValueStr)
+ throws SQLException {
+
+ if (optionValueStr == null) {
+ throwInternalException();
+
+ }
+ try {
+
+ LogicalByteArray wbuffer = SetConnectionOptionMessage.marshal(m_dialogueId, connectionOption,
+ optionValueNum, optionValueStr, this.m_ic);
+
+ getInputOutput().setTimeout(m_ic.t4props_.getNetworkTimeout());
+
+ LogicalByteArray rbuffer = getReadBuffer(TRANSPORT.SRVR_API_SQLSETCONNECTATTR, wbuffer);
+
+ SetConnectionOptionReply scor = new SetConnectionOptionReply(rbuffer, m_ncsAddress.getIPorName(), m_ic);
+
+ return scor;
+ } // end try
+ catch (SQLException se) {
+ throw se;
+ } catch (CharacterCodingException e) {
+ SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale,
+ "translation_of_parameter_failed", "SetConnectionOptionReply", 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,
+ "set_connection_option_message_error", e.getMessage());
+
+ se.initCause(e);
+ throw se;
+ } // end catch
+ } // end SetConnectionOption
+
+ /**
+ * This method will send an End Transaction command, which does not return
+ * any rowsets, to the ODBC server.
+ *
+ * @param transactionOpt
+ * A transaction opt
+ *
+ * @retrun A EndTransactionReply class representing the reply from the ODBC
+ * server is returned
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+ EndTransactionReply EndTransaction(short transactionOpt) throws SQLException {
+
+ try {
+ LogicalByteArray wbuffer = EndTransactionMessage.marshal(m_dialogueId, transactionOpt, this.m_ic);
+
+ getInputOutput().setTimeout(m_ic.t4props_.getNetworkTimeout());
+
+ LogicalByteArray rbuffer = getReadBuffer(TRANSPORT.SRVR_API_SQLENDTRAN, wbuffer);
+
+ EndTransactionReply cr = new EndTransactionReply(rbuffer, m_ncsAddress.getIPorName(), m_ic);
+ return cr;
+ } // end try
+ catch (SQLException se) {
+ throw se;
+ } catch (CharacterCodingException e) {
+ SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale,
+ "translation_of_parameter_failed", "EndTransactionMessage", 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, "end_transaction_message_error",
+ e.getMessage());
+
+ se.initCause(e);
+ throw se;
+ } // end catch
+
+ } // end EndTransaction
+
+ /**
+ * This method will send an get SQL catalogs command to the ODBC server.
+ *
+ * @param stmtLabel
+ * a statement label for use by the ODBC server
+ * @param APIType
+ * @param catalogNm
+ * @param schemaNm
+ * @param tableNm
+ * @param tableTypeList
+ * @param columnNm
+ * @param columnType
+ * @param rowIdScope
+ * @param nullable
+ * @param uniqueness
+ * @param accuracy
+ * @param sqlType
+ * @param metadataId
+ * @param fkcatalogNm
+ * @param fkschemaNm
+ * @param fktableNm
+ *
+ * @retrun a GetSQLCatalogsReply class representing the reply from the ODBC
+ * server is returned
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+ GetSQLCatalogsReply GetSQLCatalogs(String stmtLabel, short APIType, String catalogNm, String schemaNm,
+ String tableNm, String tableTypeList, String columnNm, int columnType, int rowIdScope, int nullable,
+ int uniqueness, int accuracy, short sqlType, int metadataId, String fkcatalogNm, String fkschemaNm,
+ String fktableNm) throws SQLException {
+
+ if (stmtLabel == null) {
+ throwInternalException();
+
+ }
+ try {
+ LogicalByteArray wbuffer;
+
+ wbuffer = GetSQLCatalogsMessage.marshal(m_dialogueId, stmtLabel, APIType, catalogNm, schemaNm, tableNm,
+ tableTypeList, columnNm, columnType, rowIdScope, nullable, uniqueness, accuracy, sqlType,
+ metadataId, fkcatalogNm, fkschemaNm, fktableNm, m_ic);
+
+ getInputOutput().setTimeout(m_ic.t4props_.getNetworkTimeout());
+
+ LogicalByteArray rbuffer = getReadBuffer(TRANSPORT.SRVR_API_GETCATALOGS, wbuffer);
+
+ //
+ // Process output parameters
+ //
+ GetSQLCatalogsReply gscr = new GetSQLCatalogsReply(rbuffer, m_ncsAddress.getIPorName(), m_ic);
+
+ return gscr;
+ } // end try
+ catch (SQLException se) {
+ throw se;
+ } catch (CharacterCodingException e) {
+ SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale,
+ "translation_of_parameter_failed", "GetSQLCatalogsMessage", 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,
+ "get_sql_catalogs_message_error", e.getMessage());
+
+ se.initCause(e);
+ throw se;
+ } // end catch
+
+ } // end GetSQLCatalogs
+
+}
[44/60] incubator-trafodion git commit: Merge branch 'master' of
github.com:apache/incubator-trafodion into wrkbrnch
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a0f21cde/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DatabaseMetaData.java
----------------------------------------------------------------------
diff --cc core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DatabaseMetaData.java
index d3b916d,0000000..d691a82
mode 100644,000000..100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DatabaseMetaData.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DatabaseMetaData.java
@@@ -1,5901 -1,0 +1,5901 @@@
+// @@@ 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.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.RowIdLifetime;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+/**
+ * <p>
+ * JDBC Type 4 driver DataBaseMetaData class.
+ * </p>
+ * Comprehensive information about the database and Type 4 driver as
+ * a whole. This class lets applications users know the capabilities of database
+ * in combination with the Type 4 driver. Information returned
+ * by methods in this class applies to the capabilities of a Type 4 driver and
+ * Database working together. A user for this class is commonly a
+ * tool that needs to discover how to deal with the underlying
+ * Database. This is especially true for applications that are intended to be
+ * used with more than one DBMS. For example, a tool might use the method
+ * <code>getTypeInfo</code> to find out what data types can be used in a
+ * CREATE TABLE statement. Or a user might call the method
+ * <code>supportsCorrelatedSubqueries</code> to see if it is possible to use a
+ * correlated subquery or <code>supportsBatchUpdates</code> to see if it is
+ * possible to use batch updates. Some DatabaseMetaData methods return lists of
+ * information in the form of ResultSet objects. Regular ResultSet methods, such
+ * as getString and getInt, can be used to retrieve the data from these
+ * ResultSet objects. If a given form of metadata is not available, the
+ * ResultSet getter methods throw an SQLException. Some DatabaseMetaData methods
+ * take arguments that are String patterns. These arguments all have names such
+ * as fooPattern. Within a pattern String, "%" means match any substring of 0 or
+ * more characters, and "_" means match any one character. Only metadata entries
+ * matching the search pattern are returned. If a search pattern argument is set
+ * to null, that argument's criterion will be dropped from the search. A method
+ * that gets information about a feature that the Type 4 driver does not support
+ * will throw an SQLException. In the case of methods that return a ResultSet
+ * object, either a ResultSet object (which might be empty) is returned, or an
+ * SQLException is thrown.
+ *
+ * <p>
+ * Description: JDBC Type 4 Driver
+ * </p>
+ * <p>
+ * </p>
+ */
+public class T4DatabaseMetaData extends HPT4Handle implements java.sql.DatabaseMetaData {
+
+ // ----------------------------------------------------------------------
+ // First, a variety of minor information about the target database.
+
+ /*
+ * Can all the procedures returned by getProcedures be called by the current
+ * user?
+ *
+ * @return true if so
+ */
+ public boolean allProceduresAreCallable() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "allProceduresAreCallable", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("allProceduresAreCallable");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Can all the tables returned by getTable be SELECTed by the current user?
+ *
+ * @return true if so
+ */
+ public boolean allTablesAreSelectable() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "allTablesAreSelectable", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("allTablesAreSelectable");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * What's the url for this database?
+ *
+ * @return the url or null if it can't be generated * "TCP:<hostname>:<portnumber>/JDBC"
+ * is good enough.
+ */
+ public String getURL() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getURL", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getURL");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return connection_.getT4Properties().getUrl();
+ }
+
+ /*
+ * What's our user name as known to the database?
+ *
+ * @return our database user name *
+ *
+ */
+ public String getUserName() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getUserName", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getUserName");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return connection_.getServerHandle().getUid();
+ }
+
+ /*
+ * Is the database in read-only mode?
+ *
+ * @return true if so *
+ *
+ */
+ public boolean isReadOnly() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "isReadOnly", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("isReadOnly");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Are NULL values sorted high?
+ *
+ * @return true if so
+ *
+ */
+ public boolean nullsAreSortedHigh() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "nullsAreSortedHigh", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("nullsAreSortedHigh");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Are NULL values sorted low?
+ *
+ * @return true if so
+ */
+ public boolean nullsAreSortedLow() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "nullsAreSortedLow", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("nullsAreSortedLow");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Are NULL values sorted at the start regardless of sort order?
+ *
+ * @return true if so
+ */
+ public boolean nullsAreSortedAtStart() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "nullsAreSortedAtStart", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("nullsAreSortedAtStart");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Are NULL values sorted at the end regardless of sort order?
+ *
+ * @return true if so
+ */
+ public boolean nullsAreSortedAtEnd() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "nullsAreSortedAtEnd", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("nullsAreSortedAtEnd");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * What's the name of this database product?
+ *
+ * @return database product name
+ */
+ public String getDatabaseProductName() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDatabaseProductName", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getDatabaseProductName");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("Trafodion");
+ }
+
+ /*
+ * What's the version of this database product?
+ *
+ * @return database version *
+ *
+ */
+ public String getDatabaseProductVersion() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDatabaseProductVersion", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getDatabaseProductVersion");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("" + getDatabaseMajorVersion() + "." + getDatabaseMinorVersion());
+ }
+
+ /*
+ * What's the name of this JDBC driver?
+ *
+ * @return JDBC driver name
+ */
+ public String getDriverName() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDriverName", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getDriverName");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("org.trafodion.jdbc.t4.T4Driver");
+ }
+
+ /*
+ * What's the version of this JDBC driver?
+ *
+ * @return JDBC driver version
+ */
+ public String getDriverVersion() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDriverVersion", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getDriverVersion");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return Vproc.getVproc();
+ }
+
+ /*
+ * What's this JDBC driver's major version number?
+ *
+ * @return JDBC driver major version
+ */
+ public int getDriverMajorVersion() {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDriverMajorVersion", "", p);
+ }
+ try {
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getDriverMajorVersion");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+ return Vproc.jdbcMajorVersion;
+ }
+
+ /*
+ * What's this JDBC driver's minor version number?
+ *
+ * @return JDBC driver minor version number
+ */
+ public int getDriverMinorVersion() {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDriverMinorVersion", "", p);
+ }
+ try {
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getDriverMinorVersion");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+ return Vproc.jdbcMinorVersion;
+ }
+
+ /*
+ * Does the database store tables in a local file?
+ *
+ * @return true if so
+ */
+ public boolean usesLocalFiles() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "usesLocalFiles", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("usesLocalFiles");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Does the database use a file for each table?
+ *
+ * @return true if the database uses a local file for each table
+ */
+ public boolean usesLocalFilePerTable() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "usesLocalFilePerTable", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("usesLocalFilePerTable");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Database does not treat the mixed case unquoted SQL
+ * identifiers as case sensitive and does not store the result in mixed
+ * case.
+ *
+ * @return false always for the Type 4 driver.
+ */
+ public boolean supportsMixedCaseIdentifiers() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_
+ .logp(Level.FINE, "T4DatabaseMetaData", "supportsMixedCaseIdentifiers", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsMixedCaseIdentifiers");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Database treat mixed case unquoted SQL identifiers as case
+ * insensitive and store them in upper case.
+ * @return true always for the Type 4 driver.
+ */
+ public boolean storesUpperCaseIdentifiers() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "storesUpperCaseIdentifiers", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("storesUpperCaseIdentifiers");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Does the database treat mixed case unquoted SQL identifiers as case
+ * insensitive and store them in lower case?
+ *
+ * @return true if so
+ */
+ public boolean storesLowerCaseIdentifiers() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "storesLowerCaseIdentifiers", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("storesLowerCaseIdentifiers");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Does the database treat mixed case unquoted SQL identifiers as case
+ * insensitive and store them in mixed case?
+ *
+ * @return true if so
+ */
+ public boolean storesMixedCaseIdentifiers() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "storesMixedCaseIdentifiers", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("storesMixedCaseIdentifiers");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Database treat mixed case quoted SQL identifiers as case
+ * sensitive and as a result store them in mixed case.
+ * A JDBC-Compliant driver will always return false.
+ *
+ * @return true always true for the Type 4 drive.
+ */
+ public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsMixedCaseQuotedIdentifiers",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsMixedCaseQuotedIdentifiers");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Does the database treat mixed case quoted SQL identifiers as case
+ * insensitive and store them in upper case?
+ *
+ * @return true if so
+ */
+ public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "storesUpperCaseQuotedIdentifiers",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("storesUpperCaseQuotedIdentifiers");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Does the database treat mixed case quoted SQL identifiers as case
+ * insensitive and store them in lower case?
+ *
+ * @return true if so
+ */
+ public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "storesLowerCaseQuotedIdentifiers",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("storesLowerCaseQuotedIdentifiers");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Does the database treat mixed case quoted SQL identifiers as case
+ * insensitive and store them in mixed case?
+ *
+ * @return true if so
+ */
+ public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", " storesMixedCaseQuotedIdentifiers",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName(" storesMixedCaseQuotedIdentifiers");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Database uses the " string to quote SQL identifiers. This call
+ * returns a space " " if identifier quoting isn't supported.
+ * A JDBC-Compliant driver always uses a double quote character.
+ *
+ * @return the quoting string ".
+ */
+ public String getIdentifierQuoteString() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getIdentifierQuoteString", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getIdentifierQuoteString");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("\"");
+ }
+
+ /*
+ * Get a comma separated list of all a database's SQL keywords that are NOT
+ * also SQL92 keywords.
+ *
+ * @return the list *
+ *
+ */
+ public String getSQLKeywords() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getSQLKeywords", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getSQLKeywords");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return "DATETIME,FRACTION,PROTOTYPE,SQL_CHAR,SQL_DATE,SQL_DECIMAL,SQL_DOUBLE,SQL_FLOAT"
+ + ",SQL_INT,SQL_INTEGER,SQL_REAL,SQL_SMALLINT,SQL_TIME,SQL_TIMESTAMP,SQL_VARCHAR"
+ + ",TRANSPOSE,UPSHIFT";
+ }
+
+ /*
+ * Get a comma separated list of math functions.
+ *
+ * @return the list *
+ *
+ */
+ public String getNumericFunctions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getNumericFunctions", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getNumericFunctions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String(
+ "ABS,ACOS,ASIN,ATAN,ATAN2,CEILING,COS,COSH,DEGREES,EXP,FLOOR,LOG,LOG10,MOD,PI,POWER,RADIANS,RAND"
+ + "SIGN,SIN,SINH,SORT,TAN,TANH");
+ }
+
+ /*
+ * Get a comma separated list of string functions.
+ *
+ * @return the list *
+ *
+ */
+ public String getStringFunctions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getStringFunctions", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getStringFunctions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("ASCII,CHAR,CHAR_LENGTH,CONCAT,INSERT,LCASE,LEFT,LOCATE,LOWER,LPAD,LTRIM,OCTET_LENGTH"
+ + "POSITION,REPEAT,REPLACE,RIGHT,RPAD,RTRIM,SPACE,SUBSTRING,TRIM,UCASE,UPPER,UPSHIFT");
+ }
+
+ /*
+ * Get a comma separated list of system functions.
+ *
+ * @return the list *
+ *
+ */
+ public String getSystemFunctions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getSystemFunctions", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getSystemFunctions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("CURRENT_USER,USER");
+ }
+
+ /*
+ * Get a comma separated list of time and date functions.
+ *
+ * @return the list *
+ *
+ */
+ public String getTimeDateFunctions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getTimeDateFunctions", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getTimeDateFunctions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return new String("CONVERTTIMESTAMP,CURRENT,CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP"
+ + "DATEFORMAT,DAY,DAYNAME,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,EXTRACT,HOUR,JULIANTIMESTAMP,MINUTE"
+ + "MONTH,MONTHNAME,QUARTER,SECOND,WEEK,YEAR");
+ }
+
+ /*
+ * This is the string that can be used to escape '_' or '%' in the string
+ * pattern style catalog search parameters.
+ *
+ * <P>The '_' character represents any single character. <P>The '%'
+ * character represents any sequence of zero or more characters. @return the
+ * string used to escape wildcard characters *
+ *
+ */
+ public String getSearchStringEscape() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getSearchStringEscape", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getSearchStringEscape");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("\\");
+ }
+
+ /*
+ * Get all the "extra" characters that can be used in unquoted identifier
+ * names (those beyond a-z, A-Z, 0-9 and _).
+ *
+ * @return the string containing the extra characters
+ */
+ public String getExtraNameCharacters() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getExtraNameCharacters", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getExtraNameCharacters");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return null;
+ }
+
+ // --------------------------------------------------------------------
+ // Functions describing which features are supported.
+
+ /*
+ * Is "ALTER TABLE" with add column supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsAlterTableWithAddColumn() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsAlterTableWithAddColumn",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsAlterTableWithAddColumn");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Is "ALTER TABLE" with drop column supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsAlterTableWithDropColumn() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsAlterTableWithDropColumn",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsAlterTableWithDropColumn");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Is column aliasing supported?
+ *
+ * <P>If so, the SQL AS clause can be used to provide names for computed
+ * columns or to provide alias names for columns as required.
+ *
+ * A JDBC-Compliant driver always returns true.
+ *
+ * @return true if so
+ */
+ public boolean supportsColumnAliasing() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsColumnAliasing", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsColumnAliasing");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Database concatenations between NULL and non-NULL values is
+ * NULL.
+ *
+ * A JDBC-Compliant driver always returns true.
+ *
+ * @return true always for the Type 4 driver.
+ */
+ public boolean nullPlusNonNullIsNull() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "nullPlusNonNullIsNull", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("nullPlusNonNullIsNull");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is the CONVERT function between SQL types supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsConvert() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsConvert", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsConvert");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is CONVERT between the given SQL types supported?
+ *
+ * @param fromType the type to convert from @param toType the type to
+ * convert to @return true if so
+ *
+ * @see Types
+ */
+ public boolean supportsConvert(int fromType, int toType) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, fromType, toType);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsConvert", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, fromType, toType);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsConvert");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ switch (fromType) {
+ case Types.BIGINT:
+ case Types.DECIMAL:
+ case Types.DOUBLE:
+ case Types.FLOAT:
+ case Types.INTEGER:
+ case Types.NUMERIC:
+ case Types.REAL:
+ case Types.SMALLINT:
+ switch (toType) {
+ case Types.CHAR:
+ case Types.NUMERIC:
+ case Types.DECIMAL:
+ case Types.INTEGER:
+ case Types.SMALLINT:
+ case Types.FLOAT:
+ case Types.REAL:
+ case Types.DOUBLE:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BIGINT:
+ return true;
+ default:
+ return false;
+ }
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ switch (toType) {
+ case Types.CHAR:
+ case Types.NUMERIC:
+ case Types.DECIMAL:
+ case Types.INTEGER:
+ case Types.SMALLINT:
+ case Types.FLOAT:
+ case Types.REAL:
+ case Types.DOUBLE:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BIGINT:
+ case Types.DATE:
+ case Types.TIME:
+ case Types.TIMESTAMP:
+ return true;
+ default:
+ return false;
+ }
+ case Types.DATE:
+ switch (toType) {
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.DATE:
+ case Types.TIMESTAMP:
+ return true;
+ default:
+ return false;
+ }
+ case Types.TIME:
+ switch (toType) {
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.TIME:
+ case Types.TIMESTAMP:
+ return true;
+ default:
+ return false;
+ }
+ case Types.TIMESTAMP:
+ switch (toType) {
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.DATE:
+ case Types.TIME:
+ case Types.TIMESTAMP:
+ return true;
+ default:
+ return false;
+ }
+ case Types.BIT:
+ case Types.BINARY:
+ case Types.VARBINARY:
+ case Types.LONGVARBINARY:
+ case Types.TINYINT:
+ return false;
+ default:
+ return false;
+ }
+ }
+
+ /*
+ * Type 4 driver supports table correlation names. Type 4 driver always
+ * returns true.
+ *
+ * @return true for Type 4 driver
+ */
+ public boolean supportsTableCorrelationNames() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsTableCorrelationNames", "",
+ p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsTableCorrelationNames");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Database table correlation names are supported, and they are
+ * not restricted to be different from the names of the Database
+ * tables.
+ *
+ * @return false always for Type 4 driver.
+ */
+ public boolean supportsDifferentTableCorrelationNames() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData",
+ "supportsDifferentTableCorrelationNames", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsDifferentTableCorrelationNames");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * SQL expressions in "ORDER BY" lists are not supported by the
+ * Database and Type 4 driver.
+ *
+ * @return false always for Type 4 driver.
+ */
+ public boolean supportsExpressionsInOrderBy() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_
+ .logp(Level.FINE, "T4DatabaseMetaData", "supportsExpressionsInOrderBy", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsExpressionsInOrderBy");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Can an "ORDER BY" clause use columns not in the SELECT?
+ *
+ * @return true if so
+ */
+ public boolean supportsOrderByUnrelated() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsOrderByUnrelated", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsOrderByUnrelated");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is some form of "GROUP BY" clause supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsGroupBy() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsGroupBy", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsGroupBy");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a "GROUP BY" clause use columns not in the SELECT?
+ *
+ * @return true if so
+ */
+ public boolean supportsGroupByUnrelated() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsGroupByUnrelated", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsGroupByUnrelated");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Can a "GROUP BY" clause add columns not in the SELECT provided it
+ * specifies all the columns in the SELECT?
+ *
+ * @return true if so
+ */
+ public boolean supportsGroupByBeyondSelect() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsGroupByBeyondSelect", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsGroupByBeyondSelect");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Database supports escape character in "LIKE" clauses.
+ * A JDBC-Compliant driver always returns true.
+ *
+ * @return true always true for the Type 4 driver.
+ */
+ public boolean supportsLikeEscapeClause() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsLikeEscapeClause", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsLikeEscapeClause");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Are multiple ResultSets from a single execute supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsMultipleResultSets() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsMultipleResultSets", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsMultipleResultSets");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can we have multiple transactions open at once (on different
+ * connections)?
+ *
+ * @return true if so
+ */
+ public boolean supportsMultipleTransactions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_
+ .logp(Level.FINE, "T4DatabaseMetaData", "supportsMultipleTransactions", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsMultipleTransactions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ // Need to change it 'true' once Database fixes this problem
+ return false;
+ }
+
+ /*
+ * Database table columns can be defined as non-nullable.
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsNonNullableColumns() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsNonNullableColumns", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsNonNullableColumns");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Type 4 driver supports the ODBC Minimum SQL grammar.
+ *
+ * All JDBC-Compliant drivers must return true.
+ *
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsMinimumSQLGrammar() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsMinimumSQLGrammar", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsMinimumSQLGrammar");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is the ODBC Core SQL grammar supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsCoreSQLGrammar() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsCoreSQLGrammar", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsCoreSQLGrammar");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is the ODBC Extended SQL grammar supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsExtendedSQLGrammar() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsExtendedSQLGrammar", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsExtendedSQLGrammar");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Database supports the ANSI92 entry level SQL grammar.
+ * All JDBC-Compliant drivers must return true.
+ *
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsANSI92EntryLevelSQL() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsANSI92EntryLevelSQL", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsANSI92EntryLevelSQL");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is the ANSI92 intermediate SQL grammar supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsANSI92IntermediateSQL() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsANSI92IntermediateSQL", "",
+ p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsANSI92IntermediateSQL");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Is the ANSI92 full SQL grammar supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsANSI92FullSQL() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsANSI92FullSQL", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsANSI92FullSQL");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Is the SQL Integrity Enhancement Facility supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsIntegrityEnhancementFacility() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData",
+ "supportsIntegrityEnhancementFacility", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsIntegrityEnhancementFacility");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Is some form of outer join supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsOuterJoins() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsOuterJoins", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsOuterJoins");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Are full nested outer joins supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsFullOuterJoins() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsFullOuterJoins", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsFullOuterJoins");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Database provides the limited support for outer joins. This
+ * will be true if supportFullOuterJoins is true.
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsLimitedOuterJoins() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsLimitedOuterJoins", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsLimitedOuterJoins");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * What's the database vendor's preferred term for "schema"?
+ *
+ * @return the vendor term
+ */
+ public String getSchemaTerm() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getSchemaTerm", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getSchemaTerm");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("SCHEMA");
+ }
+
+ /*
+ * What's the database vendor's preferred term for "procedure"?
+ *
+ * @return the vendor term
+ */
+ public String getProcedureTerm() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getProcedureTerm", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getProcedureTerm");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("PROCEDURE");
+ }
+
+ /*
+ * What's the database vendor's preferred term for "catalog"?
+ *
+ * @return the vendor term
+ */
+ public String getCatalogTerm() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getCatalogTerm", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getCatalogTerm");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("CATALOG");
+ }
+
+ /*
+ * Database catalog name appear at the start of a qualified table
+ * name. (Otherwise it appears at the end)
+ * @return true always for the Type 4 driver.
+ */
+ public boolean isCatalogAtStart() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "isCatalogAtStart", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("isCatalogAtStart");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * What's the separator between catalog and table name?
+ *
+ * @return the separator string
+ */
+ public String getCatalogSeparator() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getCatalogSeparator", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getCatalogSeparator");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String(".");
+ }
+
+ /*
+ * Can a schema name be used in a data manipulation statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsSchemasInDataManipulation() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSchemasInDataManipulation",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSchemasInDataManipulation");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a schema name be used in a procedure call statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsSchemasInProcedureCalls() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSchemasInProcedureCalls",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSchemasInProcedureCalls");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a schema name be used in a table definition statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsSchemasInTableDefinitions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSchemasInTableDefinitions",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSchemasInTableDefinitions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a schema name be used in an index definition statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsSchemasInIndexDefinitions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSchemasInIndexDefinitions",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSchemasInIndexDefinitions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a schema name be used in a privilege definition statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData",
+ "supportsSchemasInPrivilegeDefinitions", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSchemasInPrivilegeDefinitions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a catalog name be used in a data manipulation statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsCatalogsInDataManipulation() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsCatalogsInDataManipulation",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsCatalogsInDataManipulation");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a catalog name be used in a procedure call statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsCatalogsInProcedureCalls() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsCatalogsInProcedureCalls",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsCatalogsInProcedureCalls");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a catalog name be used in a table definition statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsCatalogsInTableDefinitions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsCatalogsInTableDefinitions",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsCatalogsInTableDefinitions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a catalog name be used in an index definition statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsCatalogsInIndexDefinitions",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsCatalogsInIndexDefinitions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a catalog name be used in a privilege definition statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData",
+ "supportsCatalogsInPrivilegeDefinitions", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsCatalogsInPrivilegeDefinitions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is positioned DELETE supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsPositionedDelete() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsPositionedDelete", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsPositionedDelete");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Database supports positioned UPDATE supported through the Type
+ * 4 driver.
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsPositionedUpdate() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsPositionedUpdate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsPositionedUpdate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Database supports SELECT for UPDATE through the Type 4 driver.
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsSelectForUpdate() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSelectForUpdate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSelectForUpdate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * stored procedure calls using the stored procedure escape syntax
+ * are supported.
+ *
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsStoredProcedures() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsStoredProcedures", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsStoredProcedures");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Trafodion Database Database subqueries in comparison expressions are supported
+ * through the Type 4 driver.
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsSubqueriesInComparisons() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSubqueriesInComparisons",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSubqueriesInComparisons");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Trafodion Database supports subqueries in 'exists' expressions through
+ * Type 4 driver.
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsSubqueriesInExists() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSubqueriesInExists", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSubqueriesInExists");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Trafodion Database supports subqueries in 'in' statements through the
+ * Type 4 driver.
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsSubqueriesInIns() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSubqueriesInIns", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSubqueriesInIns");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * The subqueries in quantified expressions supported in Trafodion Database
+ * and Type 4 driver.
+ * @return true always for Type 4 driver.
+ */
+ public boolean supportsSubqueriesInQuantifieds() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSubqueriesInQuantifieds",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSubqueriesInQuantifieds");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Trafodion Database supports correlated subqueries.
+ * A JDBC-Compliant driver always returns true.
+ *
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsCorrelatedSubqueries() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_
+ .logp(Level.FINE, "T4DatabaseMetaData", "supportsCorrelatedSubqueries", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsCorrelatedSubqueries");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is SQL UNION supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsUnion() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsUnion", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsUnion");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is SQL UNION ALL supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsUnionAll() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsUnionAll", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsUnionAll");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can cursors remain open across commits?
+ *
+ * @return true if cursors always remain open; false if they might not
+ * remain open
+ */
+ public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsOpenCursorsAcrossCommit",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsOpenCursorsAcrossCommit");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Can cursors remain open across rollbacks?
+ *
+ * @return true if cursors always remain open; false if they might not
+ * remain open
+ */
+ public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsOpenCursorsAcrossRollback",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+
<TRUNCATED>
[24/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4CallableStatement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4CallableStatement.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4CallableStatement.java
new file mode 100644
index 0000000..2a3675e
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4CallableStatement.java
@@ -0,0 +1,2462 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.DatabaseMetaData;
+import java.sql.Date;
+import java.sql.NClob;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.Types;
+import java.util.Calendar;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+public class TrafT4CallableStatement extends TrafT4PreparedStatement implements java.sql.CallableStatement {
+ public Array getArray(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getArray", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getArray");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getArray()");
+ return null;
+ }
+
+ public Array getArray(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getArray", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getArray");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getArray(parameterIndex);
+ }
+
+ public BigDecimal getBigDecimal(int parameterIndex) throws SQLException {
+ BigDecimal retValue;
+ String data;
+
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getBigDecimal", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getBigDecimal");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateGetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ // String returned may not be numeric in case of SQL_CHAR, SQL_VARCHAR
+ // and SQL_LONGVARCHAR
+ // fields. Hoping that java might throw invalid value exception
+ // For LOB Support - SB
+ // data = inputDesc_[parameterIndex-1].paramValue_;
+ data = getString(parameterIndex);
+ if (data == null) {
+ wasNull_ = true;
+ return null;
+ } else {
+ wasNull_ = false;
+ try {
+ retValue = new BigDecimal(data);
+ } catch (NumberFormatException e) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ return retValue;
+ }
+ }
+
+ public BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, scale);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getBigDecimal", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, scale);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getBigDecimal");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ BigDecimal retValue;
+
+ retValue = getBigDecimal(parameterIndex);
+ if (retValue != null) {
+ return retValue.setScale(scale);
+ } else {
+ return null;
+ }
+ }
+
+ public BigDecimal getBigDecimal(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getBigDecimal", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getBigDecimal");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getBigDecimal(parameterIndex);
+ }
+
+ public BigDecimal getBigDecimal(String parameterName, int scale) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, scale);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getBigDecimal", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, scale);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getBigDecimal");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getBigDecimal(parameterIndex, scale);
+ }
+
+
+ public boolean getBoolean(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getBoolean", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getBoolean");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+
+ validateGetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ // For LOB Support - SB
+ // data = inputDesc_[parameterIndex-1].paramValue_;
+ data = getString(parameterIndex);
+
+ if (data != null) {
+ wasNull_ = false;
+ return (!data.equals("0"));
+ } else {
+ wasNull_ = true;
+ return false;
+ }
+ }
+
+ public boolean getBoolean(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getBoolean", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getBoolean");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getBoolean(parameterIndex);
+ }
+
+ public byte getByte(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getByte", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getByte");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+
+ validateGetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ // For LOB Support - SB
+ // data = inputDesc_[parameterIndex-1].paramValue_;
+ data = getString(parameterIndex);
+
+ if (data != null) {
+ wasNull_ = false;
+ return Byte.parseByte(data);
+ } else {
+ wasNull_ = true;
+ return 0;
+ }
+ }
+
+ public byte getByte(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getByte", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getByte");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getByte(parameterIndex);
+ }
+
+ public byte[] getBytes(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getBytes", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getBytes");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+
+ validateGetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ if (dataType != Types.BINARY && dataType != Types.VARBINARY && dataType != Types.LONGVARBINARY) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ // BINARY, VARBINARY, LONGVARBINARY not supported
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "datatype_not_supported",
+ null);
+ }
+
+ public byte[] getBytes(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getBytes", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getBytes");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getBytes(parameterIndex);
+ }
+
+ public Date getDate(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ String dateStr;
+ Date retValue;
+
+ validateGetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.DATE && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ // For LOB Support - SB
+ // dateStr = inputDesc_[parameterIndex-1].paramValue_;
+ dateStr = getString(parameterIndex);
+
+ if (dateStr != null) {
+ wasNull_ = false;
+ try {
+ boolean convertDate = connection_.getDateConversion();
+
+ if (convertDate) {
+ String dt = TrafT4ResultSet.convertDateFormat(dateStr);
+ retValue = TrafT4ResultSet.valueOf(dt);
+ } else {
+ retValue = Date.valueOf(dateStr);
+ }
+ } catch (IllegalArgumentException e) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ return retValue;
+ } else {
+ wasNull_ = true;
+ return null;
+ }
+ }
+
+ public Date getDate(int parameterIndex, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Date sqlDate;
+ java.util.Date d;
+
+ sqlDate = getDate(parameterIndex);
+ if (sqlDate != null) {
+ if (cal != null) {
+ cal.setTime(sqlDate);
+ d = cal.getTime();
+ sqlDate = new Date(d.getTime());
+ }
+ return sqlDate;
+ } else {
+ return (sqlDate);
+ }
+ }
+
+ public Date getDate(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getDate(parameterIndex);
+ }
+
+ public Date getDate(String parameterName, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getDate(parameterIndex, cal);
+ }
+
+ public double getDouble(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getDouble", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getDouble");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+
+ validateGetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ // For LOB Support - SB
+ // data = inputDesc_[parameterIndex-1].paramValue_;
+ data = getString(parameterIndex);
+ if (data != null) {
+ wasNull_ = false;
+ return Double.parseDouble(data);
+ } else {
+ wasNull_ = true;
+ return 0;
+ }
+ }
+
+ public double getDouble(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getDouble", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getDouble");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getDouble(parameterIndex);
+ }
+
+ public float getFloat(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getFloat", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getFloat");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+
+ validateGetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ // For LOB Support - SB
+ // data = inputDesc_[parameterIndex-1].paramValue_;
+ data = getString(parameterIndex);
+
+ if (data != null) {
+ wasNull_ = false;
+ return Float.parseFloat(data);
+ } else {
+ wasNull_ = true;
+ return 0;
+ }
+ }
+
+ public float getFloat(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getFloat", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getFloat");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getFloat(parameterIndex);
+ }
+
+ public int getInt(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getInt", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getInt");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+
+ validateGetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ // For LOB Support - SB
+ // data = inputDesc_[parameterIndex-1].paramValue_;
+ data = getString(parameterIndex);
+ if (data != null) {
+ wasNull_ = false;
+ return Integer.parseInt(data);
+ } else {
+ wasNull_ = true;
+ return 0;
+ }
+ }
+
+ public int getInt(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getInt", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getInt");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getInt(parameterIndex);
+ }
+
+ public long getLong(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getLong", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getLong");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+
+ validateGetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ // For LOB Support - SB
+ // data = inputDesc_[parameterIndex-1].paramValue_;
+ data = getString(parameterIndex);
+ if (data != null) {
+ wasNull_ = false;
+ return Long.parseLong(data);
+ } else {
+ wasNull_ = true;
+ return 0;
+ }
+ }
+
+ public long getLong(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getLong", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getLong");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getLong(parameterIndex);
+ }
+
+ public Object getObject(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ byte byteValue;
+ short shortValue;
+ int intValue;
+ long longValue;
+ float floatValue;
+ double doubleValue;
+ boolean booleanValue;
+
+ validateGetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ switch (dataType) {
+ case Types.TINYINT:
+ byteValue = getByte(parameterIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Byte(byteValue);
+ }
+ case Types.SMALLINT:
+ intValue = getShort(parameterIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Integer(intValue);
+ }
+ case Types.INTEGER:
+ intValue = getInt(parameterIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Integer(intValue);
+ }
+ case Types.BIGINT:
+ longValue = getLong(parameterIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Long(longValue);
+ }
+ case Types.REAL:
+ floatValue = getFloat(parameterIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Float(floatValue);
+ }
+ case Types.FLOAT:
+ case Types.DOUBLE:
+ doubleValue = getDouble(parameterIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Double(doubleValue);
+ }
+ case Types.DECIMAL:
+ case Types.NUMERIC:
+ return getBigDecimal(parameterIndex);
+ case Types.BIT:
+ booleanValue = getBoolean(parameterIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Boolean(booleanValue);
+ }
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ return getString(parameterIndex);
+ case Types.BINARY:
+ case Types.VARBINARY:
+ case Types.LONGVARBINARY:
+ return getBytes(parameterIndex);
+ case Types.DATE:
+ return getDate(parameterIndex);
+ case Types.TIME:
+ return getTime(parameterIndex);
+ case Types.TIMESTAMP:
+ return getTimestamp(parameterIndex);
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ }
+
+ public Object getObject(int parameterIndex, Map map) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, map);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, map);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getObject()");
+ return null;
+ }
+
+ public Object getObject(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getOjbect", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getOjbect");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getObject(parameterIndex);
+ }
+
+ public Object getObject(String parameterName, Map map) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, map);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, map);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getObject(parameterIndex, map);
+ }
+
+ public Ref getRef(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getRef", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getRef");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getRef()");
+ return null;
+ }
+
+ public Ref getRef(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getRef", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getRef");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getRef(parameterIndex);
+ }
+
+ public short getShort(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getShort", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getShort");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+
+ validateGetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ // For LOB Support - SB
+ // data = inputDesc_[parameterIndex-1].paramValue_;
+ data = getString(parameterIndex);
+ if (data != null) {
+ wasNull_ = false;
+ return Short.parseShort(data);
+ } else {
+ wasNull_ = true;
+ return 0;
+ }
+ }
+
+ public short getShort(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getShort", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getShort");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getShort(parameterIndex);
+ }
+
+ public String getString(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getString", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getString");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+ // For LOB Support - SB 10/8/2004
+ Object x;
+ int targetSqlType;
+ int sqlCharset;
+
+ validateGetInvocation(parameterIndex);
+
+ targetSqlType = inputDesc_[parameterIndex - 1].dataType_;
+ sqlCharset = inputDesc_[parameterIndex - 1].sqlCharset_;
+ x = inputDesc_[parameterIndex - 1].paramValue_;
+
+ if (x == null) {
+ wasNull_ = true;
+ data = null;
+ } else {
+ if (x instanceof byte[]) {
+ try {
+ if (this.ist_.ic_.getISOMapping() == InterfaceUtilities.SQLCHARSETCODE_ISO88591
+ && !this.ist_.ic_.getEnforceISO()
+ && sqlCharset == InterfaceUtilities.SQLCHARSETCODE_ISO88591)
+ data = new String((byte[]) x, ist_.ic_.t4props_.getISO88591());
+ else
+ data = this.ist_.ic_.decodeBytes((byte[]) x, sqlCharset);
+
+ wasNull_ = false;
+ } catch (CharacterCodingException e) {
+ SQLException se = HPT4Messages.createSQLException(this.connection_.ic_.t4props_, this.connection_
+ .getLocale(), "translation_of_parameter_failed", "getLocalString", e.getMessage());
+ se.initCause(e);
+ throw se;
+ } catch (UnsupportedCharsetException e) {
+ SQLException se = HPT4Messages.createSQLException(this.connection_.ic_.t4props_, this.connection_
+ .getLocale(), "unsupported_encoding", e.getCharsetName());
+ se.initCause(e);
+ throw se;
+ } catch (UnsupportedEncodingException e) {
+ SQLException se = HPT4Messages.createSQLException(this.connection_.ic_.t4props_, this.connection_
+ .getLocale(), "unsupported_encoding", e.getMessage());
+ se.initCause(e);
+ throw se;
+ }
+ } else {
+ data = x.toString();
+ wasNull_ = false;
+ }
+ }
+ return data;
+ }
+
+ public String getString(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getString", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getString");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getString(parameterIndex);
+ }
+
+ public Time getTime(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ String timeStr;
+ Time retValue;
+
+ validateGetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+
+ // For LOB Support - SB 10/8/2004
+ // timeStr = inputDesc_[parameterIndex-1].paramValue_;
+ timeStr = getString(parameterIndex);
+ if (timeStr != null) {
+ try {
+ wasNull_ = false;
+ retValue = Time.valueOf(timeStr);
+ } catch (IllegalArgumentException e) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ return retValue;
+ } else {
+ wasNull_ = true;
+ return null;
+ }
+ }
+
+ public Time getTime(int parameterIndex, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Time sqlTime;
+ java.util.Date d;
+
+ sqlTime = getTime(parameterIndex);
+ if (sqlTime != null) {
+ if (cal != null) {
+ cal.setTime(sqlTime);
+ d = cal.getTime();
+ sqlTime = new Time(d.getTime());
+ }
+ return sqlTime;
+ } else {
+ return (sqlTime);
+ }
+ }
+
+ public Time getTime(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getTime(parameterIndex);
+ }
+
+ public Time getTime(String parameterName, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getTime(parameterIndex, cal);
+ }
+
+ public Timestamp getTimestamp(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ String timestampStr;
+ Timestamp retValue;
+
+ validateGetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.DATE && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+
+ // For LOB Support - SB 10/8/2004
+ // timestampStr = inputDesc_[parameterIndex - 1].paramValue_;
+ timestampStr = getString(parameterIndex);
+ if (timestampStr != null) {
+ try {
+ wasNull_ = false;
+ retValue = Timestamp.valueOf(timestampStr);
+ } catch (IllegalArgumentException e) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ return retValue;
+ } else {
+ wasNull_ = true;
+ return null;
+ }
+ }
+
+ public Timestamp getTimestamp(int parameterIndex, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Timestamp sqlTimestamp;
+ java.util.Date d;
+ int nanos;
+
+ sqlTimestamp = getTimestamp(parameterIndex);
+ if (sqlTimestamp != null) {
+ if (cal != null) {
+ nanos = sqlTimestamp.getNanos();
+ cal.setTime(sqlTimestamp);
+ d = cal.getTime();
+ sqlTimestamp = new Timestamp(d.getTime());
+ sqlTimestamp.setNanos(nanos);
+ }
+ return sqlTimestamp;
+ } else {
+ return (sqlTimestamp);
+ }
+ }
+
+ public Timestamp getTimestamp(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getTimestamp(parameterIndex);
+ }
+
+ public Timestamp getTimestamp(String parameterName, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getTimestamp(parameterIndex, cal);
+ }
+
+ public URL getURL(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getURL", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getURL");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getURL()");
+ return null;
+ }
+
+ public URL getURL(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getURL", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("getURL");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ return getURL(parameterName);
+ }
+
+ public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "registerOutParameter", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("registerOutParameter");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ // Ignoring sqlType and scale
+ validateGetInvocation(parameterIndex);
+ if (inputDesc_[parameterIndex - 1].paramMode_ == DatabaseMetaData.procedureColumnOut) {
+ inputDesc_[parameterIndex - 1].isValueSet_ = true;
+ }
+ }
+
+ public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType, scale);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "registerOutParameter", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType, scale);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("registerOutParameter");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ // Ignoring sqlType and scale
+ validateGetInvocation(parameterIndex);
+ if (inputDesc_[parameterIndex - 1].paramMode_ == DatabaseMetaData.procedureColumnOut) {
+ inputDesc_[parameterIndex - 1].isValueSet_ = true;
+ }
+ }
+
+ public void registerOutParameter(int parameterIndex, int sqlType, String typeName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType, typeName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "registerOutParameter", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType, typeName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("registerOutParameter");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ // Ignoring sqlType and typeName
+ validateGetInvocation(parameterIndex);
+ if (inputDesc_[parameterIndex - 1].paramMode_ == DatabaseMetaData.procedureColumnOut) {
+ inputDesc_[parameterIndex - 1].isValueSet_ = true;
+ }
+ }
+
+ public void registerOutParameter(String parameterName, int sqlType) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "registerOutParameter", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("registerOutParameter");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ registerOutParameter(parameterIndex, sqlType);
+ }
+
+ public void registerOutParameter(String parameterName, int sqlType, int scale) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType, scale);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "registerOutParameter", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType, scale);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("registerOutParameter");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ registerOutParameter(parameterIndex, sqlType, scale);
+ }
+
+ public void registerOutParameter(String parameterName, int sqlType, String typeName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType, typeName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "registerOutParameter", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType, typeName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("registerOutParameter");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateGetInvocation(parameterName);
+ registerOutParameter(parameterIndex, sqlType, typeName);
+ }
+
+ public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, length);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setAsciiStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, length);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setAsciiStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setAsciiStream(parameterIndex, x, length);
+ }
+
+ public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setBigDecimal", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setBigDecimal");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setBigDecimal(parameterIndex, x);
+ }
+
+ public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, length);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setBinaryStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, length);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setBinaryStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setBinaryStream(parameterIndex, x, length);
+ }
+
+ public void setBoolean(String parameterName, boolean x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setBoolean", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setBoolean");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setBoolean(parameterIndex, x);
+ }
+
+ public void setByte(String parameterName, byte x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setByte", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setByte");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setByte(parameterIndex, x);
+ }
+
+ public void setBytes(String parameterName, byte[] x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setBytes", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setBytes");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setBytes(parameterIndex, x);
+ }
+
+ public void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, reader, length);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setCharacterStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, reader, length);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setCharacterStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setCharacterStream(parameterIndex, reader, length);
+ }
+
+ public void setDate(String parameterName, Date x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setDate(parameterIndex, x);
+ }
+
+ public void setDate(String parameterName, Date x, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setDate(parameterIndex, x, cal);
+ }
+
+ public void setDouble(String parameterName, double x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setDouble", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setDouble");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setDouble(parameterIndex, x);
+ }
+
+ public void setFloat(String parameterName, float x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setFloat", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setFloat");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setFloat(parameterIndex, x);
+ }
+
+ public void setInt(String parameterName, int x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setInt", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setInt");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setInt(parameterIndex, x);
+ }
+
+ public void setLong(String parameterName, long x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setLong", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setLong");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setLong(parameterIndex, x);
+ }
+
+ public void setNull(String parameterName, int sqlType) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setNull", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setNull");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setNull(parameterIndex, sqlType);
+ }
+
+ public void setNull(String parameterName, int sqlType, String typeName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType, typeName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setNull", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType, typeName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setNull");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setNull(parameterIndex, sqlType, typeName);
+ }
+
+ public void setObject(String parameterName, Object x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setObject(parameterIndex, x);
+ }
+
+ public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, targetSqlType);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, targetSqlType);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setObject(parameterIndex, x, targetSqlType);
+ }
+
+ public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, targetSqlType, scale);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, targetSqlType, scale);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setObject(parameterIndex, x, targetSqlType, scale);
+ }
+
+ public void setShort(String parameterName, short x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setShort", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setShort");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setShort(parameterIndex, x);
+ }
+
+ public void setString(String parameterName, String x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setString", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setString");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setString(parameterIndex, x);
+ }
+
+ public void setTime(String parameterName, Time x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setTime(parameterIndex, x);
+ }
+
+ public void setTime(String parameterName, Time x, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setTime(parameterIndex, x, cal);
+ }
+
+ public void setTimestamp(String parameterName, Timestamp x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setTimestamp(parameterIndex, x);
+ }
+
+ public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setTimestamp(parameterIndex, x, cal);
+ }
+
+ public void setUnicodeStream(String parameterName, InputStream x, int length) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, length);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setUnicodeStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, length);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setUnicodeStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setUnicodeStream(parameterIndex, x, length);
+ }
+
+ public void setURL(String parameterName, URL x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setURL", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("setURL");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int parameterIndex = validateSetInvocation(parameterName);
+ setURL(parameterIndex, x);
+ }
+
+ public boolean wasNull() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "wasNull", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("wasNull");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return wasNull_;
+ }
+
+ public boolean execute() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "execute", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("execute");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Object[] valueArray = null;
+ int inDescLength = 0;
+ if (inputDesc_ != null) {
+ valueArray = getValueArray();
+ inDescLength = inputDesc_.length;
+ }
+
+ validateExecuteInvocation();
+
+ valueArray = getValueArray();
+ ist_.execute(TRANSPORT.SRVR_API_SQLEXECUTE2, paramRowCount_, inDescLength, valueArray, queryTimeout_, null,
+ this);
+
+ // SPJ: 5-18-2007
+ // if (resultSet_[result_set_offset] != null)
+ if (resultSet_[result_set_offset] != null && resultSet_[result_set_offset].spj_rs_) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public int[] executeBatch() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "executeBatch", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("executeBatch");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if ((batchCommands_ == null) || (paramRowCount_ < 1)) {
+ return new int[] {};
+ }
+
+ if (batchCommands_.isEmpty()) {
+ return new int[] {};
+ }
+
+ clearWarnings();
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "executeBatch()");
+ return null;
+ }
+
+ public ResultSet executeQuery() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "executeQuery", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("executeQuery");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Object[] valueArray = null;
+ int inDescLength = 0;
+ if (inputDesc_ != null) {
+ valueArray = getValueArray();
+ inDescLength = inputDesc_.length;
+ }
+
+ validateExecuteInvocation();
+
+ ist_.execute(TRANSPORT.SRVR_API_SQLEXECUTE2, paramRowCount_, inDescLength, valueArray, queryTimeout_, null,
+ this);
+
+ return resultSet_[result_set_offset];
+ }
+
+ public int executeUpdate() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "executeUpdate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4CallableStatement");
+ lr.setSourceMethodName("executeUpdate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Object[] valueArray = null;
+ int inDescLength = 0;
+ if (inputDesc_ != null) {
+ valueArray = getValueArray();
+ inDescLength = inputDesc_.length;
+ }
+
+ validateExecuteInvocation();
+ valueArray = getValueArray();
+ ist_.execute(TRANSPORT.SRVR_API_SQLEXECUTE2, paramRowCount_, inDescLength, valueArray, queryTimeout_, null,
+ this);
+
+ return (1);
+ }
+
+ // Other methods
+ protected void validateGetInvocation(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4CallableStatement", "validateGetInvocation", "", p);
+ }
+ clearWarnings();
+ // connection_.getServerHandle().isConnectionOpen();
+ connection_.isConnectionOpen();
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_statement",
+ null);
+ }
+ if (inputDesc_ == null) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "not_a_output_parameter", null);
+ }
+ if (parameterIndex < 1 || parameterIndex > inputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_parameter_index", null);
+ }
+ if (inputDesc_[parameterIndex - 1].paramMode_ != DatabaseMetaData.procedureColumnInOut
+ && inputDesc_[parameterIndex - 1].paramMode_ != DatabaseMetaData.procedureColumnOut) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "not_a_output_parameter", null);
+ }
+ }
+
+ protected int validateGetInvocation(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4CallableStatement", "validateGetInvocation", "", p);
+ }
+ int i;
+
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_statement",
+ null);
+ }
+ if (inputDesc_ == null) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "not_a_output_parameter", null);
+ }
+ for (i = 0; i < inputDesc_.length; i++) {
+ if (parameterName.equalsIgnoreCase(inputDesc_[i].name_)) {
+ return i + 1;
+ }
+ }
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_parameter_name",
+ null);
+ }
+
+ private int validateSetInvocation(String parameterName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4CallableStatement", "validateSetInvocation", "", p);
+ }
+ int i;
+
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "stmt_closed", null);
+ }
+ if (inputDesc_ == null) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_parameter_index", null);
+ }
+ for (i = 0; i < inputDesc_.length; i++) {
+ if (parameterName.equalsIgnoreCase(inputDesc_[i].name_)) {
+ return i + 1;
+ }
+ }
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_parameter_name",
+ null);
+ }
+
+ void setExecuteCallOutputs(Object[] outputValues
<TRUNCATED>
[53/60] incubator-trafodion git commit: Merge branch 'master' of
github.com:apache/incubator-trafodion into wrkbrnch
Posted by db...@apache.org.
Merge branch 'master' of github.com:apache/incubator-trafodion into wrkbrnch
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/c4d50df1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/c4d50df1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/c4d50df1
Branch: refs/heads/master
Commit: c4d50df102924d9bd5410d09309d3b5fa277cc89
Parents: 8ed58bf e5dcfc1
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Thu Apr 28 18:31:51 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Thu Apr 28 18:31:51 2016 +0000
----------------------------------------------------------------------
README | 2 +-
core/sqf/sqenvcom.sh | 2 +-
core/sqf/sql/scripts/get_libhdfs_files | 6 +-
.../transactional/TransactionManager.java | 85 ++--
core/sql/arkcmp/CmpContext.cpp | 4 +
core/sql/bin/SqlciErrors.txt | 4 +-
core/sql/cli/Context.cpp | 8 +-
core/sql/cli/Statement.cpp | 7 +-
core/sql/common/CharType.cpp | 19 +-
core/sql/common/CharType.h | 5 +-
core/sql/common/arkcmp_proc.cpp | 24 +-
core/sql/executor/ExExeUtil.h | 4 +-
core/sql/executor/ExExeUtilVolTab.cpp | 26 +-
core/sql/executor/ExHdfsScan.cpp | 12 +-
core/sql/executor/ex_transaction.cpp | 7 +-
core/sql/exp/ExpErrorEnums.h | 1 +
core/sql/exp/exp_clause.cpp | 12 +
core/sql/exp/exp_datetime.cpp | 28 +-
core/sql/exp/exp_datetime.h | 3 +-
core/sql/exp/exp_eval.cpp | 2 +-
core/sql/exp/exp_function.h | 2 +
core/sql/generator/GenPreCode.cpp | 5 +
core/sql/generator/GenRelDCL.cpp | 4 +
core/sql/generator/GenRelScan.cpp | 75 +--
.../java/org/trafodion/libmgmt/FileMgmt.java | 1 +
core/sql/nskgmake/Makerules.mk | 6 +-
core/sql/optimizer/BindItemExpr.cpp | 6 +-
core/sql/optimizer/RelScan.h | 5 +-
core/sql/optimizer/SchemaDB.cpp | 4 +
core/sql/regress/compGeneral/TEST004 | 6 +-
core/sql/regress/core/FILTER116 | 1 +
core/sql/regress/executor/EXPECTED013.SB | 1 -
core/sql/regress/executor/EXPECTED140 | 11 -
core/sql/regress/fullstack2/EXPECTED062 | 3 -
core/sql/regress/fullstack2/EXPECTED062.RELEASE | 3 -
core/sql/regress/seabase/EXPECTED010 | 460 ++++++++-----------
core/sql/regress/seabase/EXPECTED011 | 1 -
core/sql/regress/seabase/EXPECTED016 | 7 -
core/sql/regress/seabase/EXPECTED030 | 18 +-
core/sql/regress/seabase/TEST030 | 2 +
core/sql/regress/tools/sbdefs | 2 +-
core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp | 4 +-
core/sql/sqlcomp/CmpSeabaseDDLschema.cpp | 135 ++++--
core/sql/sqlcomp/nadefaults.cpp | 23 +-
dcs/src/assembly/all.xml | 1 +
docs/src/site/markdown/index.md | 2 +-
docs/src/site/resources/css/site.css | 5 +
docs/src/site/site.xml | 6 +-
install/installer/traf_apache_mods | 2 +-
49 files changed, 593 insertions(+), 469 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c4d50df1/core/sqf/sqenvcom.sh
----------------------------------------------------------------------
[35/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Compression.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Compression.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Compression.java
new file mode 100644
index 0000000..bb2bb8f
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Compression.java
@@ -0,0 +1,149 @@
+// @@@ 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;
+
+public class Compression {
+ private static int MAXCOUNT = 0xFF;
+ // private static int MAXUCOUNT = 0xFFFF;
+ private static int EOFCHAR = -1;
+
+
+
+ public static int compress(int alg, byte [][] sbuf, int [] sstart, int [] slen, byte[] dbuf, int dstart) {
+ int ret = 0;
+
+ switch(alg) {
+ case 1:
+ ret = compress_whitespace(sbuf, sstart, slen, dbuf, dstart);
+ break;
+ }
+
+ return ret;
+ }
+
+ public static int uncompress(int alg, byte [] sbuf, int sstart, int slen, byte [] dbuf, int dstart) {
+ int ret = 0;
+
+ switch(alg) {
+ case 1:
+ ret = uncompress_whitespace(sbuf, sstart, slen, dbuf, dstart);
+ break;
+ }
+
+ return ret;
+ }
+
+ // encodes repeated bytes in the byte form <b><b><#>
+ // b = byte which is repeated
+ // # = number of repetitions (max 255)
+ // source buffers, source lengths, destination buffer
+ private static int compress_whitespace(byte [][] param_sbuf, int [] param_sstart, int [] param_slen, byte[] dbuf, int dstart) {
+ int c = EOFCHAR, p = EOFCHAR;
+ int si = 0, di = dstart; // source, destination indexes
+ int cnt = 0; // count of repetition
+
+ byte []sbuf; //current source buffer
+ int slen; //current source length
+
+ for(int i=0;i<param_sbuf.length;i++) {
+ sbuf = param_sbuf[i];
+ slen = param_slen[i];
+ si = param_sstart[i];
+
+ while(si < slen) {
+ c = sbuf[si++]; // get the next byte from source
+ dbuf[di++] = (byte)c; // copy the byte to destination
+ cnt = 0;
+
+ if(c == p) { // check repetition
+ if(si == slen) {
+ c = EOFCHAR;
+ }
+ while(si < slen) {
+ if ((c = sbuf[si++]) == p) { // found repetition
+ cnt++;
+ if (cnt == MAXCOUNT) { // we can only store 255 in
+ // a byte
+ dbuf[di++] = (byte)cnt;
+
+ p = EOFCHAR; // move on
+ break;
+ }
+ }
+ else {
+ dbuf[di++] = (byte)cnt;
+ dbuf[di++] = (byte) c;
+
+ p = c;
+ break;
+ }
+
+ if (si == slen) {
+ c = EOFCHAR;
+ }
+ }
+ }
+ else {
+ p = c; // set our current as our previous
+ }
+
+ if (c == EOFCHAR) {
+ dbuf[di++] = (byte)cnt;
+ /*
+ * ADDED
+ */
+ p = EOFCHAR;
+ }
+ }
+ }
+
+ return di - dstart;
+ }
+
+ private static int uncompress_whitespace(byte [] sbuf, int sstart, int slen, byte [] dbuf, int dstart) {
+ int c = EOFCHAR, p = EOFCHAR;
+ int si = sstart, di = dstart, i = 0; // source, dest, and generic indexes
+ int cnt = 0;
+
+ while(si < slen ) {
+ c = sbuf[si++] & 0xFF;
+
+ /*if(di >= dbuf.length) {
+ System.out.println("%%%%%failed at " + di);
+ }*/
+ dbuf[di++] = (byte) c;
+
+ if(c == p) {
+ cnt = sbuf[si++] & 0xFF;
+
+ for(i=0;i<cnt;++i) {
+ dbuf[di++] = (byte)c;
+ }
+ p = EOFCHAR;
+ }
+ else {
+ p = c;
+ }
+ }
+
+ return di;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ConnectMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ConnectMessage.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ConnectMessage.java
new file mode 100644
index 0000000..fd594d5
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ConnectMessage.java
@@ -0,0 +1,62 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class ConnectMessage {
+ static LogicalByteArray marshal(CONNECTION_CONTEXT_def inContext, USER_DESC_def userDesc, int srvrType,
+ short retryCount, int optionFlags1, int optionFlags2, String vproc, InterfaceConnection ic)
+ throws CharacterCodingException, UnsupportedCharsetException {
+ int wlength = Header.sizeOf();
+ LogicalByteArray buf = null;
+
+ byte[] vprocBytes = ic.encodeString(vproc, 1);
+ byte[] clientUserBytes = ic.encodeString(System.getProperty("user.name"), 1);
+
+ wlength += inContext.sizeOf(ic);
+ wlength += userDesc.sizeOf(ic);
+
+ wlength += TRANSPORT.size_int; // srvrType
+ wlength += TRANSPORT.size_short; // retryCount
+ wlength += TRANSPORT.size_int; // optionFlags1
+ wlength += TRANSPORT.size_int; // optionFlags2
+ wlength += TRANSPORT.size_bytes(vprocBytes);
+
+ buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
+
+ inContext.insertIntoByteArray(buf);
+ userDesc.insertIntoByteArray(buf);
+
+ buf.insertInt(srvrType);
+ buf.insertShort(retryCount);
+ buf.insertInt(optionFlags1);
+ buf.insertInt(optionFlags2);
+ buf.insertString(vprocBytes);
+
+ //TODO: restructure all the flags and this new param
+ buf.insertString(clientUserBytes);
+
+ return buf;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ConnectReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ConnectReply.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ConnectReply.java
new file mode 100644
index 0000000..f11b5d5
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ConnectReply.java
@@ -0,0 +1,148 @@
+// @@@ 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 ConnectReply {
+ odbc_Dcs_GetObjRefHdl_exc_ m_p1_exception;
+ String m_p2_srvrObjRef;
+ int m_p3_dialogueId;
+ String m_p4_dataSource;
+ byte[] m_p5_userSid;
+ VERSION_LIST_def m_p6_versionList;
+ int isoMapping;
+ boolean byteSwap;
+
+ boolean securityEnabled;
+ int serverNode;
+ int processId;
+ byte [] timestamp;
+ String clusterName;
+
+ String serverHostName="";
+ Integer serverNodeId=0;
+ Integer serverProcessId=0;
+ String serverProcessName="";
+ String serverIpAddress="";
+ Integer serverPort=0;
+
+ String remoteHost;
+ String remoteProcess;
+
+ private NCSAddress m_ncsAddr_;
+
+ // -------------------------------------------------------------
+ ConnectReply(LogicalByteArray buf, InterfaceConnection ic) throws SQLException, UnsupportedCharsetException,
+ CharacterCodingException {
+ buf.setLocation(Header.sizeOf());
+
+ m_p1_exception = new odbc_Dcs_GetObjRefHdl_exc_();
+ m_p1_exception.extractFromByteArray(buf, ic);
+
+ this.byteSwap = buf.getByteSwap();
+
+ if (m_p1_exception.exception_nr == TRANSPORT.CEE_SUCCESS) {
+ m_p3_dialogueId = buf.extractInt();
+ m_p4_dataSource = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ m_p5_userSid = buf.extractByteString(); // byteString -- only place
+ // used -- packed length
+ // does not include the null
+ // term
+ m_p6_versionList = new VERSION_LIST_def();
+
+ //buf.setByteSwap(false);
+ m_p6_versionList.extractFromByteArray(buf);
+ //buf.setByteSwap(this.byteSwap);
+
+ buf.extractInt(); //old iso mapping
+
+ /*if ((m_p6_versionList.list[0].buildId & InterfaceConnection.CHARSET) > 0) {
+ isoMapping =
+ } else {*/
+ isoMapping = 15;
+ //}
+ serverHostName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ serverNodeId = buf.extractInt();
+ serverProcessId = buf.extractInt();
+ serverProcessName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ serverIpAddress = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ serverPort = buf.extractInt();
+
+ m_p2_srvrObjRef = String.format("TCP:%s:%d.%s,%s/%d:ODBC", serverHostName, serverNodeId, serverProcessName, serverIpAddress, serverPort);
+
+ if((m_p6_versionList.list[0].buildId & InterfaceConnection.PASSWORD_SECURITY) > 0) {
+ securityEnabled = true;
+ serverNode = serverNodeId;
+ processId = serverProcessId;
+ timestamp = buf.extractByteArray(8);
+ clusterName = ic.decodeBytes(buf.extractString(), 1);
+ }
+ else {
+ securityEnabled = false;
+ }
+ }
+ }
+
+ // -------------------------------------------------------------
+ void fixupSrvrObjRef(T4Properties t4props, Locale locale, String name) throws SQLException {
+ //
+ // This method will replace the domain name returned from the
+ // Association server, with a new name.
+ //
+ m_ncsAddr_ = null;
+
+ if (m_p2_srvrObjRef != null) {
+ remoteHost = m_p2_srvrObjRef.substring(4,m_p2_srvrObjRef.indexOf('$') - 1);
+ remoteProcess = m_p2_srvrObjRef.substring(m_p2_srvrObjRef.indexOf('$'), m_p2_srvrObjRef.indexOf(','));
+
+ try {
+ m_ncsAddr_ = new NCSAddress(t4props, locale, m_p2_srvrObjRef);
+ } catch (SQLException e) {
+ throw e;
+ }
+
+ // use your best guess if m_machineName was not found
+ if (m_ncsAddr_.m_machineName == null) {
+ if (m_ncsAddr_.m_ipAddress == null) {
+ m_ncsAddr_.m_machineName = name;
+ } else {
+ m_ncsAddr_.m_machineName = m_ncsAddr_.m_ipAddress;
+ }
+ }
+
+ m_p2_srvrObjRef = m_ncsAddr_.recreateAddress();
+ m_ncsAddr_.validateAddress();
+ m_ncsAddr_.setInputOutput();
+
+ return;
+ } // end if
+
+ } // end fixupSrvrObjRef
+
+ NCSAddress getNCSAddress() {
+ return m_ncsAddr_;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Descriptor2.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Descriptor2.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Descriptor2.java
new file mode 100644
index 0000000..fd25f51
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Descriptor2.java
@@ -0,0 +1,85 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class Descriptor2 {
+ int noNullValue_;
+ int nullValue_;
+ int version_;
+ int dataType_;
+ int datetimeCode_;
+ int maxLen_;
+ int precision_;
+ int scale_;
+ int nullInfo_;
+ int signed_;
+ int odbcDataType_;
+ int odbcPrecision_;
+ int sqlCharset_;
+ int odbcCharset_;
+ String colHeadingNm_;
+ String tableName_;
+ String catalogName_;
+ String schemaName_;
+ String headingName_;
+ int intLeadPrec_;
+ int paramMode_;
+
+ private int rowLength;
+
+ public void setRowLength(int len) {
+ rowLength = len;
+ }
+
+ public int getRowLength() {
+ return rowLength;
+ }
+
+ public Descriptor2(LogicalByteArray buf, InterfaceConnection ic) throws CharacterCodingException,
+ UnsupportedCharsetException {
+ noNullValue_ = buf.extractInt();
+ nullValue_ = buf.extractInt();
+ version_ = buf.extractInt();
+ dataType_ = buf.extractInt();
+ datetimeCode_ = buf.extractInt();
+ maxLen_ = buf.extractInt();
+ precision_ = buf.extractInt();
+ scale_ = buf.extractInt();
+ nullInfo_ = buf.extractInt();
+ signed_ = buf.extractInt();
+ odbcDataType_ = buf.extractInt();
+ odbcPrecision_ = buf.extractInt();
+ sqlCharset_ = buf.extractInt();
+ odbcCharset_ = buf.extractInt();
+
+ colHeadingNm_ = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ tableName_ = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ catalogName_ = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ schemaName_ = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ headingName_ = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ intLeadPrec_ = buf.extractInt();
+ paramMode_ = buf.extractInt();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ERROR_DESC_LIST_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ERROR_DESC_LIST_def.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ERROR_DESC_LIST_def.java
new file mode 100644
index 0000000..039fae3
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ERROR_DESC_LIST_def.java
@@ -0,0 +1,42 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class ERROR_DESC_LIST_def {
+ int length;
+ ERROR_DESC_def[] buffer;
+
+ // ----------------------------------------------------------
+ void extractFromByteArray(LogicalByteArray buf, InterfaceConnection ic) throws CharacterCodingException,
+ UnsupportedCharsetException {
+ length = buf.extractInt();
+ buffer = new ERROR_DESC_def[length];
+
+ for (int i = 0; i < length; i++) {
+ buffer[i] = new ERROR_DESC_def();
+ buffer[i].extractFromByteArray(buf, ic);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ERROR_DESC_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ERROR_DESC_def.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ERROR_DESC_def.java
new file mode 100644
index 0000000..48ebba2
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ERROR_DESC_def.java
@@ -0,0 +1,65 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class ERROR_DESC_def {
+ int rowId;
+ int errorDiagnosticId;
+ int sqlcode;
+ String sqlstate;
+ String errorText;
+ int operationAbortId;
+ int errorCodeType;
+ String Param1;
+ String Param2;
+ String Param3;
+ String Param4;
+ String Param5;
+ String Param6;
+ String Param7;
+
+ // ----------------------------------------------------------
+ void extractFromByteArray(LogicalByteArray buffer1, InterfaceConnection ic) throws CharacterCodingException,
+ UnsupportedCharsetException {
+ rowId = buffer1.extractInt();
+ errorDiagnosticId = buffer1.extractInt();
+ sqlcode = buffer1.extractInt();
+
+ // Note, SQLSTATE is logically 5 bytes, but ODBC uses 6 bytes for some
+ // reason.
+ sqlstate = ic.decodeBytes(buffer1.extractByteArray(6), 1);
+ errorText = ic.decodeBytes(buffer1.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+
+ operationAbortId = buffer1.extractInt();
+ errorCodeType = buffer1.extractInt();
+ Param1 = ic.decodeBytes(buffer1.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ Param2 = ic.decodeBytes(buffer1.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ Param3 = ic.decodeBytes(buffer1.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ Param4 = ic.decodeBytes(buffer1.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ Param5 = ic.decodeBytes(buffer1.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ Param6 = ic.decodeBytes(buffer1.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ Param7 = ic.decodeBytes(buffer1.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/EndTransactionMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/EndTransactionMessage.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/EndTransactionMessage.java
new file mode 100644
index 0000000..98a60d4
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/EndTransactionMessage.java
@@ -0,0 +1,49 @@
+// @@@ 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 EndTransactionMessage {
+ int m_dialogueId;
+ short m_transactionOpt;
+
+ // ----------------------------------------------------------
+ EndTransactionMessage(int dialogueId, short transactionOpt) {
+ m_dialogueId = dialogueId;
+ m_transactionOpt = transactionOpt;
+ }
+
+ // ----------------------------------------------------------
+ static LogicalByteArray marshal(int dialogueId, short transactionOpt, InterfaceConnection ic) {
+ int wlength = Header.sizeOf();
+ LogicalByteArray buf;
+
+ wlength += TRANSPORT.size_int; // dialogueId
+ wlength += TRANSPORT.size_short; // transactionOpt
+
+ buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
+
+ buf.insertInt(dialogueId);
+ buf.insertShort(transactionOpt);
+
+ return buf;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/EndTransactionReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/EndTransactionReply.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/EndTransactionReply.java
new file mode 100644
index 0000000..b85ce2f
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/EndTransactionReply.java
@@ -0,0 +1,49 @@
+// @@@ 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 EndTransactionReply {
+ odbc_SQLSvc_EndTransaction_exc_ m_p1;
+ ERROR_DESC_LIST_def m_p2;
+
+ // -------------------------------------------------------------
+ EndTransactionReply(LogicalByteArray buf, String addr, InterfaceConnection ic) throws CharacterCodingException,
+ UnsupportedCharsetException, SQLException {
+ buf.setLocation(Header.sizeOf());
+
+ m_p1 = new odbc_SQLSvc_EndTransaction_exc_();
+ m_p1.extractFromByteArray(buf, addr, ic);
+
+ if (m_p1.exception_nr != TRANSPORT.CEE_SUCCESS) {
+ int totalLen = buf.extractInt();
+
+ if(totalLen > 0) {
+ m_p2 = new ERROR_DESC_LIST_def();
+ m_p2.extractFromByteArray(buf, ic);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ExecuteMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ExecuteMessage.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ExecuteMessage.java
new file mode 100644
index 0000000..2911bf9
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ExecuteMessage.java
@@ -0,0 +1,107 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class ExecuteMessage {
+ // ----------------------------------------------------------
+ static LogicalByteArray marshal(int dialogueId, int sqlAsyncEnable, int queryTimeout, int inputRowCnt,
+ int maxRowsetSize, int sqlStmtType, int stmtHandle, int stmtType, String sqlString, int sqlStringCharset,
+ String cursorName, int cursorNameCharset, String stmtLabel, int stmtLabelCharset, String stmtExplainLabel,
+ SQL_DataValue_def inputDataValue, SQLValueList_def inputValueList, byte[] txId, boolean isUserBuffer,
+ InterfaceConnection ic
+
+ ) throws CharacterCodingException, UnsupportedCharsetException
+
+ {
+ int wlength = Header.sizeOf();
+ LogicalByteArray buf;
+
+ byte[] sqlStringBytes = ic.encodeString(sqlString, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] cursorNameBytes = ic.encodeString(cursorName, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] stmtLabelBytes = ic.encodeString(stmtLabel, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] stmtExplainLabelBytes = ic.encodeString(stmtExplainLabel, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+
+ wlength += TRANSPORT.size_int; // dialogueId
+ wlength += TRANSPORT.size_int; // sqlAsyncEnable
+ wlength += TRANSPORT.size_int; // queryTimeout
+ wlength += TRANSPORT.size_int; // inputRowCnt
+ wlength += TRANSPORT.size_int; // maxRowsetSize
+ wlength += TRANSPORT.size_int; // sqlStmtType
+ wlength += TRANSPORT.size_int; // stmtHandle
+ wlength += TRANSPORT.size_int; // stmtType
+ wlength += TRANSPORT.size_bytesWithCharset(sqlStringBytes); // +sqlStringCharset
+ wlength += TRANSPORT.size_bytesWithCharset(cursorNameBytes); // +cursorNameCharset
+ wlength += TRANSPORT.size_bytesWithCharset(stmtLabelBytes); // +stmtLabelCharset
+ wlength += TRANSPORT.size_bytes(stmtExplainLabelBytes);
+
+ if (!isUserBuffer) {
+ wlength += inputDataValue.sizeof();
+ wlength += TRANSPORT.size_bytes(txId); // transId
+ }
+ buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
+
+ buf.insertInt(dialogueId);
+ buf.insertInt(sqlAsyncEnable);
+ buf.insertInt(queryTimeout);
+ buf.insertInt(inputRowCnt);
+ buf.insertInt(maxRowsetSize);
+ buf.insertInt(sqlStmtType);
+ buf.insertInt(stmtHandle);
+ buf.insertInt(stmtType);
+ buf.insertStringWithCharset(sqlStringBytes, sqlStringCharset);
+ buf.insertStringWithCharset(cursorNameBytes, cursorNameCharset);
+ buf.insertStringWithCharset(stmtLabelBytes, stmtLabelCharset);
+ buf.insertString(stmtExplainLabelBytes);
+
+ if (isUserBuffer) {
+ buf.setDataBuffer(inputDataValue.userBuffer);
+
+ byte[] trailer = null;
+ if (txId == null || txId.length == 0) {
+ trailer = new byte[4];
+ for (int i = 0; i < 4; ++i) {
+ trailer[i] = (byte) 0;
+ }
+ } else {
+ int len = txId.length + 1;
+ trailer = new byte[4 + txId.length + 1];
+
+ trailer[0] = (byte) ((len >>> 24) & 0xff);
+ trailer[1] = (byte) ((len >>> 16) & 0xff);
+ trailer[2] = (byte) ((len >>> 8) & 0xff);
+ trailer[3] = (byte) ((len) & 0xff);
+ System.arraycopy(txId, 0, trailer, 4, txId.length);
+ trailer[len + 4 - 1] = '\0';
+ }
+
+ buf.setTrailer(trailer);
+ } else {
+ inputDataValue.insertIntoByteArray(buf);
+ buf.insertString(txId);
+ }
+
+ return buf;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ExecuteReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ExecuteReply.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ExecuteReply.java
new file mode 100644
index 0000000..664c71f
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ExecuteReply.java
@@ -0,0 +1,127 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class ExecuteReply {
+ int returnCode;
+ int totalErrorLength;
+ SQLWarningOrError[] errorList;
+ long rowsAffected;
+ int queryType;
+ int estimatedCost;
+ byte[] outValues;
+
+ int numResultSets;
+ Descriptor2[][] outputDesc;
+ String stmtLabels[];
+
+ int outputParamLength;
+ int outputNumberParams;
+
+ String[] proxySyntax;
+
+ // ----------------------------------------------------------
+ ExecuteReply(LogicalByteArray buf, InterfaceConnection ic) throws CharacterCodingException,
+ UnsupportedCharsetException {
+
+ buf.setLocation(Header.sizeOf());
+
+ returnCode = buf.extractInt();
+
+ totalErrorLength = buf.extractInt();
+
+ if (totalErrorLength > 0) {
+ errorList = new SQLWarningOrError[buf.extractInt()];
+ for (int i = 0; i < errorList.length; i++) {
+ errorList[i] = new SQLWarningOrError(buf, ic, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ }
+ }
+
+ int outputDescLength = buf.extractInt();
+ if (outputDescLength > 0) {
+ outputDesc = new Descriptor2[1][];
+
+ outputParamLength = buf.extractInt();
+ outputNumberParams = buf.extractInt();
+
+ outputDesc[0] = new Descriptor2[outputNumberParams];
+ for (int i = 0; i < outputNumberParams; i++) {
+ outputDesc[0][i] = new Descriptor2(buf, ic);
+ outputDesc[0][i].setRowLength(outputParamLength);
+ }
+ }
+ rowsAffected = buf.extractUnsignedInt();
+ queryType = buf.extractInt();
+ estimatedCost = buf.extractInt();
+
+ // 64 bit rowsAffected
+ // this is a horrible hack because we cannot change the protocol yet
+ // rowsAffected should be made a regular 64 bit value when possible
+ rowsAffected |= ((long) estimatedCost) << 32;
+
+ outValues = buf.extractByteArray();
+
+ numResultSets = buf.extractInt();
+
+ if (numResultSets > 0) {
+ outputDesc = new Descriptor2[numResultSets][];
+ stmtLabels = new String[numResultSets];
+ proxySyntax = new String[numResultSets];
+
+ for (int i = 0; i < numResultSets; i++) {
+ buf.extractInt(); // int stmt_handle
+
+ stmtLabels[i] = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+
+ buf.extractInt(); // long stmt_label_charset
+ outputDescLength = buf.extractInt();
+
+ int outputParamsLength = 0;
+ int outputNumberParams = 0;
+ Descriptor2[] outputParams = null;
+
+ if (outputDescLength > 0) {
+ outputParamsLength = buf.extractInt();
+ outputNumberParams = buf.extractInt();
+
+ outputParams = new Descriptor2[outputNumberParams];
+ for (int j = 0; j < outputNumberParams; j++) {
+ outputParams[j] = new Descriptor2(buf, ic);
+ outputParams[j].setRowLength(outputParamsLength);
+ }
+ }
+ outputDesc[i] = outputParams;
+ proxySyntax[i] = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ }
+ }
+
+ String singleSyntax = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+
+ if (proxySyntax == null) {
+ proxySyntax = new String[1];
+ proxySyntax[0] = singleSyntax;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/FetchMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/FetchMessage.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/FetchMessage.java
new file mode 100644
index 0000000..0f7d702
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/FetchMessage.java
@@ -0,0 +1,63 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class FetchMessage {
+ // ----------------------------------------------------------
+ static LogicalByteArray marshal(int dialogueId, int sqlAsyncEnable, int queryTimeout, int stmtHandle,
+ String stmtLabel, int stmtCharset, int maxRowCnt, int maxRowLen, String cursorName, int cursorCharset,
+ String stmtOptions, InterfaceConnection ic) throws CharacterCodingException, UnsupportedCharsetException {
+ int wlength = Header.sizeOf();
+ LogicalByteArray buf;
+
+ byte[] stmtLabelBytes = ic.encodeString(stmtLabel, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] cursorNameBytes = ic.encodeString(cursorName, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] stmtOptionsBytes = ic.encodeString(stmtOptions, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+
+ wlength += TRANSPORT.size_int; // dialogueId
+ wlength += TRANSPORT.size_int; // sqlAsyncEnable
+ wlength += TRANSPORT.size_int; // queryTimeout
+ wlength += TRANSPORT.size_int; // stmtHandle
+ wlength += TRANSPORT.size_bytesWithCharset(stmtLabelBytes);
+ wlength += TRANSPORT.size_long; // maxRowCnt
+ wlength += TRANSPORT.size_long; // maxRowLen
+ wlength += TRANSPORT.size_bytesWithCharset(cursorNameBytes);
+ wlength += TRANSPORT.size_bytes(stmtOptionsBytes);
+
+ buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
+
+ buf.insertInt(dialogueId);
+ buf.insertInt(sqlAsyncEnable);
+ buf.insertInt(queryTimeout);
+ buf.insertInt(stmtHandle);
+ buf.insertStringWithCharset(stmtLabelBytes, stmtCharset);
+ buf.insertLong(maxRowCnt);
+ buf.insertLong(maxRowLen);
+ buf.insertStringWithCharset(cursorNameBytes, cursorCharset);
+ buf.insertString(stmtOptionsBytes);
+
+ return buf;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/FetchReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/FetchReply.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/FetchReply.java
new file mode 100644
index 0000000..5e82439
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/FetchReply.java
@@ -0,0 +1,63 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class FetchReply {
+ int returnCode;
+ int totalErrorLength;
+ SQLWarningOrError[] errorList;
+ int rowsAffected;
+ int outValuesFormat;
+ byte[] outValues;
+
+ // -------------------------------------------------------------
+ public FetchReply(LogicalByteArray buf, InterfaceConnection ic) throws CharacterCodingException,
+ UnsupportedCharsetException {
+ buf.setLocation(Header.sizeOf());
+
+ returnCode = buf.extractInt();
+
+ if (returnCode != TRANSPORT.SQL_SUCCESS && returnCode != TRANSPORT.NO_DATA_FOUND) {
+ totalErrorLength = buf.extractInt();
+ if (totalErrorLength > 0) {
+ errorList = new SQLWarningOrError[buf.extractInt()];
+ for (int i = 0; i < errorList.length; i++) {
+ errorList[i] = new SQLWarningOrError(buf, ic, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ }
+ }
+ }
+
+ if (errorList == null) {
+ errorList = new SQLWarningOrError[0];
+ }
+
+ rowsAffected = buf.extractInt();
+ outValuesFormat = buf.extractInt();
+
+ if (returnCode == TRANSPORT.SQL_SUCCESS || returnCode == TRANSPORT.SQL_SUCCESS_WITH_INFO) {
+ outValues = buf.extractByteArray();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/GenericMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/GenericMessage.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/GenericMessage.java
new file mode 100644
index 0000000..3558872
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/GenericMessage.java
@@ -0,0 +1,45 @@
+// @@@ 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;
+
+class GenericMessage {
+ // ----------------------------------------------------------
+ static LogicalByteArray marshal(Locale locale, byte[] messageBuffer, InterfaceConnection ic) throws SQLException
+
+ {
+ int wlength = Header.sizeOf();
+ LogicalByteArray buf;
+
+ if (messageBuffer != null)
+ wlength += messageBuffer.length;
+ buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
+ if (messageBuffer != null)
+ buf.insertByteArray(messageBuffer, messageBuffer.length);
+
+ return buf;
+ } // end marshal
+
+} // end class GenericMessage
+
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/GenericReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/GenericReply.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/GenericReply.java
new file mode 100644
index 0000000..1aa2e8e
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/GenericReply.java
@@ -0,0 +1,43 @@
+// @@@ 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;
+
+class GenericReply {
+ byte[] replyBuffer;
+
+ // ----------------------------------------------------------
+ GenericReply(Locale locale, LogicalByteArray buf) throws SQLException {
+ Header header = new Header();
+ long bufferLength = 0;
+
+ buf.setLocation(0);
+ header.extractFromByteArray(buf);
+ buf.setLocation(Header.sizeOf());
+ bufferLength = header.total_length_;
+ replyBuffer = buf.extractByteArray(bufferLength);
+
+ } // end marshal
+
+} // end class GenericReply
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/GetSQLCatalogsMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/GetSQLCatalogsMessage.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/GetSQLCatalogsMessage.java
new file mode 100644
index 0000000..17296f6
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/GetSQLCatalogsMessage.java
@@ -0,0 +1,88 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class GetSQLCatalogsMessage {
+ static LogicalByteArray marshal(int dialogueId, String stmtLabel, short APIType, String catalogNm, String schemaNm,
+ String tableNm, String tableTypeList, String columnNm, int columnType, int rowIdScope, int nullable,
+ int uniqueness, int accuracy, short sqlType, int metadataId, String fkCatalogNm, String fkSchemaNm,
+ String fkTableNm, InterfaceConnection ic) throws CharacterCodingException, UnsupportedCharsetException {
+ int wlength = Header.sizeOf();
+ LogicalByteArray buf;
+
+ byte[] stmtLabelBytes = ic.encodeString(stmtLabel, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] catalogNmBytes = ic.encodeString(catalogNm, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] schemaNmBytes = ic.encodeString(schemaNm, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] tableNmBytes = ic.encodeString(tableNm, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] tableTypeListBytes = ic.encodeString(tableTypeList, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] columnNmBytes = ic.encodeString(columnNm, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+
+ byte[] fkCatalogNmBytes = ic.encodeString(fkCatalogNm, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] fkSchemaNmBytes = ic.encodeString(fkSchemaNm, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] fkTableNmBytes = ic.encodeString(fkTableNm, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+
+ wlength += TRANSPORT.size_int; // dialogueId
+ wlength += TRANSPORT.size_bytes(stmtLabelBytes);
+ wlength += TRANSPORT.size_short; // APIType
+ wlength += TRANSPORT.size_bytes(catalogNmBytes, true);
+ wlength += TRANSPORT.size_bytes(schemaNmBytes, true);
+ wlength += TRANSPORT.size_bytes(tableNmBytes, true);
+ wlength += TRANSPORT.size_bytes(tableTypeListBytes, true);
+ wlength += TRANSPORT.size_bytes(columnNmBytes, true);
+ wlength += TRANSPORT.size_int; // columnType
+ wlength += TRANSPORT.size_int; // rowIdScope
+ wlength += TRANSPORT.size_int; // nullable
+ wlength += TRANSPORT.size_int; // uniqueness
+ wlength += TRANSPORT.size_int; // accuracy
+ wlength += TRANSPORT.size_short; // sqlType
+ wlength += TRANSPORT.size_int; // metadataId
+ wlength += TRANSPORT.size_bytes(fkCatalogNmBytes, true);
+ wlength += TRANSPORT.size_bytes(fkSchemaNmBytes, true);
+ wlength += TRANSPORT.size_bytes(fkTableNmBytes, true);
+
+ buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
+
+ buf.insertInt(dialogueId);
+ buf.insertString(stmtLabelBytes);
+ buf.insertShort(APIType);
+ buf.insertString(catalogNmBytes, true);
+ buf.insertString(schemaNmBytes, true);
+ buf.insertString(tableNmBytes, true);
+ buf.insertString(tableTypeListBytes, true);
+ buf.insertString(columnNmBytes, true);
+ buf.insertInt(columnType);
+ buf.insertInt(rowIdScope);
+ buf.insertInt(nullable);
+ buf.insertInt(uniqueness);
+ buf.insertInt(accuracy);
+ buf.insertShort(sqlType);
+ buf.insertInt(metadataId);
+ buf.insertString(fkCatalogNmBytes, true);
+ buf.insertString(fkSchemaNmBytes, true);
+ buf.insertString(fkTableNmBytes, true);
+
+ return buf;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/GetSQLCatalogsReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/GetSQLCatalogsReply.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/GetSQLCatalogsReply.java
new file mode 100644
index 0000000..9736d47
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/GetSQLCatalogsReply.java
@@ -0,0 +1,54 @@
+// @@@ 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 GetSQLCatalogsReply {
+ odbc_SQLSvc_GetSQLCatalogs_exc_ m_p1;
+ String m_p2;
+ SQLItemDescList_def m_p3;
+ ERROR_DESC_LIST_def m_p4;
+ String proxySyntax = "";
+
+ // -------------------------------------------------------------
+ GetSQLCatalogsReply(LogicalByteArray buf, String addr, InterfaceConnection ic) throws CharacterCodingException,
+ UnsupportedCharsetException, SQLException {
+ buf.setLocation(Header.sizeOf());
+
+ m_p1 = new odbc_SQLSvc_GetSQLCatalogs_exc_();
+ m_p1.extractFromByteArray(buf, addr, ic);
+
+ if (m_p1.exception_nr == TRANSPORT.CEE_SUCCESS) {
+ m_p2 = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+
+ m_p3 = new SQLItemDescList_def(buf, true, ic);
+
+ m_p4 = new ERROR_DESC_LIST_def();
+ m_p4.extractFromByteArray(buf, ic);
+
+ proxySyntax = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4ConnectionPoolDataSource.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4ConnectionPoolDataSource.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4ConnectionPoolDataSource.java
new file mode 100644
index 0000000..39e39dd
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4ConnectionPoolDataSource.java
@@ -0,0 +1,346 @@
+// @@@ 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.sql.SQLFeatureNotSupportedException;
+import java.util.Properties;
+import java.util.logging.FileHandler;
+import java.util.logging.Formatter;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.naming.StringRefAddr;
+import javax.sql.PooledConnection;
+
+/**
+ *
+ * <p>
+ * JDBC Type 4 Driver <code>ConnectionPoolDataSource</code> class.
+ * </p>
+ * <p>
+ * Description: A <code>ConnectionPoolDataSource</code> object is a factory
+ * for <code>PooledConnection</code> objects. As the name indicates, this
+ * object provides a <code>PooledConnection</code> for data sources to be used
+ * by the application servers.
+ * </p>
+ *
+ * <p>
+ * The <code>HPT4ConnectionPoolDataSource</code> class should be used to
+ * provide JDBC3.0 connection pooling features. The
+ * <code>HPT4ConnectionPoolDataSource</code> is used by the application
+ * servers like WSAS to provide connection pooling features to the J2EE
+ * applications. <code>HPT4ConnectionPoolDataSource.getPooledConnection()</code>
+ * returns the <code>javax.sql.PooledConnection object</code>.
+ * </p>
+ *
+ *
+ * Setting connection properties such as catalog, schema, timeouts, and so on
+ * are done at the higher level objects such as DataSource or DriverManager.
+ *
+ * <p>
+ * Licensed to the Apache Software Foundation (ASF)
+ * </p>
+ *
+ * @see T4Properties
+ * @see HPT4DataSource
+ */
+
+public class HPT4ConnectionPoolDataSource extends T4DSProperties implements javax.sql.ConnectionPoolDataSource,
+ java.io.Serializable, Referenceable
+
+{
+
+ /**
+ * Attempts to establish a physical database connection that can be used as
+ * a pooled connection.
+ *
+ * @return A <code>PooledConnection</code> object that is a physical
+ * connection to the NDCS server that this
+ * <code>HPT4ConnectionPoolDataSource</code> object represents.
+ * @throws SQLException
+ * If any NDCS error occurs.
+ */
+ public PooledConnection getPooledConnection() throws SQLException {
+ if (t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ t4Logger_.logp(Level.FINE, "HPT4ConnectionPoolDataSource", "getPooledConnection", "", p);
+ }
+ if (getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ lr.setParameters(p);
+ lr.setSourceClassName("HPT4ConnectionPoolDataSource");
+ lr.setSourceMethodName("getPooledConnection");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ getLogWriter().println(temp);
+ }
+ HPT4PooledConnection connect;
+
+ Properties l_props = super.getProperties();
+ T4Properties l_t4props = new T4Properties(l_props);
+ connect = new HPT4PooledConnection(this, l_t4props);
+
+ return connect;
+ }
+
+ /**
+ * Attempts to establish a physical database connection that can be used as
+ * a pooled connection.
+ *
+ * @param username
+ * Safeguard user name.
+ * @param password
+ * Safeguard user password.
+ * @return A <code>PooledConnection</code> object that is a physical
+ * connection to the NDCS server that this
+ * <code>HPT4ConnectionPoolDataSource</code> object represents.
+ * @throws SQLException
+ * If any NDCS error occurs.
+ */
+ public PooledConnection getPooledConnection(String username, String password) throws SQLException {
+ if (t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null, username);
+ t4Logger_.logp(Level.FINE, "HPT4ConnectionPoolDataSource", "getPooledConnection", "", p);
+ }
+ if (getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null, username);
+ lr.setParameters(p);
+ lr.setSourceClassName("HPT4ConnectionPoolDataSource");
+ lr.setSourceMethodName("getPooledConnection");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ getLogWriter().println(temp);
+ }
+ HPT4PooledConnection connect;
+
+ setUser(username);
+ setPassword(password);
+ return getPooledConnection();
+
+ }
+
+ /**
+ * Returns all the properties associated with this
+ * <code>ConnectionPoolDataSource</code>.
+ *
+ * @return Reference Object containing all the Type 4 property references.
+ * @throws NamingException
+ */
+ public Reference getReference() throws NamingException {
+ if (t4Logger_ != null && t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ t4Logger_.logp(Level.FINE, "HPT4ConnectionPoolDataSource", "getReference", "", p);
+ }
+ try {
+ if (getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ lr.setParameters(p);
+ lr.setSourceClassName("HPT4ConnectionPoolDataSource");
+ lr.setSourceMethodName("getReference");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+
+ Reference ref = new Reference(this.getClass().getName(), "org.trafodion.jdbc.t4.HPT4ConnectionPoolDataSourceFactory",
+ null);
+ ref = addReferences(ref);
+ ref.add(new StringRefAddr("propertyCycle", Integer.toString(propertyCycle_)));
+ return ref;
+
+ }
+
+ /**
+ * Sets the Property cycle property. This property is not supprted by the
+ * Type 4 driver. This property is ignored by the Type 4 driver.
+ *
+ * @param propertyCycle
+ */
+ public void setPropertyCycle(int propertyCycle) {
+ if (t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ t4Logger_.logp(Level.FINE, "HPT4ConnectionPoolDataSource", "setPropertyCycle", "", p);
+ }
+ try {
+ if (getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null, propertyCycle);
+ lr.setParameters(p);
+ lr.setSourceClassName("HPT4ConnectionPoolDataSource");
+ lr.setSourceMethodName("setPropertyCycle");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+ propertyCycle_ = propertyCycle;
+ }
+
+ /**
+ * Returns the Property cycle property. This property is not supprted by the
+ * Type 4 driver. This property is ignored by the Type 4 driver.
+ *
+ * @return propertyCycle
+ */
+ public int getPropertyCycle() {
+ if (t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ t4Logger_.logp(Level.FINE, "HPT4ConnectionPoolDataSource", "getPropertyCycle", "", p);
+ }
+ try {
+ if (getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ lr.setParameters(p);
+ lr.setSourceClassName("HPT4ConnectionPoolDataSource");
+ lr.setSourceMethodName("getPropertyCycle");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+ return propertyCycle_;
+ }
+
+ // --------------------------------------------------------
+ void setupLogFileHandler() {
+ try {
+ if (getT4LogFile() == null) {
+ setT4LogFile(getT4GlobalLogFile());
+ setT4LogFileHandler(getT4GlobalLogFileHandler());
+ } else {
+ if (getT4LogFileHandler() == null) {
+ String temp = getT4LogFile();
+ FileHandler fh1 = new FileHandler(temp);
+ Formatter ff1 = new T4LogFormatter();
+
+ fh1.setFormatter(ff1);
+ setT4LogFileHandler(fh1);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } // end setupLogFileHandler
+
+ // --------------------------------------------------------
+
+ /**
+ * Creates a pooled connection object.
+ *
+ * @see #HPT4ConnectionPoolDataSource(Properties)
+ * @see T4Properties
+ */
+ public HPT4ConnectionPoolDataSource() {
+ super();
+ if (getT4LogLevel() != Level.OFF)
+ setupLogFileHandler();
+ if (t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ t4Logger_.logp(Level.FINE, "HPT4ConnectionPoolDataSource", "HPT4ConnectionPoolDataSource",
+ "Note, super called before this.", p);
+ }
+ try {
+ if (getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ lr.setParameters(p);
+ lr.setSourceClassName("HPT4ConnectionPoolDataSource");
+ lr.setSourceMethodName("");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+ }
+
+ /**
+ * Creates a pooled connection object with the properties specified.
+ *
+ * @param props
+ * properties for the Type 4 connection
+ * @see #HPT4ConnectionPoolDataSource()
+ * @link T4Properties
+ */
+ public HPT4ConnectionPoolDataSource(Properties props) {
+ super(props);
+ if (getT4LogLevel() != Level.OFF)
+ setupLogFileHandler();
+ if (t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null, props);
+ t4Logger_.logp(Level.FINE, "HPT4ConnectionPoolDataSource", "HPT4ConnectionPoolDataSource",
+ "Note, super called before this.", p);
+ }
+ try {
+ if (getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null, props);
+ lr.setParameters(p);
+ lr.setSourceClassName("HPT4ConnectionPoolDataSource");
+ lr.setSourceMethodName("");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+ }
+
+ /**
+ * @deprecated
+ */
+ public void setNameType(String nameType) {
+ }
+
+ /**
+ * @deprecated
+ */
+ public String getNameType() {
+ return null;
+ }
+
+ // Standard ConnectionPoolDataSource Properties
+ int propertyCycle_;
+
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4ConnectionPoolDataSourceFactory.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4ConnectionPoolDataSourceFactory.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4ConnectionPoolDataSourceFactory.java
new file mode 100644
index 0000000..3f87539
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4ConnectionPoolDataSourceFactory.java
@@ -0,0 +1,68 @@
+// @@@ 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.Enumeration;
+import java.util.Hashtable;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+
+public class HPT4ConnectionPoolDataSourceFactory implements javax.naming.spi.ObjectFactory {
+ public HPT4ConnectionPoolDataSourceFactory() {
+ }
+
+ public Object getObjectInstance(Object refobj, Name name, Context nameCtx, Hashtable env) throws Exception {
+ Reference ref = (Reference) refobj;
+ HPT4ConnectionPoolDataSource ds;
+ RefAddr refAddr;
+ String tmp;
+
+ if (ref.getClassName().equals("org.trafodion.jdbc.t4.HPT4ConnectionPoolDataSource")) {
+ Properties props = new Properties();
+ for (Enumeration enum2 = ref.getAll(); enum2.hasMoreElements();) {
+ RefAddr tRefAddr = (RefAddr) enum2.nextElement();
+ String type = tRefAddr.getType();
+ String content = (String) tRefAddr.getContent();
+ props.setProperty(type, content);
+ }
+ ds = new HPT4ConnectionPoolDataSource(props);
+ /*
+ * tmp = props.getProperty("initialPoolSize"); if (tmp != null) {
+ * try { ds.setInitialPoolSize(Integer.parseInt(tmp)); } catch
+ * (NumberFormatException e1) { } } tmp =
+ * props.getProperty("maxIdleTime"); if (tmp != null) { try {
+ * ds.setMaxIdleTime(Integer.parseInt(tmp)); } catch
+ * (NumberFormatException e4) { } } tmp =
+ * props.getProperty("propertyCycle"); if (tmp != null) { try {
+ * ds.setPropertyCycle(Integer.parseInt(tmp)); } catch
+ * (NumberFormatException e5) { } }
+ */
+ return ds;
+ } else {
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4DataSource.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4DataSource.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4DataSource.java
new file mode 100644
index 0000000..f0e0c8f
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4DataSource.java
@@ -0,0 +1,366 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.Properties;
+import java.util.logging.FileHandler;
+import java.util.logging.Formatter;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+
+/**
+ *
+ * <p>
+ * JDBC Type 4 Driver <code>DataSource</code> class.
+ * </p>
+ * <p>
+ * Description: A <code>DataSource</code> object is a factory for Connection
+ * objects. An object that implements the <code>DataSource</code> interface is
+ * typically registered with a JNDI service provider. A JDBC driver that is
+ * accessed through the <code>DataSource</code> API does not automatically
+ * register itself with the <code>DriverManager</code> object.
+ * </p>
+ *
+ * <p>
+ * The <code>HPT4DataSource</code> class can provide connection pooling and
+ * statement pooling features.
+ * </p>
+ *
+ * <pre>
+ * <b>Setting properties for the HPT4DataSource in the Type 4 driver</b>
+ * HPT4DataSource ds = new HPT4DataSource();
+ * ds.setUrl("jdbc:t4jdbc://<NDCS host>:<NDCS port>/:");
+ * ds.setCatalog("your catalog");
+ * ds.setSchema("your schema");
+ * ds.setUser("safeguard user name");
+ * ds.setPassword("safeguard password");
+ *
+ * // Following are optional properties
+ * ds.setConnectionTimeout("timeout in seconds");
+ * ds.setT4LogFile("your log file location");
+ * ds.setT4LogLevel("SEVERE");
+ * ds.setServerDataSource("NDCS datasource name");
+ *
+ * // Properties relevant for Type 4 connection pooling.
+ * // Set ds.setMaxPoolSize(-1) to turn OFF connection pooling
+ * ds.setMaxPoolSize("number of connections required");
+ * ds.setMinPoolSize("number of connections required");
+ *
+ * // Properties relevant for Type 4 statement pooling.
+ * // Set ds.setMaxStatement(0) to turn statement pooling OFF
+ * // Statement pooling is enabled only when connection pooling is enabled.
+ * ds.setMaxStatements("number of statements to be pooled");
+ * </pre>
+ *
+ * <pre>
+ * <b>Programmatically registering HPT4DataSource with JDNI</b>
+ * java.util.Hashtable env = new java.util.Hashtable();
+ * env.put(Context.INITIAL_CONTEXT_FACTORY, "Factory class name here");
+ * javax.naming.Context ctx = new javax.naming.InitialContext(env);
+ * ctx.rebind("DataSource name here", ds);
+ * </pre>
+ *
+ * <pre>
+ * <b>Application making Type4 connection using the DataSource from JDNI</b>
+ * java.util.Hashtable env = new java.util.Hashtable();
+ * env.put(Context.INITIAL_CONTEXT_FACTORY, "Factory class name here");
+ * javax.naming.Context ctx = new javax.naming.InitialContext(env);
+ * DataSource ds = (DataSource)ctx.lookup("DataSource name here");
+ * java.sql.Connection con = ds.getConnection();
+ * </pre>
+ *
+ * <p>
+ * Copyright: (C) Apache Software Foundation (ASF)
+ * </p>
+ *
+ * @see T4Properties
+ */
+public class HPT4DataSource extends T4DSProperties implements javax.sql.DataSource, java.io.Serializable, Referenceable
+
+{
+ /**
+ * Attempts to establish an NDCS connection.
+ *
+ * @return a connection to the NDCS server.
+ * @throws SQLException
+ * if a database access error or NDCS error occurs.
+ * @see #getConnection(String, String)
+ */
+ synchronized public Connection getConnection() throws SQLException {
+ if (logger.isLoggable(Level.FINER)) {
+ logger.entering("HPT4DataSource", "getConnection");
+ }
+
+ Connection conn;
+ TrafT4Connection t4Conn;
+ HPT4ConnectionPoolDataSource pds;
+
+ if (getSQLException() != null) {
+ throw HPT4Messages.createSQLException(null, getLocale(), "invalid_property", getSQLException());
+ }
+
+ if (getMaxPoolSize() == -1) {
+ t4Conn = new TrafT4Connection(this, getT4Properties());
+ } else {
+ if (poolManager != null) {
+ t4Conn = (TrafT4Connection) poolManager.getConnection();
+ } else {
+
+ pds = new HPT4ConnectionPoolDataSource(getProperties());
+ poolManager = new HPT4PooledConnectionManager(pds, getT4LogLevel());
+ t4Conn = (TrafT4Connection) poolManager.getConnection();
+ }
+ }
+
+ t4Conn.setLogInfo(getT4LogLevel(), getLogWriter());
+ conn = t4Conn;
+
+ if (logger.isLoggable(Level.FINER)) {
+ logger.exiting("HPT4DataSource", "getConnection", conn);
+ }
+
+ return conn;
+ }
+
+ /**
+ * Attempts to establish an NDCS connection.
+ *
+ * @return a connection to the NDCS server.
+ * @param username
+ * Safeguard user name
+ * @param password
+ * Safeguard user password
+ * @throws SQLException
+ * if a database access error or NDCS error occurs.
+ * @see #getConnection()
+ */
+ synchronized public Connection getConnection(String username, String password) throws SQLException {
+ if (logger.isLoggable(Level.FINER)) {
+ logger.entering("HPT4DataSource", "getConnection", new Object[] { this, username });
+ }
+
+ Connection conn;
+
+ setUser(username);
+ setPassword(password);
+
+ conn = getConnection();
+
+ if (logger.isLoggable(Level.FINER)) {
+ logger.exiting("HPT4DataSource", "getConnection", conn);
+ }
+
+ return conn;
+ }
+
+ /**
+ * @return Reference Object containing all the Type 4 property references.
+ * @throws NamingException
+ */
+ public Reference getReference() throws NamingException {
+
+ Reference ref = new Reference(this.getClass().getName(), "org.trafodion.jdbc.t4.HPT4DataSourceFactory", null);
+ return addReferences(ref);
+ }
+
+ /**
+ * Sets the print writer for the current Type 4 data source.
+ *
+ * @param out
+ * java.io.PrintWriter for the current T4 connection.
+ * @throws SQLException
+ * when error occurs.
+ * @see #getLogWriter()
+ * @see javax.sql.ConnectionPoolDataSource
+ */
+ public void setLogWriter(PrintWriter out) throws SQLException {
+ super.setLogWriter(out);
+ if (t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null, out);
+ t4Logger_.logp(Level.FINE, "HPT4DataSource", "setLogWriter",
+ "Note, this constructor was called before the previous constructor", p);
+ }
+ if (getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null, out);
+ lr.setParameters(p);
+ lr.setSourceClassName("HPT4DataSource");
+ lr.setSourceMethodName("setLogWriter");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ getLogWriter().println(temp);
+ }
+ if (poolManager != null) {
+ poolManager.setLogWriter(getLogWriter());
+ }
+ }
+
+ // Local methods
+ void setPoolManager(Context nameCtx, String dataSourceName) throws Exception {
+ if (t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null, nameCtx, dataSourceName);
+ t4Logger_.logp(Level.FINER, "HPT4DataSource", "setPoolManager", "", p);
+ }
+ Object pds;
+
+ try {
+ pds = nameCtx.lookup(dataSourceName);
+ if (pds instanceof HPT4ConnectionPoolDataSource) {
+ poolManager = new HPT4PooledConnectionManager((HPT4ConnectionPoolDataSource) pds, getT4LogLevel());
+ }
+ } catch (javax.naming.NameNotFoundException nnfe) {
+ }
+ }
+
+ // --------------------------------------------------------
+ void setupLogFileHandler() {
+ try {
+ if (getT4LogFile() == null) {
+ setT4LogFile(getT4GlobalLogFile());
+ setT4LogFileHandler(getT4GlobalLogFileHandler());
+ } else {
+ if (getT4LogFileHandler() == null) {
+ String temp = getT4LogFile();
+ FileHandler fh1 = new FileHandler(temp);
+
+ Formatter ff1 = new T4LogFormatter();
+
+ fh1.setFormatter(ff1);
+ setT4LogFileHandler(fh1);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } // end setupLogFileHandler
+
+ // --------------------------------------------------------
+
+ /**
+ * Contructor for the <code>HPT4DataSource</code> object.
+ *
+ * @see #HPT4DataSource(java.util.Properties)
+ */
+ public HPT4DataSource() {
+ super();
+ if (getT4LogLevel() != Level.OFF) {
+ setupLogFileHandler();
+ }
+ if (t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ t4Logger_.logp(Level.FINE, "HPT4DataSource", "<init>",
+ "Note, this constructor was called before the previous constructor", p);
+ }
+ try {
+ if (getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ lr.setParameters(p);
+ lr.setSourceClassName("HPT4DataSource");
+ lr.setSourceMethodName("<init>");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+
+ }
+
+ /**
+ * Contructor for the <code>HPT4DataSource</code> object.
+ *
+ * @param info
+ * Contains all the Type 4 properties in a <code>name,
+ * value</code>
+ * pair.
+ * @see #HPT4DataSource()
+ * @see java.util.Properties
+ */
+ public HPT4DataSource(Properties info) {
+ super(info);
+ if (getT4LogLevel() != Level.OFF) {
+ setupLogFileHandler();
+ }
+ if (t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ t4Logger_.logp(Level.FINE, "HPT4DataSource", "<init>",
+ "Note, this constructor was called before the previous constructor", p);
+ }
+ try {
+ if (getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ lr.setParameters(p);
+ lr.setSourceClassName("HPT4DataSource");
+ lr.setSourceMethodName("<init>");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+ }
+
+ /**
+ * @deprecated
+ */
+ public void setNameType(String nameType) {
+ }
+
+ /**
+ * @deprecated
+ */
+ public String getNameType() {
+ return null;
+ }
+
+ // fields
+ HPT4PooledConnectionManager poolManager;
+
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ 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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4DataSourceFactory.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4DataSourceFactory.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4DataSourceFactory.java
new file mode 100644
index 0000000..1b7a8da
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4DataSourceFactory.java
@@ -0,0 +1,62 @@
+// @@@ 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.Enumeration;
+import java.util.Hashtable;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+
+public class HPT4DataSourceFactory implements javax.naming.spi.ObjectFactory {
+ public HPT4DataSourceFactory() {
+ }
+
+ public Object getObjectInstance(Object refobj, Name name, Context nameCtx, Hashtable env) throws Exception {
+ Reference ref = (Reference) refobj;
+ HPT4DataSource ds;
+ String dataSourceName = null;
+
+ if (ref.getClassName().equals("org.trafodion.jdbc.t4.HPT4DataSource")) {
+ Properties props = new Properties();
+ for (Enumeration enum2 = ref.getAll(); enum2.hasMoreElements();) {
+ RefAddr tRefAddr = (RefAddr) enum2.nextElement();
+ String type = tRefAddr.getType();
+ String content = (String) tRefAddr.getContent();
+ props.setProperty(type, content);
+ }
+
+ ds = new HPT4DataSource(props);
+ dataSourceName = ds.getDataSourceName();
+
+ if (dataSourceName != null) {
+ ds.setPoolManager(nameCtx, dataSourceName);
+ }
+ return ds;
+ } else {
+ return null;
+ }
+ }
+}
[28/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DatabaseMetaData.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DatabaseMetaData.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DatabaseMetaData.java
new file mode 100644
index 0000000..d3b916d
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DatabaseMetaData.java
@@ -0,0 +1,5901 @@
+// @@@ 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.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.RowIdLifetime;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+/**
+ * <p>
+ * JDBC Type 4 driver DataBaseMetaData class.
+ * </p>
+ * Comprehensive information about the database and Type 4 driver as
+ * a whole. This class lets applications users know the capabilities of database
+ * in combination with the Type 4 driver. Information returned
+ * by methods in this class applies to the capabilities of a Type 4 driver and
+ * Database working together. A user for this class is commonly a
+ * tool that needs to discover how to deal with the underlying
+ * Database. This is especially true for applications that are intended to be
+ * used with more than one DBMS. For example, a tool might use the method
+ * <code>getTypeInfo</code> to find out what data types can be used in a
+ * CREATE TABLE statement. Or a user might call the method
+ * <code>supportsCorrelatedSubqueries</code> to see if it is possible to use a
+ * correlated subquery or <code>supportsBatchUpdates</code> to see if it is
+ * possible to use batch updates. Some DatabaseMetaData methods return lists of
+ * information in the form of ResultSet objects. Regular ResultSet methods, such
+ * as getString and getInt, can be used to retrieve the data from these
+ * ResultSet objects. If a given form of metadata is not available, the
+ * ResultSet getter methods throw an SQLException. Some DatabaseMetaData methods
+ * take arguments that are String patterns. These arguments all have names such
+ * as fooPattern. Within a pattern String, "%" means match any substring of 0 or
+ * more characters, and "_" means match any one character. Only metadata entries
+ * matching the search pattern are returned. If a search pattern argument is set
+ * to null, that argument's criterion will be dropped from the search. A method
+ * that gets information about a feature that the Type 4 driver does not support
+ * will throw an SQLException. In the case of methods that return a ResultSet
+ * object, either a ResultSet object (which might be empty) is returned, or an
+ * SQLException is thrown.
+ *
+ * <p>
+ * Description: JDBC Type 4 Driver
+ * </p>
+ * <p>
+ * </p>
+ */
+public class T4DatabaseMetaData extends HPT4Handle implements java.sql.DatabaseMetaData {
+
+ // ----------------------------------------------------------------------
+ // First, a variety of minor information about the target database.
+
+ /*
+ * Can all the procedures returned by getProcedures be called by the current
+ * user?
+ *
+ * @return true if so
+ */
+ public boolean allProceduresAreCallable() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "allProceduresAreCallable", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("allProceduresAreCallable");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Can all the tables returned by getTable be SELECTed by the current user?
+ *
+ * @return true if so
+ */
+ public boolean allTablesAreSelectable() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "allTablesAreSelectable", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("allTablesAreSelectable");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * What's the url for this database?
+ *
+ * @return the url or null if it can't be generated * "TCP:<hostname>:<portnumber>/JDBC"
+ * is good enough.
+ */
+ public String getURL() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getURL", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getURL");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return connection_.getT4Properties().getUrl();
+ }
+
+ /*
+ * What's our user name as known to the database?
+ *
+ * @return our database user name *
+ *
+ */
+ public String getUserName() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getUserName", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getUserName");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return connection_.getServerHandle().getUid();
+ }
+
+ /*
+ * Is the database in read-only mode?
+ *
+ * @return true if so *
+ *
+ */
+ public boolean isReadOnly() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "isReadOnly", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("isReadOnly");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Are NULL values sorted high?
+ *
+ * @return true if so
+ *
+ */
+ public boolean nullsAreSortedHigh() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "nullsAreSortedHigh", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("nullsAreSortedHigh");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Are NULL values sorted low?
+ *
+ * @return true if so
+ */
+ public boolean nullsAreSortedLow() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "nullsAreSortedLow", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("nullsAreSortedLow");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Are NULL values sorted at the start regardless of sort order?
+ *
+ * @return true if so
+ */
+ public boolean nullsAreSortedAtStart() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "nullsAreSortedAtStart", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("nullsAreSortedAtStart");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Are NULL values sorted at the end regardless of sort order?
+ *
+ * @return true if so
+ */
+ public boolean nullsAreSortedAtEnd() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "nullsAreSortedAtEnd", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("nullsAreSortedAtEnd");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * What's the name of this database product?
+ *
+ * @return database product name
+ */
+ public String getDatabaseProductName() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDatabaseProductName", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getDatabaseProductName");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("Trafodion");
+ }
+
+ /*
+ * What's the version of this database product?
+ *
+ * @return database version *
+ *
+ */
+ public String getDatabaseProductVersion() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDatabaseProductVersion", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getDatabaseProductVersion");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("" + getDatabaseMajorVersion() + "." + getDatabaseMinorVersion());
+ }
+
+ /*
+ * What's the name of this JDBC driver?
+ *
+ * @return JDBC driver name
+ */
+ public String getDriverName() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDriverName", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getDriverName");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("org.trafodion.jdbc.t4.T4Driver");
+ }
+
+ /*
+ * What's the version of this JDBC driver?
+ *
+ * @return JDBC driver version
+ */
+ public String getDriverVersion() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDriverVersion", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getDriverVersion");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return Vproc.getVproc();
+ }
+
+ /*
+ * What's this JDBC driver's major version number?
+ *
+ * @return JDBC driver major version
+ */
+ public int getDriverMajorVersion() {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDriverMajorVersion", "", p);
+ }
+ try {
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getDriverMajorVersion");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+ return Vproc.jdbcMajorVersion;
+ }
+
+ /*
+ * What's this JDBC driver's minor version number?
+ *
+ * @return JDBC driver minor version number
+ */
+ public int getDriverMinorVersion() {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDriverMinorVersion", "", p);
+ }
+ try {
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getDriverMinorVersion");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+ return Vproc.jdbcMinorVersion;
+ }
+
+ /*
+ * Does the database store tables in a local file?
+ *
+ * @return true if so
+ */
+ public boolean usesLocalFiles() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "usesLocalFiles", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("usesLocalFiles");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Does the database use a file for each table?
+ *
+ * @return true if the database uses a local file for each table
+ */
+ public boolean usesLocalFilePerTable() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "usesLocalFilePerTable", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("usesLocalFilePerTable");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Database does not treat the mixed case unquoted SQL
+ * identifiers as case sensitive and does not store the result in mixed
+ * case.
+ *
+ * @return false always for the Type 4 driver.
+ */
+ public boolean supportsMixedCaseIdentifiers() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_
+ .logp(Level.FINE, "T4DatabaseMetaData", "supportsMixedCaseIdentifiers", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsMixedCaseIdentifiers");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Database treat mixed case unquoted SQL identifiers as case
+ * insensitive and store them in upper case.
+ * @return true always for the Type 4 driver.
+ */
+ public boolean storesUpperCaseIdentifiers() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "storesUpperCaseIdentifiers", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("storesUpperCaseIdentifiers");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Does the database treat mixed case unquoted SQL identifiers as case
+ * insensitive and store them in lower case?
+ *
+ * @return true if so
+ */
+ public boolean storesLowerCaseIdentifiers() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "storesLowerCaseIdentifiers", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("storesLowerCaseIdentifiers");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Does the database treat mixed case unquoted SQL identifiers as case
+ * insensitive and store them in mixed case?
+ *
+ * @return true if so
+ */
+ public boolean storesMixedCaseIdentifiers() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "storesMixedCaseIdentifiers", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("storesMixedCaseIdentifiers");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Database treat mixed case quoted SQL identifiers as case
+ * sensitive and as a result store them in mixed case.
+ * A JDBC-Compliant driver will always return false.
+ *
+ * @return true always true for the Type 4 drive.
+ */
+ public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsMixedCaseQuotedIdentifiers",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsMixedCaseQuotedIdentifiers");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Does the database treat mixed case quoted SQL identifiers as case
+ * insensitive and store them in upper case?
+ *
+ * @return true if so
+ */
+ public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "storesUpperCaseQuotedIdentifiers",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("storesUpperCaseQuotedIdentifiers");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Does the database treat mixed case quoted SQL identifiers as case
+ * insensitive and store them in lower case?
+ *
+ * @return true if so
+ */
+ public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "storesLowerCaseQuotedIdentifiers",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("storesLowerCaseQuotedIdentifiers");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Does the database treat mixed case quoted SQL identifiers as case
+ * insensitive and store them in mixed case?
+ *
+ * @return true if so
+ */
+ public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", " storesMixedCaseQuotedIdentifiers",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName(" storesMixedCaseQuotedIdentifiers");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Database uses the " string to quote SQL identifiers. This call
+ * returns a space " " if identifier quoting isn't supported.
+ * A JDBC-Compliant driver always uses a double quote character.
+ *
+ * @return the quoting string ".
+ */
+ public String getIdentifierQuoteString() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getIdentifierQuoteString", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getIdentifierQuoteString");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("\"");
+ }
+
+ /*
+ * Get a comma separated list of all a database's SQL keywords that are NOT
+ * also SQL92 keywords.
+ *
+ * @return the list *
+ *
+ */
+ public String getSQLKeywords() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getSQLKeywords", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getSQLKeywords");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return "DATETIME,FRACTION,PROTOTYPE,SQL_CHAR,SQL_DATE,SQL_DECIMAL,SQL_DOUBLE,SQL_FLOAT"
+ + ",SQL_INT,SQL_INTEGER,SQL_REAL,SQL_SMALLINT,SQL_TIME,SQL_TIMESTAMP,SQL_VARCHAR"
+ + ",TRANSPOSE,UPSHIFT";
+ }
+
+ /*
+ * Get a comma separated list of math functions.
+ *
+ * @return the list *
+ *
+ */
+ public String getNumericFunctions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getNumericFunctions", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getNumericFunctions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String(
+ "ABS,ACOS,ASIN,ATAN,ATAN2,CEILING,COS,COSH,DEGREES,EXP,FLOOR,LOG,LOG10,MOD,PI,POWER,RADIANS,RAND"
+ + "SIGN,SIN,SINH,SORT,TAN,TANH");
+ }
+
+ /*
+ * Get a comma separated list of string functions.
+ *
+ * @return the list *
+ *
+ */
+ public String getStringFunctions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getStringFunctions", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getStringFunctions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("ASCII,CHAR,CHAR_LENGTH,CONCAT,INSERT,LCASE,LEFT,LOCATE,LOWER,LPAD,LTRIM,OCTET_LENGTH"
+ + "POSITION,REPEAT,REPLACE,RIGHT,RPAD,RTRIM,SPACE,SUBSTRING,TRIM,UCASE,UPPER,UPSHIFT");
+ }
+
+ /*
+ * Get a comma separated list of system functions.
+ *
+ * @return the list *
+ *
+ */
+ public String getSystemFunctions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getSystemFunctions", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getSystemFunctions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("CURRENT_USER,USER");
+ }
+
+ /*
+ * Get a comma separated list of time and date functions.
+ *
+ * @return the list *
+ *
+ */
+ public String getTimeDateFunctions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getTimeDateFunctions", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getTimeDateFunctions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return new String("CONVERTTIMESTAMP,CURRENT,CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP"
+ + "DATEFORMAT,DAY,DAYNAME,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,EXTRACT,HOUR,JULIANTIMESTAMP,MINUTE"
+ + "MONTH,MONTHNAME,QUARTER,SECOND,WEEK,YEAR");
+ }
+
+ /*
+ * This is the string that can be used to escape '_' or '%' in the string
+ * pattern style catalog search parameters.
+ *
+ * <P>The '_' character represents any single character. <P>The '%'
+ * character represents any sequence of zero or more characters. @return the
+ * string used to escape wildcard characters *
+ *
+ */
+ public String getSearchStringEscape() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getSearchStringEscape", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getSearchStringEscape");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("\\");
+ }
+
+ /*
+ * Get all the "extra" characters that can be used in unquoted identifier
+ * names (those beyond a-z, A-Z, 0-9 and _).
+ *
+ * @return the string containing the extra characters
+ */
+ public String getExtraNameCharacters() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getExtraNameCharacters", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getExtraNameCharacters");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return null;
+ }
+
+ // --------------------------------------------------------------------
+ // Functions describing which features are supported.
+
+ /*
+ * Is "ALTER TABLE" with add column supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsAlterTableWithAddColumn() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsAlterTableWithAddColumn",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsAlterTableWithAddColumn");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Is "ALTER TABLE" with drop column supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsAlterTableWithDropColumn() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsAlterTableWithDropColumn",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsAlterTableWithDropColumn");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Is column aliasing supported?
+ *
+ * <P>If so, the SQL AS clause can be used to provide names for computed
+ * columns or to provide alias names for columns as required.
+ *
+ * A JDBC-Compliant driver always returns true.
+ *
+ * @return true if so
+ */
+ public boolean supportsColumnAliasing() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsColumnAliasing", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsColumnAliasing");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Database concatenations between NULL and non-NULL values is
+ * NULL.
+ *
+ * A JDBC-Compliant driver always returns true.
+ *
+ * @return true always for the Type 4 driver.
+ */
+ public boolean nullPlusNonNullIsNull() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "nullPlusNonNullIsNull", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("nullPlusNonNullIsNull");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is the CONVERT function between SQL types supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsConvert() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsConvert", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsConvert");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is CONVERT between the given SQL types supported?
+ *
+ * @param fromType the type to convert from @param toType the type to
+ * convert to @return true if so
+ *
+ * @see Types
+ */
+ public boolean supportsConvert(int fromType, int toType) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, fromType, toType);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsConvert", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, fromType, toType);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsConvert");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ switch (fromType) {
+ case Types.BIGINT:
+ case Types.DECIMAL:
+ case Types.DOUBLE:
+ case Types.FLOAT:
+ case Types.INTEGER:
+ case Types.NUMERIC:
+ case Types.REAL:
+ case Types.SMALLINT:
+ switch (toType) {
+ case Types.CHAR:
+ case Types.NUMERIC:
+ case Types.DECIMAL:
+ case Types.INTEGER:
+ case Types.SMALLINT:
+ case Types.FLOAT:
+ case Types.REAL:
+ case Types.DOUBLE:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BIGINT:
+ return true;
+ default:
+ return false;
+ }
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ switch (toType) {
+ case Types.CHAR:
+ case Types.NUMERIC:
+ case Types.DECIMAL:
+ case Types.INTEGER:
+ case Types.SMALLINT:
+ case Types.FLOAT:
+ case Types.REAL:
+ case Types.DOUBLE:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BIGINT:
+ case Types.DATE:
+ case Types.TIME:
+ case Types.TIMESTAMP:
+ return true;
+ default:
+ return false;
+ }
+ case Types.DATE:
+ switch (toType) {
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.DATE:
+ case Types.TIMESTAMP:
+ return true;
+ default:
+ return false;
+ }
+ case Types.TIME:
+ switch (toType) {
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.TIME:
+ case Types.TIMESTAMP:
+ return true;
+ default:
+ return false;
+ }
+ case Types.TIMESTAMP:
+ switch (toType) {
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.DATE:
+ case Types.TIME:
+ case Types.TIMESTAMP:
+ return true;
+ default:
+ return false;
+ }
+ case Types.BIT:
+ case Types.BINARY:
+ case Types.VARBINARY:
+ case Types.LONGVARBINARY:
+ case Types.TINYINT:
+ return false;
+ default:
+ return false;
+ }
+ }
+
+ /*
+ * Type 4 driver supports table correlation names. Type 4 driver always
+ * returns true.
+ *
+ * @return true for Type 4 driver
+ */
+ public boolean supportsTableCorrelationNames() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsTableCorrelationNames", "",
+ p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsTableCorrelationNames");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Database table correlation names are supported, and they are
+ * not restricted to be different from the names of the Database
+ * tables.
+ *
+ * @return false always for Type 4 driver.
+ */
+ public boolean supportsDifferentTableCorrelationNames() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData",
+ "supportsDifferentTableCorrelationNames", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsDifferentTableCorrelationNames");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * SQL expressions in "ORDER BY" lists are not supported by the
+ * Database and Type 4 driver.
+ *
+ * @return false always for Type 4 driver.
+ */
+ public boolean supportsExpressionsInOrderBy() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_
+ .logp(Level.FINE, "T4DatabaseMetaData", "supportsExpressionsInOrderBy", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsExpressionsInOrderBy");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Can an "ORDER BY" clause use columns not in the SELECT?
+ *
+ * @return true if so
+ */
+ public boolean supportsOrderByUnrelated() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsOrderByUnrelated", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsOrderByUnrelated");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is some form of "GROUP BY" clause supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsGroupBy() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsGroupBy", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsGroupBy");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a "GROUP BY" clause use columns not in the SELECT?
+ *
+ * @return true if so
+ */
+ public boolean supportsGroupByUnrelated() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsGroupByUnrelated", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsGroupByUnrelated");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Can a "GROUP BY" clause add columns not in the SELECT provided it
+ * specifies all the columns in the SELECT?
+ *
+ * @return true if so
+ */
+ public boolean supportsGroupByBeyondSelect() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsGroupByBeyondSelect", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsGroupByBeyondSelect");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Database supports escape character in "LIKE" clauses.
+ * A JDBC-Compliant driver always returns true.
+ *
+ * @return true always true for the Type 4 driver.
+ */
+ public boolean supportsLikeEscapeClause() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsLikeEscapeClause", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsLikeEscapeClause");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Are multiple ResultSets from a single execute supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsMultipleResultSets() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsMultipleResultSets", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsMultipleResultSets");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can we have multiple transactions open at once (on different
+ * connections)?
+ *
+ * @return true if so
+ */
+ public boolean supportsMultipleTransactions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_
+ .logp(Level.FINE, "T4DatabaseMetaData", "supportsMultipleTransactions", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsMultipleTransactions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ // Need to change it 'true' once Database fixes this problem
+ return false;
+ }
+
+ /*
+ * Database table columns can be defined as non-nullable.
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsNonNullableColumns() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsNonNullableColumns", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsNonNullableColumns");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Type 4 driver supports the ODBC Minimum SQL grammar.
+ *
+ * All JDBC-Compliant drivers must return true.
+ *
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsMinimumSQLGrammar() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsMinimumSQLGrammar", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsMinimumSQLGrammar");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is the ODBC Core SQL grammar supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsCoreSQLGrammar() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsCoreSQLGrammar", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsCoreSQLGrammar");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is the ODBC Extended SQL grammar supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsExtendedSQLGrammar() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsExtendedSQLGrammar", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsExtendedSQLGrammar");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Database supports the ANSI92 entry level SQL grammar.
+ * All JDBC-Compliant drivers must return true.
+ *
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsANSI92EntryLevelSQL() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsANSI92EntryLevelSQL", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsANSI92EntryLevelSQL");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is the ANSI92 intermediate SQL grammar supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsANSI92IntermediateSQL() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsANSI92IntermediateSQL", "",
+ p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsANSI92IntermediateSQL");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Is the ANSI92 full SQL grammar supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsANSI92FullSQL() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsANSI92FullSQL", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsANSI92FullSQL");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Is the SQL Integrity Enhancement Facility supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsIntegrityEnhancementFacility() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData",
+ "supportsIntegrityEnhancementFacility", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsIntegrityEnhancementFacility");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Is some form of outer join supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsOuterJoins() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsOuterJoins", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsOuterJoins");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Are full nested outer joins supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsFullOuterJoins() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsFullOuterJoins", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsFullOuterJoins");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Database provides the limited support for outer joins. This
+ * will be true if supportFullOuterJoins is true.
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsLimitedOuterJoins() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsLimitedOuterJoins", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsLimitedOuterJoins");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * What's the database vendor's preferred term for "schema"?
+ *
+ * @return the vendor term
+ */
+ public String getSchemaTerm() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getSchemaTerm", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getSchemaTerm");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("SCHEMA");
+ }
+
+ /*
+ * What's the database vendor's preferred term for "procedure"?
+ *
+ * @return the vendor term
+ */
+ public String getProcedureTerm() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getProcedureTerm", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getProcedureTerm");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("PROCEDURE");
+ }
+
+ /*
+ * What's the database vendor's preferred term for "catalog"?
+ *
+ * @return the vendor term
+ */
+ public String getCatalogTerm() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getCatalogTerm", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getCatalogTerm");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String("CATALOG");
+ }
+
+ /*
+ * Database catalog name appear at the start of a qualified table
+ * name. (Otherwise it appears at the end)
+ * @return true always for the Type 4 driver.
+ */
+ public boolean isCatalogAtStart() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "isCatalogAtStart", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("isCatalogAtStart");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * What's the separator between catalog and table name?
+ *
+ * @return the separator string
+ */
+ public String getCatalogSeparator() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getCatalogSeparator", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("getCatalogSeparator");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return new String(".");
+ }
+
+ /*
+ * Can a schema name be used in a data manipulation statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsSchemasInDataManipulation() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSchemasInDataManipulation",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSchemasInDataManipulation");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a schema name be used in a procedure call statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsSchemasInProcedureCalls() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSchemasInProcedureCalls",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSchemasInProcedureCalls");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a schema name be used in a table definition statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsSchemasInTableDefinitions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSchemasInTableDefinitions",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSchemasInTableDefinitions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a schema name be used in an index definition statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsSchemasInIndexDefinitions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSchemasInIndexDefinitions",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSchemasInIndexDefinitions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a schema name be used in a privilege definition statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData",
+ "supportsSchemasInPrivilegeDefinitions", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSchemasInPrivilegeDefinitions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a catalog name be used in a data manipulation statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsCatalogsInDataManipulation() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsCatalogsInDataManipulation",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsCatalogsInDataManipulation");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a catalog name be used in a procedure call statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsCatalogsInProcedureCalls() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsCatalogsInProcedureCalls",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsCatalogsInProcedureCalls");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a catalog name be used in a table definition statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsCatalogsInTableDefinitions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsCatalogsInTableDefinitions",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsCatalogsInTableDefinitions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a catalog name be used in an index definition statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsCatalogsInIndexDefinitions",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsCatalogsInIndexDefinitions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can a catalog name be used in a privilege definition statement?
+ *
+ * @return true if so
+ */
+ public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData",
+ "supportsCatalogsInPrivilegeDefinitions", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsCatalogsInPrivilegeDefinitions");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is positioned DELETE supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsPositionedDelete() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsPositionedDelete", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsPositionedDelete");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Database supports positioned UPDATE supported through the Type
+ * 4 driver.
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsPositionedUpdate() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsPositionedUpdate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsPositionedUpdate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Database supports SELECT for UPDATE through the Type 4 driver.
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsSelectForUpdate() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSelectForUpdate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSelectForUpdate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * stored procedure calls using the stored procedure escape syntax
+ * are supported.
+ *
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsStoredProcedures() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsStoredProcedures", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsStoredProcedures");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Trafodion Database Database subqueries in comparison expressions are supported
+ * through the Type 4 driver.
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsSubqueriesInComparisons() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSubqueriesInComparisons",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSubqueriesInComparisons");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Trafodion Database supports subqueries in 'exists' expressions through
+ * Type 4 driver.
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsSubqueriesInExists() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSubqueriesInExists", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSubqueriesInExists");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Trafodion Database supports subqueries in 'in' statements through the
+ * Type 4 driver.
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsSubqueriesInIns() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSubqueriesInIns", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSubqueriesInIns");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * The subqueries in quantified expressions supported in Trafodion Database
+ * and Type 4 driver.
+ * @return true always for Type 4 driver.
+ */
+ public boolean supportsSubqueriesInQuantifieds() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSubqueriesInQuantifieds",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsSubqueriesInQuantifieds");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Trafodion Database supports correlated subqueries.
+ * A JDBC-Compliant driver always returns true.
+ *
+ * @return true always for the Type 4 driver.
+ */
+ public boolean supportsCorrelatedSubqueries() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_
+ .logp(Level.FINE, "T4DatabaseMetaData", "supportsCorrelatedSubqueries", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsCorrelatedSubqueries");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is SQL UNION supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsUnion() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsUnion", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsUnion");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Is SQL UNION ALL supported?
+ *
+ * @return true if so
+ */
+ public boolean supportsUnionAll() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsUnionAll", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsUnionAll");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can cursors remain open across commits?
+ *
+ * @return true if cursors always remain open; false if they might not
+ * remain open
+ */
+ public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsOpenCursorsAcrossCommit",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsOpenCursorsAcrossCommit");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Can cursors remain open across rollbacks?
+ *
+ * @return true if cursors always remain open; false if they might not
+ * remain open
+ */
+ public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsOpenCursorsAcrossRollback",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsOpenCursorsAcrossRollback");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return false;
+ }
+
+ /*
+ * Can statements remain open across commits?
+ *
+ * @return true if statements always remain open; false if they might not
+ * remain open
+ */
+ public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsOpenStatementsAcrossCommit",
+ "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsOpenStatementsAcrossCommit");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ /*
+ * Can statements remain open across rollbacks?
+ *
+ * @return true if statements always remain open; false if they might not
+ * remain open
+ */
+ public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData",
+ "supportsOpenStatementsAcrossRollback", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4DatabaseMetaData");
+ lr.setSourceMethodName("supportsOpenStatementsAcrossRollback");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return true;
+ }
+
+ // -------------------------------------
<TRUNCATED>
[54/60] incubator-trafodion git commit: Updated the dependencies
Posted by db...@apache.org.
Updated the dependencies
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/1ca6f608
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/1ca6f608
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/1ca6f608
Branch: refs/heads/master
Commit: 1ca6f60806e2d76eb7b78c4c5bbd218410d7d8ec
Parents: c4d50df
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Fri Apr 29 15:33:44 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Fri Apr 29 15:33:44 2016 +0000
----------------------------------------------------------------------
core/Makefile | 2 ++
core/conn/jdbcT4/Makefile | 2 +-
core/rest/pom.xml | 4 ++--
core/sql/lib_mgmt/Makefile | 4 ++--
dcs/pom.xml | 6 +++---
5 files changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1ca6f608/core/Makefile
----------------------------------------------------------------------
diff --git a/core/Makefile b/core/Makefile
index e07de36..c6c3606 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -112,6 +112,7 @@ clean: sqroot
cd rest && $(MAKE) clean
cd conn/odb && $(MAKE) clean
cd ../dcs && $(MAKE) clean
+ cd sql/lib_mgmt && $(MAKE) clean
$(RM) -r ../${DISTRIBUTION_DIR}
cleanall: sqroot eclipseclean cleantests
@@ -126,6 +127,7 @@ cleanall: sqroot eclipseclean cleantests
cd rest && $(MAKE) clean
cd conn/odb && $(MAKE) clean
cd ../dcs && $(MAKE) clean
+ cd sql/lib_mgmt && $(MAKE) cleanall
$(RM) -r ../${DISTRIBUTION_DIR}
package-all: package pkg-sql-regress pkg-phx-tests pkg-dcs-tests
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1ca6f608/core/conn/jdbcT4/Makefile
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/Makefile b/core/conn/jdbcT4/Makefile
index 6006abb..a53e50c 100644
--- a/core/conn/jdbcT4/Makefile
+++ b/core/conn/jdbcT4/Makefile
@@ -35,4 +35,4 @@ build_all:
clean:
-$(MAVEN) clean | grep ERROR
- $(RM) build_jdbct4.log ${MY_SQROOT}/export/lib/jdbcT4.jar
+ $(RM) build_jdbct4.log ${MY_SQROOT}/export/lib/jdbcT4*.jar
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1ca6f608/core/rest/pom.xml
----------------------------------------------------------------------
diff --git a/core/rest/pom.xml b/core/rest/pom.xml
index c364448..b56f8c8 100644
--- a/core/rest/pom.xml
+++ b/core/rest/pom.xml
@@ -572,8 +572,8 @@
<dependencies>
<!-- JDBCT4 dependencies -->
<dependency>
- <groupId>org.trafodion.jdbc.t4.T4Driver</groupId>
- <artifactId>t4driver</artifactId>
+ <groupId>org.trafodion.jdbc.t4</groupId>
+ <artifactId>jdbcT4</artifactId>
<version>${jdbct4.version}</version>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1ca6f608/core/sql/lib_mgmt/Makefile
----------------------------------------------------------------------
diff --git a/core/sql/lib_mgmt/Makefile b/core/sql/lib_mgmt/Makefile
index 3ae8c42..98ff9b6 100644
--- a/core/sql/lib_mgmt/Makefile
+++ b/core/sql/lib_mgmt/Makefile
@@ -23,13 +23,13 @@ INSTALL_LIBDIR := ${MY_SQROOT}/export/lib
INSTALL_SCRIPTSDIR := ${MY_SQROOT}/sql/scripts
CP :=/bin/cp -f
all:
- @$(MAVEN) package
+ @$(MAVEN) package -DskipTests
mkdir -p ${INSTALL_LIBDIR}
${CP} target/lib_mgmt-*.jar ${INSTALL_LIBDIR}/lib_mgmt.jar
${CP} src/main/resources/init_libmgmt.sh ${INSTALL_SCRIPTSDIR}/
@chmod +x ${INSTALL_SCRIPTSDIR}/init_libmgmt.sh
clean:
- @rm ${INSTALL_LIBDIR}/lib_mgmt.jar
+ @rm -f ${INSTALL_LIBDIR}/lib_mgmt.jar
@rm -f ${INSTALL_SCRIPTSDIR}/init_libmgmt.sh
@$(MAVEN) clean
cleanall: clean
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1ca6f608/dcs/pom.xml
----------------------------------------------------------------------
diff --git a/dcs/pom.xml b/dcs/pom.xml
index a575b3b..a1de49b 100644
--- a/dcs/pom.xml
+++ b/dcs/pom.xml
@@ -674,9 +674,9 @@
<dependencies>
<!-- JDBCT4 dependencies -->
<dependency>
- <groupId>org.trafodion.jdbc.t4.T4Driver</groupId>
- <artifactId>t4driver</artifactId>
- <version>${jdbct4.version}</version>
+ <groupId>org.trafodion.jdbc.t4</groupId>
+ <artifactId>jdbcT4</artifactId>
+ <version>${jdbct4.version}</version>
</dependency>
<!-- JDBCT2 dependencies -->
<dependency>
[10/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4DatabaseMetaData.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4DatabaseMetaData.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4DatabaseMetaData.java
deleted file mode 100644
index d3b916d..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4DatabaseMetaData.java
+++ /dev/null
@@ -1,5901 +0,0 @@
-// @@@ 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.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
-import java.sql.RowIdLifetime;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-/**
- * <p>
- * JDBC Type 4 driver DataBaseMetaData class.
- * </p>
- * Comprehensive information about the database and Type 4 driver as
- * a whole. This class lets applications users know the capabilities of database
- * in combination with the Type 4 driver. Information returned
- * by methods in this class applies to the capabilities of a Type 4 driver and
- * Database working together. A user for this class is commonly a
- * tool that needs to discover how to deal with the underlying
- * Database. This is especially true for applications that are intended to be
- * used with more than one DBMS. For example, a tool might use the method
- * <code>getTypeInfo</code> to find out what data types can be used in a
- * CREATE TABLE statement. Or a user might call the method
- * <code>supportsCorrelatedSubqueries</code> to see if it is possible to use a
- * correlated subquery or <code>supportsBatchUpdates</code> to see if it is
- * possible to use batch updates. Some DatabaseMetaData methods return lists of
- * information in the form of ResultSet objects. Regular ResultSet methods, such
- * as getString and getInt, can be used to retrieve the data from these
- * ResultSet objects. If a given form of metadata is not available, the
- * ResultSet getter methods throw an SQLException. Some DatabaseMetaData methods
- * take arguments that are String patterns. These arguments all have names such
- * as fooPattern. Within a pattern String, "%" means match any substring of 0 or
- * more characters, and "_" means match any one character. Only metadata entries
- * matching the search pattern are returned. If a search pattern argument is set
- * to null, that argument's criterion will be dropped from the search. A method
- * that gets information about a feature that the Type 4 driver does not support
- * will throw an SQLException. In the case of methods that return a ResultSet
- * object, either a ResultSet object (which might be empty) is returned, or an
- * SQLException is thrown.
- *
- * <p>
- * Description: JDBC Type 4 Driver
- * </p>
- * <p>
- * </p>
- */
-public class T4DatabaseMetaData extends HPT4Handle implements java.sql.DatabaseMetaData {
-
- // ----------------------------------------------------------------------
- // First, a variety of minor information about the target database.
-
- /*
- * Can all the procedures returned by getProcedures be called by the current
- * user?
- *
- * @return true if so
- */
- public boolean allProceduresAreCallable() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "allProceduresAreCallable", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("allProceduresAreCallable");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Can all the tables returned by getTable be SELECTed by the current user?
- *
- * @return true if so
- */
- public boolean allTablesAreSelectable() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "allTablesAreSelectable", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("allTablesAreSelectable");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * What's the url for this database?
- *
- * @return the url or null if it can't be generated * "TCP:<hostname>:<portnumber>/JDBC"
- * is good enough.
- */
- public String getURL() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getURL", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getURL");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return connection_.getT4Properties().getUrl();
- }
-
- /*
- * What's our user name as known to the database?
- *
- * @return our database user name *
- *
- */
- public String getUserName() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getUserName", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getUserName");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return connection_.getServerHandle().getUid();
- }
-
- /*
- * Is the database in read-only mode?
- *
- * @return true if so *
- *
- */
- public boolean isReadOnly() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "isReadOnly", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("isReadOnly");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Are NULL values sorted high?
- *
- * @return true if so
- *
- */
- public boolean nullsAreSortedHigh() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "nullsAreSortedHigh", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("nullsAreSortedHigh");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Are NULL values sorted low?
- *
- * @return true if so
- */
- public boolean nullsAreSortedLow() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "nullsAreSortedLow", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("nullsAreSortedLow");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Are NULL values sorted at the start regardless of sort order?
- *
- * @return true if so
- */
- public boolean nullsAreSortedAtStart() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "nullsAreSortedAtStart", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("nullsAreSortedAtStart");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Are NULL values sorted at the end regardless of sort order?
- *
- * @return true if so
- */
- public boolean nullsAreSortedAtEnd() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "nullsAreSortedAtEnd", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("nullsAreSortedAtEnd");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * What's the name of this database product?
- *
- * @return database product name
- */
- public String getDatabaseProductName() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDatabaseProductName", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getDatabaseProductName");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return new String("Trafodion");
- }
-
- /*
- * What's the version of this database product?
- *
- * @return database version *
- *
- */
- public String getDatabaseProductVersion() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDatabaseProductVersion", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getDatabaseProductVersion");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return new String("" + getDatabaseMajorVersion() + "." + getDatabaseMinorVersion());
- }
-
- /*
- * What's the name of this JDBC driver?
- *
- * @return JDBC driver name
- */
- public String getDriverName() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDriverName", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getDriverName");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return new String("org.trafodion.jdbc.t4.T4Driver");
- }
-
- /*
- * What's the version of this JDBC driver?
- *
- * @return JDBC driver version
- */
- public String getDriverVersion() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDriverVersion", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getDriverVersion");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return Vproc.getVproc();
- }
-
- /*
- * What's this JDBC driver's major version number?
- *
- * @return JDBC driver major version
- */
- public int getDriverMajorVersion() {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDriverMajorVersion", "", p);
- }
- try {
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getDriverMajorVersion");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- } catch (SQLException se) {
- // ignore
- }
- return Vproc.jdbcMajorVersion;
- }
-
- /*
- * What's this JDBC driver's minor version number?
- *
- * @return JDBC driver minor version number
- */
- public int getDriverMinorVersion() {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getDriverMinorVersion", "", p);
- }
- try {
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getDriverMinorVersion");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- } catch (SQLException se) {
- // ignore
- }
- return Vproc.jdbcMinorVersion;
- }
-
- /*
- * Does the database store tables in a local file?
- *
- * @return true if so
- */
- public boolean usesLocalFiles() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "usesLocalFiles", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("usesLocalFiles");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Does the database use a file for each table?
- *
- * @return true if the database uses a local file for each table
- */
- public boolean usesLocalFilePerTable() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "usesLocalFilePerTable", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("usesLocalFilePerTable");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Database does not treat the mixed case unquoted SQL
- * identifiers as case sensitive and does not store the result in mixed
- * case.
- *
- * @return false always for the Type 4 driver.
- */
- public boolean supportsMixedCaseIdentifiers() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_
- .logp(Level.FINE, "T4DatabaseMetaData", "supportsMixedCaseIdentifiers", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsMixedCaseIdentifiers");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Database treat mixed case unquoted SQL identifiers as case
- * insensitive and store them in upper case.
- * @return true always for the Type 4 driver.
- */
- public boolean storesUpperCaseIdentifiers() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "storesUpperCaseIdentifiers", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("storesUpperCaseIdentifiers");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Does the database treat mixed case unquoted SQL identifiers as case
- * insensitive and store them in lower case?
- *
- * @return true if so
- */
- public boolean storesLowerCaseIdentifiers() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "storesLowerCaseIdentifiers", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("storesLowerCaseIdentifiers");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Does the database treat mixed case unquoted SQL identifiers as case
- * insensitive and store them in mixed case?
- *
- * @return true if so
- */
- public boolean storesMixedCaseIdentifiers() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "storesMixedCaseIdentifiers", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("storesMixedCaseIdentifiers");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Database treat mixed case quoted SQL identifiers as case
- * sensitive and as a result store them in mixed case.
- * A JDBC-Compliant driver will always return false.
- *
- * @return true always true for the Type 4 drive.
- */
- public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsMixedCaseQuotedIdentifiers",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsMixedCaseQuotedIdentifiers");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Does the database treat mixed case quoted SQL identifiers as case
- * insensitive and store them in upper case?
- *
- * @return true if so
- */
- public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "storesUpperCaseQuotedIdentifiers",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("storesUpperCaseQuotedIdentifiers");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Does the database treat mixed case quoted SQL identifiers as case
- * insensitive and store them in lower case?
- *
- * @return true if so
- */
- public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "storesLowerCaseQuotedIdentifiers",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("storesLowerCaseQuotedIdentifiers");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Does the database treat mixed case quoted SQL identifiers as case
- * insensitive and store them in mixed case?
- *
- * @return true if so
- */
- public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", " storesMixedCaseQuotedIdentifiers",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName(" storesMixedCaseQuotedIdentifiers");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Database uses the " string to quote SQL identifiers. This call
- * returns a space " " if identifier quoting isn't supported.
- * A JDBC-Compliant driver always uses a double quote character.
- *
- * @return the quoting string ".
- */
- public String getIdentifierQuoteString() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getIdentifierQuoteString", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getIdentifierQuoteString");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return new String("\"");
- }
-
- /*
- * Get a comma separated list of all a database's SQL keywords that are NOT
- * also SQL92 keywords.
- *
- * @return the list *
- *
- */
- public String getSQLKeywords() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getSQLKeywords", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getSQLKeywords");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return "DATETIME,FRACTION,PROTOTYPE,SQL_CHAR,SQL_DATE,SQL_DECIMAL,SQL_DOUBLE,SQL_FLOAT"
- + ",SQL_INT,SQL_INTEGER,SQL_REAL,SQL_SMALLINT,SQL_TIME,SQL_TIMESTAMP,SQL_VARCHAR"
- + ",TRANSPOSE,UPSHIFT";
- }
-
- /*
- * Get a comma separated list of math functions.
- *
- * @return the list *
- *
- */
- public String getNumericFunctions() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getNumericFunctions", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getNumericFunctions");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return new String(
- "ABS,ACOS,ASIN,ATAN,ATAN2,CEILING,COS,COSH,DEGREES,EXP,FLOOR,LOG,LOG10,MOD,PI,POWER,RADIANS,RAND"
- + "SIGN,SIN,SINH,SORT,TAN,TANH");
- }
-
- /*
- * Get a comma separated list of string functions.
- *
- * @return the list *
- *
- */
- public String getStringFunctions() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getStringFunctions", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getStringFunctions");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return new String("ASCII,CHAR,CHAR_LENGTH,CONCAT,INSERT,LCASE,LEFT,LOCATE,LOWER,LPAD,LTRIM,OCTET_LENGTH"
- + "POSITION,REPEAT,REPLACE,RIGHT,RPAD,RTRIM,SPACE,SUBSTRING,TRIM,UCASE,UPPER,UPSHIFT");
- }
-
- /*
- * Get a comma separated list of system functions.
- *
- * @return the list *
- *
- */
- public String getSystemFunctions() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getSystemFunctions", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getSystemFunctions");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return new String("CURRENT_USER,USER");
- }
-
- /*
- * Get a comma separated list of time and date functions.
- *
- * @return the list *
- *
- */
- public String getTimeDateFunctions() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getTimeDateFunctions", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getTimeDateFunctions");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- return new String("CONVERTTIMESTAMP,CURRENT,CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP"
- + "DATEFORMAT,DAY,DAYNAME,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,EXTRACT,HOUR,JULIANTIMESTAMP,MINUTE"
- + "MONTH,MONTHNAME,QUARTER,SECOND,WEEK,YEAR");
- }
-
- /*
- * This is the string that can be used to escape '_' or '%' in the string
- * pattern style catalog search parameters.
- *
- * <P>The '_' character represents any single character. <P>The '%'
- * character represents any sequence of zero or more characters. @return the
- * string used to escape wildcard characters *
- *
- */
- public String getSearchStringEscape() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getSearchStringEscape", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getSearchStringEscape");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return new String("\\");
- }
-
- /*
- * Get all the "extra" characters that can be used in unquoted identifier
- * names (those beyond a-z, A-Z, 0-9 and _).
- *
- * @return the string containing the extra characters
- */
- public String getExtraNameCharacters() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getExtraNameCharacters", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getExtraNameCharacters");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return null;
- }
-
- // --------------------------------------------------------------------
- // Functions describing which features are supported.
-
- /*
- * Is "ALTER TABLE" with add column supported?
- *
- * @return true if so
- */
- public boolean supportsAlterTableWithAddColumn() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsAlterTableWithAddColumn",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsAlterTableWithAddColumn");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Is "ALTER TABLE" with drop column supported?
- *
- * @return true if so
- */
- public boolean supportsAlterTableWithDropColumn() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsAlterTableWithDropColumn",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsAlterTableWithDropColumn");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Is column aliasing supported?
- *
- * <P>If so, the SQL AS clause can be used to provide names for computed
- * columns or to provide alias names for columns as required.
- *
- * A JDBC-Compliant driver always returns true.
- *
- * @return true if so
- */
- public boolean supportsColumnAliasing() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsColumnAliasing", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsColumnAliasing");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Database concatenations between NULL and non-NULL values is
- * NULL.
- *
- * A JDBC-Compliant driver always returns true.
- *
- * @return true always for the Type 4 driver.
- */
- public boolean nullPlusNonNullIsNull() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "nullPlusNonNullIsNull", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("nullPlusNonNullIsNull");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Is the CONVERT function between SQL types supported?
- *
- * @return true if so
- */
- public boolean supportsConvert() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsConvert", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsConvert");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Is CONVERT between the given SQL types supported?
- *
- * @param fromType the type to convert from @param toType the type to
- * convert to @return true if so
- *
- * @see Types
- */
- public boolean supportsConvert(int fromType, int toType) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, fromType, toType);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsConvert", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, fromType, toType);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsConvert");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- switch (fromType) {
- case Types.BIGINT:
- case Types.DECIMAL:
- case Types.DOUBLE:
- case Types.FLOAT:
- case Types.INTEGER:
- case Types.NUMERIC:
- case Types.REAL:
- case Types.SMALLINT:
- switch (toType) {
- case Types.CHAR:
- case Types.NUMERIC:
- case Types.DECIMAL:
- case Types.INTEGER:
- case Types.SMALLINT:
- case Types.FLOAT:
- case Types.REAL:
- case Types.DOUBLE:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.BIGINT:
- return true;
- default:
- return false;
- }
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- switch (toType) {
- case Types.CHAR:
- case Types.NUMERIC:
- case Types.DECIMAL:
- case Types.INTEGER:
- case Types.SMALLINT:
- case Types.FLOAT:
- case Types.REAL:
- case Types.DOUBLE:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.BIGINT:
- case Types.DATE:
- case Types.TIME:
- case Types.TIMESTAMP:
- return true;
- default:
- return false;
- }
- case Types.DATE:
- switch (toType) {
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.DATE:
- case Types.TIMESTAMP:
- return true;
- default:
- return false;
- }
- case Types.TIME:
- switch (toType) {
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.TIME:
- case Types.TIMESTAMP:
- return true;
- default:
- return false;
- }
- case Types.TIMESTAMP:
- switch (toType) {
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.DATE:
- case Types.TIME:
- case Types.TIMESTAMP:
- return true;
- default:
- return false;
- }
- case Types.BIT:
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.LONGVARBINARY:
- case Types.TINYINT:
- return false;
- default:
- return false;
- }
- }
-
- /*
- * Type 4 driver supports table correlation names. Type 4 driver always
- * returns true.
- *
- * @return true for Type 4 driver
- */
- public boolean supportsTableCorrelationNames() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsTableCorrelationNames", "",
- p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsTableCorrelationNames");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Database table correlation names are supported, and they are
- * not restricted to be different from the names of the Database
- * tables.
- *
- * @return false always for Type 4 driver.
- */
- public boolean supportsDifferentTableCorrelationNames() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData",
- "supportsDifferentTableCorrelationNames", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsDifferentTableCorrelationNames");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * SQL expressions in "ORDER BY" lists are not supported by the
- * Database and Type 4 driver.
- *
- * @return false always for Type 4 driver.
- */
- public boolean supportsExpressionsInOrderBy() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_
- .logp(Level.FINE, "T4DatabaseMetaData", "supportsExpressionsInOrderBy", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsExpressionsInOrderBy");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Can an "ORDER BY" clause use columns not in the SELECT?
- *
- * @return true if so
- */
- public boolean supportsOrderByUnrelated() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsOrderByUnrelated", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsOrderByUnrelated");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Is some form of "GROUP BY" clause supported?
- *
- * @return true if so
- */
- public boolean supportsGroupBy() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsGroupBy", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsGroupBy");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Can a "GROUP BY" clause use columns not in the SELECT?
- *
- * @return true if so
- */
- public boolean supportsGroupByUnrelated() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsGroupByUnrelated", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsGroupByUnrelated");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Can a "GROUP BY" clause add columns not in the SELECT provided it
- * specifies all the columns in the SELECT?
- *
- * @return true if so
- */
- public boolean supportsGroupByBeyondSelect() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsGroupByBeyondSelect", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsGroupByBeyondSelect");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Database supports escape character in "LIKE" clauses.
- * A JDBC-Compliant driver always returns true.
- *
- * @return true always true for the Type 4 driver.
- */
- public boolean supportsLikeEscapeClause() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsLikeEscapeClause", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsLikeEscapeClause");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Are multiple ResultSets from a single execute supported?
- *
- * @return true if so
- */
- public boolean supportsMultipleResultSets() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsMultipleResultSets", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsMultipleResultSets");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Can we have multiple transactions open at once (on different
- * connections)?
- *
- * @return true if so
- */
- public boolean supportsMultipleTransactions() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_
- .logp(Level.FINE, "T4DatabaseMetaData", "supportsMultipleTransactions", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsMultipleTransactions");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- // Need to change it 'true' once Database fixes this problem
- return false;
- }
-
- /*
- * Database table columns can be defined as non-nullable.
- * @return true always for the Type 4 driver.
- */
- public boolean supportsNonNullableColumns() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsNonNullableColumns", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsNonNullableColumns");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Type 4 driver supports the ODBC Minimum SQL grammar.
- *
- * All JDBC-Compliant drivers must return true.
- *
- * @return true always for the Type 4 driver.
- */
- public boolean supportsMinimumSQLGrammar() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsMinimumSQLGrammar", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsMinimumSQLGrammar");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Is the ODBC Core SQL grammar supported?
- *
- * @return true if so
- */
- public boolean supportsCoreSQLGrammar() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsCoreSQLGrammar", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsCoreSQLGrammar");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Is the ODBC Extended SQL grammar supported?
- *
- * @return true if so
- */
- public boolean supportsExtendedSQLGrammar() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsExtendedSQLGrammar", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsExtendedSQLGrammar");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Database supports the ANSI92 entry level SQL grammar.
- * All JDBC-Compliant drivers must return true.
- *
- * @return true always for the Type 4 driver.
- */
- public boolean supportsANSI92EntryLevelSQL() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsANSI92EntryLevelSQL", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsANSI92EntryLevelSQL");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Is the ANSI92 intermediate SQL grammar supported?
- *
- * @return true if so
- */
- public boolean supportsANSI92IntermediateSQL() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsANSI92IntermediateSQL", "",
- p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsANSI92IntermediateSQL");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Is the ANSI92 full SQL grammar supported?
- *
- * @return true if so
- */
- public boolean supportsANSI92FullSQL() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsANSI92FullSQL", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsANSI92FullSQL");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Is the SQL Integrity Enhancement Facility supported?
- *
- * @return true if so
- */
- public boolean supportsIntegrityEnhancementFacility() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData",
- "supportsIntegrityEnhancementFacility", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsIntegrityEnhancementFacility");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Is some form of outer join supported?
- *
- * @return true if so
- */
- public boolean supportsOuterJoins() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsOuterJoins", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsOuterJoins");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Are full nested outer joins supported?
- *
- * @return true if so
- */
- public boolean supportsFullOuterJoins() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsFullOuterJoins", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsFullOuterJoins");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Database provides the limited support for outer joins. This
- * will be true if supportFullOuterJoins is true.
- * @return true always for the Type 4 driver.
- */
- public boolean supportsLimitedOuterJoins() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsLimitedOuterJoins", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsLimitedOuterJoins");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * What's the database vendor's preferred term for "schema"?
- *
- * @return the vendor term
- */
- public String getSchemaTerm() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getSchemaTerm", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getSchemaTerm");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return new String("SCHEMA");
- }
-
- /*
- * What's the database vendor's preferred term for "procedure"?
- *
- * @return the vendor term
- */
- public String getProcedureTerm() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getProcedureTerm", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getProcedureTerm");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return new String("PROCEDURE");
- }
-
- /*
- * What's the database vendor's preferred term for "catalog"?
- *
- * @return the vendor term
- */
- public String getCatalogTerm() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getCatalogTerm", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getCatalogTerm");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return new String("CATALOG");
- }
-
- /*
- * Database catalog name appear at the start of a qualified table
- * name. (Otherwise it appears at the end)
- * @return true always for the Type 4 driver.
- */
- public boolean isCatalogAtStart() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "isCatalogAtStart", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("isCatalogAtStart");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * What's the separator between catalog and table name?
- *
- * @return the separator string
- */
- public String getCatalogSeparator() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "getCatalogSeparator", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("getCatalogSeparator");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return new String(".");
- }
-
- /*
- * Can a schema name be used in a data manipulation statement?
- *
- * @return true if so
- */
- public boolean supportsSchemasInDataManipulation() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSchemasInDataManipulation",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsSchemasInDataManipulation");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Can a schema name be used in a procedure call statement?
- *
- * @return true if so
- */
- public boolean supportsSchemasInProcedureCalls() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSchemasInProcedureCalls",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsSchemasInProcedureCalls");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Can a schema name be used in a table definition statement?
- *
- * @return true if so
- */
- public boolean supportsSchemasInTableDefinitions() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSchemasInTableDefinitions",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsSchemasInTableDefinitions");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Can a schema name be used in an index definition statement?
- *
- * @return true if so
- */
- public boolean supportsSchemasInIndexDefinitions() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSchemasInIndexDefinitions",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsSchemasInIndexDefinitions");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Can a schema name be used in a privilege definition statement?
- *
- * @return true if so
- */
- public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData",
- "supportsSchemasInPrivilegeDefinitions", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsSchemasInPrivilegeDefinitions");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Can a catalog name be used in a data manipulation statement?
- *
- * @return true if so
- */
- public boolean supportsCatalogsInDataManipulation() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsCatalogsInDataManipulation",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsCatalogsInDataManipulation");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Can a catalog name be used in a procedure call statement?
- *
- * @return true if so
- */
- public boolean supportsCatalogsInProcedureCalls() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsCatalogsInProcedureCalls",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsCatalogsInProcedureCalls");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Can a catalog name be used in a table definition statement?
- *
- * @return true if so
- */
- public boolean supportsCatalogsInTableDefinitions() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsCatalogsInTableDefinitions",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsCatalogsInTableDefinitions");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Can a catalog name be used in an index definition statement?
- *
- * @return true if so
- */
- public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsCatalogsInIndexDefinitions",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsCatalogsInIndexDefinitions");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Can a catalog name be used in a privilege definition statement?
- *
- * @return true if so
- */
- public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData",
- "supportsCatalogsInPrivilegeDefinitions", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsCatalogsInPrivilegeDefinitions");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Is positioned DELETE supported?
- *
- * @return true if so
- */
- public boolean supportsPositionedDelete() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsPositionedDelete", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsPositionedDelete");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Database supports positioned UPDATE supported through the Type
- * 4 driver.
- * @return true always for the Type 4 driver.
- */
- public boolean supportsPositionedUpdate() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsPositionedUpdate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsPositionedUpdate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Database supports SELECT for UPDATE through the Type 4 driver.
- * @return true always for the Type 4 driver.
- */
- public boolean supportsSelectForUpdate() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSelectForUpdate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsSelectForUpdate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * stored procedure calls using the stored procedure escape syntax
- * are supported.
- *
- * @return true always for the Type 4 driver.
- */
- public boolean supportsStoredProcedures() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsStoredProcedures", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsStoredProcedures");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Trafodion Database Database subqueries in comparison expressions are supported
- * through the Type 4 driver.
- * @return true always for the Type 4 driver.
- */
- public boolean supportsSubqueriesInComparisons() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSubqueriesInComparisons",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsSubqueriesInComparisons");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Trafodion Database supports subqueries in 'exists' expressions through
- * Type 4 driver.
- * @return true always for the Type 4 driver.
- */
- public boolean supportsSubqueriesInExists() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSubqueriesInExists", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsSubqueriesInExists");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Trafodion Database supports subqueries in 'in' statements through the
- * Type 4 driver.
- * @return true always for the Type 4 driver.
- */
- public boolean supportsSubqueriesInIns() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSubqueriesInIns", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsSubqueriesInIns");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * The subqueries in quantified expressions supported in Trafodion Database
- * and Type 4 driver.
- * @return true always for Type 4 driver.
- */
- public boolean supportsSubqueriesInQuantifieds() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsSubqueriesInQuantifieds",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsSubqueriesInQuantifieds");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Trafodion Database supports correlated subqueries.
- * A JDBC-Compliant driver always returns true.
- *
- * @return true always for the Type 4 driver.
- */
- public boolean supportsCorrelatedSubqueries() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_
- .logp(Level.FINE, "T4DatabaseMetaData", "supportsCorrelatedSubqueries", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsCorrelatedSubqueries");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Is SQL UNION supported?
- *
- * @return true if so
- */
- public boolean supportsUnion() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsUnion", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsUnion");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Is SQL UNION ALL supported?
- *
- * @return true if so
- */
- public boolean supportsUnionAll() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsUnionAll", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsUnionAll");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Can cursors remain open across commits?
- *
- * @return true if cursors always remain open; false if they might not
- * remain open
- */
- public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsOpenCursorsAcrossCommit",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsOpenCursorsAcrossCommit");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Can cursors remain open across rollbacks?
- *
- * @return true if cursors always remain open; false if they might not
- * remain open
- */
- public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsOpenCursorsAcrossRollback",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsOpenCursorsAcrossRollback");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return false;
- }
-
- /*
- * Can statements remain open across commits?
- *
- * @return true if statements always remain open; false if they might not
- * remain open
- */
- public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData", "supportsOpenStatementsAcrossCommit",
- "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsOpenStatementsAcrossCommit");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- /*
- * Can statements remain open across rollbacks?
- *
- * @return true if statements always remain open; false if they might not
- * remain open
- */
- public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "T4DatabaseMetaData",
- "supportsOpenStatementsAcrossRollback", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("T4DatabaseMetaData");
- lr.setSourceMethodName("supportsOpenStatementsAcrossRollback");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return true;
- }
-
- // ---------------------------------------------------------
<TRUNCATED>
[29/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DSProperties.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DSProperties.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DSProperties.java
new file mode 100644
index 0000000..a44d0f3
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DSProperties.java
@@ -0,0 +1,967 @@
+// @@@ 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;
+import java.util.Properties;
+import java.util.logging.Level;
+
+/**
+ * <p>
+ * JDBC Type 4 driver data source connetion properties class.
+ * </p>
+ * <p>
+ * Description: The <code>T4DSProperties</code> class contains all the
+ * properties associated with Type 4 data source connection.
+ * <code>T4DSProperties</code> is inherited by the <code>HPT4DataSource,
+ * HPT4ConnectionPooledDataSource</code>
+ * classes for configuring Type 4 connection properties.
+ * <p>
+ * The properties passed to the Type 4 driver have this precedence order in
+ * event of the values set through more than one option:
+ * </p>
+ * <blockquote>
+ * <p>
+ * 1. java.util.properties parameter in the
+ * <code>DriverManager.getConnection</code> call or through
+ * <code>DataSource.setXXX()</code> call.
+ * </p>
+ * <p>
+ * 2. <code>java.util.properties</code> file properties set through
+ * <code>-Dt4jdbc.properties</code> option.
+ * </p>
+ * <p>
+ * 3. Command line properties using -D option. All the system properties passed
+ * through the command-line option have to be prefixed with
+ * <code>t4jdbc</code>, to distinguish JDBC Type 4 driver properties
+ * from other system properties. For example: property <code>user</code> when
+ * specified with -D has to be qualified as
+ * <code>-Dt4jdbc.user=super.super</code>.
+ * </p>
+ * </blockquote>
+ * <p>
+ * Copyright: (C) Apache Software Foundation (ASF)
+ * </p>
+ *
+ */
+public class T4DSProperties extends T4Properties {
+
+ public T4DSProperties() {
+ super();
+ }
+
+ public T4DSProperties(Properties props) {
+ super(props);
+ }
+
+ /**
+ * Sets the description for the current Type 4 connection.
+ *
+ * @param description
+ * For the current Type 4 connection.
+ * @see #getDescription()
+ */
+ public void setDescription(String description) {
+ super.setDescription(description);
+ }
+
+ /**
+ * Returns the description associated with the current Type 4 connection.
+ *
+ * @return The description associated with the current Type 4 connection.
+ * @see #setDescription(String)
+ */
+ public String getDescription() {
+ return super.getDescription();
+ }
+
+ /**
+ * Sets the data source name for the current Type 4 connection.
+ *
+ * @param dataSourceName
+ * For the client side <code>DataSource</code> object.
+ * @see #getDataSourceName()
+ */
+ public void setDataSourceName(String dataSourceName) {
+ super.setDataSourceName(dataSourceName);
+ }
+
+ /**
+ * Returns the client's data source name.
+ *
+ * @return data source name.
+ * @see #setDataSourceName(String)
+ */
+ public String getDataSourceName() {
+ return super.getDataSourceName();
+ }
+
+ /**
+ * Sets the NDCS server data source name. The NDCS server data source is
+ * defined by NDCS on the server.
+ *
+ * @param serverDataSource
+ * the NDCS data source name to use on the NDCS server side. The
+ * default value is an empty string.
+ * @see #getServerDataSourceName()
+ */
+ public void setServerDataSource(String serverDataSource) {
+ super.setServerDataSource(serverDataSource);
+ }
+
+ /**
+ * Returns the NDCS server-side data source name used for the current Type 4
+ * connection.
+ *
+ * @return NDCS server-side data source name.
+ * @see #setServerDataSource(String)
+ */
+ public String getServerDataSource() {
+ return super.getServerDataSource();
+ }
+
+ /**
+ * Sets the default catalog that will be used to access SQL objects
+ * referenced in SQL statements if the SQL objects are not fully qualified.
+ *
+ * @param catalog
+ * Database catalog name. The default catalog name is
+ * set by the DCS server-side data source.
+ * @see #getCatalog()
+ */
+ public void setCatalog(String catalog) {
+ super.setCatalog(catalog);
+ }
+
+ /**
+ * Gets the default catalog that will be used to access SQL objects
+ * referenced in SQL statements if the SQL objects are not fully qualified.
+ *
+ * @return HPT4 catalog name.
+ * @see #setCatalog(String)
+ */
+ public String getCatalog() {
+ return super.getCatalog();
+ }
+
+ /**
+ * Sets the default schema that will be used to access SQL objects
+ * referenced in SQL statements if the SQL objects are not fully qualified.
+ *
+ * @param schema
+ * Database schema name. The default schema name is
+ * set by the DCS server side data source.
+ * @see #getSchema()
+ */
+ public void setSchema(String schema) {
+ super.setSchema(schema);
+ }
+
+ /**
+ * Gets the default schema that will be used to access SQL objects
+ * referenced in SQL statements if the SQL objects are not fully qualified.
+ *
+ * @return The schema associated with the current Type 4 connection.
+ * @see #setSchema(String)
+ */
+ public String getSchema() {
+ return super.getSchema();
+ }
+
+ /**
+ * Configure the Type 4 connection to continue batch processing of next
+ * commands even after errors. Default value is true.
+ *
+ * @param batchRecovery
+ */
+ void setBatchRecovery(String batchRecovery) {
+ boolean boolBatchRecovery = true;
+ if (batchRecovery != null) {
+ if (batchRecovery.equalsIgnoreCase("false")) {
+ boolBatchRecovery = false;
+ }
+ }
+ setBatchRecovery(boolBatchRecovery);
+ }
+
+ /**
+ * Configure the Type 4 connection to continue batch processing of next
+ * commands even after errors. Default value is true.
+ *
+ * @param batchRecovery
+ */
+ void setBatchRecovery(boolean batchRecovery) {
+ super.setBatchRecovery(batchRecovery);
+ }
+
+ /**
+ * Return whether the Type 4 connection is configured to continue batch
+ * processing of next commands even after errors.
+ *
+ * @return batchRecovery
+ */
+ boolean getBatchRecovery() {
+ return super.getBatchRecovery();
+ }
+
+ /**
+ * Returns the <code>java.util.Locale</code> object associated with the
+ * current Type 4 connection.
+ *
+ * @return <code>java.util.Locale</code> object.
+ */
+ public Locale getLocale() {
+ return super.getLocale();
+ }
+
+ /**
+ * The maximum number of physical connections that the pool (free and
+ * in-use) should contain. When the maximum number of physical connections
+ * is reached, the Type 4 driver throws an <code>SQLException
+ * </code> with
+ * the message "Maximum pool size reached." Specifying a value of 0 (zero)
+ * indicates there is no maximum size for the pool. Specifying a value of -1
+ * indicates no connection pooling is performed. The default value is -1,
+ * indicating that no pooling of physical connections is done.
+ *
+ * @param maxPoolSize
+ * the maximum number of physical connections the pool should
+ * contain (free and in use).
+ * @see #getMaxPoolSize()
+ * @see #setMaxPoolSize(int)
+ */
+ public void setMaxPoolSize(String maxPoolSize) {
+ super.setMaxPoolSize(maxPoolSize);
+ }
+
+ /**
+ * The maximum number of physical connections that the pool (free and
+ * in-use) should contain. When the maximum number of physical connections
+ * is reached, the Type 4 driver throws an <code>SQLException
+ * </code> with
+ * the message "Maximum pool size reached." Specifying a value of 0 (zero)
+ * indicates there is no maximum size for the pool. Specifying a value of -1
+ * indicates no connection pooling is performed. The default value is -1,
+ * indicating that no pooling of physical connections is done.
+ *
+ * @param maxPoolSize
+ * the maximum number of physical connections the pool should
+ * contain (free and in use).
+ * @see #getMaxPoolSize()
+ * @see #setMaxPoolSize(String)
+ */
+
+ public void setMaxPoolSize(int maxPoolSize) {
+ super.setMaxPoolSize(maxPoolSize);
+ }
+
+ /**
+ * Returns the maximum number of physical connections that the pool (free
+ * and inuse) should contain. A value of zero (0) indicates no maximum size.
+ * A value of -1 indicates that connection pooling is not being done.
+ *
+ * @return the maximum number of physical connections that the pool should
+ * contain.
+ * @see #setMaxPoolSize(int)
+ */
+ public int getMaxPoolSize() {
+ return super.getMaxPoolSize();
+ }
+
+ /**
+ * Sets the number of physical connections the pool should keep available at
+ * all times.
+ *
+ * @param minPoolSize
+ * Limits the number of physical connection that can be in the
+ * free pool. When the number of physical connections in the free
+ * pool reaches the value of minPoolSize, subsequent connections
+ * that are closed are physically closed and are not added to the
+ * free pool. Specifying a value of 0 means that the value of
+ * minPoolSize is the same as the value of maxPoolSize. If the
+ * value of maxPoolSize is -1, the value of minPoolSize is
+ * ignored. The default value is 0. For this data source, it is
+ * recommended that you use the default value.
+ * @see #getMinPoolSize()
+ * @see #setMinPoolSize(int minPoolSize)
+ */
+ public void setMinPoolSize(String minPoolSize) {
+ super.setMinPoolSize(minPoolSize);
+ }
+
+ /**
+ * Sets the number of physical connections the pool should keep available at
+ * all times.
+ *
+ * @param minPoolSize
+ * Limits the number of physical connection that can be in the
+ * free pool. When the number of physical connections in the free
+ * pool reaches the value of minPoolSize, subsequent connections
+ * that are closed are physically closed and are not added to the
+ * free pool. Specifying a value of 0 means that the value of
+ * minPoolSize is the same as the value of maxPoolSize. If the
+ * value of maxPoolSize is -1, the value of minPoolSize is
+ * ignored. The default value is 0. For this data source, it is
+ * recommended that you use the default value.
+ * @see #getMinPoolSize()
+ * @see #setMinPoolSize(String minPoolSize)
+ */
+ public void setMinPoolSize(int minPoolSize) {
+ super.setMinPoolSize(minPoolSize);
+ }
+
+ /**
+ * Returns the number of physical connections the pool should keep in the
+ * free pool. A value of 0 (zero) indicates that minPoolSize is equal to
+ * maxPoolsize. If maxPoolsize is equal to -1, the value of minPoolSize is
+ * ignored. The default value is 0.
+ *
+ * @return The number of physical connections the pool should maintain in
+ * the free pool.
+ * @see #setMinPoolSize(int)
+ * @see #setMaxPoolSize(int)
+ */
+ public int getMinPoolSize() {
+ return super.getMinPoolSize();
+ }
+
+ /**
+ * The initial number of physical connections that the pool should be
+ * created with. Specifying a value of 0 (zero) or less indicates that the
+ * pool should not be created with any initial connections. The default
+ * value is -1 indicating that no initial pool of physical connections is
+ * created. The value can be less than minPoolSize but must be less than or
+ * equal to the value of maxPoolSize. Specifying a value greater than
+ * maxPoolSize will set the initialPoolSize to the value of maxPoolSize.
+ *
+ * @param initialPoolSize
+ * the initial number of physical connections the pool should be
+ * created with.
+ * @see #setInitialPoolSize(int)
+ */
+ public void setInitialPoolSize(String initialPoolSize) {
+ super.setInitialPoolSize(initialPoolSize);
+ }
+
+ /**
+ * The initial number of physical connections that the pool should be
+ * created with. Specifying a value of 0 (zero) or less indicates that the
+ * pool should not be created with any initial connections. The default
+ * value is -1 indicating that no initial pool of physical connections is
+ * created. The value can be less than minPoolSize but must be less than or
+ * equal to the value of maxPoolSize. Specifying a value greater than
+ * maxPoolSize will set the initialPoolSize to the value of maxPoolSize.
+ *
+ * @param initialPoolSize
+ * the initial number of physical connections the pool should be
+ * created with.
+ * @see #setInitialPoolSize(String)
+ */
+ public void setInitialPoolSize(int initialPoolSize) {
+ super.setInitialPoolSize(initialPoolSize);
+ }
+
+ /**
+ * Returns the number of physical connections that the pool should be
+ * created with. A value of -1 indicates that the pool is not created with
+ * any initial connections.
+ *
+ * @return initialPoolSize the number of physical connections that the pool
+ * should be created with.
+ * @see #setInitialPoolSize(int)
+ */
+ public int getInitialPoolSize() {
+ return super.getInitialPoolSize();
+ }
+
+ /**
+ * Total number of statements that can be cached. A value of zero (0)
+ * indicates that caching of statements is disabled.
+ *
+ * @param maxStatements
+ * The number of statements that can be cached.
+ * @see #setMaxStatements(int)
+ */
+ public void setMaxStatements(String maxStatements) {
+ super.setMaxStatements(maxStatements);
+ }
+
+ /**
+ * Total number of statements that can be cached. A value of zero (0)
+ * indicates that caching of statements is disabled.
+ *
+ * @param maxStatements
+ * The number of statements that can be cached.
+ * @see #setMaxStatements(String)
+ */
+ public void setMaxStatements(int maxStatements) {
+ super.setMaxStatements(maxStatements);
+ }
+
+ /**
+ * Returns the total number of statements that can be cached. A value of
+ * zero (0) indicates that pooling of statements is disabled.
+ *
+ * @return The total number of statements that can be cached.
+ */
+ public int getMaxStatements() {
+ return super.getMaxStatements();
+ }
+
+ /**
+ * Returns the URL used in the current Type 4 connection. JDBC Type 4
+ * driver URL uses the format: <code>jdbc:t4jdbc://host:port/:</code>
+ *
+ * @deprecated Use the <code>getUrl()</code> to obtain the URL string.
+ * @return the URL string.
+ * @see #getUrl()
+ */
+ public String getURL() {
+ return getURL();
+ }
+
+ /**
+ * Sets the URL for the Type 4 connection. JDBC Type 4 driver URL uses
+ * the format: <code>jdbc:t4jdbc://host:port/:prop-name=value</code>.
+ * This validates the URL value and throws SQLException if the URL value is
+ * incorrect.
+ *
+ * @param url
+ * the URL.
+ * @see #getUrl()
+ */
+ public Properties setURL(String url) throws SQLException {
+ return super.setURL(url);
+ }
+
+ /**
+ * Returns the URL used in the current Type 4 connection. JDBC Type 4
+ * driver URL uses the format:
+ * <code>jdbc:t4jdbc://host:port/[:][prop-name=value][,prop-name=value]...</code>
+ *
+ * @return the URL string.
+ * @see #setUrl(String)
+ */
+ public String getUrl() {
+ return super.getUrl();
+ }
+
+ /**
+ * Sets the URL for the Type 4 connection. JDBC Type 4 driver URL uses
+ * the format:
+ * <code>jdbc:t4jdbc://host:port/[:][prop-name=value][,prop-name=value]...</code>
+ * This method does not validate the URL value.
+ *
+ * @param url
+ * the URL.
+ * @see #getUrl()
+ */
+ public void setUrl(String url) {
+ super.setUrl(url);
+ }
+
+ /**
+ * Sets the Safeguard user name to be used while connecting to NDCS server
+ * for authentication.
+ *
+ * @param user
+ * Sets the user for the current Type 4 connection.
+ * @see #getUser()
+ */
+ public void setUser(String user) {
+ super.setUser(user);
+ }
+
+ /**
+ * Returns the Safeguard user name associated with this Type 4 connection.
+ *
+ * @return The user name.
+ * @see #setUser(String)
+ */
+ public String getUser() {
+ return super.getUser();
+ }
+
+ /**
+ * Sets the Safeguard password to be used for authentication when connecting
+ * to the NDCS server.
+ *
+ * @param pwd
+ * The Safeguard password for the current Type 4 connection.
+ */
+ public void setPassword(String pwd) {
+ super.setPassword(pwd);
+ }
+
+ /**
+ * Sets the login timeout in seconds for the Type 4 connection. The default
+ * login timeout value is set to 60 seconds.
+ *
+ * @param loginTimeout
+ * The login timeout value in seconds.
+ * @see #setLoginTimeout(int)
+ * @see #getLoginTimeout()
+ */
+ public void setLoginTimeout(String loginTimeout) {
+ super.setLoginTimeout(loginTimeout);
+ }
+
+ /**
+ * Sets the login timeout in seconds for the Type 4 connection. The default
+ * login timeout value is set to 60 seconds.
+ *
+ * @param loginTimeout
+ * The login timeout value in seconds.
+ * @see #setLoginTimeout(String)
+ * @see #getLoginTimeout()
+ */
+ public void setLoginTimeout(int loginTimeout) {
+ super.setLoginTimeout(loginTimeout);
+ }
+
+ /**
+ * Returns the login timeout value set for the current Type 4 connection.
+ *
+ * @return the login timeout value in seconds.
+ * @see #setLoginTimeout(int)
+ * @see #setLoginTimeout(String)
+ */
+ public int getLoginTimeout() {
+ return super.getLoginTimeout();
+ }
+
+ /**
+ * Sets the network timeout in seconds for the Type 4 connection. The
+ * default network timeout value is set to infinity.
+ *
+ * @param networkTimeout
+ * The network timeout value in seconds.
+ * @see #setNetworkTimeout(int)
+ * @see #getNetworkTimeout()
+ */
+ public void setNetworkTimeout(String networkTimeout) {
+ super.setNetworkTimeout(networkTimeout);
+ }
+
+ /**
+ * Sets the network timeout in seconds for the Type 4 connection. The
+ * default network timeout value is set to infinity.
+ *
+ * @param networkTimeout
+ * The network timeout value in seconds.
+ * @see #setNetworkTimeout(String)
+ * @see #getNetworkTimeout()
+ */
+ public void setNetworkTimeout(int networkTimeout) {
+ super.setNetworkTimeout(networkTimeout);
+ }
+
+ /**
+ * Returns the network timeout value set for the current Type 4 connection.
+ *
+ * @return The network timeout value in seconds.
+ * @see #setNetworkTimeout(int)
+ * @see #setNetworkTimeout(String)
+ */
+ public int getNetworkTimeout() {
+ return super.getNetworkTimeout();
+ }
+
+ // -----------------------------------------------------------------
+
+ /*
+ * Sets the connection timeout value for the Type 4 connection. Set this
+ * value to 0 for infinite timeout. The default is set to -1. A negative
+ * value indicates the NDCS server to use the connection timeout value set
+ * by the administrator on the NDCS data source. @param connectionTimeout
+ * The connection timeout value in seconds.
+ *
+ * @see #setConnectionTimeout(int)
+ * @see #setServerDataSource(String)
+ */
+ public void setConnectionTimeout(String connectionTimeout) {
+ super.setConnectionTimeout(connectionTimeout);
+ }
+
+ /*
+ * Sets the connection timeout value for the Type 4 connection. Set this
+ * value to 0 for infinite timeout. The default is set to -1. A negative
+ * value indicates the NDCS server to use the connection timeout value set
+ * by the administrator on the NDCS data source. @param connectionTimeout
+ * The connection timeout value in seconds.
+ *
+ * @see #setConnectionTimeout(String)
+ * @see #setServerDataSource(String)
+ */
+ public void setConnectionTimeout(int connectionTimeout) {
+ super.setConnectionTimeout(connectionTimeout);
+ }
+
+ /**
+ * Sets the max idle time value for the Type 4 connection. The default is
+ * set to 0 (no timeout). Negative values are treated as 0.
+ *
+ * @param maxIdleTime
+ * The timeout value in seconds.
+ * @see #setMaxIdleTime(int)
+ */
+ public void setMaxIdleTime(String maxIdleTime) {
+ super.setMaxIdleTime(maxIdleTime);
+ }
+
+ /**
+ * Sets the max idle time value for the Type 4 connection.The default is set
+ * to 0 (no timeout). Negative values are treated as 0.
+ *
+ * @param maxIdleTime
+ * The timeout value in seconds.
+ * @see #setMaxIdleTime(String)
+ */
+ public void setMaxIdleTime(int maxIdleTime) {
+ super.setMaxIdleTime(maxIdleTime);
+ }
+
+ /*
+ * Returns the connection timeout value associated with this Type 4
+ * connection. @return The connection timeout value in seconds.
+ *
+ * @see #setConnectionTimeout(int)
+ */
+
+ public int getConnectionTimeout() {
+ return super.getConnectionTimeout();
+ }
+
+ /**
+ * Returns the max idle time value associated with this Type 4 connection.
+ *
+ * @return The max idle timeout value in seconds.
+ * @see #setMaxIdleTime(int)
+ */
+ public int getMaxIdleTime() {
+ return super.getMaxIdleTime();
+ }
+
+ /**
+ * Sets the logging level for the current Type 4 connection. The default
+ * value is OFF. Valid values are:
+ *
+ * <PRE>
+ * OFF (no logging)
+ * SEVERE (highest value)
+ * WARNING
+ * INFO
+ * CONFIG
+ * FINE
+ * FINER
+ * FINEST (lowest value).
+ * ALL (log all messages)
+ * </PRE>
+ *
+ * @param level
+ * logging level.
+ * @see #getT4LogLevel()
+ * @see java.util.logging.Level
+ */
+ public void setT4LogLevel(String level) {
+ super.setT4LogLevel(level);
+ }
+
+ /**
+ * Returns the Type 4 log level associated with the current Type 4
+ * connection. Possible log levels are described in java.util.logging.Level
+ *
+ * @return <code>java.util.logging.Level</code> associated with the
+ * current Type 4 connection.
+ * @see #setT4LogLevel(String)
+ * @see java.util.logging.Level
+ */
+ public Level getT4LogLevel() {
+ return super.getT4LogLevel();
+ }
+
+ /**
+ * Sets the location of the file to which the logging is to be done.
+ * Changing this location after making a connection has no effect; because
+ * the driver reads this property before the connection is made. The default
+ * name is a generated file name defined by the following pattern:
+ * %h/t4jdbc%u.log where: "/" represents the local pathname separator "%h"
+ * represents the value of the "user.home" system property. If %h is not
+ * defined, then the behavior is undefined "%u" represents a unique number
+ * to resolve conflicts
+ *
+ * @param t4LogFile
+ * The Type 4 log file location. If the parameter is null, then
+ * the T4LogFile is set to the global log file.
+ * @see #getT4LogFile()
+ * @see java.util.logging.Logger
+ */
+ public void setT4LogFile(String t4LogFile) {
+ super.setT4LogFile(t4LogFile);
+ }
+
+ /**
+ * Returns the Type 4 log file location associated with the current Type 4
+ * connection.
+ *
+ * @return The Type 4 log file location.
+ * @see #setT4LogFile(String)
+ */
+ public String getT4LogFile() {
+ return super.getT4LogFile();
+ }
+
+ /**
+ * Sets the table name to store and retrieve the CLOB data for all CLOB
+ * columns accessed in the connection using the data source.
+ *
+ * @param clobTableName
+ * The clob table name, which is in the format
+ * <code><var>catalog_name.schema_name.clob_table_name</code></var>
+ *
+ * @since 1.1
+ */
+ public void setClobTableName(String clobTableName) throws SQLException {
+ super.setClobTableName(clobTableName);
+ }
+
+ /**
+ * Retrieves the table name used to store CBLOB data for all CLOB columns
+ * accessed in the connection using the data source.
+ *
+ * @return the clob table name, which is in the format
+ * <code><var>catalog_name.schema_name.clob_table_name</code></var>
+ *
+ * @since 1.1
+ */
+ public String getClobTableName() {
+ return super.getClobTableName();
+ }
+
+ /**
+ * Sets the table name to store and retrieve the BLOB data for all BLOB
+ * columns accessed in the connection using the data source.
+ *
+ * @param blobTableName
+ * the blob table name, which is in the format
+ * <code><var>catalog_name.schema_name.blob_table_name</code></var>
+ *
+ * @since 1.1
+ */
+ public void setBlobTableName(String blobTableName) throws SQLException {
+ super.setBlobTableName(blobTableName);
+ }
+
+ /**
+ * Retrieves the table name used to store BLOB data for all BLOB columns
+ * accessed in the connection using the data source.
+ *
+ * @return the blob table name which is of the format
+ * <code><var>catalog_name.schema_name.blob_table_name</code></var>
+ *
+ * @since 1.1
+ */
+ public String getBlobTableName() {
+ return super.getBlobTableName();
+ }
+
+ /**
+ * Configures the number of data locators to be reserved by the Type 4
+ * connection. Default value is 100.
+ *
+ * @param reserveDataLocator
+ * Sets the value of the reserve data locator length for the
+ * binding) feature.
+ *
+ * @since 1.1
+ */
+ public void setReserveDataLocator(String reserveDataLocator) {
+ super.setReserveDataLocator(reserveDataLocator);
+ }
+
+ /**
+ * Configures the number of data locators to be reserved by the Type 4
+ * connection. Default value is 100.
+ *
+ * @param reserveDataLocatorLen
+ * Sets the value of the reserve data locator length for the Type
+ * 4 connection.
+ *
+ * @since 1.1
+ */
+ public void setReserveDataLocator(long reserveDataLocatorLen) {
+ super.setReserveDataLocator(reserveDataLocatorLen);
+ }
+
+ /**
+ * Returns the value of the reserve data locator length.
+ *
+ * @return The value of the reserved data locator length.
+ *
+ * @since 1.1
+ */
+ public long getReserveDataLocator() {
+ return super.getReserveDataLocator();
+ }
+
+ /**
+ * @return Returns the rounding mode set for the driver as an Integer value
+ * with one of the values:
+ *
+ * <PRE>
+ * static int ROUND_CEILING
+ * Rounding mode to round toward positive infinity.
+ * static int ROUND_DOWN
+ * Rounding mode to round toward zero.
+ * static int ROUND_FLOOR
+ * Rounding mode to round toward negative infinity.
+ * static int ROUND_HALF_DOWN
+ * Rounding mode to round toward "nearest neighbor" unless both
+ * neighbors are equidistant, in which case round down.
+ * static int ROUND_HALF_EVEN
+ * Rounding mode to round toward the "nearest neighbor" unless
+ * both neighbors are equidistant, in which case, round towards the even neighbor.
+ * static int ROUND_HALF_UP
+ * Rounding mode to round toward "nearest neighbor" unless both
+ * neighbors are equidistant, in which case round up.
+ * static int ROUND_UNNECESSARY
+ * Rounding mode to assert that the requested operation has an exact
+ * result; hence no rounding is necessary.
+ * static int ROUND_UP
+ * Rounding mode to round away from zero.
+ * </PRE>
+ */
+ public int getRoundingMode() {
+ return super.getRoundingMode();
+ }
+
+ /**
+ * Sets the round mode behaviour for the driver.
+ *
+ * @param roundMode
+ * String value with one of the values:
+ *
+ * <PRE>
+ * static int ROUND_CEILING
+ * Rounding mode to round toward positive infinity.
+ * static int ROUND_DOWN
+ * Rounding mode to round toward zero.
+ * static int ROUND_FLOOR
+ * Rounding mode to round toward negative infinity.
+ * static int ROUND_HALF_DOWN
+ * Rounding mode to round toward "nearest neighbor" unless both
+ * neighbors are equidistant, in which case round down.
+ * static int ROUND_HALF_EVEN
+ * Rounding mode to round toward the "nearest neighbor" unless
+ * both neighbors are equidistant, in which case, round towards the even neighbor.
+ * static int ROUND_HALF_UP
+ * Rounding mode to round toward "nearest neighbor" unless both
+ * neighbors are equidistant, in which case round up.
+ * static int ROUND_UNNECESSARY
+ * Rounding mode to assert that the requested operation has an exact
+ * result; hence no rounding is necessary.
+ * static int ROUND_UP
+ * Rounding mode to round away from zero.
+ * </PRE>
+ *
+ * The default value is ROUND_HALF_EVEN.
+ */
+ public void setRoundingMode(String roundMode) {
+ super.setRoundingMode(roundMode);
+ }
+
+ /**
+ * Sets the round mode behaviour for the driver.
+ *
+ * @param roundMode
+ * Integer value with one of the values:
+ *
+ * <PRE>
+ * static int ROUND_CEILING
+ * Rounding mode to round toward positive infinity.
+ * static int ROUND_DOWN
+ * Rounding mode to round toward zero.
+ * static int ROUND_FLOOR
+ * Rounding mode to round toward negative infinity.
+ * static int ROUND_HALF_DOWN
+ * Rounding mode to round toward "nearest neighbor" unless both
+ * neighbors are equidistant, in which case round down.
+ * static int ROUND_HALF_EVEN
+ * Rounding mode to round toward the "nearest neighbor" unless
+ * both neighbors are equidistant, in which case, round towards the even neighbor.
+ * static int ROUND_HALF_UP
+ * Rounding mode to round toward "nearest neighbor" unless both
+ * neighbors are equidistant, in which case round up.
+ * static int ROUND_UNNECESSARY
+ * Rounding mode to assert that the requested operation has an exact
+ * result; hence no rounding is necessary.
+ * static int ROUND_UP
+ * Rounding mode to round away from zero.
+ * </PRE>
+ *
+ * The default value is ROUND_HALF_EVEN.
+ */
+ public void setRoundingMode(int roundMode) {
+ super.setRoundingMode(roundMode);
+ }
+
+ /**
+ * Sets the value (in KB) for the size of the fetch buffer. This is used
+ * when rows are fetched are performed from a ResultSet object after a
+ * successful executeQuery() operation on a statement. The default size is
+ * 4. Zero and negative values are treated as default values.
+ *
+ * @param fetchBufferSize
+ * @see #getFetchBufferSize()
+ * @see #setFetchBufferSize(String)
+ */
+ void setFetchBufferSize(short fetchBufferSize) {
+ super.setFetchBufferSize(fetchBufferSize);
+ }
+
+ /**
+ * Sets the value (in KB) for the size of the fetch buffer. This is used
+ * when rows are fetched are performed from a ResultSet object after a
+ * successful executeQuery() operation on a statement. The default size is
+ * 4. Zero and negative values are treated as default values.
+ *
+ * @param fetchBufferSize
+ * @see #getFetchBufferSize()
+ * @see #setFetchBufferSize(short)
+ */
+ void setFetchBufferSize(String fetchBufferSize) {
+ super.setFetchBufferSize(fetchBufferSize);
+ }
+
+ /**
+ * Returns the size of the fetch buffer.
+ *
+ * @see #setFetchBufferSize(short)
+ * @see #setFetchBufferSize(String)
+ */
+ short getFetchBufferSize() {
+ return super.getFetchBufferSize();
+ }
+
+} // end class T4DSProperties
+
[06/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4CallableStatement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4CallableStatement.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4CallableStatement.java
deleted file mode 100644
index 2a3675e..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4CallableStatement.java
+++ /dev/null
@@ -1,2462 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.math.BigDecimal;
-import java.net.URL;
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.DatabaseMetaData;
-import java.sql.Date;
-import java.sql.NClob;
-import java.sql.Ref;
-import java.sql.ResultSet;
-import java.sql.RowId;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.sql.Types;
-import java.util.Calendar;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-public class TrafT4CallableStatement extends TrafT4PreparedStatement implements java.sql.CallableStatement {
- public Array getArray(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getArray", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getArray");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- clearWarnings();
- HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getArray()");
- return null;
- }
-
- public Array getArray(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getArray", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getArray");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getArray(parameterIndex);
- }
-
- public BigDecimal getBigDecimal(int parameterIndex) throws SQLException {
- BigDecimal retValue;
- String data;
-
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getBigDecimal", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getBigDecimal");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateGetInvocation(parameterIndex);
- inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
- // String returned may not be numeric in case of SQL_CHAR, SQL_VARCHAR
- // and SQL_LONGVARCHAR
- // fields. Hoping that java might throw invalid value exception
- // For LOB Support - SB
- // data = inputDesc_[parameterIndex-1].paramValue_;
- data = getString(parameterIndex);
- if (data == null) {
- wasNull_ = true;
- return null;
- } else {
- wasNull_ = false;
- try {
- retValue = new BigDecimal(data);
- } catch (NumberFormatException e) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
- return retValue;
- }
- }
-
- public BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, scale);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getBigDecimal", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, scale);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getBigDecimal");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- BigDecimal retValue;
-
- retValue = getBigDecimal(parameterIndex);
- if (retValue != null) {
- return retValue.setScale(scale);
- } else {
- return null;
- }
- }
-
- public BigDecimal getBigDecimal(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getBigDecimal", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getBigDecimal");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getBigDecimal(parameterIndex);
- }
-
- public BigDecimal getBigDecimal(String parameterName, int scale) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, scale);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getBigDecimal", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, scale);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getBigDecimal");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getBigDecimal(parameterIndex, scale);
- }
-
-
- public boolean getBoolean(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getBoolean", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getBoolean");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
-
- validateGetInvocation(parameterIndex);
- inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
- // For LOB Support - SB
- // data = inputDesc_[parameterIndex-1].paramValue_;
- data = getString(parameterIndex);
-
- if (data != null) {
- wasNull_ = false;
- return (!data.equals("0"));
- } else {
- wasNull_ = true;
- return false;
- }
- }
-
- public boolean getBoolean(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getBoolean", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getBoolean");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getBoolean(parameterIndex);
- }
-
- public byte getByte(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getByte", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getByte");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
-
- validateGetInvocation(parameterIndex);
- inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
- // For LOB Support - SB
- // data = inputDesc_[parameterIndex-1].paramValue_;
- data = getString(parameterIndex);
-
- if (data != null) {
- wasNull_ = false;
- return Byte.parseByte(data);
- } else {
- wasNull_ = true;
- return 0;
- }
- }
-
- public byte getByte(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getByte", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getByte");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getByte(parameterIndex);
- }
-
- public byte[] getBytes(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getBytes", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getBytes");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
-
- validateGetInvocation(parameterIndex);
- dataType = inputDesc_[parameterIndex - 1].dataType_;
- if (dataType != Types.BINARY && dataType != Types.VARBINARY && dataType != Types.LONGVARBINARY) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
- // BINARY, VARBINARY, LONGVARBINARY not supported
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "datatype_not_supported",
- null);
- }
-
- public byte[] getBytes(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getBytes", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getBytes");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getBytes(parameterIndex);
- }
-
- public Date getDate(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getDate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getDate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- String dateStr;
- Date retValue;
-
- validateGetInvocation(parameterIndex);
- dataType = inputDesc_[parameterIndex - 1].dataType_;
- if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
- && dataType != Types.DATE && dataType != Types.TIMESTAMP) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
- // For LOB Support - SB
- // dateStr = inputDesc_[parameterIndex-1].paramValue_;
- dateStr = getString(parameterIndex);
-
- if (dateStr != null) {
- wasNull_ = false;
- try {
- boolean convertDate = connection_.getDateConversion();
-
- if (convertDate) {
- String dt = TrafT4ResultSet.convertDateFormat(dateStr);
- retValue = TrafT4ResultSet.valueOf(dt);
- } else {
- retValue = Date.valueOf(dateStr);
- }
- } catch (IllegalArgumentException e) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
- return retValue;
- } else {
- wasNull_ = true;
- return null;
- }
- }
-
- public Date getDate(int parameterIndex, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getDate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getDate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- Date sqlDate;
- java.util.Date d;
-
- sqlDate = getDate(parameterIndex);
- if (sqlDate != null) {
- if (cal != null) {
- cal.setTime(sqlDate);
- d = cal.getTime();
- sqlDate = new Date(d.getTime());
- }
- return sqlDate;
- } else {
- return (sqlDate);
- }
- }
-
- public Date getDate(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getDate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getDate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getDate(parameterIndex);
- }
-
- public Date getDate(String parameterName, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getDate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getDate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getDate(parameterIndex, cal);
- }
-
- public double getDouble(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getDouble", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getDouble");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
-
- validateGetInvocation(parameterIndex);
- inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
- // For LOB Support - SB
- // data = inputDesc_[parameterIndex-1].paramValue_;
- data = getString(parameterIndex);
- if (data != null) {
- wasNull_ = false;
- return Double.parseDouble(data);
- } else {
- wasNull_ = true;
- return 0;
- }
- }
-
- public double getDouble(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getDouble", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getDouble");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getDouble(parameterIndex);
- }
-
- public float getFloat(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getFloat", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getFloat");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
-
- validateGetInvocation(parameterIndex);
- inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
- // For LOB Support - SB
- // data = inputDesc_[parameterIndex-1].paramValue_;
- data = getString(parameterIndex);
-
- if (data != null) {
- wasNull_ = false;
- return Float.parseFloat(data);
- } else {
- wasNull_ = true;
- return 0;
- }
- }
-
- public float getFloat(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getFloat", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getFloat");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getFloat(parameterIndex);
- }
-
- public int getInt(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getInt", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getInt");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
-
- validateGetInvocation(parameterIndex);
- inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
- // For LOB Support - SB
- // data = inputDesc_[parameterIndex-1].paramValue_;
- data = getString(parameterIndex);
- if (data != null) {
- wasNull_ = false;
- return Integer.parseInt(data);
- } else {
- wasNull_ = true;
- return 0;
- }
- }
-
- public int getInt(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getInt", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getInt");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getInt(parameterIndex);
- }
-
- public long getLong(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getLong", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getLong");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
-
- validateGetInvocation(parameterIndex);
- inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
- // For LOB Support - SB
- // data = inputDesc_[parameterIndex-1].paramValue_;
- data = getString(parameterIndex);
- if (data != null) {
- wasNull_ = false;
- return Long.parseLong(data);
- } else {
- wasNull_ = true;
- return 0;
- }
- }
-
- public long getLong(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getLong", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getLong");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getLong(parameterIndex);
- }
-
- public Object getObject(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getObject", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getObject");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- byte byteValue;
- short shortValue;
- int intValue;
- long longValue;
- float floatValue;
- double doubleValue;
- boolean booleanValue;
-
- validateGetInvocation(parameterIndex);
- dataType = inputDesc_[parameterIndex - 1].dataType_;
- switch (dataType) {
- case Types.TINYINT:
- byteValue = getByte(parameterIndex);
- if (wasNull_) {
- return null;
- } else {
- return new Byte(byteValue);
- }
- case Types.SMALLINT:
- intValue = getShort(parameterIndex);
- if (wasNull_) {
- return null;
- } else {
- return new Integer(intValue);
- }
- case Types.INTEGER:
- intValue = getInt(parameterIndex);
- if (wasNull_) {
- return null;
- } else {
- return new Integer(intValue);
- }
- case Types.BIGINT:
- longValue = getLong(parameterIndex);
- if (wasNull_) {
- return null;
- } else {
- return new Long(longValue);
- }
- case Types.REAL:
- floatValue = getFloat(parameterIndex);
- if (wasNull_) {
- return null;
- } else {
- return new Float(floatValue);
- }
- case Types.FLOAT:
- case Types.DOUBLE:
- doubleValue = getDouble(parameterIndex);
- if (wasNull_) {
- return null;
- } else {
- return new Double(doubleValue);
- }
- case Types.DECIMAL:
- case Types.NUMERIC:
- return getBigDecimal(parameterIndex);
- case Types.BIT:
- booleanValue = getBoolean(parameterIndex);
- if (wasNull_) {
- return null;
- } else {
- return new Boolean(booleanValue);
- }
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- return getString(parameterIndex);
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.LONGVARBINARY:
- return getBytes(parameterIndex);
- case Types.DATE:
- return getDate(parameterIndex);
- case Types.TIME:
- return getTime(parameterIndex);
- case Types.TIMESTAMP:
- return getTimestamp(parameterIndex);
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
- }
-
- public Object getObject(int parameterIndex, Map map) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, map);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getObject", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, map);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getObject");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getObject()");
- return null;
- }
-
- public Object getObject(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getOjbect", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getOjbect");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getObject(parameterIndex);
- }
-
- public Object getObject(String parameterName, Map map) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, map);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getObject", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, map);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getObject");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getObject(parameterIndex, map);
- }
-
- public Ref getRef(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getRef", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getRef");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getRef()");
- return null;
- }
-
- public Ref getRef(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getRef", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getRef");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getRef(parameterIndex);
- }
-
- public short getShort(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getShort", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getShort");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
-
- validateGetInvocation(parameterIndex);
- inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
- // For LOB Support - SB
- // data = inputDesc_[parameterIndex-1].paramValue_;
- data = getString(parameterIndex);
- if (data != null) {
- wasNull_ = false;
- return Short.parseShort(data);
- } else {
- wasNull_ = true;
- return 0;
- }
- }
-
- public short getShort(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getShort", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getShort");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getShort(parameterIndex);
- }
-
- public String getString(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getString", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getString");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- String data;
- // For LOB Support - SB 10/8/2004
- Object x;
- int targetSqlType;
- int sqlCharset;
-
- validateGetInvocation(parameterIndex);
-
- targetSqlType = inputDesc_[parameterIndex - 1].dataType_;
- sqlCharset = inputDesc_[parameterIndex - 1].sqlCharset_;
- x = inputDesc_[parameterIndex - 1].paramValue_;
-
- if (x == null) {
- wasNull_ = true;
- data = null;
- } else {
- if (x instanceof byte[]) {
- try {
- if (this.ist_.ic_.getISOMapping() == InterfaceUtilities.SQLCHARSETCODE_ISO88591
- && !this.ist_.ic_.getEnforceISO()
- && sqlCharset == InterfaceUtilities.SQLCHARSETCODE_ISO88591)
- data = new String((byte[]) x, ist_.ic_.t4props_.getISO88591());
- else
- data = this.ist_.ic_.decodeBytes((byte[]) x, sqlCharset);
-
- wasNull_ = false;
- } catch (CharacterCodingException e) {
- SQLException se = HPT4Messages.createSQLException(this.connection_.ic_.t4props_, this.connection_
- .getLocale(), "translation_of_parameter_failed", "getLocalString", e.getMessage());
- se.initCause(e);
- throw se;
- } catch (UnsupportedCharsetException e) {
- SQLException se = HPT4Messages.createSQLException(this.connection_.ic_.t4props_, this.connection_
- .getLocale(), "unsupported_encoding", e.getCharsetName());
- se.initCause(e);
- throw se;
- } catch (UnsupportedEncodingException e) {
- SQLException se = HPT4Messages.createSQLException(this.connection_.ic_.t4props_, this.connection_
- .getLocale(), "unsupported_encoding", e.getMessage());
- se.initCause(e);
- throw se;
- }
- } else {
- data = x.toString();
- wasNull_ = false;
- }
- }
- return data;
- }
-
- public String getString(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getString", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getString");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getString(parameterIndex);
- }
-
- public Time getTime(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getTime", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getTime");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- String timeStr;
- Time retValue;
-
- validateGetInvocation(parameterIndex);
- dataType = inputDesc_[parameterIndex - 1].dataType_;
- if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
- && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
-
- // For LOB Support - SB 10/8/2004
- // timeStr = inputDesc_[parameterIndex-1].paramValue_;
- timeStr = getString(parameterIndex);
- if (timeStr != null) {
- try {
- wasNull_ = false;
- retValue = Time.valueOf(timeStr);
- } catch (IllegalArgumentException e) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
- return retValue;
- } else {
- wasNull_ = true;
- return null;
- }
- }
-
- public Time getTime(int parameterIndex, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getTime", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getTime");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- Time sqlTime;
- java.util.Date d;
-
- sqlTime = getTime(parameterIndex);
- if (sqlTime != null) {
- if (cal != null) {
- cal.setTime(sqlTime);
- d = cal.getTime();
- sqlTime = new Time(d.getTime());
- }
- return sqlTime;
- } else {
- return (sqlTime);
- }
- }
-
- public Time getTime(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getTime", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getTime");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getTime(parameterIndex);
- }
-
- public Time getTime(String parameterName, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getTime", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getTime");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getTime(parameterIndex, cal);
- }
-
- public Timestamp getTimestamp(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getTimestamp", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getTimestamp");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- String timestampStr;
- Timestamp retValue;
-
- validateGetInvocation(parameterIndex);
- dataType = inputDesc_[parameterIndex - 1].dataType_;
- if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
- && dataType != Types.DATE && dataType != Types.TIMESTAMP) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
-
- // For LOB Support - SB 10/8/2004
- // timestampStr = inputDesc_[parameterIndex - 1].paramValue_;
- timestampStr = getString(parameterIndex);
- if (timestampStr != null) {
- try {
- wasNull_ = false;
- retValue = Timestamp.valueOf(timestampStr);
- } catch (IllegalArgumentException e) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_cast_specification", null);
- }
- return retValue;
- } else {
- wasNull_ = true;
- return null;
- }
- }
-
- public Timestamp getTimestamp(int parameterIndex, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getTimestamp", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getTimestamp");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- Timestamp sqlTimestamp;
- java.util.Date d;
- int nanos;
-
- sqlTimestamp = getTimestamp(parameterIndex);
- if (sqlTimestamp != null) {
- if (cal != null) {
- nanos = sqlTimestamp.getNanos();
- cal.setTime(sqlTimestamp);
- d = cal.getTime();
- sqlTimestamp = new Timestamp(d.getTime());
- sqlTimestamp.setNanos(nanos);
- }
- return sqlTimestamp;
- } else {
- return (sqlTimestamp);
- }
- }
-
- public Timestamp getTimestamp(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getTimestamp", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getTimestamp");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getTimestamp(parameterIndex);
- }
-
- public Timestamp getTimestamp(String parameterName, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getTimestamp", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getTimestamp");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getTimestamp(parameterIndex, cal);
- }
-
- public URL getURL(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getURL", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getURL");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- clearWarnings();
- HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getURL()");
- return null;
- }
-
- public URL getURL(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "getURL", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("getURL");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- return getURL(parameterName);
- }
-
- public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "registerOutParameter", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("registerOutParameter");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- // Ignoring sqlType and scale
- validateGetInvocation(parameterIndex);
- if (inputDesc_[parameterIndex - 1].paramMode_ == DatabaseMetaData.procedureColumnOut) {
- inputDesc_[parameterIndex - 1].isValueSet_ = true;
- }
- }
-
- public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType, scale);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "registerOutParameter", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType, scale);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("registerOutParameter");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- // Ignoring sqlType and scale
- validateGetInvocation(parameterIndex);
- if (inputDesc_[parameterIndex - 1].paramMode_ == DatabaseMetaData.procedureColumnOut) {
- inputDesc_[parameterIndex - 1].isValueSet_ = true;
- }
- }
-
- public void registerOutParameter(int parameterIndex, int sqlType, String typeName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType, typeName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "registerOutParameter", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType, typeName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("registerOutParameter");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- // Ignoring sqlType and typeName
- validateGetInvocation(parameterIndex);
- if (inputDesc_[parameterIndex - 1].paramMode_ == DatabaseMetaData.procedureColumnOut) {
- inputDesc_[parameterIndex - 1].isValueSet_ = true;
- }
- }
-
- public void registerOutParameter(String parameterName, int sqlType) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "registerOutParameter", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("registerOutParameter");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- registerOutParameter(parameterIndex, sqlType);
- }
-
- public void registerOutParameter(String parameterName, int sqlType, int scale) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType, scale);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "registerOutParameter", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType, scale);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("registerOutParameter");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- registerOutParameter(parameterIndex, sqlType, scale);
- }
-
- public void registerOutParameter(String parameterName, int sqlType, String typeName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType, typeName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "registerOutParameter", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType, typeName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("registerOutParameter");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateGetInvocation(parameterName);
- registerOutParameter(parameterIndex, sqlType, typeName);
- }
-
- public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, length);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setAsciiStream", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, length);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setAsciiStream");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setAsciiStream(parameterIndex, x, length);
- }
-
- public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setBigDecimal", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setBigDecimal");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setBigDecimal(parameterIndex, x);
- }
-
- public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, length);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setBinaryStream", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, length);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setBinaryStream");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setBinaryStream(parameterIndex, x, length);
- }
-
- public void setBoolean(String parameterName, boolean x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setBoolean", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setBoolean");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setBoolean(parameterIndex, x);
- }
-
- public void setByte(String parameterName, byte x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setByte", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setByte");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setByte(parameterIndex, x);
- }
-
- public void setBytes(String parameterName, byte[] x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setBytes", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setBytes");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setBytes(parameterIndex, x);
- }
-
- public void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, reader, length);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setCharacterStream", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, reader, length);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setCharacterStream");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setCharacterStream(parameterIndex, reader, length);
- }
-
- public void setDate(String parameterName, Date x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setDate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setDate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setDate(parameterIndex, x);
- }
-
- public void setDate(String parameterName, Date x, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setDate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setDate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setDate(parameterIndex, x, cal);
- }
-
- public void setDouble(String parameterName, double x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setDouble", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setDouble");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setDouble(parameterIndex, x);
- }
-
- public void setFloat(String parameterName, float x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setFloat", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setFloat");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setFloat(parameterIndex, x);
- }
-
- public void setInt(String parameterName, int x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setInt", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setInt");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setInt(parameterIndex, x);
- }
-
- public void setLong(String parameterName, long x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setLong", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setLong");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setLong(parameterIndex, x);
- }
-
- public void setNull(String parameterName, int sqlType) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setNull", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setNull");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setNull(parameterIndex, sqlType);
- }
-
- public void setNull(String parameterName, int sqlType, String typeName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType, typeName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setNull", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, sqlType, typeName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setNull");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setNull(parameterIndex, sqlType, typeName);
- }
-
- public void setObject(String parameterName, Object x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setObject", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setObject");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setObject(parameterIndex, x);
- }
-
- public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, targetSqlType);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setObject", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, targetSqlType);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setObject");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setObject(parameterIndex, x, targetSqlType);
- }
-
- public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, targetSqlType, scale);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setObject", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, targetSqlType, scale);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setObject");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setObject(parameterIndex, x, targetSqlType, scale);
- }
-
- public void setShort(String parameterName, short x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setShort", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setShort");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setShort(parameterIndex, x);
- }
-
- public void setString(String parameterName, String x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setString", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setString");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setString(parameterIndex, x);
- }
-
- public void setTime(String parameterName, Time x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setTime", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setTime");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setTime(parameterIndex, x);
- }
-
- public void setTime(String parameterName, Time x, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setTime", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setTime");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setTime(parameterIndex, x, cal);
- }
-
- public void setTimestamp(String parameterName, Timestamp x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setTimestamp", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setTimestamp");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setTimestamp(parameterIndex, x);
- }
-
- public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setTimestamp", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setTimestamp");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setTimestamp(parameterIndex, x, cal);
- }
-
- public void setUnicodeStream(String parameterName, InputStream x, int length) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, length);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setUnicodeStream", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x, length);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setUnicodeStream");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setUnicodeStream(parameterIndex, x, length);
- }
-
- public void setURL(String parameterName, URL x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "setURL", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("setURL");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int parameterIndex = validateSetInvocation(parameterName);
- setURL(parameterIndex, x);
- }
-
- public boolean wasNull() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "wasNull", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("wasNull");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- return wasNull_;
- }
-
- public boolean execute() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "execute", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("execute");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- Object[] valueArray = null;
- int inDescLength = 0;
- if (inputDesc_ != null) {
- valueArray = getValueArray();
- inDescLength = inputDesc_.length;
- }
-
- validateExecuteInvocation();
-
- valueArray = getValueArray();
- ist_.execute(TRANSPORT.SRVR_API_SQLEXECUTE2, paramRowCount_, inDescLength, valueArray, queryTimeout_, null,
- this);
-
- // SPJ: 5-18-2007
- // if (resultSet_[result_set_offset] != null)
- if (resultSet_[result_set_offset] != null && resultSet_[result_set_offset].spj_rs_) {
- return true;
- } else {
- return false;
- }
- }
-
- public int[] executeBatch() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "executeBatch", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("executeBatch");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- if ((batchCommands_ == null) || (paramRowCount_ < 1)) {
- return new int[] {};
- }
-
- if (batchCommands_.isEmpty()) {
- return new int[] {};
- }
-
- clearWarnings();
- HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "executeBatch()");
- return null;
- }
-
- public ResultSet executeQuery() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "executeQuery", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("executeQuery");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- Object[] valueArray = null;
- int inDescLength = 0;
- if (inputDesc_ != null) {
- valueArray = getValueArray();
- inDescLength = inputDesc_.length;
- }
-
- validateExecuteInvocation();
-
- ist_.execute(TRANSPORT.SRVR_API_SQLEXECUTE2, paramRowCount_, inDescLength, valueArray, queryTimeout_, null,
- this);
-
- return resultSet_[result_set_offset];
- }
-
- public int executeUpdate() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4CallableStatement", "executeUpdate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4CallableStatement");
- lr.setSourceMethodName("executeUpdate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- Object[] valueArray = null;
- int inDescLength = 0;
- if (inputDesc_ != null) {
- valueArray = getValueArray();
- inDescLength = inputDesc_.length;
- }
-
- validateExecuteInvocation();
- valueArray = getValueArray();
- ist_.execute(TRANSPORT.SRVR_API_SQLEXECUTE2, paramRowCount_, inDescLength, valueArray, queryTimeout_, null,
- this);
-
- return (1);
- }
-
- // Other methods
- protected void validateGetInvocation(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4CallableStatement", "validateGetInvocation", "", p);
- }
- clearWarnings();
- // connection_.getServerHandle().isConnectionOpen();
- connection_.isConnectionOpen();
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_statement",
- null);
- }
- if (inputDesc_ == null) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "not_a_output_parameter", null);
- }
- if (parameterIndex < 1 || parameterIndex > inputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_parameter_index", null);
- }
- if (inputDesc_[parameterIndex - 1].paramMode_ != DatabaseMetaData.procedureColumnInOut
- && inputDesc_[parameterIndex - 1].paramMode_ != DatabaseMetaData.procedureColumnOut) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "not_a_output_parameter", null);
- }
- }
-
- protected int validateGetInvocation(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4CallableStatement", "validateGetInvocation", "", p);
- }
- int i;
-
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_statement",
- null);
- }
- if (inputDesc_ == null) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "not_a_output_parameter", null);
- }
- for (i = 0; i < inputDesc_.length; i++) {
- if (parameterName.equalsIgnoreCase(inputDesc_[i].name_)) {
- return i + 1;
- }
- }
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_parameter_name",
- null);
- }
-
- private int validateSetInvocation(String parameterName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterName);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4CallableStatement", "validateSetInvocation", "", p);
- }
- int i;
-
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "stmt_closed", null);
- }
- if (inputDesc_ == null) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_parameter_index", null);
- }
- for (i = 0; i < inputDesc_.length; i++) {
- if (parameterName.equalsIgnoreCase(inputDesc_[i].name_)) {
- return i + 1;
- }
- }
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_parameter_name",
- null);
- }
-
- void setExecuteCallOutputs(Object[] outputValues, short rowsAffected
<TRUNCATED>
[32/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java
new file mode 100644
index 0000000..0d7c0b4
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java
@@ -0,0 +1,927 @@
+// @@@ 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;
+import java.math.BigInteger;
+import java.sql.Date;
+import java.sql.SQLException;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.text.DecimalFormat;
+import java.text.FieldPosition;
+import java.util.Properties;
+import java.util.logging.Level;
+
+class InterfaceResultSet {
+ InterfaceConnection ic_;
+ String stmtLabel_;
+
+ /* CHAR/CHARACTER */
+ static final int SQLTYPECODE_CHAR = 1;
+
+ /* NUMERIC */
+ static final int SQLTYPECODE_NUMERIC = 2;
+ static final int SQLTYPECODE_NUMERIC_UNSIGNED = -201;
+
+ /* DECIMAL */
+ static final int SQLTYPECODE_DECIMAL = 3;
+
+ static final int SQLTYPECODE_DECIMAL_UNSIGNED = -301;
+ static final int SQLTYPECODE_DECIMAL_LARGE = -302;
+ static final int SQLTYPECODE_DECIMAL_LARGE_UNSIGNED = -303;
+
+ /* INTEGER/INT */
+ static final int SQLTYPECODE_INTEGER = 4;
+
+ static final int SQLTYPECODE_INTEGER_UNSIGNED = -401;
+ static final int SQLTYPECODE_LARGEINT = -402;
+
+ /* SMALLINT */
+ static final int SQLTYPECODE_SMALLINT = 5;
+
+ static final int SQLTYPECODE_SMALLINT_UNSIGNED = -502;
+
+ static final int SQLTYPECODE_BPINT_UNSIGNED = -503;
+
+ /*
+ * DOUBLE depending on precision
+ */
+ static final int SQLTYPECODE_FLOAT = 6;
+
+ /*
+ */
+ static final int SQLTYPECODE_REAL = 7;
+
+ /*
+ */
+ static final int SQLTYPECODE_DOUBLE = 8;
+
+ /* DATE,TIME,TIMESTAMP */
+ static final int SQLTYPECODE_DATETIME = 9;
+
+ /* TIMESTAMP */
+ static final int SQLTYPECODE_INTERVAL = 10;
+
+ /* no ANSI value 11 */
+
+ /* VARCHAR/CHARACTER VARYING */
+ static final int SQLTYPECODE_VARCHAR = 12;
+
+ /* SQL/MP stype VARCHAR with length prefix:
+ * */
+ static final int SQLTYPECODE_VARCHAR_WITH_LENGTH = -601;
+ static final int SQLTYPECODE_BLOB = -602;
+ static final int SQLTYPECODE_CLOB = -603;
+
+ /* LONG VARCHAR/ODBC CHARACTER VARYING */
+ static final int SQLTYPECODE_VARCHAR_LONG = -1; /* ## NEGATIVE??? */
+
+ /* no ANSI value 13 */
+
+ /* BIT */
+ static final int SQLTYPECODE_BIT = 14; /* not supported */
+
+ /* BIT VARYING */
+ static final int SQLTYPECODE_BITVAR = 15; /* not supported */
+
+ /* NCHAR -- CHAR(n) CHARACTER SET s -- where s uses two bytes per char */
+ static final int SQLTYPECODE_CHAR_DBLBYTE = 16;
+
+ /* NCHAR VARYING -- VARCHAR(n) CHARACTER SET s -- s uses 2 bytes per char */
+ static final int SQLTYPECODE_VARCHAR_DBLBYTE = 17;
+
+ /* Date/Time/TimeStamp related constants */
+ static final int SQLDTCODE_DATE = 1;
+ static final int SQLDTCODE_TIME = 2;
+ static final int SQLDTCODE_TIMESTAMP = 3;
+ static final int SQLDTCODE_MPDATETIME = 4;
+ static final int dateLength = 10;
+ static final int timeLength = 8;
+ static final int timestampLength = 26;
+
+ T4ResultSet t4resultSet_;
+
+ static Properties javaLangToJavaNio = null;
+
+ TrafT4ResultSet rs_;
+
+ InterfaceResultSet(TrafT4ResultSet rs) throws SQLException {
+ this.ic_ = ((TrafT4Connection) rs.connection_).getServerHandle();
+ stmtLabel_ = rs.stmtLabel_;
+ t4resultSet_ = new T4ResultSet(this);
+ rs_ = rs;
+ };
+
+ // -------------------------------------------------------------------
+ // from nskieee.cpp -- find the length for the data based on datatype
+ //
+ static int dataLengthFetchPerf(int SQLDataType, int SQLDateTimeCode, int SQLOctetLength, int maxRowLen,
+ int bufferLen, int ODBCDataType, int ODBCPrecision) {
+ int allocLength = 0;
+ switch (SQLDataType) {
+ case SQLTYPECODE_INTERVAL:
+ allocLength = SQLOctetLength;
+ break;
+ case SQLTYPECODE_VARCHAR_WITH_LENGTH:
+ case SQLTYPECODE_VARCHAR_LONG:
+ case SQLTYPECODE_VARCHAR_DBLBYTE:
+ case SQLTYPECODE_BITVAR:
+ case SQLTYPECODE_BLOB:
+ case SQLTYPECODE_CLOB:
+ allocLength = bufferLen + 2;
+ break;
+ case SQLTYPECODE_CHAR:
+
+ // allocLength = SQLOctetLength - 1; // no null at the end
+ allocLength = SQLOctetLength;
+ if (maxRowLen > 0) {
+ allocLength = (allocLength > maxRowLen) ? (maxRowLen + 1) : (allocLength);
+ }
+ break;
+ case SQLTYPECODE_BIT:
+ case SQLTYPECODE_CHAR_DBLBYTE:
+ case SQLTYPECODE_VARCHAR:
+ allocLength = SQLOctetLength - 1; // no null at the end
+ if (maxRowLen > 0) {
+ allocLength = (allocLength > maxRowLen) ? (maxRowLen + 1) : (allocLength);
+ }
+ break;
+ case SQLTYPECODE_DATETIME:
+ switch (SQLDateTimeCode) {
+ case SQLDTCODE_DATE:
+ allocLength = dateLength;
+ break;
+ case SQLDTCODE_TIME:
+ if (ODBCDataType == java.sql.Types.OTHER) // For
+ // HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION
+ {
+ allocLength = SQLOctetLength;
+ } else {
+ allocLength = timeLength;
+ }
+ break;
+ case SQLDTCODE_TIMESTAMP:
+
+ /*
+ * allocLength = timestampLength; if (SQLOctetLength <
+ * timestampLength) { allocLength = 19; // timestamp without
+ * fraction }
+ */
+ allocLength = ODBCPrecision;
+ break;
+ default:
+ allocLength = SQLOctetLength;
+ break;
+ }
+
+ break;
+ default:
+ allocLength = SQLOctetLength; // exclude nullable
+ break;
+ }
+ return allocLength;
+ }
+
+ // -------------------------------------------------------------------
+ // get the column value data in String format
+ Object getFetchString(TrafT4Connection conn, int scale, int SQLDataType, int SQLDatetimeCode, int FSDataType,
+ byte[] ibuffer, int byteIndex, int byteLen, int SQLcharset, int ODBCDataType) throws SQLException {
+ Object retObj;
+ String tmpStr;
+ byte[] tbuffer;
+ BigDecimal tmpbd;
+
+ switch (SQLDataType) {
+
+ case SQLTYPECODE_CHAR:
+ tbuffer = new byte[byteLen];
+ System.arraycopy(ibuffer, byteIndex, tbuffer, 0, byteLen);
+ retObj = tbuffer;
+ break;
+ case SQLTYPECODE_VARCHAR:
+ tbuffer = new byte[byteLen];
+ System.arraycopy(ibuffer, byteIndex, tbuffer, 0, byteLen);
+ retObj = tbuffer;
+ break;
+ case SQLTYPECODE_INTERVAL:
+ tbuffer = new byte[byteLen];
+ System.arraycopy(ibuffer, byteIndex, tbuffer, 0, byteLen);
+ retObj = tbuffer;
+ break;
+ case SQLTYPECODE_VARCHAR_WITH_LENGTH:
+ case SQLTYPECODE_VARCHAR_LONG:
+ case SQLTYPECODE_BLOB:
+ case SQLTYPECODE_CLOB:
+ tbuffer = new byte[byteLen - 2];
+ System.arraycopy(ibuffer, byteIndex + 2, tbuffer, 0, byteLen - 2);
+
+ // retObj = new String(tbuffer); Swastik for LOB Support 10/29/2004
+ retObj = tbuffer;
+ break;
+ case SQLTYPECODE_DATETIME:
+ tmpStr = new String(Bytes.read_chars(ibuffer, byteIndex, byteLen));
+ switch (SQLDatetimeCode) {
+ case SQLDTCODE_DATE:
+ retObj = Date.valueOf(tmpStr);
+ break;
+ case SQLDTCODE_TIMESTAMP:
+ retObj = Timestamp.valueOf(tmpStr);
+ break;
+ case SQLDTCODE_TIME:
+
+ // Need to add code here to check if it's
+ // HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION
+ if (ODBCDataType != java.sql.Types.OTHER) {
+ retObj = Time.valueOf(tmpStr);
+ break;
+ } else {
+ // Do default processing as it is
+ // HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION
+ }
+ default:
+ retObj = tmpStr;
+ break;
+ }
+ break;
+ case SQLTYPECODE_SMALLINT:
+ short sValue = Bytes.extractShort(ibuffer, byteIndex, this.ic_.getByteSwap());
+ retObj = new Short(sValue);
+ if (scale > 0) {
+ retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
+ }
+ break;
+ case SQLTYPECODE_SMALLINT_UNSIGNED:
+ retObj = new Integer(Bytes.extractUShort(ibuffer, byteIndex, this.ic_.getByteSwap()));
+ if (scale > 0) {
+ retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
+ }
+ break;
+ case SQLTYPECODE_INTEGER:
+ retObj = new Integer(Bytes.extractInt(ibuffer, byteIndex, this.ic_.getByteSwap()));
+ if (scale > 0) {
+ retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
+ }
+ break;
+ case SQLTYPECODE_INTEGER_UNSIGNED:
+ retObj = new Long(Bytes.extractUInt(ibuffer, byteIndex, this.ic_.getByteSwap()));
+ if (scale > 0) {
+ retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
+ }
+ break;
+ case SQLTYPECODE_LARGEINT:
+ tbuffer = new byte[byteLen];
+ System.arraycopy(ibuffer, byteIndex, tbuffer, 0, byteLen);
+ retObj = new BigInteger(tbuffer);
+ if (scale > 0) {
+ retObj = new BigDecimal((BigInteger) retObj, scale);
+ }
+ break;
+ case SQLTYPECODE_NUMERIC:
+ case SQLTYPECODE_NUMERIC_UNSIGNED:
+ switch (FSDataType) {
+ case 130:
+ case 131:
+ tmpStr = String.valueOf(Bytes.extractShort(ibuffer, byteIndex, this.ic_.getByteSwap()));
+ break;
+ case 132:
+ case 133:
+ tmpStr = String.valueOf(Bytes.extractInt(ibuffer, byteIndex, this.ic_.getByteSwap()));
+ break;
+ case 134:
+ tmpStr = String.valueOf(Bytes.extractLong(ibuffer, byteIndex, this.ic_.getByteSwap()));
+ break;
+ default:
+ throw HPT4Messages.createSQLException(conn.props_, conn.getLocale(), "restricted_data_type", null);
+ }
+ retObj = new BigDecimal((new BigInteger(tmpStr)), scale);
+ break;
+ case SQLTYPECODE_DECIMAL:
+ case SQLTYPECODE_DECIMAL_UNSIGNED:
+ case SQLTYPECODE_DECIMAL_LARGE:
+ case SQLTYPECODE_DECIMAL_LARGE_UNSIGNED:
+ String retStr;
+
+ // check if the sign is minus (-80)
+ byte sign = (byte) (ibuffer[byteIndex] & (byte) (-80));
+
+ // first byte = inbyte - (-80)
+ if (sign == (byte) (-80)) {
+ byte firstByte = (byte) (ibuffer[byteIndex] - (byte) (-80));
+ retStr = "-" + firstByte + String.valueOf(Bytes.read_chars(ibuffer, byteIndex + 1, byteLen - 1));
+ } else {
+ retStr = String.valueOf(Bytes.read_chars(ibuffer, byteIndex, byteLen));
+ }
+ retObj = new BigDecimal(new BigInteger(retStr), scale);
+ break;
+ case SQLTYPECODE_REAL:
+ retObj = new Float(Float.intBitsToFloat(Bytes.extractInt(ibuffer, byteIndex, this.ic_.getByteSwap())));
+ break;
+ case SQLTYPECODE_DOUBLE:
+ case SQLTYPECODE_FLOAT:
+ retObj = new Double(Double.longBitsToDouble(Bytes.extractLong(ibuffer, byteIndex, this.ic_.getByteSwap())));
+ break;
+ case SQLTYPECODE_BIT:
+ case SQLTYPECODE_BITVAR:
+ case SQLTYPECODE_BPINT_UNSIGNED:
+ default:
+ throw HPT4Messages.createSQLException(conn.props_, conn.getLocale(), "restricted_data_type", null);
+ }
+ return retObj;
+ } // end getFetchString
+
+ private static String padZero(long i, int len) {
+ String s = String.valueOf(i);
+
+ while (s.length() < len)
+ s = '0' + s;
+
+ return s;
+ }
+
+ // -------------------------------------------------------------------
+ // get the column value data from Execute2 in String format
+ static Object getExecute2FetchString(TrafT4Connection conn, HPT4Desc desc, byte[] values, int noNullValue,
+ int ODBCDataType, boolean useOldDateFormat, boolean swap) throws SQLException {
+ Object retObj;
+ String tmpStr;
+ byte[] tbuffer;
+ BigDecimal tmpbd;
+ int length;
+ int year, month, day, hour, minute, second;
+ long nanoSeconds;
+
+ switch (desc.sqlDataType_) {
+ case SQLTYPECODE_CHAR:
+ length = desc.sqlOctetLength_;
+ tbuffer = new byte[length];
+ System.arraycopy(values, noNullValue, tbuffer, 0, length);
+ retObj = tbuffer;
+ break;
+ case SQLTYPECODE_VARCHAR:
+ case SQLTYPECODE_VARCHAR_WITH_LENGTH:
+ case SQLTYPECODE_VARCHAR_LONG:
+ case SQLTYPECODE_BLOB:
+ case SQLTYPECODE_CLOB:
+ boolean shortLength = desc.precision_ < Math.pow(2, 15);
+ int dataOffset = noNullValue + ((shortLength) ? 2 : 4);
+
+ length = (shortLength) ? Bytes.extractShort(values, noNullValue, swap) : Bytes.extractInt(values, noNullValue, swap);
+
+ tbuffer = new byte[length];
+ int len = values.length - (dataOffset);
+ System.arraycopy(values, (dataOffset), tbuffer, 0, (length > len) ? len : length);
+ retObj = tbuffer;
+ break;
+ case SQLTYPECODE_INTERVAL:
+ length = desc.sqlOctetLength_;
+ tbuffer = new byte[length];
+ System.arraycopy(values, noNullValue, tbuffer, 0, length);
+ retObj = tbuffer;
+ break;
+ case SQLTYPECODE_DATETIME:
+ switch (desc.sqlDatetimeCode_) {
+ case SQLDTCODE_DATE:
+ if (!useOldDateFormat) // new date format, only for bulk move
+ {
+ // "yyyy-mm-dd"
+ year = Bytes.extractUShort(values, noNullValue, swap);
+ month = values[noNullValue + 2];
+ day = values[noNullValue + 3];
+ String t = padZero(year,4) + "-" + padZero(month,2) + "-" + padZero(day,2);
+ retObj = Date.valueOf(t);
+ } else {// do the old way
+ length = dateLength;
+ retObj = Date.valueOf(new String(Bytes.read_chars(values, noNullValue, length)));
+ }
+ break;
+ case SQLDTCODE_TIMESTAMP:
+ if (!useOldDateFormat) // new date format, if not SQLCatalogs
+ {
+ // yyyy-mm-dd hh:mm:ss.fffffffff
+ year = Bytes.extractUShort(values, noNullValue, swap);
+ month = values[noNullValue + 2];
+ day = values[noNullValue + 3];
+ hour = values[noNullValue + 4];
+ minute = values[noNullValue + 5];
+ second = values[noNullValue + 6];
+
+ if (desc.sqlPrecision_ > 0) {
+ nanoSeconds = Bytes.extractUInt(values, noNullValue + 7, swap);
+
+ if (nanoSeconds > 999999) // returned in microseconds
+ nanoSeconds = 0;
+
+ // apply leading 0's for string conversion
+ tmpStr = "" + nanoSeconds;
+ length = tmpStr.length();
+ for (int i = 0; i < desc.sqlPrecision_ - length; i++) {
+ tmpStr = "0" + tmpStr;
+ }
+ } else {
+ tmpStr = "0";
+ }
+
+ retObj = Timestamp.valueOf(padZero((int) year, 4) + "-" + padZero(month, 2) + "-" + padZero(day, 2)
+ + " " + padZero(hour, 2) + ":" + padZero(minute, 2) + ":" + padZero(second, 2) + "."
+ + tmpStr);
+ } else { // do the old way
+ length = desc.precision_;
+ retObj = Timestamp.valueOf(new String(Bytes.read_chars(values, noNullValue, length)));
+ }
+ break;
+
+ case SQLDTCODE_TIME:
+ if (ODBCDataType == java.sql.Types.OTHER) // For
+ // HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION
+ {
+ length = desc.sqlOctetLength_;
+ retObj = new String(Bytes.read_chars(values, noNullValue, length));
+ } else {
+ length = timeLength;
+ if (!useOldDateFormat) // new date format, only for bulk
+ // move
+ {
+ // "hh:mm:ss"
+ hour = values[noNullValue];
+ minute = values[noNullValue + 1];
+ second = values[noNullValue + 2];
+
+ if (desc.sqlPrecision_ > 0) {
+ nanoSeconds = Bytes.extractUInt(values, noNullValue + 3, swap);
+
+ if (nanoSeconds > 999999) // returned in microseconds
+ nanoSeconds = 0;
+
+ String formatStr = "";
+ for(int i=0;i<desc.sqlPrecision_;i++)
+ formatStr += "0";
+
+ StringBuffer sb = new StringBuffer();
+ DecimalFormat format = new DecimalFormat("00");
+ format.format(hour, sb, new FieldPosition(0));
+ sb.append(':');
+ format.format(minute, sb, new FieldPosition(0));
+ sb.append(':');
+ format.format(second, sb, new FieldPosition(0));
+ sb.append('.');
+ format = new DecimalFormat(formatStr);
+ format.format(nanoSeconds, sb, new FieldPosition(0));
+
+ retObj = sb.toString();
+ } else {
+ retObj = Time.valueOf(String.valueOf(hour) + ":" + String.valueOf(minute) + ":"
+ + String.valueOf(second));
+ }
+ } else
+ // do the old way
+ retObj = Time.valueOf(new String(Bytes.read_chars(values, noNullValue, length)));
+ }
+ break;
+ default:
+ length = desc.sqlOctetLength_;
+ retObj = new String(Bytes.read_chars(values, noNullValue, length));
+ break;
+ }
+ break;
+ case SQLTYPECODE_SMALLINT:
+ short sValue = Bytes.extractShort(values, noNullValue, swap);
+ retObj = new Short(sValue);
+ if (desc.scale_ > 0) {
+ retObj = new BigDecimal(new BigInteger(retObj.toString()), desc.scale_);
+ }
+ break;
+ case SQLTYPECODE_SMALLINT_UNSIGNED:
+ int signedSValue = Bytes.extractUShort(values, noNullValue, swap);
+ if (desc.scale_ > 0) {
+ tmpbd = new BigDecimal(new BigInteger(String.valueOf(signedSValue)), (int) desc.scale_);
+ } else {
+ tmpbd = new BigDecimal(String.valueOf(signedSValue));
+ }
+ retObj = tmpbd;
+ break;
+ case SQLTYPECODE_INTEGER:
+ retObj = new Integer(Bytes.extractInt(values, noNullValue,swap));
+ if (desc.scale_ > 0) {
+ retObj = new BigDecimal(new BigInteger(retObj.toString()), desc.scale_);
+ }
+ break;
+ case SQLTYPECODE_INTEGER_UNSIGNED:
+ retObj = new Long(Bytes.extractUInt(values, noNullValue, swap));
+ if (desc.scale_ > 0) {
+ retObj = new BigDecimal(new BigInteger(retObj.toString()), desc.scale_);
+ }
+ break;
+ case SQLTYPECODE_LARGEINT:
+ retObj = new Long(Bytes.extractLong(values, noNullValue, swap));
+ if (desc.scale_ > 0) {
+ retObj = new BigDecimal(new BigInteger(retObj.toString()), desc.scale_);
+ }
+ break;
+ case SQLTYPECODE_NUMERIC:
+ case SQLTYPECODE_NUMERIC_UNSIGNED:
+ tbuffer = new byte[desc.sqlOctetLength_];
+ System.arraycopy(values, noNullValue, tbuffer, 0, desc.sqlOctetLength_);
+ retObj = InterfaceUtilities.convertSQLBigNumToBigDecimal(tbuffer, desc.scale_, swap);
+ break;
+ case SQLTYPECODE_DECIMAL:
+ case SQLTYPECODE_DECIMAL_UNSIGNED:
+ case SQLTYPECODE_DECIMAL_LARGE:
+ case SQLTYPECODE_DECIMAL_LARGE_UNSIGNED:
+ String retStr;
+
+ // check if the sign is minus (-80)
+ byte sign = (byte) (values[noNullValue] & (byte) (-80));
+
+ // first byte = inbyte - (-80)
+ if (sign == (byte) (-80)) {
+ byte firstByte = (byte) (values[noNullValue] - (byte) (-80));
+ retStr = "-" + firstByte
+ + String.valueOf(Bytes.read_chars(values, noNullValue + 1, desc.sqlOctetLength_ - 1));
+ } else {
+ retStr = String.valueOf(Bytes.read_chars(values, noNullValue, desc.sqlOctetLength_));
+ }
+ retObj = new BigDecimal(new BigInteger(retStr), desc.scale_);
+ break;
+ case SQLTYPECODE_REAL:
+ retObj = new Float(Float.intBitsToFloat(Bytes.extractInt(values, noNullValue, swap)));
+ break;
+ case SQLTYPECODE_DOUBLE:
+ case SQLTYPECODE_FLOAT:
+ retObj = new Double(Double.longBitsToDouble(Bytes.extractLong(values, noNullValue, swap)));
+ break;
+ case SQLTYPECODE_BIT:
+ case SQLTYPECODE_BITVAR:
+ case SQLTYPECODE_BPINT_UNSIGNED:
+ default:
+ throw HPT4Messages.createSQLException(conn.props_, conn.getLocale(), "restricted_data_type", null);
+ }
+ return retObj;
+ } // end getExecute2FetchString
+
+ // -------------------------------------------------------------------
+ void setFetchOutputs(TrafT4ResultSet rs, int rowsAffected, boolean endOfData, byte[] outputDataValue)
+ throws SQLException
+
+ {
+ Row[] rowArray;
+ Object[] objectArray;
+ Object columnValue;
+
+ int columnCount;
+ int rowIndex;
+ int columnIndex;
+ int byteIndex = 0;
+ short SQLDataInd = 0;
+ int byteLen = 0;
+ int maxRowLen = rs.connection_.ic_.getTransportBufferSize(); // maxRowLen
+
+ rowArray = new Row[rowsAffected];
+
+ // get the number of colums
+ columnCount = rs.getNoOfColumns();
+
+ for (rowIndex = 0; rowIndex < rowsAffected; rowIndex++) {
+ if (rs.connection_.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, rs, outputDataValue, rowsAffected,
+ endOfData, 0);
+ String temp = "Reading row = " + rowIndex;
+ rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "setFetchOutputs", temp, p);
+ }
+ objectArray = new Object[columnCount];
+
+ for (columnIndex = 0; columnIndex < columnCount; columnIndex++) {
+ if (rs.connection_.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, rs, outputDataValue,
+ rowsAffected, endOfData, 0);
+ String temp = "Reading column = " + columnIndex;
+ rs.connection_.props_.t4Logger_
+ .logp(Level.FINEST, "InterfaceResultSet", "setFetchOutputs", temp, p);
+ }
+ SQLDataInd = new Byte(outputDataValue[byteIndex++]).shortValue();
+ if (rs.connection_.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, rs, outputDataValue,
+ rowsAffected, endOfData, 0);
+ String temp = "Row = " + rowIndex + "," + "Column = " + columnIndex + " SQLDataInd is = "
+ + SQLDataInd;
+ rs.connection_.props_.t4Logger_
+ .logp(Level.FINEST, "InterfaceResultSet", "setFetchOutputs", temp, p);
+ }
+ if (SQLDataInd == 0) {
+ short varDataLen;
+ if (outputDataValue.length > (byteIndex + 2)) {
+ varDataLen = Bytes.extractShort(outputDataValue, byteIndex, this.ic_.getByteSwap());
+ } else {
+ varDataLen = 0;
+
+ }
+ byteLen = dataLengthFetchPerf(rs.outputDesc_[columnIndex].sqlDataType_,
+ rs.outputDesc_[columnIndex].sqlDatetimeCode_, rs.outputDesc_[columnIndex].sqlOctetLength_,
+ maxRowLen, // maxLength
+ varDataLen, rs.outputDesc_[columnIndex].dataType_, rs.outputDesc_[columnIndex].precision_);
+
+ columnValue = getFetchString(rs.connection_, rs.outputDesc_[columnIndex].scale_,
+ rs.outputDesc_[columnIndex].sqlDataType_, rs.outputDesc_[columnIndex].sqlDatetimeCode_,
+ rs.outputDesc_[columnIndex].fsDataType_, outputDataValue, byteIndex, byteLen,
+ rs.outputDesc_[columnIndex].sqlCharset_, rs.outputDesc_[columnIndex].dataType_);
+
+ byteIndex = byteIndex + byteLen;
+
+ switch (rs.outputDesc_[columnIndex].sqlDataType_) {
+ case SQLTYPECODE_VARCHAR_WITH_LENGTH:
+ case SQLTYPECODE_VARCHAR_LONG:
+ case SQLTYPECODE_VARCHAR_DBLBYTE:
+ case SQLTYPECODE_BITVAR:
+ case SQLTYPECODE_CHAR:
+ case SQLTYPECODE_CHAR_DBLBYTE:
+ case SQLTYPECODE_VARCHAR:
+ case SQLTYPECODE_BLOB:
+ case SQLTYPECODE_CLOB:
+ byteIndex++;
+ break;
+ }
+
+ if (columnValue == null) {
+ throw HPT4Messages
+ .createSQLException(rs.connection_.props_, ic_.getLocale(), "null_data", null);
+ }
+ } else {
+ columnValue = null;
+
+ }
+ objectArray[columnIndex] = columnValue;
+ }
+ rowArray[rowIndex] = new Row(columnCount, objectArray);
+ }
+ rs.setFetchOutputs(rowArray, rowsAffected, endOfData);
+ }
+
+ // ----------------------------------------------------------------------------
+ void setExecute2FetchOutputs(TrafT4ResultSet rs, int rowsAffected, boolean endOfData, byte[] values)
+ throws SQLException {
+ if (rs.useOldDateFormat()) {
+ setFetchOutputs(rs, rowsAffected, endOfData, values);
+ return;
+ }
+ Object[] objectArray;
+ Object columnValue;
+ Row[] rowArray = new Row[rowsAffected];
+
+ int columnCount = rs.getNoOfColumns();
+ int rowIndex;
+ int columnIndex;
+ int byteIndex = 0;
+ int SQLDataInd = 0;
+ int byteLen = 0;
+ int maxRowLen = rs.connection_.ic_.getTransportBufferSize(); // maxRowLen
+
+ objectArray = new Object[columnCount];
+
+ int dataLength = 0;
+
+ if (rs.outputDesc_ != null && rs.outputDesc_.length > 0) {
+ dataLength = rs.outputDesc_[0].rowLength_;
+ }
+
+ int rowOffset = 0;
+ for (rowIndex = 0; rowIndex < rowsAffected; rowIndex++) {
+ rowOffset = rowIndex * dataLength;
+
+ for (columnIndex = 0; columnIndex < columnCount; columnIndex++) {
+ int noNullValueOffset = rs.outputDesc_[columnIndex].noNullValue_;
+ int nullValueOffset = rs.outputDesc_[columnIndex].nullValue_;
+
+ if (nullValueOffset != -1)
+ nullValueOffset += rowOffset;
+ if (noNullValueOffset != -1)
+ noNullValueOffset += rowOffset;
+
+ if (rs.connection_.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, rs, endOfData, values);
+ String temp = "Processing column = " + columnIndex + ": noNullValueOffset = " + noNullValueOffset
+ + ": nullValueOffset = " + nullValueOffset;
+ rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "setExecute2FetchOutputs",
+ temp, p);
+ }
+
+ if (nullValueOffset != -1 && Bytes.extractShort(values, nullValueOffset, this.ic_.getByteSwap()) == -1) {
+ columnValue = null;
+ } else {
+ columnValue = getExecute2FetchString(rs.connection_, rs.outputDesc_[columnIndex], values,
+ noNullValueOffset, rs.outputDesc_[columnIndex].dataType_, rs.useOldDateFormat(), this.ic_.getByteSwap());
+ if (columnValue == null) {
+ throw HPT4Messages
+ .createSQLException(rs.connection_.props_, ic_.getLocale(), "null_data", null);
+ }
+ } // end if else
+
+ objectArray[columnIndex] = columnValue;
+ } // end for
+
+ rowArray[rowIndex] = new Row(columnCount, objectArray);
+ }
+ rs.setFetchOutputs(rowArray, rowsAffected, endOfData);
+
+ } // end setExectue2FetchOutputs
+
+ // ----------------------------------------------------------------------------
+ // Interface methods
+ boolean fetch(String stmtLabel, int maxRowCnt, int queryTimeout, int holdability, TrafT4ResultSet rs)
+ throws SQLException {
+ int sqlAsyncEnable = 0;
+ int stmtHandle = 0;
+ int stmtCharset = 1;
+ String cursorName = "";
+ int cursorCharset = 1;
+ String stmtOptions = "";
+
+ boolean endOfData = false;
+ boolean dataFound = false;
+ String sqlStmt = ""; // qs_interface
+
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, stmtLabel, maxRowCnt, queryTimeout,
+ holdability);
+ String temp = "Entering Fetch";
+ rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "fetch", temp, p);
+ }
+
+ if (rs_.stmt_ != null && rs_.stmt_.sql_ != null) {
+ sqlStmt = rs_.stmt_.sql_.toUpperCase();
+ }
+
+ FetchReply fr;
+
+ try {
+ fr = t4resultSet_.Fetch(sqlAsyncEnable, queryTimeout, stmtHandle, stmtCharset, maxRowCnt, cursorName,
+ cursorCharset, stmtOptions);
+
+ } catch (SQLException tex) {
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, stmtLabel, maxRowCnt, queryTimeout,
+ holdability);
+ String temp = "SQLException while fetching.";
+ rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "fetch", temp, p);
+ }
+ throw tex;
+ }
+
+ switch (fr.returnCode) {
+ case TRANSPORT.CEE_SUCCESS:
+ case TRANSPORT.SQL_SUCCESS_WITH_INFO:
+
+ // do warning processing
+ if (fr.errorList.length != 0) {
+ HPT4Messages.setSQLWarning(rs.connection_.props_, rs, fr.errorList);
+ }
+ //endOfData = (fr.rowsAffected < maxRowCnt) ? true : false;
+
+ if (fr.rowsAffected > 0) {
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, stmtLabel, maxRowCnt,
+ queryTimeout, holdability);
+ String temp = "Data Found. Setting fetch outputs";
+ rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "fetch", temp, p);
+ }
+ if (rs.keepRawBuffer_ == true) {
+ rs.rawBuffer_ = fr.outValues;
+ }
+
+ setExecute2FetchOutputs(rs, fr.rowsAffected, endOfData, fr.outValues);
+
+ dataFound = true;
+ }
+ break;
+ case 100: // fix this
+ case odbc_SQLSvc_Fetch_exc_.odbc_SQLSvc_Fetch_SQLNoDataFound_exn_:
+ dataFound = false;
+ endOfData = true;
+ break;
+
+ default:
+ HPT4Messages.throwSQLException(rs.connection_.props_, fr.errorList);
+
+ }
+
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, stmtLabel, maxRowCnt, queryTimeout,
+ holdability);
+ String temp = "Exiting Fetch.";
+ rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "fetch", temp, p);
+ }
+
+ // see if the rows fetched is valid
+ return dataFound;
+ };
+
+ void close() throws SQLException {
+ ic_.isConnectionOpen();
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs_.connection_.props_);
+ String temp = "Closing resultset.";
+ rs_.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "close", temp, p);
+ }
+
+ int rval = 0;
+ CloseReply cry_ = null;
+
+ //
+ // If the query is non-unique, then close the result set (cursor).
+ // If the query was a unique select, then the result set was implicitly
+ // closed by NCS.
+ //
+ if (rs_ != null && rs_.stmt_ != null && rs_.stmt_.ist_ != null
+ && rs_.stmt_.ist_.sqlQueryType_ != TRANSPORT.SQL_SELECT_UNIQUE) {
+ cry_ = t4resultSet_.Close();
+
+ switch (cry_.m_p1.exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+
+ // ignore the SQLWarning for the static close
+ break;
+ case odbc_SQLSvc_Close_exc_.odbc_SQLSvc_Close_SQLError_exn_:
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs_.connection_.props_);
+ String temp = "odbc_SQLSvc_Close_SQLError_exn_";
+ rs_.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "close", temp, p);
+ }
+
+ HPT4Messages.throwSQLException(rs_.connection_.props_, cry_.m_p1.SQLError);
+ default:
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs_.connection_.props_);
+ String temp = "UnknownException occurred during close.";
+ rs_.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "close", temp, p);
+ }
+ throw HPT4Messages.createSQLException(rs_.connection_.props_, ic_.getLocale(),
+ "ids_unknown_reply_error", null);
+ } // end switch
+ } // end if
+
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs_.connection_.props_);
+ String temp = "Closed resultset.";
+ rs_.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "close", temp, p);
+ }
+ };
+
+ // ----------------------------------------------------------------------------
+ static Object[] getExecute2Outputs(TrafT4Connection conn, HPT4Desc[] desc, byte[] values, boolean swap) throws SQLException
+
+ {
+ Object[] objectArray;
+ Object columnValue;
+ int columnIndex;
+ int columnCount = (desc == null) ? 0 : desc.length;
+
+ objectArray = new Object[columnCount];
+
+ for (columnIndex = 0; columnIndex < columnCount; columnIndex++) {
+ int noNullValueOffset = desc[columnIndex].noNullValue_;
+ int nullValueOffset = desc[columnIndex].nullValue_;
+
+ if (conn.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(conn.props_, conn, desc, values);
+ String temp = "Processing column = " + columnIndex + ": noNullValueOffset = " + noNullValueOffset
+ + ": nullValueOffset = " + nullValueOffset;
+ conn.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "getExecute2Outputs", temp, p);
+ }
+
+ if ((nullValueOffset != -1 && Bytes.extractShort(values, nullValueOffset, swap) == -1)
+ || (desc[columnIndex].paramMode_ == HPT4ParameterMetaData.parameterModeIn)) {
+ columnValue = null;
+ } else {
+ columnValue = getExecute2FetchString(conn, desc[columnIndex], values, noNullValueOffset,
+ desc[columnIndex].dataType_, false, swap);
+ if (columnValue == null) {
+ throw HPT4Messages.createSQLException(conn.props_, conn.getLocale(), "null_data", null);
+ }
+ } // end if else
+
+ objectArray[columnIndex] = columnValue;
+ } // end for
+
+ return objectArray;
+
+ } // end getExectue2Outputs
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceStatement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceStatement.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceStatement.java
new file mode 100644
index 0000000..e6c7af8
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceStatement.java
@@ -0,0 +1,1392 @@
+// @@@ 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;
+import java.sql.DataTruncation;
+import java.sql.Date;
+import java.sql.SQLException;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Locale;
+import java.util.logging.Level;
+
+class InterfaceStatement {
+ InterfaceConnection ic_;
+ private long rowCount_;
+ static final short SQL_DROP = 1;
+ static short EXTERNAL_STMT = 0;
+ int sqlStmtType_ = TRANSPORT.TYPE_UNKNOWN;
+ int stmtType_ = 0;
+ T4Statement t4statement_;
+ int queryTimeout_;
+ String stmtLabel_;
+ String cursorName_;
+ TrafT4Statement stmt_;
+
+ int sqlQueryType_;
+ int stmtHandle_;
+ int estimatedCost_;
+ boolean prepare2 = false;
+ boolean stmtIsLock = false;
+
+ // used for SPJ transaction
+ static Class LmUtility_class_ = null;
+ static java.lang.reflect.Method LmUtility_getTransactionId_ = null;
+
+ PrepareReply pr_;
+
+ // ----------------------------------------------------------------------
+ InterfaceStatement(TrafT4Statement stmt) throws SQLException {
+ this.ic_ = ((TrafT4Connection) stmt.getConnection()).getServerHandle();
+ queryTimeout_ = stmt.queryTimeout_;
+ stmtLabel_ = stmt.stmtLabel_;
+ cursorName_ = stmt.cursorName_;
+ t4statement_ = new T4Statement(this);
+ stmt_ = stmt;
+ };
+
+ public int getSqlQueryType() {
+ return sqlQueryType_;
+ }
+
+ private String convertDateFormat(String dt) {
+ String tokens[] = dt.split("[/]", 3);
+
+ if (tokens.length != 3) {
+ return dt;
+ }
+ StringBuffer sb = new StringBuffer();
+ sb.append(tokens[0]).append("-").append(tokens[1]).append("-").append(tokens[2]);
+ return sb.toString();
+ }
+
+ // ----------------------------------------------------------------------
+ /**
+ * This method will take an object and convert it to the approperite format
+ * for sending to TrafT4.
+ *
+ * @param locale
+ * The locale for this operation
+ * @param pstmt
+ * The prepared statement associated with the object
+ * @param paramValue
+ * The object to convert
+ * @param paramNumber
+ * The parameter number associated with this object
+ * @param values
+ * The array to place the converted object into
+ */
+ void convertObjectToSQL2(Locale locale, TrafT4Statement pstmt, Object paramValue, int paramRowCount, int paramNumber,
+ byte[] values, int rowNumber) throws SQLException {
+ byte[] tmpBarray = null;
+ int i;
+ BigDecimal tmpbd;
+
+ int precision = pstmt.inputDesc_[paramNumber].precision_;
+ int scale = pstmt.inputDesc_[paramNumber].scale_;
+ int sqlDatetimeCode = pstmt.inputDesc_[paramNumber].sqlDatetimeCode_;
+ int FSDataType = pstmt.inputDesc_[paramNumber].fsDataType_;
+ int OdbcDataType = pstmt.inputDesc_[paramNumber].dataType_;
+ int maxLength = pstmt.inputDesc_[paramNumber].sqlOctetLength_;
+ int dataType = pstmt.inputDesc_[paramNumber].sqlDataType_;
+ int dataCharSet = pstmt.inputDesc_[paramNumber].sqlCharset_;
+ int dataLen;
+
+ // setup the offsets
+ int noNullValue = pstmt.inputDesc_[paramNumber].noNullValue_;
+ int nullValue = pstmt.inputDesc_[paramNumber].nullValue_;
+ int dataLength = pstmt.inputDesc_[paramNumber].maxLen_;
+
+ boolean shortLength = precision < Math.pow(2, 15);
+ int dataOffset = ((shortLength) ? 2 : 4);
+
+ if ((dataType == InterfaceResultSet.SQLTYPECODE_VARCHAR_WITH_LENGTH)
+ || (dataType == InterfaceResultSet.SQLTYPECODE_BLOB)
+ || (dataType == InterfaceResultSet.SQLTYPECODE_CLOB)) {
+ dataLength += dataOffset;
+
+ if (dataLength % 2 != 0)
+ dataLength++;
+ }
+
+ noNullValue = (noNullValue * paramRowCount) + (rowNumber * dataLength);
+
+ if (nullValue != -1)
+ nullValue = (nullValue * paramRowCount) + (rowNumber * 2);
+
+ if (paramValue == null) {
+ if (nullValue == -1) {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale,
+ "null_parameter_for_not_null_column", new Integer(paramNumber));
+ }
+
+ // values[nullValue] = -1;
+ Bytes.insertShort(values, nullValue, (short) -1, this.ic_.getByteSwap());
+ return;
+ }
+
+ switch (dataType) {
+ case InterfaceResultSet.SQLTYPECODE_CHAR:
+ if (paramValue == null) {
+ // Note for future optimization. We can probably remove the next
+ // line,
+ // because the array is already initialized to 0.
+ Bytes.insertShort(values, noNullValue, (short) 0, this.ic_.getByteSwap());
+ } else if (paramValue instanceof byte[]) {
+ tmpBarray = (byte[]) paramValue;
+ } else if (paramValue instanceof String) {
+ String charSet = "";
+
+ try {
+ if (this.ic_.getISOMapping() == InterfaceUtilities.SQLCHARSETCODE_ISO88591
+ && !this.ic_.getEnforceISO() && dataCharSet == InterfaceUtilities.SQLCHARSETCODE_ISO88591)
+ charSet = ic_.t4props_.getISO88591();
+ else
+ {
+ if(dataCharSet == InterfaceUtilities.SQLCHARSETCODE_UNICODE && this.ic_.getByteSwap())
+ charSet = "UTF-16LE";
+ else
+ charSet = InterfaceUtilities.getCharsetName(dataCharSet);
+ }
+ tmpBarray = ((String) paramValue).getBytes(charSet);
+ } catch (Exception e) {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
+ charSet);
+ }
+ } // end if (paramValue instanceof String)
+ else {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_parameter_value",
+ "CHAR data should be either bytes or String for column: " + paramNumber);
+ }
+
+ //
+ // We now have a byte array containing the parameter
+ //
+
+ dataLen = tmpBarray.length;
+ if (maxLength >= dataLen) {
+ System.arraycopy(tmpBarray, 0, values, noNullValue, dataLen);
+ // Blank pad for rest of the buffer
+ if (maxLength > dataLen) {
+ if (dataCharSet == InterfaceUtilities.SQLCHARSETCODE_UNICODE) {
+ // pad with Unicode spaces (0x00 0x32)
+ int i2 = dataLen;
+ while (i2 < maxLength) {
+ values[noNullValue + i2] = (byte) ' ';
+ values[noNullValue + (i2 + 1)] = (byte) 0 ;
+ i2 = i2 + 2;
+ }
+ } else {
+ Arrays.fill(values, (noNullValue + dataLen), (noNullValue + maxLength), (byte) ' ');
+ }
+ }
+ } else {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_string_parameter",
+ "CHAR input data is longer than the length for column: " + paramNumber);
+ }
+
+ break;
+ case InterfaceResultSet.SQLTYPECODE_VARCHAR:
+ if (paramValue instanceof byte[]) {
+ tmpBarray = (byte[]) paramValue;
+ } else if (paramValue instanceof String) {
+ String charSet = "";
+
+ try {
+ if (this.ic_.getISOMapping() == InterfaceUtilities.SQLCHARSETCODE_ISO88591
+ && !this.ic_.getEnforceISO() && dataCharSet == InterfaceUtilities.SQLCHARSETCODE_ISO88591)
+ charSet = ic_.t4props_.getISO88591();
+ else
+ {
+ if(dataCharSet == InterfaceUtilities.SQLCHARSETCODE_UNICODE && this.ic_.getByteSwap())
+ charSet = "UTF-16LE";
+ else
+ charSet = InterfaceUtilities.getCharsetName(dataCharSet);
+ }
+ tmpBarray = ((String) paramValue).getBytes(charSet);
+ } catch (Exception e) {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
+ charSet);
+ }
+
+ } // end if (paramValue instanceof String)
+ else {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_parameter_value",
+ "VARCHAR data should be either bytes or String for column: " + paramNumber);
+ }
+
+ dataLen = tmpBarray.length;
+ if (maxLength > dataLen) {
+ Bytes.insertShort(values, noNullValue, (short) dataLen, this.ic_.getByteSwap());
+ System.arraycopy(tmpBarray, 0, values, noNullValue + 2, dataLen);
+ } else {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_parameter_value",
+ "VARCHAR input data is longer than the length for column: " + paramNumber);
+ }
+ break;
+ case InterfaceResultSet.SQLTYPECODE_DATETIME:
+ Date tmpdate = null;
+ switch (sqlDatetimeCode) {
+ case InterfaceResultSet.SQLDTCODE_DATE:
+ try {
+ if (((String) paramValue)
+ .matches("(\\d{4}-\\d{1,2}-\\d{1,2})|(\\d{1,2}\\.\\d{1,2}\\.\\d{4})|(\\d{1,2}/\\d{1,2}/\\d{4})")) {
+ tmpdate = Date.valueOf((String) ((String) paramValue)
+ .replaceFirst("(\\d{1,2})\\.(\\d{1,2})\\.(\\d{4})", "$3-$2-$1")
+ .replaceFirst("(\\d{1,2})/(\\d{1,2})/(\\d{4})", "$3-$1-$2"));
+ }else{
+ throw new IllegalArgumentException();
+ }
+ } catch (IllegalArgumentException iex) {
+ throw HPT4Messages
+ .createSQLException(
+ pstmt.connection_.props_,
+ locale,
+ "invalid_parameter_value",
+ "["+paramValue+"] Date format is incorrect or date value is invalide. "
+ + " Supported format: YYYY-MM-DD, MM/DD/YYYY, DD.MM.YYYY");
+ }
+ try {
+ byte[] temp1 = tmpdate.toString().getBytes("ASCII");
+ System.arraycopy(temp1, 0, values, noNullValue, temp1.length);
+ } catch (java.io.UnsupportedEncodingException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
+ messageArguments);
+ }
+ break;
+ case InterfaceResultSet.SQLDTCODE_TIMESTAMP:
+ Timestamp tmpts;
+ try {
+ tmpts = Timestamp.valueOf((String) paramValue);
+ } catch (IllegalArgumentException iex) {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_parameter_value",
+ "Timestamp data format is incorrect for column: " + paramNumber + " = " + paramValue);
+ }
+
+ // ODBC precision is nano secs. JDBC precision is micro secs
+ // so substract 3 from ODBC precision.
+ maxLength = maxLength - 3;
+ try {
+ tmpBarray = tmpts.toString().getBytes("ASCII");
+ } catch (java.io.UnsupportedEncodingException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
+ messageArguments);
+ }
+ dataLen = tmpBarray.length;
+
+ if (maxLength > dataLen) {
+ System.arraycopy(tmpBarray, 0, values, noNullValue, dataLen);
+
+ // Don't know when we need this. padding blanks. Legacy??
+ Arrays.fill(values, (noNullValue + dataLen), (noNullValue + maxLength), (byte) ' ');
+ } else {
+ System.arraycopy(tmpBarray, 0, values, noNullValue, maxLength);
+ }
+ break;
+ case InterfaceResultSet.SQLDTCODE_TIME:
+ // If the OdbcDataType is equal to Types.Other, that means
+ // that this is HOUR_TO_FRACTION and should be treated
+ // as a Type.Other --> see in SQLDesc.java
+ if (OdbcDataType != java.sql.Types.OTHER) // do the processing
+ // for TIME
+ {
+ Time tmptime;
+ try {
+ if (paramValue instanceof byte[]) {
+ tmptime = Time.valueOf(new String((byte[]) paramValue, "ASCII"));
+ } else {
+ tmptime = Time.valueOf(paramValue.toString());
+ }
+ byte[] tempb1 = tmptime.toString().getBytes("ASCII");
+ System.arraycopy(tempb1, 0, values, noNullValue, tempb1.length);
+ } catch (IllegalArgumentException iex) {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale,
+ "invalid_parameter_value", "Time data format is incorrect for column: " + paramNumber
+ + " = " + paramValue);
+ } catch (java.io.UnsupportedEncodingException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
+ messageArguments);
+ }
+ break;
+ } else {
+ // HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION data type!!!
+ // let the next case structure handle it
+ }
+ case HPT4Desc.SQLDTCODE_YEAR:
+ case HPT4Desc.SQLDTCODE_YEAR_TO_MONTH:
+ case HPT4Desc.SQLDTCODE_MONTH:
+ case HPT4Desc.SQLDTCODE_MONTH_TO_DAY:
+ case HPT4Desc.SQLDTCODE_DAY:
+ case HPT4Desc.SQLDTCODE_HOUR:
+ case HPT4Desc.SQLDTCODE_HOUR_TO_MINUTE:
+ case HPT4Desc.SQLDTCODE_MINUTE:
+ case HPT4Desc.SQLDTCODE_MINUTE_TO_SECOND:
+ // case HPT4Desc.SQLDTCODE_MINUTE_TO_FRACTION:
+ case HPT4Desc.SQLDTCODE_SECOND:
+ // case HPT4Desc.SQLDTCODE_SECOND_TO_FRACTION:
+ case HPT4Desc.SQLDTCODE_YEAR_TO_HOUR:
+ case HPT4Desc.SQLDTCODE_YEAR_TO_MINUTE:
+ case HPT4Desc.SQLDTCODE_MONTH_TO_HOUR:
+ case HPT4Desc.SQLDTCODE_MONTH_TO_MINUTE:
+ case HPT4Desc.SQLDTCODE_MONTH_TO_SECOND:
+ // case HPT4Desc.SQLDTCODE_MONTH_TO_FRACTION:
+ case HPT4Desc.SQLDTCODE_DAY_TO_HOUR:
+ case HPT4Desc.SQLDTCODE_DAY_TO_MINUTE:
+ case HPT4Desc.SQLDTCODE_DAY_TO_SECOND:
+ // case HPT4Desc.SQLDTCODE_DAY_TO_FRACTION:
+ default:
+ if (paramValue instanceof String) {
+ try {
+ tmpBarray = ((String) paramValue).getBytes("ASCII");
+ } catch (Exception e) {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
+ "ASCII");
+ }
+ } else if (paramValue instanceof byte[]) {
+ tmpBarray = (byte[]) paramValue;
+ } else {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale,
+ "invalid_cast_specification", "DATETIME data should be either bytes or String for column: "
+ + paramNumber);
+ }
+ dataLen = tmpBarray.length;
+ if (maxLength == dataLen) {
+ System.arraycopy(tmpBarray, 0, values, noNullValue, maxLength);
+ } else if (maxLength > dataLen) {
+ System.arraycopy(tmpBarray, 0, values, noNullValue, dataLen);
+
+ // Don't know when we need this. padding blanks. Legacy??
+ Arrays.fill(values, (noNullValue + dataLen), (noNullValue + maxLength), (byte) ' ');
+ } else {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_parameter_value",
+ "DATETIME data longer than column length: " + paramNumber);
+ }
+ break;
+ }
+ break;
+ case InterfaceResultSet.SQLTYPECODE_INTERVAL:
+ if (paramValue instanceof byte[]) {
+ tmpBarray = (byte[]) paramValue;
+ } else if (paramValue instanceof String) {
+ try {
+ tmpBarray = ((String) paramValue).getBytes("ASCII");
+ } catch (Exception e) {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
+ "ASCII");
+ }
+ } else {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_cast_specification",
+ "INTERVAL data should be either bytes or String for column: " + paramNumber);
+ }
+
+ dataLen = tmpBarray.length;
+ if (maxLength >= dataLen) {
+ dataLen = tmpBarray.length;
+ if (maxLength == dataLen) {
+ System.arraycopy(tmpBarray, 0, values, noNullValue, maxLength);
+ } else if (maxLength > dataLen) {
+ System.arraycopy(tmpBarray, 0, values, noNullValue, dataLen);
+
+ // Don't know when we need this. padding blanks. Legacy??
+ Arrays.fill(values, (noNullValue + dataLen), (noNullValue + maxLength), (byte) ' ');
+ }
+ } else {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_parameter_value",
+ "INTERVAL data longer than column length: " + paramNumber);
+ }
+
+ break;
+ case InterfaceResultSet.SQLTYPECODE_VARCHAR_WITH_LENGTH:
+ case InterfaceResultSet.SQLTYPECODE_VARCHAR_LONG:
+ case InterfaceResultSet.SQLTYPECODE_BLOB:
+ case InterfaceResultSet.SQLTYPECODE_CLOB:
+ if (paramValue instanceof byte[]) {
+ tmpBarray = (byte[]) paramValue;
+ } else if (paramValue instanceof String) {
+ String charSet = "";
+
+ try {
+ if (this.ic_.getISOMapping() == InterfaceUtilities.SQLCHARSETCODE_ISO88591
+ && !this.ic_.getEnforceISO() && dataCharSet == InterfaceUtilities.SQLCHARSETCODE_ISO88591)
+ charSet = ic_.t4props_.getISO88591();
+ else
+ {
+ if(dataCharSet == InterfaceUtilities.SQLCHARSETCODE_UNICODE && this.ic_.getByteSwap())
+ charSet = "UTF-16LE";
+ else
+ charSet = InterfaceUtilities.getCharsetName(dataCharSet);
+ }
+ tmpBarray = ((String) paramValue).getBytes(charSet);
+ } catch (Exception e) {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
+ charSet);
+ }
+ } // end if (paramValue instanceof String)
+ else {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_cast_specification",
+ "VARCHAR data should be either bytes or String for column: " + paramNumber);
+ }
+
+ dataLen = tmpBarray.length;
+ if (maxLength > (dataLen + dataOffset)) {
+ maxLength = dataLen + dataOffset;
+
+ if (shortLength) {
+ System.arraycopy(Bytes.createShortBytes((short) dataLen, this.ic_.getByteSwap()), 0, values, noNullValue, dataOffset);
+ } else {
+ System.arraycopy(Bytes.createIntBytes((int) dataLen, this.ic_.getByteSwap()), 0, values, noNullValue, dataOffset);
+ }
+ System.arraycopy(tmpBarray, 0, values, (noNullValue + dataOffset), dataLen);
+ } else {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_string_parameter",
+ "VARCHAR data longer than column length: " + paramNumber);
+ }
+ break;
+ case InterfaceResultSet.SQLTYPECODE_INTEGER:
+ tmpbd = Utility.getBigDecimalValue(locale, paramValue);
+ if (scale > 0) {
+ tmpbd = tmpbd.movePointRight(scale);
+ }
+
+ // data truncation check
+ if (pstmt.roundingMode_ == BigDecimal.ROUND_UNNECESSARY) {
+ Utility.checkLongTruncation(paramNumber, tmpbd);
+
+ }
+ Utility.checkIntegerBoundary(locale, tmpbd);
+
+ // check boundary condition for Numeric.
+ Utility.checkDecimalBoundary(locale, tmpbd, precision);
+
+ Bytes.insertInt(values, noNullValue, tmpbd.intValue(), this.ic_.getByteSwap());
+ break;
+ case InterfaceResultSet.SQLTYPECODE_INTEGER_UNSIGNED:
+ tmpbd = Utility.getBigDecimalValue(locale, paramValue);
+ if (scale > 0) {
+ tmpbd = tmpbd.movePointRight(scale);
+ }
+
+ // data truncation check
+ if (pstmt.roundingMode_ == BigDecimal.ROUND_UNNECESSARY) {
+ Utility.checkLongTruncation(paramNumber, tmpbd);
+
+ // range checking
+ }
+ Utility.checkUnsignedIntegerBoundary(locale, tmpbd);
+
+ // check boundary condition for Numeric.
+ Utility.checkDecimalBoundary(locale, tmpbd, precision);
+
+ Bytes.insertInt(values, noNullValue, tmpbd.intValue(), this.ic_.getByteSwap());
+ break;
+ case InterfaceResultSet.SQLTYPECODE_SMALLINT:
+ tmpbd = Utility.getBigDecimalValue(locale, paramValue);
+ if (scale > 0) {
+ tmpbd = tmpbd.movePointRight(scale);
+ }
+
+ // data truncation check
+ if (pstmt.roundingMode_ == BigDecimal.ROUND_UNNECESSARY) {
+ Utility.checkLongTruncation(paramNumber, tmpbd);
+
+ // range checking
+ }
+ Utility.checkShortBoundary(locale, tmpbd);
+
+ // check boundary condition for Numeric.
+ Utility.checkDecimalBoundary(locale, tmpbd, precision);
+
+ Bytes.insertShort(values, noNullValue, tmpbd.shortValue(), this.ic_.getByteSwap());
+ break;
+ case InterfaceResultSet.SQLTYPECODE_SMALLINT_UNSIGNED:
+ tmpbd = Utility.getBigDecimalValue(locale, paramValue);
+ if (scale > 0) {
+ tmpbd = tmpbd.movePointRight(scale);
+ }
+
+ // data truncation check
+ if (pstmt.roundingMode_ == BigDecimal.ROUND_UNNECESSARY) {
+ Utility.checkLongTruncation(paramNumber, tmpbd);
+
+ // range checking
+ }
+ Utility.checkSignedShortBoundary(locale, tmpbd);
+
+ // check boundary condition for Numeric.
+ Utility.checkDecimalBoundary(locale, tmpbd, precision);
+
+ Bytes.insertShort(values, noNullValue, tmpbd.shortValue(), this.ic_.getByteSwap());
+ break;
+ case InterfaceResultSet.SQLTYPECODE_LARGEINT:
+ tmpbd = Utility.getBigDecimalValue(locale, paramValue);
+
+ if (scale > 0) {
+ tmpbd = tmpbd.movePointRight(scale);
+
+ // check boundary condition for Numeric.
+ }
+ Utility.checkDecimalBoundary(locale, tmpbd, precision);
+ Bytes.insertLong(values, noNullValue, tmpbd.longValue(), this.ic_.getByteSwap());
+ break;
+ case InterfaceResultSet.SQLTYPECODE_DECIMAL:
+ case InterfaceResultSet.SQLTYPECODE_DECIMAL_UNSIGNED:
+
+ // create an parameter with out "."
+ try {
+ tmpbd = Utility.getBigDecimalValue(locale, paramValue);
+ if (scale > 0) {
+ tmpbd = tmpbd.movePointRight(scale);
+
+ }
+
+ tmpbd = Utility.setScale(tmpbd, scale, pstmt.roundingMode_);
+
+ // data truncation check.
+ if (pstmt.roundingMode_ == BigDecimal.ROUND_UNNECESSARY) {
+ Utility.checkLongTruncation(paramNumber, tmpbd);
+
+ // get only the mantissa part
+ }
+ try {
+ tmpBarray = String.valueOf(tmpbd.longValue()).getBytes("ASCII");
+ } catch (java.io.UnsupportedEncodingException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
+ messageArguments);
+ }
+ } catch (NumberFormatException nex) {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_parameter_value",
+ "DECIMAL data format incorrect for column: " + paramNumber + ". Error is: " + nex.getMessage());
+ }
+
+ dataLen = tmpBarray.length;
+
+ // pad leading zero's if datalen < maxLength
+ int desPos = 0;
+ int srcPos = 0;
+ boolean minus = false;
+
+ // check if data is negative.
+ if (tmpbd.signum() == -1) {
+ minus = true;
+ srcPos++;
+ dataLen--;
+ }
+
+ // pad beginning 0 for empty space.
+ int numOfZeros = maxLength - dataLen;
+
+ // DataTruncation is happening.
+ if (numOfZeros < 0) {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "data_truncation_exceed", new int[]{dataLen, maxLength});
+ }
+
+ for (i = 0; i < numOfZeros; i++) {
+ values[noNullValue + desPos] = (byte) '0';
+ desPos = desPos + 1;
+ }
+ System.arraycopy(tmpBarray, srcPos, values, noNullValue + desPos, dataLen);
+
+ // handling minus sign in decimal. OR -80 with the first byte for
+ // minus
+ if (minus) {
+ values[noNullValue] = (byte) ((byte) (-80) | values[noNullValue]);
+ }
+ break;
+ case InterfaceResultSet.SQLTYPECODE_REAL:
+ tmpbd = Utility.getBigDecimalValue(locale, paramValue);
+ Utility.checkFloatBoundary(locale, tmpbd);
+ float fvalue = tmpbd.floatValue();
+ int bits = Float.floatToIntBits(fvalue);
+
+ Bytes.insertInt(values, noNullValue, bits, this.ic_.getByteSwap());
+ break;
+ case InterfaceResultSet.SQLTYPECODE_FLOAT:
+ tmpbd = Utility.getBigDecimalValue(locale, paramValue);
+ Utility.checkFloatBoundary(locale, tmpbd);
+ Bytes.insertLong(values, noNullValue, Double.doubleToLongBits(tmpbd.doubleValue()), this.ic_.getByteSwap());
+ break;
+ case InterfaceResultSet.SQLTYPECODE_DOUBLE:
+ tmpbd = Utility.getBigDecimalValue(locale, paramValue);
+ Utility.checkDoubleBoundary(locale, tmpbd);
+ Bytes.insertLong(values, noNullValue, Double.doubleToLongBits(tmpbd.doubleValue()), this.ic_.getByteSwap());
+ break;
+ case InterfaceResultSet.SQLTYPECODE_NUMERIC:
+ case InterfaceResultSet.SQLTYPECODE_NUMERIC_UNSIGNED:
+ tmpbd = Utility.getBigDecimalValue(locale, paramValue);
+ byte[] b = InterfaceUtilities.convertBigDecimalToSQLBigNum(tmpbd, maxLength, scale);
+ System.arraycopy(b, 0, values, noNullValue, maxLength);
+ break;
+ // You will not get this type, since server internally converts it
+ // SMALLINT, INTERGER or LARGEINT
+ case InterfaceResultSet.SQLTYPECODE_DECIMAL_LARGE:
+ case InterfaceResultSet.SQLTYPECODE_DECIMAL_LARGE_UNSIGNED:
+ case InterfaceResultSet.SQLTYPECODE_BIT:
+ case InterfaceResultSet.SQLTYPECODE_BITVAR:
+ case InterfaceResultSet.SQLTYPECODE_BPINT_UNSIGNED:
+ default:
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(stmt_.connection_.props_, locale, pstmt, paramValue,
+ paramNumber);
+ String temp = "Restricted_Datatype_Error";
+ ic_.t4props_.t4Logger_.logp(Level.FINEST, "InterfaceStatement", "convertObjectToSQL2", temp, p);
+ }
+
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "restricted_data_type", null);
+ }
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities
+ .makeParams(stmt_.connection_.props_, locale, pstmt, paramValue, paramNumber);
+ String temp = "datatype = " + dataType;
+ ic_.t4props_.t4Logger_.logp(Level.FINEST, "InterfaceStatement", "convertObjectToSQL2", temp, p);
+ }
+
+ } // end convertObjectToSQL2
+
+ private SQLWarningOrError[] mergeErrors(SQLWarningOrError[] client, SQLWarningOrError[] server) {
+ SQLWarningOrError[] target = new SQLWarningOrError[client.length + server.length];
+
+ int si = 0; // server index
+ int ci = 0; // client index
+ int ti = 0; // target index
+
+ int sr; // server rowId
+ int cr; // client rowId
+
+ int so = 0; // server offset
+
+ while (ci < client.length && si < server.length) {
+ cr = client[ci].rowId;
+ sr = server[si].rowId + so;
+
+ if (cr <= sr || server[si].rowId == 0) {
+ so++;
+ target[ti++] = client[ci++];
+ } else {
+ server[si].rowId += so;
+ target[ti++] = server[si++];
+ }
+ }
+
+ // we only have one array left
+ while (ci < client.length) {
+ target[ti++] = client[ci++];
+ }
+
+ while (si < server.length) {
+ if (server[si].rowId != 0)
+ server[si].rowId += so;
+ target[ti++] = server[si++];
+ }
+
+ return target;
+ }
+
+ SQL_DataValue_def fillInSQLValues2(Locale locale, TrafT4Statement stmt, int paramRowCount, int paramCount,
+ Object[] paramValues, ArrayList clientErrors) throws SQLException
+
+ {
+ SQL_DataValue_def dataValue = new SQL_DataValue_def();
+
+ if (paramRowCount == 0 && paramValues != null && paramValues.length > 0)
+ paramRowCount = 1; // fake a single row if we are doing inputParams
+ // for an SPJ
+
+ // TODO: we should really figure out WHY this could happen
+ if (stmt.inputParamsLength_ < 0) {
+ dataValue.buffer = new byte[0];
+ dataValue.length = 0;
+ } else {
+ int bufLen = stmt.inputParamsLength_ * paramRowCount;
+
+ dataValue.buffer = new byte[bufLen];
+
+ for (int row = 0; row < paramRowCount; row++) {
+ for (int col = 0; col < paramCount; col++) {
+ try {
+ convertObjectToSQL2(locale, stmt, paramValues[row * paramCount + col], paramRowCount, col,
+ dataValue.buffer, row - clientErrors.size());
+ } catch (HPT4Exception e) {
+ if (paramRowCount == 1) // for single rows we need to
+ // throw immediately
+ throw e;
+
+ clientErrors.add(new SQLWarningOrError(row + 1, e.getErrorCode(), e.getMessage(), e
+ .getSQLState()));
+ break; // skip the rest of the row
+ }
+ }
+ }
+
+ // fix the column offsets if we had errors
+ if (clientErrors.size() > 0) {
+ int oldOffset;
+ int newOffset;
+ int noNullValue;
+ int nullValue;
+ int colLength;
+ int dataType;
+
+ for (int i = 1; i < paramCount; i++) // skip the first col
+ {
+ noNullValue = stmt.inputDesc_[i].noNullValue_;
+ nullValue = stmt.inputDesc_[i].nullValue_;
+ colLength = stmt.inputDesc_[i].maxLen_;
+ dataType = stmt.inputDesc_[i].dataType_;
+ if (dataType == InterfaceResultSet.SQLTYPECODE_VARCHAR_WITH_LENGTH
+ || dataType == InterfaceResultSet.SQLTYPECODE_BLOB
+ || dataType == InterfaceResultSet.SQLTYPECODE_CLOB
+ || dataType == InterfaceResultSet.SQLTYPECODE_VARCHAR_LONG
+ || dataType == InterfaceResultSet.SQLTYPECODE_VARCHAR) {
+ boolean shortLength = colLength < Math.pow(2, 15);
+ int dataOffset = ((shortLength) ? 2 : 4);
+ colLength += dataOffset;
+
+ if (colLength % 2 != 0)
+ colLength++;
+ }
+
+ if (nullValue != -1) {
+ oldOffset = nullValue * paramRowCount;
+ newOffset = oldOffset - (nullValue * clientErrors.size());
+ System.arraycopy(dataValue.buffer, oldOffset, dataValue.buffer, newOffset,
+ 2 * (paramRowCount - clientErrors.size()));
+ }
+
+ oldOffset = noNullValue * paramRowCount;
+ newOffset = oldOffset - (noNullValue * clientErrors.size());
+ System.arraycopy(dataValue.buffer, oldOffset, dataValue.buffer, newOffset, colLength
+ * (paramRowCount - clientErrors.size()));
+ }
+ }
+
+ dataValue.length = stmt.inputParamsLength_ * (paramRowCount - clientErrors.size());
+ }
+ return dataValue;
+ }
+
+ boolean hasParameters(String sql) {
+ boolean foundParam = false;
+
+ String[] s = sql.split("\"[^\"]*\"|'[^']*'");
+ for (int i = 0; i < s.length; i++) {
+ if (s[i].indexOf('?') != -1) {
+ foundParam = true;
+ break;
+ }
+ }
+
+ return foundParam;
+ }
+
+ /**
+ * Get the transaction status
+ *
+ * @param sql
+ * @return
+ */
+ private short getTransactionStatus(String sql) {
+ String tokens[] = sql.split("[^a-zA-Z]+", 3);
+ short rt1 = 0;
+ if (tokens.length > 1 && tokens[1].equalsIgnoreCase("WORK")) {
+ if (tokens[0].equalsIgnoreCase("BEGIN"))
+ rt1 = TRANSPORT.TYPE_BEGIN_TRANSACTION;
+ } else if (tokens[0].equalsIgnoreCase("COMMIT")
+ || tokens[0].equalsIgnoreCase("ROLLBACK")) {
+ rt1 = TRANSPORT.TYPE_END_TRANSACTION;
+ }
+
+ return rt1;
+ }
+
+ // -------------------------------------------------------------
+ //TODO: this whole function needs to be rewritten
+ short getSqlStmtType(String str) {
+ str=str.replaceAll("\\n"," ");
+ str=str.replaceAll("\\s*/\\*.*?\\*/\\s*", " ").trim();
+
+ // 7708
+ stmtIsLock = false;
+
+ String tokens[] = str.split("[^a-zA-Z]+", 3);
+ short rt1 = TRANSPORT.TYPE_UNKNOWN;
+ String str3 = "";
+
+ if (tokens[0].length() > 0)
+ str3 = tokens[0].toUpperCase();
+ else
+ str3 = tokens[1].toUpperCase();
+
+ if(str3.equals("JOINXATXN")){
+ rt1 = TRANSPORT.TYPE_SELECT;
+ }
+ else if(str3.equals("WMSOPEN")) {
+ rt1 = TRANSPORT.TYPE_QS_OPEN;
+ }
+ else if(str3.equals("WMSCLOSE")) {
+ rt1 = TRANSPORT.TYPE_QS_CLOSE;
+ }
+ else if(str3.equals("CMDOPEN")) {
+ rt1 = TRANSPORT.TYPE_CMD_OPEN;
+ }
+ else if(str3.equals("CMDCLOSE")) {
+ rt1 = TRANSPORT.TYPE_CMD_CLOSE;
+ }
+ else {
+ switch(this.ic_.getMode()) {
+ case InterfaceConnection.MODE_SQL:
+ if ((str3.equals("SELECT")) || (str3.equals("SHOWSHAPE")) || (str3.equals("INVOKE"))
+ || (str3.equals("SHOWCONTROL")) || (str3.equals("SHOWDDL")) || (str3.equals("EXPLAIN"))
+ || (str3.equals("SHOWPLAN")) || (str3.equals("REORGANIZE")) || (str3.equals("MAINTAIN"))
+ || (str3.equals("SHOWLABEL")) || (str3.equals("VALUES"))
+ || (str3.equals("REORG")) || (str3.equals("SEL")) || (str3.equals("GET")) || (str3.equals("SHOWSTATS"))
+ || str3.equals("GIVE") || str3.equals("STATUS") || str3.equals("INFO") || str3.equals("LIST")
+ ) {
+ rt1 = TRANSPORT.TYPE_SELECT;
+ }
+ else if (str3.equals("UPDATE") || str3.equals("MERGE")) {
+ rt1 = TRANSPORT.TYPE_UPDATE;
+ } else if (str3.equals("DELETE") || str3.equals("STOP") || str3.equals("START")) {
+ rt1 = TRANSPORT.TYPE_DELETE;
+ } else if (str3.equals("INSERT") || str3.equals("INS") || str3.equals("UPSERT")) {
+ if (hasParameters(str)) {
+ rt1 = TRANSPORT.TYPE_INSERT_PARAM;
+ } else {
+ rt1 = TRANSPORT.TYPE_INSERT;
+ }
+ }
+ else if (str3.equals("CREATE")) {
+ rt1 = TRANSPORT.TYPE_CREATE;
+ } else if (str3.equals("GRANT")) {
+ rt1 = TRANSPORT.TYPE_GRANT;
+ } else if (str3.equals("DROP")) {
+ rt1 = TRANSPORT.TYPE_DROP;
+ } else if (str3.equals("CALL")) {
+ rt1 = TRANSPORT.TYPE_CALL;
+ } else if (str3.equals("EXPLAIN")) {
+ rt1 = TRANSPORT.TYPE_EXPLAIN;
+ } else if (str3.equals("INFOSTATS")) {
+ rt1 = TRANSPORT.TYPE_STATS;
+ }
+ break;
+ case InterfaceConnection.MODE_WMS:
+ if (str3.equals("STATUS") || str3.equals("INFO")) {
+ rt1 = TRANSPORT.TYPE_SELECT;
+ }
+ break;
+ /* FROM ODBC
+ if (_strnicmp(token, "STATUS", 6) == 0)
+ m_StmtType = TYPE_SELECT;
+ else if (_strnicmp(token, "CANCEL", 6) == 0)
+ m_StmtType = TYPE_UNKNOWN;
+ else if (_strnicmp(token, "SUSPEND", 7) == 0)
+ m_StmtType = TYPE_UNKNOWN;
+ else if (_strnicmp(token, "RESUME", 6) == 0)
+ m_StmtType = TYPE_UNKNOWN;
+ else if (_strnicmp(token, "ALTPRI", 6) == 0)
+ m_StmtType = TYPE_UNKNOWN;
+ else if (_strnicmp(token, "ADD", 3) == 0)
+ m_StmtType = TYPE_UNKNOWN;
+ else if (_strnicmp(token, "ALTER", 5) == 0)
+ m_StmtType = TYPE_UNKNOWN;
+ else if (_strnicmp(token, "DELETE", 6) == 0)
+ m_StmtType = TYPE_UNKNOWN;
+ else if (_strnicmp(token, "INFO", 4) == 0)
+ m_StmtType = TYPE_SELECT;
+ else
+ m_StmtType = TYPE_UNKNOWN;
+ }*/
+ case InterfaceConnection.MODE_CMD:
+ if (str3.equals("STATUS") || str3.equals("INFO") || str3.equals("LIST")) {
+ rt1 = TRANSPORT.TYPE_SELECT;
+ }
+ else if(str3.equals("ADD") || str3.equals("ALTER")) {
+ rt1 = TRANSPORT.TYPE_INSERT;
+ }
+ else if(str3.equals("DELETE") || str3.equals("STOP") || str3.equals("START")) {
+ rt1 = TRANSPORT.TYPE_DELETE;
+ }
+ break;
+ }
+ }
+
+ return rt1;
+
+ } // end getSqlStmtType
+
+ // -------------------------------------------------------------
+ long getRowCount() {
+ return rowCount_;
+ }
+
+ // -------------------------------------------------------------
+ void setRowCount(long rowCount) {
+ if (rowCount < 0) {
+ rowCount_ = -1;
+ } else {
+ rowCount_ = rowCount;
+ }
+ }
+
+ // -------------------------------------------------------------
+ static HPT4Desc[] NewDescArray(SQLItemDescList_def desc) {
+ int index;
+ HPT4Desc[] HPT4DescArray;
+ SQLItemDesc_def SQLDesc;
+
+ if (desc.list == null || desc.list.length == 0) {
+ return null;
+ }
+
+ HPT4DescArray = new HPT4Desc[desc.list.length];
+
+ for (index = 0; index < desc.list.length; index++) {
+ SQLDesc = desc.list[index];
+ boolean nullInfo = (((new Byte(SQLDesc.nullInfo)).shortValue()) == 1) ? true : false;
+ boolean signType = (((new Byte(SQLDesc.signType)).shortValue()) == 1) ? true : false;
+ HPT4DescArray[index] = new HPT4Desc(SQLDesc.dataType, (short) SQLDesc.datetimeCode, SQLDesc.maxLen,
+ SQLDesc.precision, SQLDesc.scale, nullInfo, SQLDesc.colHeadingNm, signType, SQLDesc.ODBCDataType,
+ SQLDesc.ODBCPrecision, SQLDesc.SQLCharset, SQLDesc.ODBCCharset, SQLDesc.CatalogName,
+ SQLDesc.SchemaName, SQLDesc.TableName, SQLDesc.dataType, SQLDesc.intLeadPrec, SQLDesc.paramMode);
+ }
+ return HPT4DescArray;
+ }
+
+ // -------------------------------------------------------------
+ static HPT4Desc[] NewDescArray(Descriptor2[] descArray) {
+ int index;
+ HPT4Desc[] HPT4DescArray;
+ Descriptor2 desc;
+
+ if (descArray == null || descArray.length == 0) {
+ return null;
+ }
+
+ HPT4DescArray = new HPT4Desc[descArray.length];
+
+ for (index = 0; index < descArray.length; index++) {
+ desc = descArray[index];
+ boolean nullInfo = false;
+ boolean signType = false;
+
+ if (desc.nullInfo_ != 0) {
+ nullInfo = true;
+ }
+ if (desc.signed_ != 0) {
+ signType = true;
+
+ }
+ HPT4DescArray[index] = new HPT4Desc(desc.noNullValue_, desc.nullValue_, desc.version_, desc.dataType_,
+ (short) desc.datetimeCode_, desc.maxLen_, (short) desc.precision_, (short) desc.scale_, nullInfo,
+ signType, desc.odbcDataType_, desc.odbcPrecision_, desc.sqlCharset_, desc.odbcCharset_,
+ desc.colHeadingNm_, desc.tableName_, desc.catalogName_, desc.schemaName_, desc.headingName_,
+ desc.intLeadPrec_, desc.paramMode_, desc.dataType_, desc.getRowLength());
+ }
+ return HPT4DescArray;
+ }
+
+ // -------------------------------------------------------------
+ // Interface methods
+ void executeDirect(int queryTimeout, TrafT4Statement stmt) throws SQLException {
+ short executeAPI = stmt.getOperationID();
+ byte[] messageBuffer = stmt.getOperationBuffer();
+ GenericReply gr = null;
+
+ gr = t4statement_.ExecuteGeneric(executeAPI, messageBuffer);
+ stmt.operationReply_ = gr.replyBuffer;
+
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(stmt_.connection_.props_, queryTimeout, stmt);
+ String temp = "Exiting ExecDirect.";
+ ic_.t4props_.t4Logger_.logp(Level.FINEST, "InterfaceStatement", "executeDirect", temp, p);
+ }
+ } // end executeDirect
+
+ // --------------------------------------------------------------------------
+ int close() throws SQLException {
+ int rval = 0;
+ CloseReply cry_ = null;
+ ic_.isConnectionOpen();
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(stmt_.connection_.props_);
+ String temp = "Closing = " + stmtLabel_;
+ ic_.t4props_.t4Logger_.logp(Level.FINEST, "InterfaceStatement", "close", temp, p);
+ }
+
+ cry_ = t4statement_.Close();
+ switch (cry_.m_p1.exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+
+ // ignore the SQLWarning for the static close
+ break;
+ case odbc_SQLSvc_Close_exc_.odbc_SQLSvc_Close_SQLError_exn_:
+ HPT4Messages.throwSQLException(stmt_.connection_.props_, cry_.m_p1.SQLError);
+ default:
+ throw HPT4Messages.createSQLException(stmt_.connection_.props_, ic_.getLocale(), "ids_unknown_reply_error",
+ null);
+ } // end switch
+
+ return cry_.m_p2; // rowsAffected
+ } // end close
+
+ // --------------------------------------------------------------------------
+ void cancel() throws SQLException {
+ ic_.cancel();
+ }
+
+ // --------------------------------------------------------------------------
+ // Interface methods for prepared statement
+ void prepare(String sql, int queryTimeout, TrafT4PreparedStatement pstmt) throws SQLException {
+ int sqlAsyncEnable = 0;
+ this.stmtType_ = this.EXTERNAL_STMT;
+ this.sqlStmtType_ = getSqlStmtType(sql);
+ this.setTransactionStatus(pstmt.connection_, sql);
+ int stmtLabelCharset = 1;
+ String cursorName = pstmt.cursorName_;
+ int cursorNameCharset = 1;
+ String moduleName = pstmt.moduleName_;
+ int moduleNameCharset = 1;
+ long moduleTimestamp = pstmt.moduleTimestamp_;
+ String sqlString = sql;
+ int sqlStringCharset = 1;
+ String stmtOptions = "";
+ int maxRowsetSize = pstmt.getMaxRows();
+
+ byte[] txId;
+
+//3196 - NDCS transaction for SPJ
+// if (ic_.t4props_.getSPJEnv())
+// txId = getUDRTransaction(this.ic_.getByteSwap());
+// else
+// txId = Bytes.createIntBytes(0, false);
+ txId = Bytes.createIntBytes(0, false);
+
+ if (sqlStmtType_ == TRANSPORT.TYPE_STATS) {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, ic_.getLocale(), "infostats_invalid_error",
+ null);
+ } else if (sqlStmtType_ == TRANSPORT.TYPE_CONFIG) {
+ throw HPT4Messages.createSQLException(pstmt.connection_.props_, ic_.getLocale(),
+ "config_cmd_invalid_error", null);
+ }
+
+ PrepareReply pr = t4statement_.Prepare(sqlAsyncEnable, (short) this.stmtType_, this.sqlStmtType_,
+ pstmt.stmtLabel_, stmtLabelCharset, cursorName, cursorNameCharset, moduleName, moduleNameCharset,
+ moduleTimestamp, sqlString, sqlStringCharset, stmtOptions, maxRowsetSize, txId);
+
+ pr_ = pr;
+ this.sqlQueryType_ = pr.sqlQueryType;
+
+ switch (pr.returnCode) {
+ case TRANSPORT.SQL_SUCCESS:
+ case TRANSPORT.SQL_SUCCESS_WITH_INFO:
+ HPT4Desc[] OutputDesc = InterfaceStatement.NewDescArray(pr.outputDesc);
+ HPT4Desc[] InputDesc = InterfaceStatement.NewDescArray(pr.inputDesc);
+ pstmt.setPrepareOutputs2(InputDesc, OutputDesc, pr.inputNumberParams, pr.outputNumberParams,
+ pr.inputParamLength, pr.outputParamLength, pr.inputDescLength, pr.outputDescLength);
+
+ if (pr.errorList != null && pr.errorList.length > 0) {
+ HPT4Messages.setSQLWarning(stmt_.connection_.props_, pstmt, pr.errorList);
+ }
+
+ this.stmtHandle_ = pr.stmtHandle;
+
+ break;
+
+ case odbc_SQLSvc_Prepare_exc_.odbc_SQLSvc_Prepare_SQLError_exn_:
+
+ default:
+ HPT4Messages.throwSQLException(stmt_.connection_.props_, pr.errorList);
+ }
+
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(stmt_.connection_.props_, sql, queryTimeout, pstmt);
+ String temp = "Exiting prepare...";
+ ic_.t4props_.t4Logger_.logp(Level.FINEST, "InterfaceStatement", "prepare", temp, p);
+ }
+ };
+
+ // used to keep the same transaction inside an SPJ. we call out to the UDR
+ // server and use their transaction for all executes.
+ byte[] getUDRTransaction(boolean swapBytes) throws SQLException {
+ byte[] ret = null;
+
+ try {
+ // To get references to method
+ InterfaceStatement.LmUtility_class_ = Class.forName("com.tandem.sqlmx.LmUtility");
+ InterfaceStatement.LmUtility_getTransactionId_ = InterfaceStatement.LmUtility_class_.getMethod(
+ "getTransactionId", new Class[] {});
+
+ // To invoke the method
+ short[] tId = (short[]) InterfaceStatement.LmUtility_getTransactionId_.invoke(null, new Object[] {});
+
+ ret = new byte[tId.length * 2];
+
+ for (int i = 0; i < tId.length; i++) {
+ Bytes.insertShort(ret, i * 2, tId[i], swapBytes);
+ }
+ } catch (Exception e) {
+ ic_.t4props_.t4Logger_.logp(Level.FINEST, "InterfaceStatement", "getUDRTransaction",
+ "Error calling UDR for transaction id");
+
+ String s = e.toString() + "\r\n";
+ StackTraceElement[] st = e.getStackTrace();
+
+ for (int i = 0; i < st.length; i++) {
+ s += st[i].toString() + "\r\n";
+ }
+
+ throw new SQLException(s);
+ }
+
+ return ret;
+ }
+
+ // -------------------------------------------------------------------
+ void execute(short executeAPI, int paramRowCount, int paramCount, Object[] paramValues, int queryTimeout
+ // executeDirect
+ , String sql, TrafT4Statement stmt
+
+ ) throws SQLException {
+ cursorName_ = stmt.cursorName_;
+ rowCount_ = 0;
+
+ int sqlAsyncEnable = (stmt.getResultSetHoldability() == TrafT4ResultSet.HOLD_CURSORS_OVER_COMMIT) ? 1 : 0;
+ int inputRowCnt = paramRowCount;
+ int maxRowsetSize = stmt.getMaxRows();
+ String sqlString = (sql == null) ? stmt.getSQL() : sql;
+ int sqlStringCharset = 1;
+ int cursorNameCharset = 1;
+ int stmtLabelCharset = 1;
+ byte[] txId;
+ ArrayList clientErrors = new ArrayList();
+
+//3196 - NDCS transaction for SPJ
+// if (ic_.t4props_.getSPJEnv())
+// txId = getUDRTransaction(this.ic_.getByteSwap());
+// else if (stmt.transactionToJoin != null)
+// txId = stmt.transactionToJoin;
+// else if (stmt.connection_.transactionToJoin != null)
+// txId = stmt.connection_.transactionToJoin;
+// else
+// txId = Bytes.createIntBytes(0, false); // 0 length, no data
+ if (stmt.transactionToJoin != null)
+ txId = stmt.transactionToJoin;
+ else if (stmt.connection_.transactionToJoin != null)
+ txId = stmt.connection_.transactionToJoin;
+ else
+ txId = Bytes.createIntBytes(0, false); // 0 length, no data
+
+ SQL_DataValue_def inputDataValue;
+ SQLValueList_def inputValueList = new SQLValueList_def();
+ byte[] inputParams = null;
+
+ if (executeAPI == TRANSPORT.SRVR_API_SQLEXECDIRECT) {
+ sqlStmtType_ = getSqlStmtType(sql);
+ setTransactionStatus(stmt.connection_, sql);
+ stmt.outputDesc_ = null; // clear the output descriptors
+ }
+
+ if (stmt.usingRawRowset_ == true) {
+ executeAPI = TRANSPORT.SRVR_API_SQLEXECUTE2;
+ inputDataValue = new SQL_DataValue_def();
+ inputDataValue.userBuffer = stmt.rowwiseRowsetBuffer_;
+ inputDataValue.length = stmt.rowwiseRowsetBuffer_.limit() - 4;
+
+ if (this.sqlQueryType_ == 16) // use the param values
+ {
+ try {
+ inputRowCnt = Integer.parseInt(paramValues[0].toString());
+ maxRowsetSize = Integer.parseInt(paramValues[1].toString());
+ } catch (Exception e) {
+ throw new SQLException(
+ "Error setting inputRowCnt and maxRowsetSize. Parameters not set or invalid.");
+ }
+ } else {
+ inputRowCnt = paramRowCount - 1;
+ }
+
+ } else {
+ inputDataValue = fillInSQLValues2(ic_.getLocale(), stmt, inputRowCnt, paramCount, paramValues, clientErrors);
+
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(stmt_.connection_.props_, paramRowCount, paramCount,
+ paramValues, queryTimeout, stmt);
+ String temp = "invoke ==> Execute2";
+ ic_.t4props_.t4Logger_.logp(Level.FINEST, "InterfaceStatement", "execute", temp, p);
+ }
+ }
+
+ ExecuteReply er = t4statement_.Execute(executeAPI, sqlAsyncEnable, inputRowCnt - clientErrors.size(),
+ maxRowsetSize, this.sqlStmtType_, this.stmtHandle_, sqlString, sqlStringCharset, this.cursorName_,
+ cursorNameCharset, stmt.stmtLabel_, stmtLabelCharset, inputDataValue, inputValueList, txId,
+ stmt.usingRawRowset_);
+
+ if (executeAPI == TRANSPORT.SRVR_API_SQLEXECDIRECT) {
+ this.sqlQueryType_ = er.queryType;
+ }
+
+ if (clientErrors.size() > 0) {
+ if (er.errorList == null)
+ er.errorList = (SQLWarningOrError[]) clientErrors.toArray(new SQLWarningOrError[clientErrors.size()]);
+ else
+ er.errorList = mergeErrors((SQLWarningOrError[]) clientErrors
+ .toArray(new SQLWarningOrError[clientErrors.size()]), er.errorList);
+ }
+
+ stmt_.result_set_offset = 0;
+ rowCount_ = er.rowsAffected;
+
+ int numStatus;
+
+ if (stmt_.connection_.props_.getDelayedErrorMode())
+ {
+ if (stmt_._lastCount > 0) {
+ numStatus = stmt_._lastCount;
+ }
+ else {
+ numStatus = inputRowCnt;
+ }
+ }
+ else
+ {
+ numStatus = inputRowCnt;
+ }
+
+ if (numStatus < 1)
+ {
+ numStatus = 1;
+ }
+
+ stmt.batchRowCount_ = new int[numStatus];
+ boolean batchException = false; //3164
+
+ if (stmt_.connection_.props_.getDelayedErrorMode() && stmt_._lastCount < 1) {
+ Arrays.fill(stmt.batchRowCount_, -2); // fill with success
+ }
+ else if (er.returnCode == TRANSPORT.SQL_SUCCESS || er.returnCode == TRANSPORT.SQL_SUCCESS_WITH_INFO
+ || er.returnCode == TRANSPORT.NO_DATA_FOUND) {
+ Arrays.fill(stmt.batchRowCount_, -2); // fill with success
+ if (er.errorList != null) // if we had errors with valid rowIds,
+ // update the array
+ {
+ for (int i = 0; i < er.errorList.length; i++) {
+ int row = er.errorList[i].rowId - 1;
+ if (row >= 0 && row < stmt.batchRowCount_.length) {
+ stmt.batchRowCount_[row] = -3;
+ batchException = true; //3164
+ }
+ }
+ }
+
+ //set the statement mode as the command succeeded
+ if (sqlStmtType_ == TRANSPORT.TYPE_QS_OPEN) {
+ this.ic_.setMode(InterfaceConnection.MODE_WMS);
+ } else if (sqlStmtType_ == TRANSPORT.TYPE_QS_CLOSE) {
+ this.ic_.setMode(InterfaceConnection.MODE_SQL);
+ } else if(sqlStmtType_ == TRANSPORT.TYPE_CMD_OPEN) {
+ this.ic_.setMode(InterfaceConnection.MODE_CMD);
+ } else if(sqlStmtType_ == TRANSPORT.TYPE_CMD_CLOSE) {
+ this.ic_.setMode(InterfaceConnection.MODE_SQL);
+ }
+
+ // set the statement label if we didnt get one back.
+ if (er.stmtLabels == null || er.stmtLabels.length == 0) {
+ er.stmtLabels = new String[1];
+ er.stmtLabels[0] = stmt.stmtLabel_;
+ }
+
+ // get the descriptors from the proper location
+ HPT4Desc[][] desc = null;
+
+ // try from execute data first
+ if (er.outputDesc != null && er.outputDesc.length > 0) {
+ desc = new HPT4Desc[er.outputDesc.length][];
+
+ for (int i = 0; i < er.outputDesc.length; i++) {
+ desc[i] = InterfaceStatement.NewDescArray(er.outputDesc[i]);
+ }
+ }
+ // try from the prepare data
+ else if (stmt.outputDesc_ != null && stmt.outputDesc_.length > 0) {
+ desc = new HPT4Desc[1][];
+ desc[0] = stmt.outputDesc_;
+ }
+
+ if (this.sqlStmtType_ == TRANSPORT.TYPE_CALL) {
+ TrafT4CallableStatement cstmt = (TrafT4CallableStatement) stmt;
+ Object[] outputValueArray;
+ if(er.returnCode == TRANSPORT.NO_DATA_FOUND) { //this should really only happen with LAST0 specified
+ outputValueArray = new Object[cstmt.outputDesc_.length];
+ }
+ else {
+ outputValueArray = InterfaceResultSet.getExecute2Outputs(cstmt.connection_, cstmt.outputDesc_,
+ er.outValues, this.ic_.getByteSwap());
+ }
+
+ cstmt.setExecuteCallOutputs(outputValueArray, (short) er.rowsAffected);
+ stmt.setMultipleResultSets(er.numResultSets, desc, er.stmtLabels, er.proxySyntax);
+ } else {
+ // fix until we start returning numResultsets for more than just
+ // SPJs
+ if (desc != null && desc.length > 0 && er.numResultSets == 0) {
+ er.numResultSets = 1;
+ }
+
+ if (er.outValues != null && er.outValues.length > 0) {
+ stmt.setExecute2Outputs(er.outValues, (short) er.rowsAffected, false, er.proxySyntax, desc[0]);
+ } else {
+ stmt.setMultipleResultSets(er.numResultSets, desc, er.stmtLabels, er.proxySyntax);
+ }
+ }
+ if (er.errorList != null) {
+ HPT4Messages.setSQLWarning(stmt_.connection_.props_, stmt, er.errorList);
+ }
+ } else {
+ Arrays.fill(stmt.batchRowCount_, -3); // fill with failed
+ HPT4Messages.throwSQLException(stmt_.connection_.props_, er.errorList);
+ }
+ //3164
+ if (batchException) {
+ HPT4Messages.throwSQLException(stmt_.connection_.props_, er.errorList);
+ }
+ }
+
+ protected void setTransactionStatus(TrafT4Connection conn, String sql) {
+ short tranStatus = getTransactionStatus(sql);
+ if(tranStatus == TRANSPORT.TYPE_BEGIN_TRANSACTION){
+ conn.setBeginTransaction(true);
+ }else if (tranStatus == TRANSPORT.TYPE_END_TRANSACTION){
+ conn.setBeginTransaction(false);
+ }
+
+ }
+} // end class InterfaceStatement
[57/60] incubator-trafodion git commit: Included the missing copyright
Posted by db...@apache.org.
Included the missing copyright
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/6897f880
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/6897f880
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/6897f880
Branch: refs/heads/master
Commit: 6897f880cf9c5ee3eceb6e683784b28379c8b555
Parents: 780f976
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Fri Apr 29 18:17:55 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Fri Apr 29 18:17:55 2016 +0000
----------------------------------------------------------------------
.../java/org/trafodion/jdbc/t4/AppTest.java | 23 ++++++++++++++++++++
1 file changed, 23 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6897f880/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/AppTest.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/AppTest.java b/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/AppTest.java
index 0a07e0b..220660c 100644
--- a/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/AppTest.java
+++ b/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/AppTest.java
@@ -1,3 +1,26 @@
+/*
+* @@@ 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 junit.framework.Test;
[11/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Address.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Address.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Address.java
deleted file mode 100644
index 6cc2085..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Address.java
+++ /dev/null
@@ -1,315 +0,0 @@
-// @@@ 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;
-
-/**********************************************************
- * This class represents an address reference.
- *
- * @version 1.0
- **********************************************************/
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.Locale;
-import java.util.Properties;
-
-final class T4Address extends Address {
-
- private static final String t4ConnectionPrefix = "jdbc:t4jdbc:";
- private static final String urlPrefix = t4ConnectionPrefix + "//";
- private static final int minT4ConnectionAddrLen = t4ConnectionPrefix.length() + 4;
- private static final int AS_type = 1; // jdbc:subprotocol:subname
-
- /**
- * The constructor.
- *
- * @param addr
- * The addr has two forms:
- *
- * DriverManager getConnection addr parameter format for connecting via the
- * Fast JDBC Type 4 driver.
- *
- * jdbc:subprotocol:subname
- *
- * Where:
- *
- * subprotocol = t4jdbc
- *
- * subname = //<{IP Address|Machine Name}[:port]>/<properties>
- *
- * Example: jdbc:t4jdbc://130.168.200.30:1433/database1
- *
- */
-
- // ----------------------------------------------------------
- T4Address(T4Properties t4props, Locale locale, String addr) throws SQLException {
- super(t4props, locale, addr);
-
- if (addr == null) {
- SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_null_error", null);
- throw se;
- }
-
- //
- // We are now expecting addr = "//<{IP Address|Machine
- // Name}[:port]>/<properties>"
- //
- m_type = AS_type;
-
- //
- // We don't recognize this address syntax
- //
- if (acceptsURL(addr) == false) {
- SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", addr);
- SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "unknown_prefix_error", null);
-
- se.setNextException(se2);
- throw se;
- }
-
- //
- // We are now expecting addr = "<{IP Address|Machine Name}[:port]>"
- // Get the IP or Name
- //
- String IPorName = extractHostFromUrl(addr);
- if (isIPAddress(IPorName)) {
- m_ipAddress = IPorName;
- } else {
- m_machineName = IPorName;
-
- //
- // Get the port number if there is one.
- //
- }
- m_portNumber = new Integer(extractPortFromUrl(addr));
- m_properties = extractPropertiesFromString(addr);
-
- m_url = recreateAddress();
-
- validateAddress();
- setInputOutput();
- }
-
- String recreateAddress() {
- String addr = null;
-
- addr = t4ConnectionPrefix + "//";
-
- if (m_machineName != null) {
- addr = addr + m_machineName;
- } else if (m_ipAddress != null) {
- addr = addr + m_ipAddress;
-
- }
- if (m_portNumber != null) {
- addr = addr + ":" + m_portNumber;
-
- }
- addr = addr + "/";
-
- return addr;
- } // end recreateAddress
-
- static boolean acceptsURL(String url) throws SQLException {
- try {
- return url.toLowerCase().startsWith(t4ConnectionPrefix);
- } catch (Exception ex) {
- throw new SQLException(ex.toString());
- }
- }
-
- // ----------------------------------------------------------
- String getUrl() {
- return urlPrefix + getIPorName() + ':' + getPort().toString() + "/:";
- } // end getProps()
-
- // ----------------------------------------------------------
- Properties getProps() {
- return m_properties;
- } // end getProps()
-
- /**
- * Return the host value
- *
- * @param url
- * of format jdbc:t4jdbc://host:port/:[prop-name=prop-value]..
- * @return host string
- */
- private String extractHostFromUrl(String url) throws SQLException {
- if (url.length() < minT4ConnectionAddrLen) {
- SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", url);
- SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "min_address_length_error", null);
-
- se.setNextException(se2);
- throw se;
- }
-
- int hostStartIndex = urlPrefix.length();
- int hostEndIndex = -1;
- if (isIPV6(url)) {
- hostEndIndex = url.lastIndexOf(']', hostStartIndex); // IP6
- } else {
- hostEndIndex = url.indexOf(':', hostStartIndex); // IP4
-
- }
- if (hostEndIndex < 0) {
- SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", url);
- SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "address_format_error", url);
-
- se.setNextException(se2);
- throw se;
- }
-
- String host = url.substring(hostStartIndex, hostEndIndex);
- if ((host == null) || (host.length() == 0)) {
- SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", url);
- SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "address_format_error", null);
- SQLException se3 = HPT4Messages.createSQLException(m_t4props, m_locale, "missing_ip_or_name_error", null);
- se.setNextException(se2);
- se2.setNextException(se3);
- throw se;
- }
-
- return host;
- }
-
- /**
- * Return the port value
- *
- * @param url
- * of format jdbc:t4jdbc://host:port/:[prop-name=prop-value]..
- * @return port string
- */
- private String extractPortFromUrl(String url) throws SQLException {
- int portStartIndex = url.indexOf(':', urlPrefix.length()) + 1;
- int portEndIndex = url.indexOf('/', portStartIndex);
- if (portEndIndex < 0) {
- portEndIndex = url.length();
-
- }
- String port = url.substring(portStartIndex, portEndIndex);
- if (port.length() < 1) {
- throw new SQLException("Incorrect port value in the URL.");
- }
- ;
-
- int asPort;
- try {
- asPort = Integer.parseInt(port);
- } catch (Exception e) {
- throw new SQLException("Incorrect port value in the URL.");
- }
-
- if ((asPort < 0) || (asPort > 65535)) {
- throw new SQLException("Port value out of range in the URL.");
- }
-
- return port;
- }
-
- /**
- * Checks if the url is of IP6 protocol
- */
- private boolean isIPV6(String url) throws SQLException {
- if (url == null) {
- SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", url);
- SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "address_format_2_error", null);
- se.setNextException(se2);
- throw se;
-
- }
- int hostStartIndex = urlPrefix.length();
- return (url.charAt(hostStartIndex) == '[');
- }
-
- /**
- * Extracts the property name, value pair from a url String, seperated by ;
- *
- * @param url
- * of format jdbc:t4jdbc://host:port/:[prop-name=prop-value]..
- * @return Propeties object
- * @throws IOException
- */
- private Properties extractPropertiesFromString(String url) throws SQLException {
- int urLength = url.length();
- int hostStartIndex = urlPrefix.length();
- int propStartIndex = url.indexOf('/', hostStartIndex);
- if (propStartIndex < 0) {
- return null;
- }
-
- if (propStartIndex == urLength) {
- return null;
- }
-
- if (url.charAt(propStartIndex) == '/') {
- propStartIndex++;
-
- }
- if (propStartIndex == urLength) {
- return null;
- }
-
- if (url.charAt(propStartIndex) == ':') {
- propStartIndex++;
-
- }
- if (propStartIndex == urLength) {
- return null;
- }
-
- String propStr = url.substring(propStartIndex);
- if ((propStr == null) || (propStr.length() == 0)) {
- return null;
- }
-
- Properties props = new Properties();
- propStr = propStr.replace(';', '\n');
- ByteArrayInputStream byteArrIPStream = new ByteArrayInputStream(propStr.getBytes());
-
- try {
- props.load(byteArrIPStream);
- } catch (IOException ioex) {
- throw new SQLException(ioex.getMessage());
- }
-
- return props;
- }
-
- /**
- * Checks the string is host or port.
- *
- * @param IPorName
- * @return true if the address is a IP address
- */
- private boolean isIPAddress(String IPorName) {
- // Minimum length = 7; 1.1.1.1
- if (IPorName.length() < 7)
- return false;
- //
- // If first letter is a digit or ":" (i.e. IPv6), I'll assume it is an
- // IP address
- //
- return (Character.isDigit(IPorName.charAt(0)) || (IPorName.charAt(1) == ':'));
- }
-} // end class Address
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Connection.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Connection.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Connection.java
deleted file mode 100644
index d1ce34f..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4Connection.java
+++ /dev/null
@@ -1,505 +0,0 @@
-// @@@ 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;
-import java.util.logging.Level;
-
-class T4Connection {
- protected Locale m_locale;
- protected int m_dialogueId;
- protected NCSAddress m_ncsAddress;
- private InputOutput m_io;
- private USER_DESC_def m_userDesc;
- private CONNECTION_CONTEXT_def m_inContext;
- private String m_sessionName;
- InterfaceConnection m_ic;
-
- static final int INCONTEXT_OPT1_SESSIONNAME = 0x80000000; // (2^31)
- static final int INCONTEXT_OPT1_FETCHAHEAD = 0x40000000; // (2^30)
- static final int INCONTEXT_OPT1_CERTIFICATE_TIMESTAMP = 0x20000000; //(2^29)
- static final int INCONTEXT_OPT1_CLIENT_USERNAME = 0x10000000; //(2^28)
-
- T4Connection(InterfaceConnection ic) throws SQLException {
- if (ic == null) {
- throwInternalException();
-
- }
- m_ic = ic;
- m_locale = ic.getLocale();
- m_dialogueId = ic.getDialogueId();
- m_ncsAddress = ic.getNCSAddress();
- m_userDesc = ic.getUserDescription();
- m_inContext = ic.getInContext();
- m_sessionName = ic.getSessionName();
-
- if (m_dialogueId < 1 || m_ncsAddress == null || m_userDesc == null || m_inContext == null) {
- throwInternalException();
-
- }
- m_io = m_ncsAddress.getInputOutput();
- if (m_io == null) {
- throwInternalException();
- }
- m_io.setDialogueId(m_dialogueId);
- m_io.setConnectionIdleTimeout(ic.getConnectionTimeout());
- // trace_connection - AM
- m_io.setT4Connection(this);
- m_io.openIO();
- getInputOutput().setTimeout(ic.getLoginTimeout());
- checkConnectionIdleTimeout();
- resetConnectionIdleTimeout();
- }
-
- public void finalizer() {
- closeTimers();
- }
-
- protected int getDialogueId() {
- return m_dialogueId;
- }
-
- protected Locale getLocale() {
- return m_locale;
- }
-
- protected String getSessionName() {
- return this.m_sessionName;
- }
-
- protected NCSAddress getNCSAddress() {
- return m_ncsAddress;
- }
-
- void closeTimers() {
- if (m_io != null) {
- m_io.closeTimers();
- }
- }
-
- protected void reuse() {
- resetConnectionIdleTimeout();
- }
-
- private void setConnectionIdleTimeout() {
- m_io.startConnectionIdleTimeout();
- }
-
- private void resetConnectionIdleTimeout() {
- m_io.resetConnectionIdleTimeout();
- }
-
- private void checkConnectionIdleTimeout() throws SQLException {
- if (m_io.checkConnectionIdleTimeout()) {
- try {
- m_ic.close();
- } catch (SQLException sqex) {
- // ignores
- }
- throw HPT4Messages.createSQLException(m_ic.t4props_, m_locale, "ids_s1_t00", null);
- }
- }
-
- protected boolean connectionIdleTimeoutOccured() {
- return m_io.checkConnectionIdleTimeout();
- }
-
- protected InputOutput getInputOutput() throws SQLException {
- checkConnectionIdleTimeout();
- resetConnectionIdleTimeout();
- return m_io;
- }
-
- protected void throwInternalException() throws SQLException {
- T4Properties tempP = null;
-
- if (m_ic != null) {
- tempP = m_ic.t4props_;
-
- }
- SQLException se = HPT4Messages.createSQLException(tempP, m_locale, "internal_error", null);
- SQLException se2 = HPT4Messages.createSQLException(tempP, m_locale, "contact_hp_error", null);
-
- se.setNextException(se2);
- throw se;
- }
-
- // --------------------------------------------------------------------------------
- protected LogicalByteArray getReadBuffer(short odbcAPI, LogicalByteArray wbuffer) throws SQLException {
- // trace_connection - AM
- if (m_ic.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(m_ic.t4props_);
- String temp = "LogicalByteArray";
- m_ic.t4props_.t4Logger_.logp(Level.FINEST, "T4Connection", "getReadBuffer", temp, p);
- }
- LogicalByteArray rbuffer = m_io.doIO(odbcAPI, wbuffer);
-
- return rbuffer;
- }
-
- // --------------------------------------------------------------------------------
- /**
- * This class corresponds to the ODBC client driver function
- * odbc_SQLSvc_InitializeDialogue_pst_ as taken from odbccs_drvr.cpp.
- * @version 1.0
- *
- * This method will make a connection to an ODBC server. The ODBC server's
- * locaiton This method will make a connection to an ODBC server. The ODBC
- * server's locaiton (i.e. ip address and port number), were provided by an
- * earlier call to the ODBC association server.
- *
- * @param inContext
- * a CONNETION_CONTEXT_def object containing connection
- * information
- * @param userDesc
- * a USER_DESC_def object containing user information
- * @param inContext
- * a CONNECTION_CONTEXT_def object containing information for
- * this connection
- * @param dialogueId
- * a unique id identifing this connection as supplied by an
- * earlier call to the association server
- *
- * @retrun a InitializeDialogueReply class representing the reply from the
- * ODBC server is returned
- *
- * @exception A
- * SQLException is thrown
- */
-
- InitializeDialogueReply InitializeDialogue(boolean setTimestamp, boolean downloadCert) throws SQLException {
- try {
- int optionFlags1 = INCONTEXT_OPT1_CLIENT_USERNAME;
- int optionFlags2 = 0;
-
- if(setTimestamp) {
- optionFlags1 |= INCONTEXT_OPT1_CERTIFICATE_TIMESTAMP;
- }
-
- if (m_sessionName != null && m_sessionName.length() > 0) {
- optionFlags1 |= INCONTEXT_OPT1_SESSIONNAME;
- }
-
- if (this.m_ic.t4props_.getFetchAhead()) {
- optionFlags1 |= INCONTEXT_OPT1_FETCHAHEAD;
- }
-
- // trace_connection - AM
- if (m_ic.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(m_ic.t4props_);
- String temp = "m_dialogueId=" + m_dialogueId;
- m_ic.t4props_.t4Logger_.logp(Level.FINEST, "T4Connection", "InitializeDialogue", temp, p);
- }
- LogicalByteArray wbuffer = InitializeDialogueMessage.marshal(m_userDesc, m_inContext, m_dialogueId,
- optionFlags1, optionFlags2, m_sessionName, m_ic);
-
- getInputOutput().setTimeout(m_ic.t4props_.getLoginTimeout());
-
- LogicalByteArray rbuffer = getReadBuffer(TRANSPORT.SRVR_API_SQLCONNECT, wbuffer);
-
- //
- // Process output parameters
- //
- InitializeDialogueReply idr1 = new InitializeDialogueReply(rbuffer, m_ncsAddress.getIPorName(), m_ic, downloadCert);
-
- return idr1;
- } catch (SQLException se) {
- throw se;
- } catch (CharacterCodingException e) {
- SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale,
- "translation_of_parameter_failed", "InitializeDialogueMessage", 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,
- "initialize_dialogue_message_error", e.getMessage());
-
- se.initCause(e);
- throw se;
- } // end catch
- } // end InitializeDialogue
-
- /**
- * This method will end a connection to an ODBC server. The ODBC server's
- * locaiton (i.e. ip address and port number), were provided by an earlier
- * call to the ODBC association server.
- *
- * @retrun a TerminateDialogueReply class representing the reply from the
- * ODBC server is returned
- *
- * @exception A
- * SQLException is thrown
- */
- TerminateDialogueReply TerminateDialogue() throws SQLException {
- try {
- // trace_connection - AM
- if (m_ic.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(m_ic.t4props_);
- String temp = "m_dialogueId=" + m_dialogueId;
- m_ic.t4props_.t4Logger_.logp(Level.FINEST, "T4Connection", "TerminateDialogue", temp, p);
- }
- LogicalByteArray wbuffer = TerminateDialogueMessage.marshal(m_dialogueId, this.m_ic);
-
- //
- // used m_ic instead of getInputOutput, because getInputOutput
- // implicitly calls close at timeout, which will call
- // TerminateDialogue
- // which causes recursion.
- //
- // m_io.setTimeout(m_ic.t4props_.getCloseConnectionTimeout());
- m_io.setTimeout(m_ic.t4props_.getLoginTimeout());
-
- LogicalByteArray rbuffer = getReadBuffer(TRANSPORT.SRVR_API_SQLDISCONNECT, wbuffer);
-
- //
- // Process output parameters
- //
- TerminateDialogueReply tdr1 = new TerminateDialogueReply(rbuffer, m_ncsAddress.getIPorName(), m_ic);
-
- //
- // Send a close message and close the port if we don't have an
- // error.
- // If there is an error, it's up to the calling routine to decide
- // what to do.
- //
- if (tdr1.m_p1.exception_nr == TRANSPORT.CEE_SUCCESS) {
- m_io.CloseIO(wbuffer); // note, I'm re-using wbuffer
-
- }
-
- closeTimers();
-
- return tdr1;
- } // end try
- catch (SQLException se) {
- throw se;
- } catch (CharacterCodingException e) {
- SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale,
- "translation_of_parameter_failed", "TerminateDialogMessage", 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,
- "terminate_dialogue_message_error", e.getMessage());
-
- se.initCause(e);
- throw se;
- } // end catch
- } // end TerminateDialogue
-
- /**
- * This method will send a set connection option command to the server.
- *
- * @param connetionOption
- * The connection option to be set
- * @param optionValueNum
- * The number value of the option
- * @param optionValueStr
- * The string value of the option
- *
- * @retrun a SetConnectionOptionReply class representing the reply from the
- * ODBC server is returned
- *
- * @exception A
- * SQLException is thrown
- */
- SetConnectionOptionReply SetConnectionOption(short connectionOption, int optionValueNum, String optionValueStr)
- throws SQLException {
-
- if (optionValueStr == null) {
- throwInternalException();
-
- }
- try {
-
- LogicalByteArray wbuffer = SetConnectionOptionMessage.marshal(m_dialogueId, connectionOption,
- optionValueNum, optionValueStr, this.m_ic);
-
- getInputOutput().setTimeout(m_ic.t4props_.getNetworkTimeout());
-
- LogicalByteArray rbuffer = getReadBuffer(TRANSPORT.SRVR_API_SQLSETCONNECTATTR, wbuffer);
-
- SetConnectionOptionReply scor = new SetConnectionOptionReply(rbuffer, m_ncsAddress.getIPorName(), m_ic);
-
- return scor;
- } // end try
- catch (SQLException se) {
- throw se;
- } catch (CharacterCodingException e) {
- SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale,
- "translation_of_parameter_failed", "SetConnectionOptionReply", 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,
- "set_connection_option_message_error", e.getMessage());
-
- se.initCause(e);
- throw se;
- } // end catch
- } // end SetConnectionOption
-
- /**
- * This method will send an End Transaction command, which does not return
- * any rowsets, to the ODBC server.
- *
- * @param transactionOpt
- * A transaction opt
- *
- * @retrun A EndTransactionReply class representing the reply from the ODBC
- * server is returned
- *
- * @exception A
- * SQLException is thrown
- */
- EndTransactionReply EndTransaction(short transactionOpt) throws SQLException {
-
- try {
- LogicalByteArray wbuffer = EndTransactionMessage.marshal(m_dialogueId, transactionOpt, this.m_ic);
-
- getInputOutput().setTimeout(m_ic.t4props_.getNetworkTimeout());
-
- LogicalByteArray rbuffer = getReadBuffer(TRANSPORT.SRVR_API_SQLENDTRAN, wbuffer);
-
- EndTransactionReply cr = new EndTransactionReply(rbuffer, m_ncsAddress.getIPorName(), m_ic);
- return cr;
- } // end try
- catch (SQLException se) {
- throw se;
- } catch (CharacterCodingException e) {
- SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale,
- "translation_of_parameter_failed", "EndTransactionMessage", 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, "end_transaction_message_error",
- e.getMessage());
-
- se.initCause(e);
- throw se;
- } // end catch
-
- } // end EndTransaction
-
- /**
- * This method will send an get SQL catalogs command to the ODBC server.
- *
- * @param stmtLabel
- * a statement label for use by the ODBC server
- * @param APIType
- * @param catalogNm
- * @param schemaNm
- * @param tableNm
- * @param tableTypeList
- * @param columnNm
- * @param columnType
- * @param rowIdScope
- * @param nullable
- * @param uniqueness
- * @param accuracy
- * @param sqlType
- * @param metadataId
- * @param fkcatalogNm
- * @param fkschemaNm
- * @param fktableNm
- *
- * @retrun a GetSQLCatalogsReply class representing the reply from the ODBC
- * server is returned
- *
- * @exception A
- * SQLException is thrown
- */
- GetSQLCatalogsReply GetSQLCatalogs(String stmtLabel, short APIType, String catalogNm, String schemaNm,
- String tableNm, String tableTypeList, String columnNm, int columnType, int rowIdScope, int nullable,
- int uniqueness, int accuracy, short sqlType, int metadataId, String fkcatalogNm, String fkschemaNm,
- String fktableNm) throws SQLException {
-
- if (stmtLabel == null) {
- throwInternalException();
-
- }
- try {
- LogicalByteArray wbuffer;
-
- wbuffer = GetSQLCatalogsMessage.marshal(m_dialogueId, stmtLabel, APIType, catalogNm, schemaNm, tableNm,
- tableTypeList, columnNm, columnType, rowIdScope, nullable, uniqueness, accuracy, sqlType,
- metadataId, fkcatalogNm, fkschemaNm, fktableNm, m_ic);
-
- getInputOutput().setTimeout(m_ic.t4props_.getNetworkTimeout());
-
- LogicalByteArray rbuffer = getReadBuffer(TRANSPORT.SRVR_API_GETCATALOGS, wbuffer);
-
- //
- // Process output parameters
- //
- GetSQLCatalogsReply gscr = new GetSQLCatalogsReply(rbuffer, m_ncsAddress.getIPorName(), m_ic);
-
- return gscr;
- } // end try
- catch (SQLException se) {
- throw se;
- } catch (CharacterCodingException e) {
- SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale,
- "translation_of_parameter_failed", "GetSQLCatalogsMessage", 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,
- "get_sql_catalogs_message_error", e.getMessage());
-
- se.initCause(e);
- throw se;
- } // end catch
-
- } // end GetSQLCatalogs
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4DSProperties.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4DSProperties.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4DSProperties.java
deleted file mode 100644
index a44d0f3..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/T4DSProperties.java
+++ /dev/null
@@ -1,967 +0,0 @@
-// @@@ 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;
-import java.util.Properties;
-import java.util.logging.Level;
-
-/**
- * <p>
- * JDBC Type 4 driver data source connetion properties class.
- * </p>
- * <p>
- * Description: The <code>T4DSProperties</code> class contains all the
- * properties associated with Type 4 data source connection.
- * <code>T4DSProperties</code> is inherited by the <code>HPT4DataSource,
- * HPT4ConnectionPooledDataSource</code>
- * classes for configuring Type 4 connection properties.
- * <p>
- * The properties passed to the Type 4 driver have this precedence order in
- * event of the values set through more than one option:
- * </p>
- * <blockquote>
- * <p>
- * 1. java.util.properties parameter in the
- * <code>DriverManager.getConnection</code> call or through
- * <code>DataSource.setXXX()</code> call.
- * </p>
- * <p>
- * 2. <code>java.util.properties</code> file properties set through
- * <code>-Dt4jdbc.properties</code> option.
- * </p>
- * <p>
- * 3. Command line properties using -D option. All the system properties passed
- * through the command-line option have to be prefixed with
- * <code>t4jdbc</code>, to distinguish JDBC Type 4 driver properties
- * from other system properties. For example: property <code>user</code> when
- * specified with -D has to be qualified as
- * <code>-Dt4jdbc.user=super.super</code>.
- * </p>
- * </blockquote>
- * <p>
- * Copyright: (C) Apache Software Foundation (ASF)
- * </p>
- *
- */
-public class T4DSProperties extends T4Properties {
-
- public T4DSProperties() {
- super();
- }
-
- public T4DSProperties(Properties props) {
- super(props);
- }
-
- /**
- * Sets the description for the current Type 4 connection.
- *
- * @param description
- * For the current Type 4 connection.
- * @see #getDescription()
- */
- public void setDescription(String description) {
- super.setDescription(description);
- }
-
- /**
- * Returns the description associated with the current Type 4 connection.
- *
- * @return The description associated with the current Type 4 connection.
- * @see #setDescription(String)
- */
- public String getDescription() {
- return super.getDescription();
- }
-
- /**
- * Sets the data source name for the current Type 4 connection.
- *
- * @param dataSourceName
- * For the client side <code>DataSource</code> object.
- * @see #getDataSourceName()
- */
- public void setDataSourceName(String dataSourceName) {
- super.setDataSourceName(dataSourceName);
- }
-
- /**
- * Returns the client's data source name.
- *
- * @return data source name.
- * @see #setDataSourceName(String)
- */
- public String getDataSourceName() {
- return super.getDataSourceName();
- }
-
- /**
- * Sets the NDCS server data source name. The NDCS server data source is
- * defined by NDCS on the server.
- *
- * @param serverDataSource
- * the NDCS data source name to use on the NDCS server side. The
- * default value is an empty string.
- * @see #getServerDataSourceName()
- */
- public void setServerDataSource(String serverDataSource) {
- super.setServerDataSource(serverDataSource);
- }
-
- /**
- * Returns the NDCS server-side data source name used for the current Type 4
- * connection.
- *
- * @return NDCS server-side data source name.
- * @see #setServerDataSource(String)
- */
- public String getServerDataSource() {
- return super.getServerDataSource();
- }
-
- /**
- * Sets the default catalog that will be used to access SQL objects
- * referenced in SQL statements if the SQL objects are not fully qualified.
- *
- * @param catalog
- * Database catalog name. The default catalog name is
- * set by the DCS server-side data source.
- * @see #getCatalog()
- */
- public void setCatalog(String catalog) {
- super.setCatalog(catalog);
- }
-
- /**
- * Gets the default catalog that will be used to access SQL objects
- * referenced in SQL statements if the SQL objects are not fully qualified.
- *
- * @return HPT4 catalog name.
- * @see #setCatalog(String)
- */
- public String getCatalog() {
- return super.getCatalog();
- }
-
- /**
- * Sets the default schema that will be used to access SQL objects
- * referenced in SQL statements if the SQL objects are not fully qualified.
- *
- * @param schema
- * Database schema name. The default schema name is
- * set by the DCS server side data source.
- * @see #getSchema()
- */
- public void setSchema(String schema) {
- super.setSchema(schema);
- }
-
- /**
- * Gets the default schema that will be used to access SQL objects
- * referenced in SQL statements if the SQL objects are not fully qualified.
- *
- * @return The schema associated with the current Type 4 connection.
- * @see #setSchema(String)
- */
- public String getSchema() {
- return super.getSchema();
- }
-
- /**
- * Configure the Type 4 connection to continue batch processing of next
- * commands even after errors. Default value is true.
- *
- * @param batchRecovery
- */
- void setBatchRecovery(String batchRecovery) {
- boolean boolBatchRecovery = true;
- if (batchRecovery != null) {
- if (batchRecovery.equalsIgnoreCase("false")) {
- boolBatchRecovery = false;
- }
- }
- setBatchRecovery(boolBatchRecovery);
- }
-
- /**
- * Configure the Type 4 connection to continue batch processing of next
- * commands even after errors. Default value is true.
- *
- * @param batchRecovery
- */
- void setBatchRecovery(boolean batchRecovery) {
- super.setBatchRecovery(batchRecovery);
- }
-
- /**
- * Return whether the Type 4 connection is configured to continue batch
- * processing of next commands even after errors.
- *
- * @return batchRecovery
- */
- boolean getBatchRecovery() {
- return super.getBatchRecovery();
- }
-
- /**
- * Returns the <code>java.util.Locale</code> object associated with the
- * current Type 4 connection.
- *
- * @return <code>java.util.Locale</code> object.
- */
- public Locale getLocale() {
- return super.getLocale();
- }
-
- /**
- * The maximum number of physical connections that the pool (free and
- * in-use) should contain. When the maximum number of physical connections
- * is reached, the Type 4 driver throws an <code>SQLException
- * </code> with
- * the message "Maximum pool size reached." Specifying a value of 0 (zero)
- * indicates there is no maximum size for the pool. Specifying a value of -1
- * indicates no connection pooling is performed. The default value is -1,
- * indicating that no pooling of physical connections is done.
- *
- * @param maxPoolSize
- * the maximum number of physical connections the pool should
- * contain (free and in use).
- * @see #getMaxPoolSize()
- * @see #setMaxPoolSize(int)
- */
- public void setMaxPoolSize(String maxPoolSize) {
- super.setMaxPoolSize(maxPoolSize);
- }
-
- /**
- * The maximum number of physical connections that the pool (free and
- * in-use) should contain. When the maximum number of physical connections
- * is reached, the Type 4 driver throws an <code>SQLException
- * </code> with
- * the message "Maximum pool size reached." Specifying a value of 0 (zero)
- * indicates there is no maximum size for the pool. Specifying a value of -1
- * indicates no connection pooling is performed. The default value is -1,
- * indicating that no pooling of physical connections is done.
- *
- * @param maxPoolSize
- * the maximum number of physical connections the pool should
- * contain (free and in use).
- * @see #getMaxPoolSize()
- * @see #setMaxPoolSize(String)
- */
-
- public void setMaxPoolSize(int maxPoolSize) {
- super.setMaxPoolSize(maxPoolSize);
- }
-
- /**
- * Returns the maximum number of physical connections that the pool (free
- * and inuse) should contain. A value of zero (0) indicates no maximum size.
- * A value of -1 indicates that connection pooling is not being done.
- *
- * @return the maximum number of physical connections that the pool should
- * contain.
- * @see #setMaxPoolSize(int)
- */
- public int getMaxPoolSize() {
- return super.getMaxPoolSize();
- }
-
- /**
- * Sets the number of physical connections the pool should keep available at
- * all times.
- *
- * @param minPoolSize
- * Limits the number of physical connection that can be in the
- * free pool. When the number of physical connections in the free
- * pool reaches the value of minPoolSize, subsequent connections
- * that are closed are physically closed and are not added to the
- * free pool. Specifying a value of 0 means that the value of
- * minPoolSize is the same as the value of maxPoolSize. If the
- * value of maxPoolSize is -1, the value of minPoolSize is
- * ignored. The default value is 0. For this data source, it is
- * recommended that you use the default value.
- * @see #getMinPoolSize()
- * @see #setMinPoolSize(int minPoolSize)
- */
- public void setMinPoolSize(String minPoolSize) {
- super.setMinPoolSize(minPoolSize);
- }
-
- /**
- * Sets the number of physical connections the pool should keep available at
- * all times.
- *
- * @param minPoolSize
- * Limits the number of physical connection that can be in the
- * free pool. When the number of physical connections in the free
- * pool reaches the value of minPoolSize, subsequent connections
- * that are closed are physically closed and are not added to the
- * free pool. Specifying a value of 0 means that the value of
- * minPoolSize is the same as the value of maxPoolSize. If the
- * value of maxPoolSize is -1, the value of minPoolSize is
- * ignored. The default value is 0. For this data source, it is
- * recommended that you use the default value.
- * @see #getMinPoolSize()
- * @see #setMinPoolSize(String minPoolSize)
- */
- public void setMinPoolSize(int minPoolSize) {
- super.setMinPoolSize(minPoolSize);
- }
-
- /**
- * Returns the number of physical connections the pool should keep in the
- * free pool. A value of 0 (zero) indicates that minPoolSize is equal to
- * maxPoolsize. If maxPoolsize is equal to -1, the value of minPoolSize is
- * ignored. The default value is 0.
- *
- * @return The number of physical connections the pool should maintain in
- * the free pool.
- * @see #setMinPoolSize(int)
- * @see #setMaxPoolSize(int)
- */
- public int getMinPoolSize() {
- return super.getMinPoolSize();
- }
-
- /**
- * The initial number of physical connections that the pool should be
- * created with. Specifying a value of 0 (zero) or less indicates that the
- * pool should not be created with any initial connections. The default
- * value is -1 indicating that no initial pool of physical connections is
- * created. The value can be less than minPoolSize but must be less than or
- * equal to the value of maxPoolSize. Specifying a value greater than
- * maxPoolSize will set the initialPoolSize to the value of maxPoolSize.
- *
- * @param initialPoolSize
- * the initial number of physical connections the pool should be
- * created with.
- * @see #setInitialPoolSize(int)
- */
- public void setInitialPoolSize(String initialPoolSize) {
- super.setInitialPoolSize(initialPoolSize);
- }
-
- /**
- * The initial number of physical connections that the pool should be
- * created with. Specifying a value of 0 (zero) or less indicates that the
- * pool should not be created with any initial connections. The default
- * value is -1 indicating that no initial pool of physical connections is
- * created. The value can be less than minPoolSize but must be less than or
- * equal to the value of maxPoolSize. Specifying a value greater than
- * maxPoolSize will set the initialPoolSize to the value of maxPoolSize.
- *
- * @param initialPoolSize
- * the initial number of physical connections the pool should be
- * created with.
- * @see #setInitialPoolSize(String)
- */
- public void setInitialPoolSize(int initialPoolSize) {
- super.setInitialPoolSize(initialPoolSize);
- }
-
- /**
- * Returns the number of physical connections that the pool should be
- * created with. A value of -1 indicates that the pool is not created with
- * any initial connections.
- *
- * @return initialPoolSize the number of physical connections that the pool
- * should be created with.
- * @see #setInitialPoolSize(int)
- */
- public int getInitialPoolSize() {
- return super.getInitialPoolSize();
- }
-
- /**
- * Total number of statements that can be cached. A value of zero (0)
- * indicates that caching of statements is disabled.
- *
- * @param maxStatements
- * The number of statements that can be cached.
- * @see #setMaxStatements(int)
- */
- public void setMaxStatements(String maxStatements) {
- super.setMaxStatements(maxStatements);
- }
-
- /**
- * Total number of statements that can be cached. A value of zero (0)
- * indicates that caching of statements is disabled.
- *
- * @param maxStatements
- * The number of statements that can be cached.
- * @see #setMaxStatements(String)
- */
- public void setMaxStatements(int maxStatements) {
- super.setMaxStatements(maxStatements);
- }
-
- /**
- * Returns the total number of statements that can be cached. A value of
- * zero (0) indicates that pooling of statements is disabled.
- *
- * @return The total number of statements that can be cached.
- */
- public int getMaxStatements() {
- return super.getMaxStatements();
- }
-
- /**
- * Returns the URL used in the current Type 4 connection. JDBC Type 4
- * driver URL uses the format: <code>jdbc:t4jdbc://host:port/:</code>
- *
- * @deprecated Use the <code>getUrl()</code> to obtain the URL string.
- * @return the URL string.
- * @see #getUrl()
- */
- public String getURL() {
- return getURL();
- }
-
- /**
- * Sets the URL for the Type 4 connection. JDBC Type 4 driver URL uses
- * the format: <code>jdbc:t4jdbc://host:port/:prop-name=value</code>.
- * This validates the URL value and throws SQLException if the URL value is
- * incorrect.
- *
- * @param url
- * the URL.
- * @see #getUrl()
- */
- public Properties setURL(String url) throws SQLException {
- return super.setURL(url);
- }
-
- /**
- * Returns the URL used in the current Type 4 connection. JDBC Type 4
- * driver URL uses the format:
- * <code>jdbc:t4jdbc://host:port/[:][prop-name=value][,prop-name=value]...</code>
- *
- * @return the URL string.
- * @see #setUrl(String)
- */
- public String getUrl() {
- return super.getUrl();
- }
-
- /**
- * Sets the URL for the Type 4 connection. JDBC Type 4 driver URL uses
- * the format:
- * <code>jdbc:t4jdbc://host:port/[:][prop-name=value][,prop-name=value]...</code>
- * This method does not validate the URL value.
- *
- * @param url
- * the URL.
- * @see #getUrl()
- */
- public void setUrl(String url) {
- super.setUrl(url);
- }
-
- /**
- * Sets the Safeguard user name to be used while connecting to NDCS server
- * for authentication.
- *
- * @param user
- * Sets the user for the current Type 4 connection.
- * @see #getUser()
- */
- public void setUser(String user) {
- super.setUser(user);
- }
-
- /**
- * Returns the Safeguard user name associated with this Type 4 connection.
- *
- * @return The user name.
- * @see #setUser(String)
- */
- public String getUser() {
- return super.getUser();
- }
-
- /**
- * Sets the Safeguard password to be used for authentication when connecting
- * to the NDCS server.
- *
- * @param pwd
- * The Safeguard password for the current Type 4 connection.
- */
- public void setPassword(String pwd) {
- super.setPassword(pwd);
- }
-
- /**
- * Sets the login timeout in seconds for the Type 4 connection. The default
- * login timeout value is set to 60 seconds.
- *
- * @param loginTimeout
- * The login timeout value in seconds.
- * @see #setLoginTimeout(int)
- * @see #getLoginTimeout()
- */
- public void setLoginTimeout(String loginTimeout) {
- super.setLoginTimeout(loginTimeout);
- }
-
- /**
- * Sets the login timeout in seconds for the Type 4 connection. The default
- * login timeout value is set to 60 seconds.
- *
- * @param loginTimeout
- * The login timeout value in seconds.
- * @see #setLoginTimeout(String)
- * @see #getLoginTimeout()
- */
- public void setLoginTimeout(int loginTimeout) {
- super.setLoginTimeout(loginTimeout);
- }
-
- /**
- * Returns the login timeout value set for the current Type 4 connection.
- *
- * @return the login timeout value in seconds.
- * @see #setLoginTimeout(int)
- * @see #setLoginTimeout(String)
- */
- public int getLoginTimeout() {
- return super.getLoginTimeout();
- }
-
- /**
- * Sets the network timeout in seconds for the Type 4 connection. The
- * default network timeout value is set to infinity.
- *
- * @param networkTimeout
- * The network timeout value in seconds.
- * @see #setNetworkTimeout(int)
- * @see #getNetworkTimeout()
- */
- public void setNetworkTimeout(String networkTimeout) {
- super.setNetworkTimeout(networkTimeout);
- }
-
- /**
- * Sets the network timeout in seconds for the Type 4 connection. The
- * default network timeout value is set to infinity.
- *
- * @param networkTimeout
- * The network timeout value in seconds.
- * @see #setNetworkTimeout(String)
- * @see #getNetworkTimeout()
- */
- public void setNetworkTimeout(int networkTimeout) {
- super.setNetworkTimeout(networkTimeout);
- }
-
- /**
- * Returns the network timeout value set for the current Type 4 connection.
- *
- * @return The network timeout value in seconds.
- * @see #setNetworkTimeout(int)
- * @see #setNetworkTimeout(String)
- */
- public int getNetworkTimeout() {
- return super.getNetworkTimeout();
- }
-
- // -----------------------------------------------------------------
-
- /*
- * Sets the connection timeout value for the Type 4 connection. Set this
- * value to 0 for infinite timeout. The default is set to -1. A negative
- * value indicates the NDCS server to use the connection timeout value set
- * by the administrator on the NDCS data source. @param connectionTimeout
- * The connection timeout value in seconds.
- *
- * @see #setConnectionTimeout(int)
- * @see #setServerDataSource(String)
- */
- public void setConnectionTimeout(String connectionTimeout) {
- super.setConnectionTimeout(connectionTimeout);
- }
-
- /*
- * Sets the connection timeout value for the Type 4 connection. Set this
- * value to 0 for infinite timeout. The default is set to -1. A negative
- * value indicates the NDCS server to use the connection timeout value set
- * by the administrator on the NDCS data source. @param connectionTimeout
- * The connection timeout value in seconds.
- *
- * @see #setConnectionTimeout(String)
- * @see #setServerDataSource(String)
- */
- public void setConnectionTimeout(int connectionTimeout) {
- super.setConnectionTimeout(connectionTimeout);
- }
-
- /**
- * Sets the max idle time value for the Type 4 connection. The default is
- * set to 0 (no timeout). Negative values are treated as 0.
- *
- * @param maxIdleTime
- * The timeout value in seconds.
- * @see #setMaxIdleTime(int)
- */
- public void setMaxIdleTime(String maxIdleTime) {
- super.setMaxIdleTime(maxIdleTime);
- }
-
- /**
- * Sets the max idle time value for the Type 4 connection.The default is set
- * to 0 (no timeout). Negative values are treated as 0.
- *
- * @param maxIdleTime
- * The timeout value in seconds.
- * @see #setMaxIdleTime(String)
- */
- public void setMaxIdleTime(int maxIdleTime) {
- super.setMaxIdleTime(maxIdleTime);
- }
-
- /*
- * Returns the connection timeout value associated with this Type 4
- * connection. @return The connection timeout value in seconds.
- *
- * @see #setConnectionTimeout(int)
- */
-
- public int getConnectionTimeout() {
- return super.getConnectionTimeout();
- }
-
- /**
- * Returns the max idle time value associated with this Type 4 connection.
- *
- * @return The max idle timeout value in seconds.
- * @see #setMaxIdleTime(int)
- */
- public int getMaxIdleTime() {
- return super.getMaxIdleTime();
- }
-
- /**
- * Sets the logging level for the current Type 4 connection. The default
- * value is OFF. Valid values are:
- *
- * <PRE>
- * OFF (no logging)
- * SEVERE (highest value)
- * WARNING
- * INFO
- * CONFIG
- * FINE
- * FINER
- * FINEST (lowest value).
- * ALL (log all messages)
- * </PRE>
- *
- * @param level
- * logging level.
- * @see #getT4LogLevel()
- * @see java.util.logging.Level
- */
- public void setT4LogLevel(String level) {
- super.setT4LogLevel(level);
- }
-
- /**
- * Returns the Type 4 log level associated with the current Type 4
- * connection. Possible log levels are described in java.util.logging.Level
- *
- * @return <code>java.util.logging.Level</code> associated with the
- * current Type 4 connection.
- * @see #setT4LogLevel(String)
- * @see java.util.logging.Level
- */
- public Level getT4LogLevel() {
- return super.getT4LogLevel();
- }
-
- /**
- * Sets the location of the file to which the logging is to be done.
- * Changing this location after making a connection has no effect; because
- * the driver reads this property before the connection is made. The default
- * name is a generated file name defined by the following pattern:
- * %h/t4jdbc%u.log where: "/" represents the local pathname separator "%h"
- * represents the value of the "user.home" system property. If %h is not
- * defined, then the behavior is undefined "%u" represents a unique number
- * to resolve conflicts
- *
- * @param t4LogFile
- * The Type 4 log file location. If the parameter is null, then
- * the T4LogFile is set to the global log file.
- * @see #getT4LogFile()
- * @see java.util.logging.Logger
- */
- public void setT4LogFile(String t4LogFile) {
- super.setT4LogFile(t4LogFile);
- }
-
- /**
- * Returns the Type 4 log file location associated with the current Type 4
- * connection.
- *
- * @return The Type 4 log file location.
- * @see #setT4LogFile(String)
- */
- public String getT4LogFile() {
- return super.getT4LogFile();
- }
-
- /**
- * Sets the table name to store and retrieve the CLOB data for all CLOB
- * columns accessed in the connection using the data source.
- *
- * @param clobTableName
- * The clob table name, which is in the format
- * <code><var>catalog_name.schema_name.clob_table_name</code></var>
- *
- * @since 1.1
- */
- public void setClobTableName(String clobTableName) throws SQLException {
- super.setClobTableName(clobTableName);
- }
-
- /**
- * Retrieves the table name used to store CBLOB data for all CLOB columns
- * accessed in the connection using the data source.
- *
- * @return the clob table name, which is in the format
- * <code><var>catalog_name.schema_name.clob_table_name</code></var>
- *
- * @since 1.1
- */
- public String getClobTableName() {
- return super.getClobTableName();
- }
-
- /**
- * Sets the table name to store and retrieve the BLOB data for all BLOB
- * columns accessed in the connection using the data source.
- *
- * @param blobTableName
- * the blob table name, which is in the format
- * <code><var>catalog_name.schema_name.blob_table_name</code></var>
- *
- * @since 1.1
- */
- public void setBlobTableName(String blobTableName) throws SQLException {
- super.setBlobTableName(blobTableName);
- }
-
- /**
- * Retrieves the table name used to store BLOB data for all BLOB columns
- * accessed in the connection using the data source.
- *
- * @return the blob table name which is of the format
- * <code><var>catalog_name.schema_name.blob_table_name</code></var>
- *
- * @since 1.1
- */
- public String getBlobTableName() {
- return super.getBlobTableName();
- }
-
- /**
- * Configures the number of data locators to be reserved by the Type 4
- * connection. Default value is 100.
- *
- * @param reserveDataLocator
- * Sets the value of the reserve data locator length for the
- * binding) feature.
- *
- * @since 1.1
- */
- public void setReserveDataLocator(String reserveDataLocator) {
- super.setReserveDataLocator(reserveDataLocator);
- }
-
- /**
- * Configures the number of data locators to be reserved by the Type 4
- * connection. Default value is 100.
- *
- * @param reserveDataLocatorLen
- * Sets the value of the reserve data locator length for the Type
- * 4 connection.
- *
- * @since 1.1
- */
- public void setReserveDataLocator(long reserveDataLocatorLen) {
- super.setReserveDataLocator(reserveDataLocatorLen);
- }
-
- /**
- * Returns the value of the reserve data locator length.
- *
- * @return The value of the reserved data locator length.
- *
- * @since 1.1
- */
- public long getReserveDataLocator() {
- return super.getReserveDataLocator();
- }
-
- /**
- * @return Returns the rounding mode set for the driver as an Integer value
- * with one of the values:
- *
- * <PRE>
- * static int ROUND_CEILING
- * Rounding mode to round toward positive infinity.
- * static int ROUND_DOWN
- * Rounding mode to round toward zero.
- * static int ROUND_FLOOR
- * Rounding mode to round toward negative infinity.
- * static int ROUND_HALF_DOWN
- * Rounding mode to round toward "nearest neighbor" unless both
- * neighbors are equidistant, in which case round down.
- * static int ROUND_HALF_EVEN
- * Rounding mode to round toward the "nearest neighbor" unless
- * both neighbors are equidistant, in which case, round towards the even neighbor.
- * static int ROUND_HALF_UP
- * Rounding mode to round toward "nearest neighbor" unless both
- * neighbors are equidistant, in which case round up.
- * static int ROUND_UNNECESSARY
- * Rounding mode to assert that the requested operation has an exact
- * result; hence no rounding is necessary.
- * static int ROUND_UP
- * Rounding mode to round away from zero.
- * </PRE>
- */
- public int getRoundingMode() {
- return super.getRoundingMode();
- }
-
- /**
- * Sets the round mode behaviour for the driver.
- *
- * @param roundMode
- * String value with one of the values:
- *
- * <PRE>
- * static int ROUND_CEILING
- * Rounding mode to round toward positive infinity.
- * static int ROUND_DOWN
- * Rounding mode to round toward zero.
- * static int ROUND_FLOOR
- * Rounding mode to round toward negative infinity.
- * static int ROUND_HALF_DOWN
- * Rounding mode to round toward "nearest neighbor" unless both
- * neighbors are equidistant, in which case round down.
- * static int ROUND_HALF_EVEN
- * Rounding mode to round toward the "nearest neighbor" unless
- * both neighbors are equidistant, in which case, round towards the even neighbor.
- * static int ROUND_HALF_UP
- * Rounding mode to round toward "nearest neighbor" unless both
- * neighbors are equidistant, in which case round up.
- * static int ROUND_UNNECESSARY
- * Rounding mode to assert that the requested operation has an exact
- * result; hence no rounding is necessary.
- * static int ROUND_UP
- * Rounding mode to round away from zero.
- * </PRE>
- *
- * The default value is ROUND_HALF_EVEN.
- */
- public void setRoundingMode(String roundMode) {
- super.setRoundingMode(roundMode);
- }
-
- /**
- * Sets the round mode behaviour for the driver.
- *
- * @param roundMode
- * Integer value with one of the values:
- *
- * <PRE>
- * static int ROUND_CEILING
- * Rounding mode to round toward positive infinity.
- * static int ROUND_DOWN
- * Rounding mode to round toward zero.
- * static int ROUND_FLOOR
- * Rounding mode to round toward negative infinity.
- * static int ROUND_HALF_DOWN
- * Rounding mode to round toward "nearest neighbor" unless both
- * neighbors are equidistant, in which case round down.
- * static int ROUND_HALF_EVEN
- * Rounding mode to round toward the "nearest neighbor" unless
- * both neighbors are equidistant, in which case, round towards the even neighbor.
- * static int ROUND_HALF_UP
- * Rounding mode to round toward "nearest neighbor" unless both
- * neighbors are equidistant, in which case round up.
- * static int ROUND_UNNECESSARY
- * Rounding mode to assert that the requested operation has an exact
- * result; hence no rounding is necessary.
- * static int ROUND_UP
- * Rounding mode to round away from zero.
- * </PRE>
- *
- * The default value is ROUND_HALF_EVEN.
- */
- public void setRoundingMode(int roundMode) {
- super.setRoundingMode(roundMode);
- }
-
- /**
- * Sets the value (in KB) for the size of the fetch buffer. This is used
- * when rows are fetched are performed from a ResultSet object after a
- * successful executeQuery() operation on a statement. The default size is
- * 4. Zero and negative values are treated as default values.
- *
- * @param fetchBufferSize
- * @see #getFetchBufferSize()
- * @see #setFetchBufferSize(String)
- */
- void setFetchBufferSize(short fetchBufferSize) {
- super.setFetchBufferSize(fetchBufferSize);
- }
-
- /**
- * Sets the value (in KB) for the size of the fetch buffer. This is used
- * when rows are fetched are performed from a ResultSet object after a
- * successful executeQuery() operation on a statement. The default size is
- * 4. Zero and negative values are treated as default values.
- *
- * @param fetchBufferSize
- * @see #getFetchBufferSize()
- * @see #setFetchBufferSize(short)
- */
- void setFetchBufferSize(String fetchBufferSize) {
- super.setFetchBufferSize(fetchBufferSize);
- }
-
- /**
- * Returns the size of the fetch buffer.
- *
- * @see #setFetchBufferSize(short)
- * @see #setFetchBufferSize(String)
- */
- short getFetchBufferSize() {
- return super.getFetchBufferSize();
- }
-
-} // end class T4DSProperties
-
[19/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/VERSION_LIST_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/VERSION_LIST_def.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/VERSION_LIST_def.java
new file mode 100644
index 0000000..62214a4
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/VERSION_LIST_def.java
@@ -0,0 +1,65 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class VERSION_LIST_def {
+ VERSION_def[] list;
+
+ int sizeOf() { // since VERSION_def is a constant size we can just call the
+ // sizeOf() once
+ return VERSION_def.sizeOf() * list.length + TRANSPORT.size_int;
+ }
+
+ void insertIntoByteArray(LogicalByteArray buf) {
+ buf.insertInt(list.length);
+
+ for (int i = 0; i < list.length; i++) {
+ list[i].insertIntoByteArray(buf);
+ }
+ }
+
+ int sizeOfChar() {
+ return list.length * VERSION_def.sizeOfChar() + 10;
+ }
+
+ void insertIntoByteArrayChar(LogicalByteArray buf, InterfaceConnection ic) throws CharacterCodingException, UnsupportedCharsetException{
+ buf.insertFixedString(ic.encodeString("" + list.length, 1), 10);
+
+ for (int i = 0; i < list.length; i++) {
+ list[i].insertIntoByteArrayChar(buf, ic);
+ }
+ }
+
+ void extractFromByteArray(LogicalByteArray buf) {
+ int len = buf.extractInt();
+
+ list = new VERSION_def[len];
+
+ for (int i = 0; i < list.length; i++) {
+ list[i] = new VERSION_def();
+ list[i].extractFromByteArray(buf);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/VERSION_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/VERSION_def.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/VERSION_def.java
new file mode 100644
index 0000000..108622a
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/VERSION_def.java
@@ -0,0 +1,61 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class VERSION_def {
+ short componentId;
+ short majorVersion;
+ short minorVersion;
+ int buildId;
+
+ static int sizeOf() {
+ return TRANSPORT.size_int + TRANSPORT.size_short * 3;
+ }
+
+ void insertIntoByteArray(LogicalByteArray buf) {
+ buf.insertShort(componentId);
+ buf.insertShort(majorVersion);
+ buf.insertShort(minorVersion);
+ buf.insertInt(buildId);
+ }
+
+ static int sizeOfChar() {
+ return 50;
+ }
+
+ void insertIntoByteArrayChar(LogicalByteArray buf, InterfaceConnection ic) throws CharacterCodingException, UnsupportedCharsetException{
+ buf.insertFixedString(ic.encodeString("" + componentId, 1), 10);
+ buf.insertFixedString(ic.encodeString("" + majorVersion, 1), 10);
+ buf.insertFixedString(ic.encodeString("" + minorVersion, 1), 10);
+ buf.insertFixedString(ic.encodeString("" + buildId, 1), 20);
+ }
+
+ void extractFromByteArray(LogicalByteArray buf) {
+ componentId = buf.extractShort();
+ majorVersion = buf.extractShort();
+ minorVersion = buf.extractShort();
+ buildId = buf.extractInt();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Vproc.java-tmpl
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Vproc.java-tmpl b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Vproc.java-tmpl
new file mode 100644
index 0000000..9ab6727
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Vproc.java-tmpl
@@ -0,0 +1,36 @@
+// @@@ 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;
+
+public class Vproc {
+ private static final String vprocStr = "@@@@";
+ static final int jdbcMajorVersion = 1;
+ static final int jdbcMinorVersion = 0;
+
+ public static void main(String[] args) {
+ System.out.println(vprocStr);
+ }
+
+ public static String getVproc() {
+ return vprocStr;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_Dcs_GetObjRefHdl_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_Dcs_GetObjRefHdl_exc_.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_Dcs_GetObjRefHdl_exc_.java
new file mode 100644
index 0000000..564fe5b
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_Dcs_GetObjRefHdl_exc_.java
@@ -0,0 +1,95 @@
+// @@@ 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 odbc_Dcs_GetObjRefHdl_exc_ {
+ int exception_nr;
+ int exception_detail;
+
+ String ErrorText;
+ int errorCode;
+
+ //
+ // It looks like ODBC doesn't generate error text in all
+ // error cases, so the following variable will contain
+ // any error text generated by this JDBC driver.
+ // Note, this variable is not part of the message, but it
+ // represents a value stored in the HPT4Messages_*.properties file.
+ //
+
+ String clientErrorText;
+
+ static final int odbc_Dcs_GetObjRefHdl_ASParamError_exn_ = 1;
+ static final int odbc_Dcs_GetObjRefHdl_ASTimeout_exn_ = 2;
+ static final int odbc_Dcs_GetObjRefHdl_ASNoSrvrHdl_exn_ = 3;
+ static final int odbc_Dcs_GetObjRefHdl_ASTryAgain_exn_ = 4;
+ static final int odbc_Dcs_GetObjRefHdl_ASNotAvailable_exn_ = 5;
+ static final int odbc_Dcs_GetObjRefHdl_DSNotAvailable_exn_ = 6;
+ static final int odbc_Dcs_GetObjRefHdl_PortNotAvailable_exn_ = 7;
+ static final int odbc_Dcs_GetObjRefHdl_InvalidUser_exn_ = 8;
+ static final int odbc_Dcs_GetObjRefHdl_LogonUserFailure_exn_ = 9;
+
+ // -------------------------------------------------------------------
+ void extractFromByteArray(LogicalByteArray buffer1, InterfaceConnection ic) throws SQLException,
+ UnsupportedCharsetException, CharacterCodingException {
+ exception_nr = buffer1.extractInt();
+ exception_detail = buffer1.extractInt();
+
+ String temp0 = Integer.toString(exception_nr);
+ String temp1 = Integer.toString(exception_detail);
+
+ ErrorText = ic.decodeBytes(buffer1.extractString(), 1);
+
+ switch (exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ break;
+ case odbc_Dcs_GetObjRefHdl_ASParamError_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ErrorText);
+ case odbc_Dcs_GetObjRefHdl_LogonUserFailure_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unable_to_logon", "");
+ case odbc_Dcs_GetObjRefHdl_ASNotAvailable_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_dcs_srvr_not_available", ErrorText);
+ case odbc_Dcs_GetObjRefHdl_DSNotAvailable_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_ds_not_available", new T4Properties()
+ .getServerDataSource());
+ case odbc_Dcs_GetObjRefHdl_PortNotAvailable_exn_:
+ case odbc_Dcs_GetObjRefHdl_ASTryAgain_exn_:
+ case odbc_Dcs_GetObjRefHdl_ASNoSrvrHdl_exn_:
+ case -27:
+ case -29:
+
+ // should be retried by the driver so dont throw exception
+ clientErrorText = "ids_port_not_available";
+ break;
+ case odbc_Dcs_GetObjRefHdl_InvalidUser_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_28_000", null);
+ case odbc_Dcs_GetObjRefHdl_ASTimeout_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_s1_t00", null);
+ default:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "unknown_connect_error", null);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_Dcs_StopSrvr_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_Dcs_StopSrvr_exc_.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_Dcs_StopSrvr_exc_.java
new file mode 100644
index 0000000..44b6796
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_Dcs_StopSrvr_exc_.java
@@ -0,0 +1,86 @@
+// @@@ 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 odbc_Dcs_StopSrvr_exc_ {
+
+ int exception_nr;
+ int exception_detail;
+ //
+ // If the third element is not zero, then it is an offset
+ // to a character array that contains a message.
+ //
+ String ErrorText;
+ int errorCode;
+
+ //
+ // It looks like ODBC doesn't generate error text in all
+ // error cases, so the following variable will contain
+ // any error text generated by this JDBC driver.
+ // Note, this variable is not part of the message, but it
+ // represents a value stored in the HPT4Messages_*.properties file.
+ //
+
+ String clientErrorText;
+
+ static final int odbcas_ASSvc_StopSrvr_ASParamError_exn_ = 1;
+ static final int odbcas_ASSvc_StopSrvr_ASNotAvailable_exn_ = 2;
+ static final int odbcas_ASSvc_StopSrvr_SrvrNotFound_exn_ = 3;
+ static final int odbcas_ASSvc_StopSrvr_SrvrInUseByAnotherClient_exn_ = 4;
+ static final int odbcas_ASSvc_StopSrvr_ProcessStopError_exn_ = 5;
+
+ // -------------------------------------------------------------------
+ odbc_Dcs_StopSrvr_exc_() {
+ // Do nothing constructor
+ }
+
+ // -------------------------------------------------------------------
+ void extractFromByteArray(LogicalByteArray buffer1, InterfaceConnection ic) throws SQLException,
+ UnsupportedCharsetException, CharacterCodingException {
+ exception_nr = buffer1.extractInt();
+ exception_detail = buffer1.extractInt();
+
+ String temp0 = Integer.toString(exception_nr);
+ String temp1 = Integer.toString(exception_detail);
+
+ switch (exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ break;
+ case odbcas_ASSvc_StopSrvr_ASParamError_exn_:
+ case odbcas_ASSvc_StopSrvr_SrvrNotFound_exn_:
+ case odbcas_ASSvc_StopSrvr_ProcessStopError_exn_:
+ case odbcas_ASSvc_StopSrvr_SrvrInUseByAnotherClient_exn_:
+ ErrorText = ic.decodeBytes(buffer1.extractString(), 1);
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ErrorText);
+ case odbcas_ASSvc_StopSrvr_ASNotAvailable_exn_:
+ ErrorText = ic.decodeBytes(buffer1.extractString(), 1);
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_dcs_srvr_not_available", ErrorText);
+
+ default:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "unknown_error", null);
+ } // end switch
+ } // end extractFromByteArray
+} // end odbc_Dcs_StopSrvr_exc_
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_Close_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_Close_exc_.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_Close_exc_.java
new file mode 100644
index 0000000..619bece
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_Close_exc_.java
@@ -0,0 +1,69 @@
+// @@@ 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 odbc_SQLSvc_Close_exc_ {
+ int exception_nr;
+ int exception_detail;
+ String ParamError;
+ ERROR_DESC_LIST_def SQLError;
+
+ String clientErrorText = null;
+
+ static final int odbc_SQLSvc_Close_ParamError_exn_ = 1;
+ static final int odbc_SQLSvc_Close_InvalidConnection_exn_ = 2;
+ static final int odbc_SQLSvc_Close_SQLError_exn_ = 3;
+ static final int odbc_SQLSvc_Close_TransactionError_exn_ = 4;
+
+ // -------------------------------------------------------------------
+ void extractFromByteArray(LogicalByteArray buf, String addr, InterfaceConnection ic)
+ throws CharacterCodingException, UnsupportedCharsetException, SQLException {
+ exception_nr = buf.extractInt();
+ exception_detail = buf.extractInt();
+
+ String temp0 = Integer.toString(exception_nr);
+ String temp1 = Integer.toString(exception_detail);
+
+ switch (exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ break;
+ case odbc_SQLSvc_Close_SQLError_exn_:
+ SQLError = new ERROR_DESC_LIST_def();
+ SQLError.extractFromByteArray(buf, ic);
+ break;
+ case odbc_SQLSvc_Close_ParamError_exn_:
+ ParamError = ic.decodeBytes(buf.extractString(), 1);
+ ;
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
+ case odbc_SQLSvc_Close_InvalidConnection_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
+ case odbc_SQLSvc_Close_TransactionError_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_transaction_error", temp1, addr);
+ default:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0, temp1);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_EndTransaction_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_EndTransaction_exc_.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_EndTransaction_exc_.java
new file mode 100644
index 0000000..f46d161
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_EndTransaction_exc_.java
@@ -0,0 +1,87 @@
+// @@@ 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 odbc_SQLSvc_EndTransaction_exc_ {
+ int exception_nr;
+ int exception_detail;
+ String ParamError;
+ ERROR_DESC_LIST_def SQLError;
+
+ //
+ // From odbc_cl.h
+ //
+ // struct odbc_SQLSvc_EndTransaction_exc_ {
+ // size_int exception_nr;
+ // size_int exception_detail;
+ // union {
+ // odbc_SQLSvc_ParamError ParamError;
+ // odbc_SQLSvc_SQLError SQLError;
+ // } u;
+ // };
+
+ String clientErrorText = null;
+
+ //
+ // Exception number constants for
+ // operation 'odbc_SQLSvc_EndTransaction'
+ //
+
+ static final int odbc_SQLSvc_EndTransaction_ParamError_exn_ = 1;
+ static final int odbc_SQLSvc_EndTransaction_InvalidConnection_exn_ = 2;
+ static final int odbc_SQLSvc_EndTransaction_SQLError_exn_ = 3;
+ static final int odbc_SQLSvc_EndTransaction_SQLInvalidHandle_exn_ = 4;
+ static final int odbc_SQLSvc_EndTransaction_TransactionError_exn_ = 5;
+
+ // ----------------------------------------------------------
+ void extractFromByteArray(LogicalByteArray buffer1, String addr, InterfaceConnection ic)
+ throws CharacterCodingException, UnsupportedCharsetException, SQLException {
+ exception_nr = buffer1.extractInt();
+ exception_detail = buffer1.extractInt();
+
+ String temp0 = Integer.toString(exception_nr);
+ String temp1 = Integer.toString(exception_detail);
+
+ switch (exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ break;
+ case odbc_SQLSvc_EndTransaction_SQLError_exn_:
+ SQLError = new ERROR_DESC_LIST_def();
+ SQLError.extractFromByteArray(buffer1, ic);
+ break;
+ case odbc_SQLSvc_EndTransaction_ParamError_exn_:
+ ParamError = ic.decodeBytes(buffer1.extractString(), 1);
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
+ case odbc_SQLSvc_EndTransaction_InvalidConnection_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
+ case odbc_SQLSvc_EndTransaction_SQLInvalidHandle_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_transaction_error", temp1, addr);
+ default:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0, temp1);
+ } // end switch
+ } // end extractFromByteArray
+
+} // end class odbc_SQLSvc_EndTransaction_exc_
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_Execute_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_Execute_exc_.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_Execute_exc_.java
new file mode 100644
index 0000000..ebf444e
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_Execute_exc_.java
@@ -0,0 +1,89 @@
+// @@@ 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 odbc_SQLSvc_Execute_exc_ {
+ int exception_nr;
+ int exception_detail;
+
+ String ParamError;
+ ERROR_DESC_LIST_def SQLError;
+ ERROR_DESC_LIST_def SQLRetryCompile;
+ int SQLQueryCancelled;
+
+ //
+ // Taken from odbc_cl.h
+ // Exception number constants for
+ // operation 'odbc_SQLSvc_ExecuteRowset'
+ //
+ static final int odbc_SQLSvc_Execute_ParamError_exn_ = 1;
+ static final int odbc_SQLSvc_Execute_InvalidConnection_exn_ = 2;
+ static final int odbc_SQLSvc_Execute_SQLError_exn_ = 3;
+ static final int odbc_SQLSvc_Execute_SQLInvalidHandle_exn_ = 4;
+ static final int odbc_SQLSvc_ExecuteSQLNeedData_exn_ = 5;
+ static final int odbc_SQLSvc_Execute_SQLRetryCompile_exn_ = 6;
+ static final int odbc_SQLSvc_Execute_SQLStillExecuting_exn_ = 7;
+ static final int odbc_SQLSvc_Execute_SQLQueryCancelled_exn_ = 8;
+ static final int odbc_SQLSvc_Execute_TransactionError_exn_ = 9;
+
+ odbc_SQLSvc_Execute_exc_() {
+ }
+
+ void extractFromByteArray(LogicalByteArray buf, String addr, InterfaceConnection ic)
+ throws CharacterCodingException, UnsupportedCharsetException, SQLException {
+ exception_nr = buf.extractInt();
+ exception_detail = buf.extractInt();
+
+ String temp0 = Integer.toString(exception_nr);
+ String temp1 = Integer.toString(exception_detail);
+
+ switch (exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ break;
+ case odbc_SQLSvc_Execute_SQLStillExecuting_exn_:
+ break;
+ case odbc_SQLSvc_Execute_SQLQueryCancelled_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_s1_008", null);
+ case odbc_SQLSvc_Execute_SQLError_exn_:
+ SQLError = new ERROR_DESC_LIST_def();
+ SQLError.extractFromByteArray(buf, ic);
+ break;
+ case odbc_SQLSvc_Execute_SQLRetryCompile_exn_:
+ SQLRetryCompile = new ERROR_DESC_LIST_def();
+ SQLRetryCompile.extractFromByteArray(buf, ic);
+ break;
+ case odbc_SQLSvc_Execute_ParamError_exn_:
+ ParamError = ic.decodeBytes(buf.extractString(), 1);
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
+ case odbc_SQLSvc_Execute_InvalidConnection_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
+ case odbc_SQLSvc_Execute_TransactionError_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_transaction_error", temp1, addr);
+ default:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0, temp1);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_Fetch_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_Fetch_exc_.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_Fetch_exc_.java
new file mode 100644
index 0000000..b125b5d
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_Fetch_exc_.java
@@ -0,0 +1,87 @@
+// @@@ 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 odbc_SQLSvc_Fetch_exc_ {
+ int exception_nr;
+ int exception_detail;
+
+ String ParamError;
+ ERROR_DESC_LIST_def SQLError;
+ int SQLQueryCancelled;
+
+ //
+ // Taken from odbc_cl.h
+ // Exception number constants for
+ // operation 'odbc_SQLSvc_Fetch'
+ //
+ static final int odbc_SQLSvc_Fetch_ParamError_exn_ = 1;
+ static final int odbc_SQLSvc_Fetch_InvalidConnection_exn_ = 2;
+ static final int odbc_SQLSvc_Fetch_SQLError_exn_ = 3;
+ static final int odbc_SQLSvc_Fetch_SQLInvalidHandle_exn_ = 4;
+ static final int odbc_SQLSvc_Fetch_SQLNoDataFound_exn_ = 5;
+ static final int odbc_SQLSvc_Fetch_SQLStillExecuting_exn_ = 6;
+ static final int odbc_SQLSvc_Fetch_SQLQueryCancelled_exn_ = 7;
+ static final int odbc_SQLSvc_Fetch_TransactionError_exn_ = 8;
+
+ odbc_SQLSvc_Fetch_exc_() {
+ // Do nothing constructor
+ }
+
+ void extractFromByteArray(LogicalByteArray buffer1, String addr, InterfaceConnection ic)
+ throws CharacterCodingException, UnsupportedCharsetException, SQLException {
+ exception_nr = buffer1.extractInt();
+ exception_detail = buffer1.extractInt();
+
+ String temp0 = Integer.toString(exception_nr);
+ String temp1 = Integer.toString(exception_detail);
+
+ switch (exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ break;
+ case odbc_SQLSvc_Fetch_SQLStillExecuting_exn_:
+ break;
+ case odbc_SQLSvc_Fetch_SQLNoDataFound_exn_:
+ break;
+ case odbc_SQLSvc_Fetch_SQLQueryCancelled_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_s1_008", null);
+ case odbc_SQLSvc_Fetch_SQLError_exn_:
+ SQLError = new ERROR_DESC_LIST_def();
+ SQLError.extractFromByteArray(buffer1, ic);
+ break;
+ case odbc_SQLSvc_Fetch_ParamError_exn_:
+ ParamError = ic.decodeBytes(buffer1.extractString(), 1);
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
+ case odbc_SQLSvc_Fetch_InvalidConnection_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
+ case odbc_SQLSvc_Fetch_TransactionError_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_transaction_error", temp1, addr);
+ default:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0, temp1);
+ }
+ } // end extractFromByteArray
+
+} // end odbc_SQLSvc_Fetch_exc_
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_GetSQLCatalogs_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_GetSQLCatalogs_exc_.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_GetSQLCatalogs_exc_.java
new file mode 100644
index 0000000..c48c67f
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_GetSQLCatalogs_exc_.java
@@ -0,0 +1,100 @@
+// @@@ 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 odbc_SQLSvc_GetSQLCatalogs_exc_ {
+
+ // From odbc_cl.h
+ //
+ // struct odbc_SQLSvc_GetSQLCatalogs_exc_
+ // {
+ // size_int exception_nr;
+ // size_int exception_detail;
+ // union {
+ // odbc_SQLSvc_ParamError ParamError;
+ // odbc_SQLSvc_SQLError SQLError;
+ // } u;
+ // };
+
+ int exception_nr;
+ int exception_detail;
+
+ //
+ // The third element is special when it is stored in
+ // the buffer. It may be:
+ //
+ // an offset to a character array (ParamError)
+ // an offset to an odbc_SQLSvc_SQLError (SQLError)
+ // or it may be an integer (SQLQueryCancelled).
+ //
+
+ int p3Index;
+ String ParamError;
+ ERROR_DESC_LIST_def SQLError;
+ int SQLQueryCancelled;
+
+ //
+ // Taken from odbc_cl.h
+ // Exception number constants for
+ // operation 'odbc_SQLSvc_GetSQLCatalogs'
+ //
+ static final int odbc_SQLSvc_GetSQLCatalogs_ParamError_exn_ = 1;
+ static final int odbc_SQLSvc_GetSQLCatalogs_InvalidConnection_exn_ = 2;
+ static final int odbc_SQLSvc_GetSQLCatalogs_SQLError_exn_ = 3;
+ static final int odbc_SQLSvc_GetSQLCatalogs_SQLInvalidHandle_exn_ = 4;
+
+ odbc_SQLSvc_GetSQLCatalogs_exc_() {
+ // Do nothing constructor
+ }
+
+ void extractFromByteArray(LogicalByteArray buffer1, String addr, InterfaceConnection ic)
+ throws CharacterCodingException, UnsupportedCharsetException, SQLException {
+ exception_nr = buffer1.extractInt();
+ exception_detail = buffer1.extractInt();
+
+ String temp0 = Integer.toString(exception_nr);
+ String temp1 = Integer.toString(exception_detail);
+
+ switch (exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ break;
+ case odbc_SQLSvc_GetSQLCatalogs_SQLError_exn_:
+ SQLError = new ERROR_DESC_LIST_def();
+ SQLError.extractFromByteArray(buffer1, ic);
+ break;
+ case odbc_SQLSvc_GetSQLCatalogs_ParamError_exn_:
+ ParamError = ic.decodeBytes(buffer1.extractString(), 1);
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
+ case odbc_SQLSvc_GetSQLCatalogs_SQLInvalidHandle_exn_:
+ break;
+ case odbc_SQLSvc_GetSQLCatalogs_InvalidConnection_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
+ default:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0, temp1);
+ }
+ } // end extractFromByteArray
+
+} // end odbc_SQLSvc_GetSQLCatalogs_exc_
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_InitializeDialogue_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_InitializeDialogue_exc_.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_InitializeDialogue_exc_.java
new file mode 100644
index 0000000..0488eef
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_InitializeDialogue_exc_.java
@@ -0,0 +1,76 @@
+// @@@ 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 odbc_SQLSvc_InitializeDialogue_exc_ {
+ int exception_nr;
+ int exception_detail;
+ String ParamError;
+ ERROR_DESC_LIST_def SQLError;
+ ERROR_DESC_LIST_def InvalidUser;
+
+ String clientErrorText;
+
+ static final int odbc_SQLSvc_InitializeDialogue_ParamError_exn_ = 1;
+ static final int odbc_SQLSvc_InitializeDialogue_InvalidConnection_exn_ = 2;
+ static final int odbc_SQLSvc_InitializeDialogue_SQLError_exn_ = 3;
+ static final int odbc_SQLSvc_InitializeDialogue_SQLInvalidHandle_exn_ = 4;
+ static final int odbc_SQLSvc_InitializeDialogue_SQLNeedData_exn_ = 5;
+ static final int odbc_SQLSvc_InitializeDialogue_InvalidUser_exn_ = 6;
+
+ static final int SQL_PASSWORD_EXPIRING = 8857;
+ static final int SQL_PASSWORD_GRACEPERIOD = 8837;
+
+ // ----------------------------------------------------------
+ void extractFromByteArray(LogicalByteArray buf, String addr, InterfaceConnection ic)
+ throws CharacterCodingException, UnsupportedCharsetException, SQLException {
+ exception_nr = buf.extractInt();
+ exception_detail = buf.extractInt();
+
+ String temp0 = Integer.toString(exception_nr);
+ String temp1 = Integer.toString(exception_detail);
+
+ switch (exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ break;
+ case odbc_SQLSvc_InitializeDialogue_SQLError_exn_:
+ SQLError = new ERROR_DESC_LIST_def();
+ SQLError.extractFromByteArray(buf, ic);
+ break;
+ case odbc_SQLSvc_InitializeDialogue_InvalidUser_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_28_000", null);
+ case odbc_SQLSvc_InitializeDialogue_ParamError_exn_:
+ ParamError = ic.decodeBytes(buf.extractString(), 1);
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
+ case odbc_SQLSvc_InitializeDialogue_InvalidConnection_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
+
+ default:
+ clientErrorText = "unknown_initialize_dialogue_reply_error";
+ break;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_Prepare_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_Prepare_exc_.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_Prepare_exc_.java
new file mode 100644
index 0000000..62d056a
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_Prepare_exc_.java
@@ -0,0 +1,68 @@
+// @@@ 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 odbc_SQLSvc_Prepare_exc_ {
+ int returnCode;
+ String sqlError;
+ int rowsAffected;
+ int outValuesFormat;
+ byte[] outValues;
+
+ static final int odbc_SQLSvc_Prepare_ParamError_exn_ = 1;
+ static final int odbc_SQLSvc_Prepare_InvalidConnection_exn_ = 2;
+ static final int odbc_SQLSvc_Prepare_SQLError_exn_ = 3;
+ static final int odbc_SQLSvc_Prepare_SQLStillExecuting_exn_ = 4;
+ static final int odbc_SQLSvc_Prepare_SQLQueryCancelled_exn_ = 5;
+ static final int odbc_SQLSvc_Prepare_TransactionError_exn_ = 6;
+
+ void extractFromByteArray(LogicalByteArray buf, String addr, InterfaceConnection ic) throws SQLException,
+ UnsupportedCharsetException, CharacterCodingException {
+ returnCode = buf.extractInt();
+
+ String temp0 = Integer.toString(returnCode);
+
+ switch (returnCode) {
+ case TRANSPORT.CEE_SUCCESS:
+ break;
+ case odbc_SQLSvc_Prepare_SQLStillExecuting_exn_:
+ break;
+ case odbc_SQLSvc_Prepare_SQLQueryCancelled_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_s1_008", null);
+ case odbc_SQLSvc_Prepare_SQLError_exn_:
+ break;
+ case odbc_SQLSvc_Prepare_ParamError_exn_:
+ sqlError = ic.decodeBytes(buf.extractString(), 1);
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", sqlError, addr);
+ case odbc_SQLSvc_Prepare_InvalidConnection_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
+ case odbc_SQLSvc_Prepare_TransactionError_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_transaction_error", temp0, addr);
+ default:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_SetConnectionOption_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_SetConnectionOption_exc_.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_SetConnectionOption_exc_.java
new file mode 100644
index 0000000..192e527
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_SetConnectionOption_exc_.java
@@ -0,0 +1,70 @@
+// @@@ 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 odbc_SQLSvc_SetConnectionOption_exc_ {
+ int exception_nr;
+ int exception_detail;
+ String ParamError;
+ SQLWarningOrError[] errorList;
+ ERROR_DESC_LIST_def SQLError;
+
+ static final int odbc_SQLSvc_SetConnectionOption_ParamError_exn_ = 1;
+ static final int odbc_SQLSvc_SetConnectionOption_InvalidConnection_exn_ = 2;
+ static final int odbc_SQLSvc_SetConnectionOption_SQLError_exn_ = 3;
+ static final int odbc_SQLSvc_SetConnectionOption_SQLInvalidHandle_exn_ = 4;
+
+ // ----------------------------------------------------------
+ void extractFromByteArray(LogicalByteArray buf, String addr, InterfaceConnection ic) throws SQLException,
+ UnsupportedCharsetException, CharacterCodingException {
+ exception_nr = buf.extractInt();
+ exception_detail = buf.extractInt();
+
+ String temp0 = Integer.toString(exception_nr);
+ String temp1 = Integer.toString(exception_detail);
+
+ switch (exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ break;
+ case odbc_SQLSvc_SetConnectionOption_SQLError_exn_:
+ SQLError = new ERROR_DESC_LIST_def();
+ SQLError.extractFromByteArray(buf, ic);
+ HPT4Messages.throwSQLException(ic.t4props_, SQLError);
+ case odbc_SQLSvc_SetConnectionOption_ParamError_exn_:
+ ParamError = ic.decodeBytes(buf.extractString(), 1);
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
+ case odbc_SQLSvc_SetConnectionOption_InvalidConnection_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
+ case odbc_SQLSvc_SetConnectionOption_SQLInvalidHandle_exn_:
+ // SQLInvalidHandle
+ // throw HPT4Messages.createSQLException(null, locale, "ids_08_s01",
+ // null);
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "autocommit_txn_in_progress", null);
+ default:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0, temp1);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_TerminateDialogue_exc_.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_TerminateDialogue_exc_.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_TerminateDialogue_exc_.java
new file mode 100644
index 0000000..6242b6e
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/odbc_SQLSvc_TerminateDialogue_exc_.java
@@ -0,0 +1,66 @@
+// @@@ 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 odbc_SQLSvc_TerminateDialogue_exc_ {
+ int exception_nr;
+ int exception_detail;
+ String ParamError;
+ ERROR_DESC_LIST_def SQLError;
+
+ static final int odbc_SQLSvc_TerminateDialogue_ParamError_exn_ = 1;
+ static final int odbc_SQLSvc_TerminateDialogue_InvalidConnection_exn_ = 2;
+ static final int odbc_SQLSvc_TerminateDialogue_SQLError_exn_ = 3;
+
+ // ----------------------------------------------------------
+ void extractFromByteArray(LogicalByteArray buffer1, String addr, InterfaceConnection ic)
+ throws CharacterCodingException, UnsupportedCharsetException, SQLException {
+ exception_nr = buffer1.extractInt();
+ exception_detail = buffer1.extractInt();
+
+ String temp0 = Integer.toString(exception_nr);
+ String temp1 = Integer.toString(exception_detail);
+
+ switch (exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ break;
+ case odbc_SQLSvc_TerminateDialogue_SQLError_exn_:
+ if (exception_detail == 25000) {
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_25_000", null);
+ }
+ SQLError = new ERROR_DESC_LIST_def();
+ SQLError.extractFromByteArray(buffer1, ic);
+ break;
+ case odbc_SQLSvc_TerminateDialogue_ParamError_exn_:
+ ParamError = ic.decodeBytes(buffer1.extractString(), 1);
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
+ case odbc_SQLSvc_TerminateDialogue_InvalidConnection_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
+ default:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_unknown_reply_error", temp0, temp1);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/secClient.properties
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/secClient.properties b/core/conn/jdbcT4/src/main/java/secClient.properties
new file mode 100644
index 0000000..4b71fa2
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/secClient.properties
@@ -0,0 +1,53 @@
+#**********************************************************************
+# @@@ 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 Security Client error messages
+
+# Make sure the file SecClientMsgKeys.java is also updated if a new error
+# message is added to this file
+
+ERR_RETRIEVE_KEY_FROM_FILE = 29701 *** ERROR[29701] failed to retrieve the public key from the certificate file {0}.
+SESSION_KEY_GENERATION_FAILED = 29702 *** ERROR[29702] Internal error: Session key generation failed.
+INPUT_PARAMETER_IS_NULL = 29703 *** ERROR[29703] Internal error: The input parameter {0} is null.
+PWD_LENGTH_TOO_LONG = 29704 *** ERROR[29704] The password was too long.
+ENCRYPTION_FAILED = 29705 *** ERROR[29705] Internal error: Failed to encrypt the password.
+HMAC_FAILED = 29706 *** ERROR[29706] Internal error: Failed to create the keyed-Hash Message Authentication Code.
+PUBKEY_LENGTH_IS_ZERO = 29707 *** ERROR[29707] Internal error: The public key length was zero.
+ERR_CREATE_SYMMETRIC_KEY = 29708 *** ERROR[29708] Internal error: Symmetric key creation failed.
+ERR_READ_CERT_FILE = 29709 *** ERROR[29709] Error reading the certificate file {0}.
+FAILED_GENERATE_RANDOM_NUM = 29710 *** ERROR[29710] Internal error: Random number generation failed.
+CIPHER_TEXT_LEN_NOT_EQUAL_KEY_LEN = 29711 *** ERROR[29711] Internal error: The length of the cipher text was not equal to the length of the public key.
+BAD_MESSAGE_DIGEST_LEN = 29712 *** ERROR[29712] Internal error: The length of the HMAC message was less than the expected length.
+FILE_NOTFOUND = 29713 *** ERROR[29713] Certificate file {0} is not found.
+DATA_ENCRYPTION_FAILED = 29714 *** ERROR[29714] Internal error: Failed to encrypt the data.
+DECRYPTION_FAILED = 29715 *** ERROR[29715] Internal error: Failed to decrypt the password.
+ERR_WRITE_CERT_FILE = 29716 *** ERROR[29716] Error writing to the certificate file {0}.
+GET_LOCAL_HOST_NAME_FAILED = 29717 *** ERROR[29717] Internal error: Error getting the name of the local host.
+BAD_TOKEN_LEN = 29718 *** ERROR[29718] Internal error: The length of the token was not equal to the expected length.
+INCORRECT_TOKEN_FORMAT = 29719 *** ERROR[29719] Internal error: Unexpected token format.
+HOME_ENVIRONMENT_VAR_IS_NULL = 29720 *** ERROR[29720] No HOME environment variables are set on the system.
+FILE_CORRUPTION = 29721 *** ERROR[29721] The certificate file {0} is corrupted.
+FAILED_BUILDING_PWDKEY = 29722 *** ERROR[29722] Internal error: Error building the password key.
+DIR_NOTFOUND = 29723 *** ERROR[29723] Directory {0} is not found.
+ERR_OPEN_INPUT_FILE = 29729 *** ERROR[29729] Failed to open the certificate file {0}.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/samples/CallableStatementSample/CallableStatementSample.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/samples/CallableStatementSample/CallableStatementSample.java b/core/conn/jdbc_type4/samples/CallableStatementSample/CallableStatementSample.java
deleted file mode 100755
index d96864d..0000000
--- a/core/conn/jdbc_type4/samples/CallableStatementSample/CallableStatementSample.java
+++ /dev/null
@@ -1,83 +0,0 @@
-// @@@ 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 @@@
-import common.*;
-
-import java.sql.*;
-public class CallableStatementSample
-{
- public static void main(String args[]) throws Exception
- {
- try
- {
- Connection conn = sampleUtils.getPropertiesConnection();
- Statement stmt = conn.createStatement();
-
- try
- {
- String st = "drop procedure CallableStatementSample";
- try {
- stmt.executeUpdate(st);
- } catch (Exception e) {}
-
- st = "drop library qaspj";
- try {
- stmt.executeUpdate(st);
- } catch (Exception e) {}
-
-
- String path = System.getProperty("serverJarPath");
-
- st = "create library qaspj file '" + path + "/qaspj.jar'";
- stmt.executeUpdate(st);
-
- st = "create procedure CallableStatementSample(out OUT_PARAM INTEGER) EXTERNAL NAME 'IntegerSPJ.Integer_Proc(int[])' LANGUAGE JAVA PARAMETER STYLE JAVA NO ISOLATE LIBRARY QASPJ";
- stmt.executeUpdate(st);
- stmt.close();
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- System.exit(0);
- }
-
-
- // get the CallableStatement object
- CallableStatement cstmt = conn.prepareCall("{call CallableStatementSample(?)}");
- //System.out.println("The Callable Statement " + cstmt);
-
- //register the output parameters
- cstmt.registerOutParameter(1, java.sql.Types.VARCHAR);
-
- //execute the procedure
- cstmt.execute();
-
- //invoke getInt method
- int nRetVal = cstmt.getInt(1);
-
- System.out.println("Out parameter is " + cstmt.getInt(1));
- }
- catch(Exception ex)
- {
- System.err.println("Unexpected Exception" + ex.getMessage());
- throw new Exception("Call to getWarnings is Failed!");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/samples/CallableStatementSample/IntegerSPJ.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/samples/CallableStatementSample/IntegerSPJ.java b/core/conn/jdbc_type4/samples/CallableStatementSample/IntegerSPJ.java
deleted file mode 100755
index 1b64ee9..0000000
--- a/core/conn/jdbc_type4/samples/CallableStatementSample/IntegerSPJ.java
+++ /dev/null
@@ -1,28 +0,0 @@
-// @@@ 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 @@@
-public class IntegerSPJ
-{
- public static void Integer_Proc (int[] out_param)
- {
-
- out_param[0] = 100;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/samples/CallableStatementSample/README
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/samples/CallableStatementSample/README b/core/conn/jdbc_type4/samples/CallableStatementSample/README
deleted file mode 100755
index 3fdfa2b..0000000
--- a/core/conn/jdbc_type4/samples/CallableStatementSample/README
+++ /dev/null
@@ -1,42 +0,0 @@
-This sample demonstrates the invocation of a stored procedure in Java (SPJ).
-
-
-Statement
-===========================================
- "/tmp" is a server-side path where the SPJ jar files are located.
-
-
-Generate the jar file by running build.xml, which is located in the samples directory.
-===========================================
- ant build.xml
-
-Copy the jar file to the system where your instance is running.
-===========================================
- cp samples/target/qaspj.jar /tmp
-Note:
- 1.The sample will create and drop the SPJ via the CREATE/DROP PROCEDURE statement by indirectly using qaspj.jar.
- 2.The jar file must be copied to all nodes in a cluster environment.
-
-Compiling the Java files
-===========================================
- On Windows Platform:
- cd samples\CallableStatementSample
- %JAVA_HOME%\bin\javac -classpath ..\..\lib\jdbcT4.jar *.java ..\common\*.java
- On Linux:
- cd samples/CallableStatementSample
- $JAVA_HOME/bin/javac -classpath ../../lib/jdbcT4.jar *.java ../common/*.java
-Note: Make sure there are no compilation errors displayed on the screen.
-
-Executing CallableStatementSample
-===========================================
- On Windows Platform:
- cd samples\CallableStatementSample
- %JAVA_HOME%\bin\java -classpath ..\..\lib\jdbcT4.jar;..;. -Dt4jdbc.properties=..\t4jdbc.properties -DserverJarPath=/tmp CallableStatementSample
- On Linux:
- cd samples/CallableStatementSample
- $JAVA_HOME/bin/java -classpath ../../lib/jdbcT4.jar:..:. -Dt4jdbc.properties=../t4jdbc.properties -DserverJarPath=/tmp CallableStatementSample
-
- A successful execution of the sample will produce output similar to the following:
- <DATE, TIME> common.sampleUtils getPropertiesConnection
- INFO: DriverManager.getConnection(url, props) passed
- Out parameter is 100
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/samples/DBMetaSample/DBMetaSample.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/samples/DBMetaSample/DBMetaSample.java b/core/conn/jdbc_type4/samples/DBMetaSample/DBMetaSample.java
deleted file mode 100755
index 8f0a2b7..0000000
--- a/core/conn/jdbc_type4/samples/DBMetaSample/DBMetaSample.java
+++ /dev/null
@@ -1,132 +0,0 @@
-// @@@ 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 @@@
-import common.*;
-
-import java.sql.*;
-import java.math.BigDecimal;
-
-public class DBMetaSample
-{
- public static void main(String args[])
- {
-
- Connection connection;
- Statement stmt;
- PreparedStatement pStmt;
- ResultSet rs;
- DatabaseMetaData dbMeta;
- int rowNo;
- String table = "DBMETASAMPLE";
-
- try
- {
- connection = sampleUtils.getPropertiesConnection();
- sampleUtils.dropTable(connection, table);
- sampleUtils.initialData(connection, table);
- sampleUtils.initialCurrentData(connection, table);
-
-
- System.out.println("");
-
-
- for (int i = 0; i < 6; i++)
- {
- switch (i)
- {
- case 0:
- System.out.println("");
- System.out.println("getTypeInfo() ");
- dbMeta = connection.getMetaData();
- rs = dbMeta.getTypeInfo();
- break;
- case 2:
- System.out.println("");
- System.out.println("getCatalogs()");
- dbMeta = connection.getMetaData();
- rs = dbMeta.getCatalogs();
- break;
- case 3:
- System.out.println("");
- System.out.println("getTables() ");
- dbMeta = connection.getMetaData();
- rs = dbMeta.getTables(connection.getCatalog(), sampleUtils.props.getProperty("schema"), "DBMETASAMPLE", null);
- break;
- case 4:
- System.out.println("");
- System.out.println("getColumns()");
- dbMeta = connection.getMetaData();
- rs = dbMeta.getColumns(connection.getCatalog(), sampleUtils.props.getProperty("schema"), "DBMETASAMPLE", "C1");
- break;
- case 5:
- System.out.println("");
- System.out.println("getProcedures()");
- dbMeta = connection.getMetaData();
- rs = dbMeta.getProcedures(connection.getCatalog(), sampleUtils.props.getProperty("schema"), "Integer_Proc");
- break;
- default:
- rs = null;
- continue;
- }
-
- ResultSetMetaData rsMD = rs.getMetaData();
- System.out.println("");
- System.out.println("Printing ResultSetMetaData ...");
- System.out.println("No. of Columns " + rsMD.getColumnCount());
- for (int j = 1; j <= rsMD.getColumnCount(); j++)
- {
- System.out.println("Column " + j + " Data Type: " + rsMD.getColumnTypeName(j) + " Name: " + rsMD.getColumnName(j));
- }
- System.out.println("");
- System.out.println("Fetching rows...");
- rowNo = 0;
- while (rs.next())
- {
- rowNo++;
- System.out.println("");
- System.out.println("Printing Row " + rowNo + " using getString(), getObject()");
- for (int j=1; j <= rsMD.getColumnCount(); j++)
- {
- System.out.println("Column " + j + " - " + rs.getString(j) + "," + rs.getObject(j));
- }
-
- }
- System.out.println("");
- System.out.println("End of Data");
- rs.close();
- }
-
- sampleUtils.dropTable(connection, table);
- connection.close();
- }
- catch (SQLException e)
- {
- SQLException nextException;
-
- nextException = e;
- do
- {
- System.out.println(nextException.getMessage());
- System.out.println("SQLState " + nextException.getSQLState());
- System.out.println("Error Code " + nextException.getErrorCode());
- } while ((nextException = nextException.getNextException()) != null);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/samples/DBMetaSample/README
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/samples/DBMetaSample/README b/core/conn/jdbc_type4/samples/DBMetaSample/README
deleted file mode 100755
index 77dc3a3..0000000
--- a/core/conn/jdbc_type4/samples/DBMetaSample/README
+++ /dev/null
@@ -1,904 +0,0 @@
-Compiling the Java files
-========================
-On Windows Platform:
-%JAVA_HOME%\bin\javac -classpath ..\..\lib\jdbcT4.jar *.java ..\common\*.java
-
-On Linux:
-$JAVA_HOME/bin/javac -classpath ../../lib/jdbcT4.jar *.java ../common/*.java
-
-Note: Make sure there are no compilation errors displayed on
- the screen.
-
-
-Executing DBMetaSample
-======================
-On Windows Platform:
-%JAVA_HOME%\bin\java -classpath ..\..\lib\jdbcT4.jar;..;. -Dt4jdbc.properties=..\t4jdbc.properties DBMetaSample
-
-On Linux:
-$JAVA_HOME/bin/java -classpath ../../lib/jdbcT4.jar:..:. -Dt4jdbc.properties=../t4jdbc.properties DBMetaSample
-
-
-Output of the execution would look like:
-========================================
-<DATE, TIME> common.sampleUtils getPropertiesConnection
-INFO: DriverManager.getConnection(url, props) passed
-
-Inserting TimeStamp
-
-INFO: DriverManager.getConnection(url, props) passed
-
-Inserting TimeStamp
-
-
-getTypeInfo()
-
-Printing ResultSetMetaData ...
-No. of Columns 19
-Column 1 Data Type: VARCHAR Name: TYPE_NAME
-Column 2 Data Type: SMALLINT Name: DATA_TYPE
-Column 3 Data Type: INTEGER Name: PRECISION
-Column 4 Data Type: VARCHAR Name: LITERAL_PREFIX
-Column 5 Data Type: VARCHAR Name: LITERAL_SUFFIX
-Column 6 Data Type: VARCHAR Name: CREATE_PARAMS
-Column 7 Data Type: SMALLINT Name: NULLABLE
-Column 8 Data Type: SMALLINT Name: CASE_SENSITIVE
-Column 9 Data Type: SMALLINT Name: SEARCHABLE
-Column 10 Data Type: SMALLINT Name: UNSIGNED_ATTRIBUTE
-Column 11 Data Type: SMALLINT Name: FIXED_PREC_SCALE
-Column 12 Data Type: SMALLINT Name: AUTO_INCREMENT
-Column 13 Data Type: VARCHAR Name: LOCAL_TYPE_NAME
-Column 14 Data Type: SMALLINT Name: MINIMUM_SCALE
-Column 15 Data Type: SMALLINT Name: MAXIMUM_SCALE
-Column 16 Data Type: SMALLINT Name: SQL_DATA_TYPE
-Column 17 Data Type: SMALLINT Name: SQL_DATETIME_SUB
-Column 18 Data Type: SMALLINT Name: NUM_PREC_RADIX
-Column 19 Data Type: SMALLINT Name: INTERVAL_PRECISION
-
-Fetching rows...
-
-Printing Row 1 using getString(), getObject()
-Column 1 - BIGINT,BIGINT
-Column 2 - -5,-5
-Column 3 - 19,19
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - LARGEINT,LARGEINT
-Column 14 - null,null
-Column 15 - null,null
-Column 16 - -402,-402
-Column 17 - null,null
-Column 18 - 10,10
-Column 19 - null,null
-
-Printing Row 2 using getString(), getObject()
-Column 1 - BIGINT SIGNED,BIGINT SIGNED
-Column 2 - -5,-5
-Column 3 - 19,19
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - LARGEINT,LARGEINT
-Column 14 - null,null
-Column 15 - null,null
-Column 16 - -402,-402
-Column 17 - null,null
-Column 18 - 10,10
-Column 19 - null,null
-
-Printing Row 3 using getString(), getObject()
-Column 1 - CHAR,CHAR
-Column 2 - 1,1
-Column 3 - 32000,32000
-Column 4 - ','
-Column 5 - ','
-Column 6 - max length,max length
-Column 7 - 1,1
-Column 8 - 1,1
-Column 9 - 3,3
-Column 10 - null,null
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - CHARACTER,CHARACTER
-Column 14 - null,null
-Column 15 - null,null
-Column 16 - 1,1
-Column 17 - null,null
-Column 18 - null,null
-Column 19 - null,null
-
-Printing Row 4 using getString(), getObject()
-Column 1 - NUMERIC,NUMERIC
-Column 2 - 2,2
-Column 3 - 128,128
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - precision,scale,precision,scale
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - NUMERIC,NUMERIC
-Column 14 - 0,0
-Column 15 - 128,128
-Column 16 - 2,2
-Column 17 - null,null
-Column 18 - 10,10
-Column 19 - null,null
-
-Printing Row 5 using getString(), getObject()
-Column 1 - NUMERIC SIGNED,NUMERIC SIGNED
-Column 2 - 2,2
-Column 3 - 128,128
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - precision,scale,precision,scale
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - NUMERIC,NUMERIC
-Column 14 - 0,0
-Column 15 - 128,128
-Column 16 - 2,2
-Column 17 - null,null
-Column 18 - 10,10
-Column 19 - null,null
-
-Printing Row 6 using getString(), getObject()
-Column 1 - NUMERIC UNSIGNED,NUMERIC UNSIGNED
-Column 2 - 2,2
-Column 3 - 128,128
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - precision,scale,precision,scale
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 1,1
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - NUMERIC,NUMERIC
-Column 14 - 0,0
-Column 15 - 128,128
-Column 16 - 2,2
-Column 17 - null,null
-Column 18 - 10,10
-Column 19 - null,null
-
-Printing Row 7 using getString(), getObject()
-Column 1 - DECIMAL,DECIMAL
-Column 2 - 3,3
-Column 3 - 18,18
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - precision,scale,precision,scale
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - DECIMAL,DECIMAL
-Column 14 - 0,0
-Column 15 - 18,18
-Column 16 - 3,3
-Column 17 - null,null
-Column 18 - 10,10
-Column 19 - null,null
-
-Printing Row 8 using getString(), getObject()
-Column 1 - DECIMAL SIGNED,DECIMAL SIGNED
-Column 2 - 3,3
-Column 3 - 18,18
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - precision,scale,precision,scale
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - DECIMAL,DECIMAL
-Column 14 - 0,0
-Column 15 - 18,18
-Column 16 - 3,3
-Column 17 - null,null
-Column 18 - 10,10
-Column 19 - null,null
-
-Printing Row 9 using getString(), getObject()
-Column 1 - DECIMAL UNSIGNED,DECIMAL UNSIGNED
-Column 2 - 3,3
-Column 3 - 18,18
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - precision,scale,precision,scale
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 1,1
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - DECIMAL,DECIMAL
-Column 14 - 0,0
-Column 15 - 18,18
-Column 16 - -301,-301
-Column 17 - null,null
-Column 18 - 10,10
-Column 19 - null,null
-
-Printing Row 10 using getString(), getObject()
-Column 1 - INTEGER,INTEGER
-Column 2 - 4,4
-Column 3 - 10,10
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - INTEGER,INTEGER
-Column 14 - null,null
-Column 15 - null,null
-Column 16 - 4,4
-Column 17 - null,null
-Column 18 - 10,10
-Column 19 - null,null
-
-Printing Row 11 using getString(), getObject()
-Column 1 - INTEGER SIGNED,INTEGER SIGNED
-Column 2 - 4,4
-Column 3 - 10,10
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - INTEGER,INTEGER
-Column 14 - null,null
-Column 15 - null,null
-Column 16 - 4,4
-Column 17 - null,null
-Column 18 - 10,10
-Column 19 - null,null
-
-Printing Row 12 using getString(), getObject()
-Column 1 - INTEGER UNSIGNED,INTEGER UNSIGNED
-Column 2 - 4,4
-Column 3 - 10,10
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 1,1
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - INTEGER,INTEGER
-Column 14 - null,null
-Column 15 - null,null
-Column 16 - -401,-401
-Column 17 - null,null
-Column 18 - 10,10
-Column 19 - null,null
-
-Printing Row 13 using getString(), getObject()
-Column 1 - SMALLINT,SMALLINT
-Column 2 - 5,5
-Column 3 - 5,5
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - SMALLINT,SMALLINT
-Column 14 - null,null
-Column 15 - null,null
-Column 16 - 5,5
-Column 17 - null,null
-Column 18 - 10,10
-Column 19 - null,null
-
-Printing Row 14 using getString(), getObject()
-Column 1 - SMALLINT SIGNED,SMALLINT SIGNED
-Column 2 - 5,5
-Column 3 - 5,5
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - SMALLINT,SMALLINT
-Column 14 - null,null
-Column 15 - null,null
-Column 16 - 5,5
-Column 17 - null,null
-Column 18 - 10,10
-Column 19 - null,null
-
-Printing Row 15 using getString(), getObject()
-Column 1 - SMALLINT UNSIGNED,SMALLINT UNSIGNED
-Column 2 - 5,5
-Column 3 - 5,5
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 1,1
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - SMALLINT,SMALLINT
-Column 14 - null,null
-Column 15 - null,null
-Column 16 - -502,-502
-Column 17 - null,null
-Column 18 - 10,10
-Column 19 - null,null
-
-Printing Row 16 using getString(), getObject()
-Column 1 - FLOAT,FLOAT
-Column 2 - 6,6
-Column 3 - 15,15
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - FLOAT,FLOAT
-Column 14 - null,null
-Column 15 - null,null
-Column 16 - 6,6
-Column 17 - null,null
-Column 18 - 2,2
-Column 19 - null,null
-
-Printing Row 17 using getString(), getObject()
-Column 1 - REAL,REAL
-Column 2 - 7,7
-Column 3 - 7,7
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - REAL,REAL
-Column 14 - null,null
-Column 15 - null,null
-Column 16 - 7,7
-Column 17 - null,null
-Column 18 - 2,2
-Column 19 - null,null
-
-Printing Row 18 using getString(), getObject()
-Column 1 - DOUBLE PRECISION,DOUBLE PRECISION
-Column 2 - 8,8
-Column 3 - 15,15
-Column 4 - null,null
-Column 5 - null,null
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - 0,0
-Column 13 - DOUBLE,DOUBLE
-Column 14 - null,null
-Column 15 - null,null
-Column 16 - 8,8
-Column 17 - null,null
-Column 18 - 2,2
-Column 19 - null,null
-
-Printing Row 19 using getString(), getObject()
-Column 1 - VARCHAR,VARCHAR
-Column 2 - 12,12
-Column 3 - 32000,32000
-Column 4 - ','
-Column 5 - ','
-Column 6 - max length,max length
-Column 7 - 1,1
-Column 8 - 1,1
-Column 9 - 3,3
-Column 10 - null,null
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - VARCHAR,VARCHAR
-Column 14 - null,null
-Column 15 - null,null
-Column 16 - 12,12
-Column 17 - null,null
-Column 18 - null,null
-Column 19 - null,null
-
-Printing Row 20 using getString(), getObject()
-Column 1 - DATE,DATE
-Column 2 - 91,91
-Column 3 - 10,10
-Column 4 - {d ',{d '
-Column 5 - '},'}
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - null,null
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - DATE,DATE
-Column 14 - null,null
-Column 15 - null,null
-Column 16 - 9,9
-Column 17 - 1,1
-Column 18 - null,null
-Column 19 - null,null
-
-Printing Row 21 using getString(), getObject()
-Column 1 - TIME,TIME
-Column 2 - 92,92
-Column 3 - 8,8
-Column 4 - {t ',{t '
-Column 5 - '},'}
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - null,null
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - TIME,TIME
-Column 14 - null,null
-Column 15 - null,null
-Column 16 - 9,9
-Column 17 - 2,2
-Column 18 - null,null
-Column 19 - null,null
-
-Printing Row 22 using getString(), getObject()
-Column 1 - TIMESTAMP,TIMESTAMP
-Column 2 - 93,93
-Column 3 - 26,26
-Column 4 - {ts ',{ts '
-Column 5 - '},'}
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - null,null
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - TIMESTAMP,TIMESTAMP
-Column 14 - 0,0
-Column 15 - 6,6
-Column 16 - 9,9
-Column 17 - 3,3
-Column 18 - null,null
-Column 19 - null,null
-
-Printing Row 23 using getString(), getObject()
-Column 1 - INTERVAL,INTERVAL
-Column 2 - 101,101
-Column 3 - 0,0
-Column 4 - {INTERVAL ',{INTERVAL '
-Column 5 - ' YEAR},' YEAR}
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - INTERVAL,INTERVAL
-Column 14 - 0,0
-Column 15 - 0,0
-Column 16 - 100,100
-Column 17 - 1,1
-Column 18 - null,null
-Column 19 - 2,2
-
-Printing Row 24 using getString(), getObject()
-Column 1 - INTERVAL,INTERVAL
-Column 2 - 102,102
-Column 3 - 0,0
-Column 4 - {INTERVAL ',{INTERVAL '
-Column 5 - ' MONTH},' MONTH}
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - INTERVAL,INTERVAL
-Column 14 - 0,0
-Column 15 - 0,0
-Column 16 - 100,100
-Column 17 - 2,2
-Column 18 - null,null
-Column 19 - 2,2
-
-Printing Row 25 using getString(), getObject()
-Column 1 - INTERVAL,INTERVAL
-Column 2 - 103,103
-Column 3 - 0,0
-Column 4 - {INTERVAL ',{INTERVAL '
-Column 5 - ' DAY},' DAY}
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - INTERVAL,INTERVAL
-Column 14 - 0,0
-Column 15 - 0,0
-Column 16 - 100,100
-Column 17 - 3,3
-Column 18 - null,null
-Column 19 - 2,2
-
-Printing Row 26 using getString(), getObject()
-Column 1 - INTERVAL,INTERVAL
-Column 2 - 104,104
-Column 3 - 0,0
-Column 4 - {INTERVAL ',{INTERVAL '
-Column 5 - ' HOUR},' HOUR}
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - INTERVAL,INTERVAL
-Column 14 - 0,0
-Column 15 - 0,0
-Column 16 - 100,100
-Column 17 - 4,4
-Column 18 - null,null
-Column 19 - 2,2
-
-Printing Row 27 using getString(), getObject()
-Column 1 - INTERVAL,INTERVAL
-Column 2 - 105,105
-Column 3 - 0,0
-Column 4 - {INTERVAL ',{INTERVAL '
-Column 5 - ' MINUTE},' MINUTE}
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - INTERVAL,INTERVAL
-Column 14 - 0,0
-Column 15 - 0,0
-Column 16 - 100,100
-Column 17 - 5,5
-Column 18 - null,null
-Column 19 - 2,2
-
-Printing Row 28 using getString(), getObject()
-Column 1 - INTERVAL,INTERVAL
-Column 2 - 106,106
-Column 3 - 0,0
-Column 4 - {INTERVAL ',{INTERVAL '
-Column 5 - ' SECOND},' SECOND}
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - INTERVAL,INTERVAL
-Column 14 - 0,0
-Column 15 - 0,0
-Column 16 - 100,100
-Column 17 - 6,6
-Column 18 - null,null
-Column 19 - 2,2
-
-Printing Row 29 using getString(), getObject()
-Column 1 - INTERVAL,INTERVAL
-Column 2 - 107,107
-Column 3 - 0,0
-Column 4 - {INTERVAL ',{INTERVAL '
-Column 5 - ' YEAR TO MONTH},' YEAR TO MONTH}
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - INTERVAL,INTERVAL
-Column 14 - 0,0
-Column 15 - 0,0
-Column 16 - 100,100
-Column 17 - 7,7
-Column 18 - null,null
-Column 19 - 2,2
-
-Printing Row 30 using getString(), getObject()
-Column 1 - INTERVAL,INTERVAL
-Column 2 - 108,108
-Column 3 - 0,0
-Column 4 - {INTERVAL ',{INTERVAL '
-Column 5 - ' DAY TO HOUR},' DAY TO HOUR}
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - INTERVAL,INTERVAL
-Column 14 - 0,0
-Column 15 - 0,0
-Column 16 - 100,100
-Column 17 - 8,8
-Column 18 - null,null
-Column 19 - 2,2
-
-Printing Row 31 using getString(), getObject()
-Column 1 - INTERVAL,INTERVAL
-Column 2 - 109,109
-Column 3 - 0,0
-Column 4 - {INTERVAL ',{INTERVAL '
-Column 5 - ' DAY TO MINUTE},' DAY TO MINUTE}
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - INTERVAL,INTERVAL
-Column 14 - 0,0
-Column 15 - 0,0
-Column 16 - 100,100
-Column 17 - 9,9
-Column 18 - null,null
-Column 19 - 2,2
-
-Printing Row 32 using getString(), getObject()
-Column 1 - INTERVAL,INTERVAL
-Column 2 - 110,110
-Column 3 - 0,0
-Column 4 - {INTERVAL ',{INTERVAL '
-Column 5 - ' DAY TO SECOND},' DAY TO SECOND}
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - INTERVAL,INTERVAL
-Column 14 - 0,0
-Column 15 - 0,0
-Column 16 - 100,100
-Column 17 - 10,10
-Column 18 - null,null
-Column 19 - 2,2
-
-Printing Row 33 using getString(), getObject()
-Column 1 - INTERVAL,INTERVAL
-Column 2 - 111,111
-Column 3 - 0,0
-Column 4 - {INTERVAL ',{INTERVAL '
-Column 5 - ' HOUR TO MINUTE},' HOUR TO MINUTE}
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - INTERVAL,INTERVAL
-Column 14 - 0,0
-Column 15 - 0,0
-Column 16 - 100,100
-Column 17 - 11,11
-Column 18 - null,null
-Column 19 - 2,2
-
-Printing Row 34 using getString(), getObject()
-Column 1 - INTERVAL,INTERVAL
-Column 2 - 112,112
-Column 3 - 0,0
-Column 4 - {INTERVAL ',{INTERVAL '
-Column 5 - ' HOUR TO SECOND},' HOUR TO SECOND}
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - INTERVAL,INTERVAL
-Column 14 - 0,0
-Column 15 - 0,0
-Column 16 - 100,100
-Column 17 - 12,12
-Column 18 - null,null
-Column 19 - 2,2
-
-Printing Row 35 using getString(), getObject()
-Column 1 - INTERVAL,INTERVAL
-Column 2 - 113,113
-Column 3 - 0,0
-Column 4 - {INTERVAL ',{INTERVAL '
-Column 5 - ' MINUTE TO SECOND},' MINUTE TO SECOND}
-Column 6 - null,null
-Column 7 - 1,1
-Column 8 - 0,0
-Column 9 - 2,2
-Column 10 - 0,0
-Column 11 - 0,0
-Column 12 - null,null
-Column 13 - INTERVAL,INTERVAL
-Column 14 - 0,0
-Column 15 - 0,0
-Column 16 - 100,100
-Column 17 - 13,13
-Column 18 - null,null
-Column 19 - 2,2
-
-End of Data
-
-getCatalogs()
-
-Printing ResultSetMetaData ...
-No. of Columns 1
-Column 1 Data Type: VARCHAR Name: TABLE_CAT
-
-Fetching rows...
-
-Printing Row 1 using getString(), getObject()
-Column 1 - TRAFODION,TRAFODION
-
-End of Data
-
-getTables()
-
-Printing ResultSetMetaData ...
-No. of Columns 10
-Column 1 Data Type: VARCHAR Name: TABLE_CAT
-Column 2 Data Type: VARCHAR Name: TABLE_SCHEM
-Column 3 Data Type: VARCHAR Name: TABLE_NAME
-Column 4 Data Type: VARCHAR Name: TABLE_TYPE
-Column 5 Data Type: VARCHAR Name: REMARKS
-Column 6 Data Type: VARCHAR Name: TYPE_CAT
-Column 7 Data Type: VARCHAR Name: TYPE_SCHEM
-Column 8 Data Type: VARCHAR Name: TYPE_NAME
-Column 9 Data Type: VARCHAR Name: SELF_REFERENCING_COL_NAME
-Column 10 Data Type: VARCHAR Name: REF_GENERATION
-
-Fetching rows...
-
-Printing Row 1 using getString(), getObject()
-Column 1 - TRAFODION,TRAFODION
-Column 2 - SEABASE,SEABASE
-Column 3 - DBMETASAMPLE,DBMETASAMPLE
-Column 4 - TABLE,TABLE
-Column 5 - null,null
-Column 6 - null,null
-Column 7 - null,null
-Column 8 - null,null
-Column 9 - null,null
-Column 10 - null,null
-
-End of Data
-
-getColumns()
-
-Printing ResultSetMetaData ...
-No. of Columns 18
-Column 1 Data Type: VARCHAR Name: TABLE_CAT
-Column 2 Data Type: VARCHAR Name: TABLE_SCHEM
-Column 3 Data Type: VARCHAR Name: TABLE_NAME
-Column 4 Data Type: VARCHAR Name: COLUMN_NAME
-Column 5 Data Type: SMALLINT Name: DATA_TYPE
-Column 6 Data Type: VARCHAR Name: TYPE_NAME
-Column 7 Data Type: INTEGER Name: COLUMN_SIZE
-Column 8 Data Type: INTEGER Name: BUFFER_LENGTH
-Column 9 Data Type: SMALLINT Name: DECIMAL_DIGITS
-Column 10 Data Type: SMALLINT Name: NUM_PREC_RADIX
-Column 11 Data Type: SMALLINT Name: NULLABLE
-Column 12 Data Type: VARCHAR Name: REMARKS
-Column 13 Data Type: VARCHAR Name: COLUMN_DEF
-Column 14 Data Type: SMALLINT Name: SQL_DATA_TYPE
-Column 15 Data Type: SMALLINT Name: SQL_DATETIME_SUB
-Column 16 Data Type: INTEGER Name: CHAR_OCTET_LENGTH
-Column 17 Data Type: INTEGER Name: ORDINAL_POSITION
-Column 18 Data Type: VARCHAR Name: IS_NULLABLE
-
-Fetching rows...
-
-Printing Row 1 using getString(), getObject()
-Column 1 - TRAFODION,TRAFODION
-Column 2 - SEABASE,SEABASE
-Column 3 - DBMETASAMPLE,DBMETASAMPLE
-Column 4 - C1,C1
-Column 5 - 1,1
-Column 6 - CHAR,CHAR
-Column 7 - 20,20
-Column 8 - 20,20
-Column 9 - 0,0
-Column 10 - null,null
-Column 11 - 2,2
-Column 12 - null,null
-Column 13 - ,
-Column 14 - 1,1
-Column 15 - null,null
-Column 16 - 20,20
-Column 17 - 1,1
-Column 18 - YES,YES
-
-End of Data
-
-getProcedures()
-
-Printing ResultSetMetaData ...
-No. of Columns 8
-Column 1 Data Type: VARCHAR Name: PROCEDURE_CAT
-Column 2 Data Type: VARCHAR Name: PROCEDURE_SCHEM
-Column 3 Data Type: VARCHAR Name: PROCEDURE_NAME
-Column 4 Data Type: SMALLINT Name: NUM_INPUT_PARAMS
-Column 5 Data Type: SMALLINT Name: NUM_OUTPUT_PARAMS
-Column 6 Data Type: SMALLINT Name: NUM_RESULT_SETS
-Column 7 Data Type: VARCHAR Name: REMARKS
-Column 8 Data Type: SMALLINT Name: PROCEDURE_TYPE
-
-Fetching rows...
-
-End of Data
-=======================================================
[27/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Driver.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Driver.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Driver.java
new file mode 100644
index 0000000..a1724aa
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Driver.java
@@ -0,0 +1,367 @@
+// @@@ 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.DriverManager;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+/**
+ * <p>
+ * JDBC Type 4 Driver implementation.
+ * </p>
+ * <p>
+ * Description: <code>T4Driver</code> is an implementation of the
+ * <code>java.sql.Driver</code> interface. The Java SQL framework allows for
+ * multiple database drivers to be loaded in single java program. The
+ * <code>T4Driver</code> can be loaded programatically by
+ * <code>Class.forName("org.trafodion.jdbc.t4.T4Driver") </code> or by passing
+ * <code>-Djdbc.drivers=org.trafodion.jdbc.t4.T4Driver</code> in the command line of
+ * the Java program.
+ * </p>
+ * <p>
+ * Licensed to the Apache Software Foundation (ASF)
+ * </p>
+ *
+ * @see java.sql.DriverManager
+ * @see java.sql.Connection
+ */
+public class T4Driver extends T4Properties implements java.sql.Driver {
+ /**
+ * Retrieves whether the Type 4 driver determined that it can open a
+ * connection to the given URL. Typically drivers return true if they
+ * recognize the subprotocol specified in the URL and false if they do not.
+ * For Type 4 driver to recognize the protocol, the URL must start with
+ * <code>jdbc:t4jdbc</code>.
+ *
+ * @param url
+ * The URL of the database.
+ * @return true if the Type 4 driver recognizes the given URL; otherwise,
+ * false.
+ */
+ public boolean acceptsURL(String url) throws SQLException {
+ if (t4GlobalLogger.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null,filterOutPWD(url));
+ t4GlobalLogger.logp(Level.FINE, "T4Driver", "acceptsURL", "", p);
+ }
+ if (getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null, filterOutPWD(url));
+ lr.setParameters(p);
+ lr.setSourceClassName("T4Driver");
+ lr.setSourceMethodName("acceptsURL");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ getLogWriter().println(temp);
+ }
+
+ return T4Address.acceptsURL(url);
+ }
+
+ /**
+ * Attempts to make an NDCS connection to the given URL. The Type 4 driver
+ * returns "null" when it determines that the driver is the wrong kind of
+ * driver to connect to the given URL. This occurence is common; for
+ * example, when the JDBC driver manager is requested to connect to a given
+ * URL, the driver manager it passes the URL to each loaded driver in turn.
+ * The Type 4 driver throws an SQLException when it has trouble connecting
+ * to NDCS. You can use the <code>java.util.Properties</code> argument to
+ * pass arbitrary string name-value pairs as connection arguments.
+ * Typically, you should include "user" and "password" properties in the
+ * Properties object.
+ *
+ * @param url
+ * The URL string of format
+ * <code>jdbc:t4jdbc://host:port/:</code>
+ * @param info
+ * <code>java.util.Properties</code> object containing
+ * name-value pair.
+ * @return The <code>TrafT4Connection</code> object.
+ * @throws SQLException
+ * When an error occurs connecting to NDCS.
+ * @see T4Properties
+ */
+ public java.sql.Connection connect(String url, Properties info) throws SQLException {
+ Properties tempinfo = null;
+ if (t4GlobalLogger.isLoggable(Level.FINE) == true) {
+ tempinfo = new Properties();
+ tempinfo.putAll(info);
+ tempinfo.remove("password");
+ Object p[] = T4LoggingUtilities.makeParams(null, filterOutPWD(url), tempinfo);
+ t4GlobalLogger.logp(Level.FINE, "T4Driver", "connect", "", p);
+ }
+ if (getLogWriter() != null) {
+ if (tempinfo == null) {
+ tempinfo = new Properties();
+ tempinfo.putAll(info);
+ tempinfo.remove("password");
+ }
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null, filterOutPWD(url), tempinfo);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4Driver");
+ lr.setSourceMethodName("connect");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ getLogWriter().println(temp);
+ }
+
+ if (logger.isLoggable(Level.INFO)) {
+ logger.entering("HPT4DataSource", "getConnection");
+ }
+
+ String key = null;
+ HPT4DataSource ds = null;
+
+ if (acceptsURL(url)) {
+ synchronized(this) {
+ // properties in the info take precedence.
+ // Note, setURL also assigns the T4Properties that are on the URL
+ Properties urlProps = setURL(url);
+
+ //
+ // Merge any property that is in the url but not in info.
+ //
+ if (urlProps != null && info != null) {
+ Enumeration en1 = urlProps.propertyNames();
+ String key1 = null;
+
+ while (en1 != null && en1.hasMoreElements() == true) {
+ key1 = (String) en1.nextElement();
+ if (info.getProperty(key1) == null) {
+ info.setProperty(key1, urlProps.getProperty(key1));
+ }
+ }
+ }
+
+ // If info is false, but there were properties on the URL,
+ // the URL properties were already set when we called setURL.
+ if (info != null) {
+ initialize(info);
+ if (getSQLException() != null) {
+ throw HPT4Messages.createSQLException(null, getLocale(), "invalid_property", getSQLException());
+ }
+ }
+ if (getMaxPoolSize() != -1) {
+ key = getUrl() + getCatalog() + getSchema() + getUser() + getPassword() + getServerDataSource()
+ + getBlobTableName() + getClobTableName();
+
+ ds = (HPT4DataSource) dsCache_.get(key);
+
+ if (ds == null) {
+ ds = new HPT4DataSource(getProperties());
+ dsCache_.put(key, ds);
+ }
+ } else {
+ ds = new HPT4DataSource(getProperties());
+ }
+ }
+
+ return ds.getConnection(ds.getUser(), ds.getPassword());
+ } else {
+ return null;
+ }
+ }
+
+ private String filterOutPWD(String url) {
+ return url.replaceAll("password\\s*\\=\\s*[^;]*", "");
+ }
+
+ /**
+ * Retrieves the driver's major JDBC version number. For the Type 4 Driver,
+ * the number should be 3.
+ *
+ * @return 3.
+ */
+ public int getMajorVersion() {
+ if (t4GlobalLogger.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ t4GlobalLogger.logp(Level.FINE, "T4Driver", "getMajorVersion", "", p);
+ }
+ try {
+ if (getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4Driver");
+ lr.setSourceMethodName("getMajorVersion");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+
+ return 3;
+ }
+
+ /**
+ * Gets the Type 4 driver's minor version number. For the Type 4 driver, the
+ * number should be 11.
+ *
+ * @return 11
+ */
+ public int getMinorVersion() {
+ if (t4GlobalLogger.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ t4GlobalLogger.logp(Level.FINE, "T4Driver", "getMinorVersion", "", p);
+ }
+ try {
+ if (getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4Driver");
+ lr.setSourceMethodName("getMinorVersion");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+
+ return 11;
+ }
+
+ /**
+ * Gets information about the possible properties for the Type 4 driver. The
+ * <code>getPropertyInfo</code> method is intended to allow a generic GUI
+ * tool to determine the properties that the tool should prompt from a human
+ * to get enough information to connect to NDCS. Depending on the values the
+ * human has supplied so far, additional values might be necessary, so you
+ * might need to iterate though several calls to the
+ * <code>getPropertyInfo</code> method.
+ *
+ * @param url
+ * The URL of the database to which to connect
+ * @param info
+ * <code>java.util.Properties</code> object containing
+ * name-value pairs. The Type 4 driver ignores the Properties
+ * parameter passed to the driver.
+ * @return array of <code>DriverPropertyInfo</code> containing property
+ * details.
+ */
+
+ public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
+ Properties tempinfo = null;
+ if (t4GlobalLogger.isLoggable(Level.FINE) == true) {
+ tempinfo = new Properties();
+ tempinfo.putAll(info);
+ tempinfo.remove("password");
+ Object p[] = T4LoggingUtilities.makeParams(null, filterOutPWD(url), tempinfo);
+ t4GlobalLogger.logp(Level.FINE, "T4Driver", "getPropertyInfo", "", p);
+ }
+ if (getLogWriter() != null) {
+ if(tempinfo == null){
+ tempinfo = new Properties();
+ tempinfo.putAll(info);
+ tempinfo.remove("password");
+ }
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null, filterOutPWD(url), tempinfo);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4Driver");
+ lr.setSourceMethodName("getPropertyInfo");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ getLogWriter().println(temp);
+ }
+ if (acceptsURL(url)) {
+ return super.getPropertyInfo(url, info);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns whether the Type 4 driver is JDBC compliant.
+ *
+ * @return true
+ */
+ public boolean jdbcCompliant() {
+ if (t4GlobalLogger.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ t4GlobalLogger.logp(Level.FINE, "T4Driver", "jdbcCompliant", "", p);
+ }
+ try {
+ if (getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ lr.setParameters(p);
+ lr.setSourceClassName("T4Driver");
+ lr.setSourceMethodName("jdbcCompliant");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+
+ return true;
+ };
+
+ // Fields
+ private static T4Driver singleton_;
+ static Hashtable dsCache_;
+
+ /**
+ * Instantiated by either <code>
+ * Class.forName("org.trafodion.jdbc.t4.T4Driver")</code>
+ * or by passing <code>-Djdbc.drivers=org.trafodion.jdbc.t4.T4Driver</code>
+ * property in the command line of the JDBC program.
+ */
+ public T4Driver() {
+ super();
+ if (logger.isLoggable(Level.INFO)) {
+ logger.entering("HPT4DataSource", "getConnection");
+ }
+ }
+
+ // initializer to register the Driver with the Driver manager
+ static {
+ // Register the Driver with the Driver Manager
+ try {
+ singleton_ = new T4Driver();
+ DriverManager.registerDriver(singleton_);
+ } catch (SQLException e) {
+ singleton_ = null;
+ e.printStackTrace();
+ }
+
+ dsCache_ = new Hashtable();
+ }
+
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4LogFormatter.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4LogFormatter.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4LogFormatter.java
new file mode 100644
index 0000000..b61b207
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4LogFormatter.java
@@ -0,0 +1,236 @@
+// @@@ 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.text.DateFormat;
+import java.text.DecimalFormat;
+import java.util.logging.LogRecord;
+
+public class T4LogFormatter extends java.util.logging.Formatter {
+
+ static DecimalFormat df = new DecimalFormat("########################################################00000000");
+
+ // ----------------------------------------------------------
+ public T4LogFormatter() {
+ }
+
+ // ----------------------------------------------------------
+ public String format(LogRecord lr) {
+ String m1;
+ String separator = " ~ ";
+ Object params[] = lr.getParameters();
+ Object tempParam = null;
+
+ try {
+ long sequence_number = lr.getSequenceNumber();
+ String time_stamp = null;
+ long thread_id = lr.getThreadID();
+ String connection_id = "";
+ String server_id = "";
+ String dialogue_id = "";
+ String class_name = lr.getSourceClassName();
+ String method = lr.getSourceMethodName();
+ String parameters = ""; // need to fix
+ String message = lr.getMessage();
+
+ long time_mills = lr.getMillis();
+ java.util.Date d1 = new java.util.Date(time_mills);
+ DateFormat df1 = java.text.DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.FULL);
+
+ time_stamp = df1.format(d1);
+
+ //
+ // By convension, the first parameter is a TrafT4Connection object or
+ // a T4Properties object
+ //
+ TrafT4Connection sc = null;
+ T4Properties tp = null;
+
+ if (params != null && params.length > 0) {
+ if (params[0] instanceof TrafT4Connection)
+ tp = ((TrafT4Connection) params[0]).props_;
+ else
+ tp = (T4Properties) params[0];
+ }
+
+ if (tp != null) {
+ connection_id = tp.getConnectionID();
+ server_id = tp.getServerID();
+ dialogue_id = tp.getDialogueID();
+ }
+
+ //
+ // Format for message:
+ //
+ // sequence-number ~ time-stamp ~ thread-id ~ [connection-id] ~
+ // [server-id]
+ // ~ [dialogue-id] ~ [class] ~ [method] ~ [parameters] ~ [text]
+ //
+
+ Long l1 = new Long(sequence_number);
+ String t1 = df.format(l1);
+ String p1 = "";
+
+ m1 = t1 + separator + time_stamp + separator + thread_id + separator + connection_id + separator
+ + server_id + separator + dialogue_id + separator + class_name + "." + method + "(";
+
+ if (params != null) {
+ String paramText = null;
+
+ //
+ // Skip the first parameter, which is a T4Connection, and is
+ // handled above.
+ //
+ for (int i = 1; i < params.length; i++) {
+ tempParam = params[i];
+ if (tempParam != null) {
+ //
+ // If the parameter is an array, try to print each
+ // element of the array.
+ //
+ tempParam = makeObjectArray(tempParam);
+
+ if (tempParam instanceof Object[]) {
+ Object[] tempOa = (Object[]) tempParam;
+ String tempOas = "";
+ String tempStr2 = null;
+
+ for (int j = 0; j < tempOa.length; j++) {
+ if (tempOa[j] != null) {
+ tempStr2 = tempOa[j].toString();
+ } else {
+ tempStr2 = "null";
+ }
+ tempOas = tempOas + " [" + j + "]" + tempStr2;
+ }
+ paramText = tempOas;
+ } else {
+ paramText = tempParam.toString();
+ }
+ } else {
+ paramText = "null";
+
+ }
+ p1 = p1 + "\"" + paramText + "\"";
+ if (i + 1 < params.length) {
+ p1 = p1 + ", ";
+ }
+ }
+ }
+
+ m1 = m1 + p1 + ")" + separator + message + "\n";
+
+ } catch (Exception e) {
+ //
+ // Tracing should never cause an internal error, but if it does, we
+ // do want to
+ // capture it here. An internal error here has no effect on the user
+ // program,
+ // so we don't want to throw an exception. We'll put the error in
+ // the trace log
+ // instead, and instruct the user to report it
+ //
+ m1 = "An internal error has occurred in the tracing logic. Please report this to your representative. \n"
+ + " exception = "
+ + e.toString()
+ + "\n"
+ + " message = "
+ + e.getMessage()
+ + "\n"
+ + " Stack trace = \n";
+
+ StackTraceElement st[] = e.getStackTrace();
+
+ for (int i = 0; i < st.length; i++) {
+ m1 = m1 + " " + st[i].toString() + "\n";
+ }
+ m1 = m1 + "\n";
+ } // end catch
+
+ //
+ // The params array is reused, so we must null it out before returning.
+ //
+ if (params != null) {
+ for (int i = 0; i < params.length; i++) {
+ params[i] = null;
+ }
+ }
+
+ return m1;
+
+ } // end formatMessage
+
+ // ---------------------------------------------------------------------
+ Object makeObjectArray(Object obj) {
+ Object retVal = obj;
+ Object[] newVal = null;
+ int i;
+
+ if (obj instanceof boolean[]) {
+ boolean[] temp = (boolean[]) obj;
+ newVal = new Boolean[temp.length];
+ for (i = 0; i < temp.length; i++)
+ newVal[i] = new Boolean(temp[i]);
+ } else if (obj instanceof char[]) {
+ char[] temp = (char[]) obj;
+ newVal = new Character[temp.length];
+ for (i = 0; i < temp.length; i++)
+ newVal[i] = new Character(temp[i]);
+ } else if (obj instanceof byte[]) {
+ byte[] temp = (byte[]) obj;
+ newVal = new Byte[temp.length];
+ for (i = 0; i < temp.length; i++)
+ newVal[i] = new Byte(temp[i]);
+ } else if (obj instanceof short[]) {
+ short[] temp = (short[]) obj;
+ newVal = new Short[temp.length];
+ for (i = 0; i < temp.length; i++)
+ newVal[i] = new Short(temp[i]);
+ } else if (obj instanceof int[]) {
+ int[] temp = (int[]) obj;
+ newVal = new Integer[temp.length];
+ for (i = 0; i < temp.length; i++)
+ newVal[i] = new Integer(temp[i]);
+ } else if (obj instanceof long[]) {
+ long[] temp = (long[]) obj;
+ newVal = new Long[temp.length];
+ for (i = 0; i < temp.length; i++)
+ newVal[i] = new Long(temp[i]);
+ } else if (obj instanceof float[]) {
+ float[] temp = (float[]) obj;
+ newVal = new Float[temp.length];
+ for (i = 0; i < temp.length; i++)
+ newVal[i] = new Float(temp[i]);
+ } else if (obj instanceof double[]) {
+ double[] temp = (double[]) obj;
+ newVal = new Double[temp.length];
+ for (i = 0; i < temp.length; i++)
+ newVal[i] = new Double(temp[i]);
+ }
+
+ if (newVal != null)
+ retVal = newVal;
+
+ return retVal;
+ } // end makeObjectArray
+
+} // end class T4LogFormatter
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4LoggingUtilities.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4LoggingUtilities.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4LoggingUtilities.java
new file mode 100644
index 0000000..e29da5e
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4LoggingUtilities.java
@@ -0,0 +1,816 @@
+// @@@ 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;
+
+public class T4LoggingUtilities {
+
+ static final Long m_syncL = new Long(1L);
+
+ // ----------------------------------------------------------
+ public T4LoggingUtilities() {
+ }
+
+ // ----------------------------------------------------------
+ static String getUniqueID() {
+ synchronized (m_syncL) {
+ try {
+ Thread.sleep(m_syncL.longValue()); // wait 1 millisecond
+ } catch (Exception e) {
+ }
+ }
+
+ java.util.Date d1 = new java.util.Date();
+ long t1 = d1.getTime();
+ String name = null;
+
+ name = Long.toString(t1);
+ return name;
+ }
+
+ // ----------------------------------------------------------
+ static String getUniqueLogFileName(String uniqueID) {
+ String name = null;
+
+ name = "%h/t4jdbc" + uniqueID + ".log";
+ return name;
+ }
+
+ // ----------------------------------------------------------
+ static String getUniqueLoggerName(String uniqueID) {
+ String name = null;
+
+ name = "org.trafodion.jdbc.t4.logger" + uniqueID;
+ return name;
+ }
+
+ // ----------------------------------------------------------
+ static Object[] makeParams() {
+ return null;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props) {
+ Object obj[] = new Object[1];
+
+ obj[0] = t4props;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, boolean b1) {
+ Object obj[] = new Object[2];
+
+ obj[0] = t4props;
+ obj[1] = Boolean.toString(b1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, int i1) {
+ Object obj[] = new Object[2];
+
+ obj[0] = t4props;
+ obj[1] = Integer.toString(i1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1) {
+ Object obj[] = new Object[2];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, long l1) {
+ Object obj[] = new Object[2];
+
+ obj[0] = t4props;
+ obj[1] = Long.toString(l1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, int i1, int i2) {
+ Object obj[] = new Object[3];
+
+ obj[0] = t4props;
+ obj[1] = Integer.toString(i1);
+ obj[2] = Integer.toString(i2);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, int i1) {
+ Object obj[] = new Object[3];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = Integer.toString(i1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2) {
+ Object obj[] = new Object[3];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = obj2;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, int i1, Object obj1) {
+ Object obj[] = new Object[3];
+
+ obj[0] = t4props;
+ obj[1] = Integer.toString(i1);
+ obj[2] = obj1;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, int i1, boolean b1) {
+ Object obj[] = new Object[3];
+
+ obj[0] = t4props;
+ obj[1] = Integer.toString(i1);
+ obj[2] = Boolean.toString(b1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, int i1, double d1) {
+ Object obj[] = new Object[3];
+
+ obj[0] = t4props;
+ obj[1] = Integer.toString(i1);
+ obj[2] = Double.toString(d1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, boolean b1, boolean b2) {
+ Object obj[] = new Object[3];
+
+ obj[0] = t4props;
+ obj[1] = Boolean.toString(b1);
+ obj[2] = Boolean.toString(b2);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, boolean b1) {
+ Object obj[] = new Object[3];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = Boolean.toString(b1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, short s1) {
+ Object obj[] = new Object[3];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = Short.toString(s1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, double d1) {
+ Object obj[] = new Object[3];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = Double.toString(d1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, long l1, int i1) {
+ Object obj[] = new Object[3];
+
+ obj[0] = t4props;
+ obj[1] = Long.toString(l1);
+ obj[2] = Integer.toString(i1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, long l1, Object o1) {
+ Object obj[] = new Object[3];
+
+ obj[0] = t4props;
+ obj[1] = Long.toString(l1);
+ obj[2] = o1;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, long l1) {
+ Object obj[] = new Object[3];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = Long.toString(l1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, int i1, int i2) {
+ Object obj[] = new Object[4];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = Integer.toString(i1);
+ obj[3] = Integer.toString(i2);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, int i1, Object obj1, int i2) {
+ Object obj[] = new Object[4];
+
+ obj[0] = t4props;
+ obj[1] = Integer.toString(i1);
+ obj[2] = obj1;
+ obj[3] = Integer.toString(i2);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, int i1, Object obj1, Object obj2) {
+ Object obj[] = new Object[4];
+
+ obj[0] = t4props;
+ obj[1] = Integer.toString(i1);
+ obj[2] = obj1;
+ obj[3] = obj2;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, int i1, int i2, Object obj1) {
+ Object obj[] = new Object[4];
+
+ obj[0] = t4props;
+ obj[1] = Integer.toString(i1);
+ obj[2] = Integer.toString(i2);
+ obj[3] = obj1;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, int i1, int i2, int i3) {
+ Object obj[] = new Object[4];
+
+ obj[0] = t4props;
+ obj[1] = Integer.toString(i1);
+ obj[2] = Integer.toString(i2);
+ obj[3] = Integer.toString(i3);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, Object o2, Object o3) {
+ Object obj[] = new Object[4];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = o2;
+ obj[3] = o3;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, int i1, Object o2) {
+ Object obj[] = new Object[4];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = Integer.toString(i1);
+ obj[3] = o2;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, Object o2, int i1) {
+ Object obj[] = new Object[4];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = o2;
+ obj[3] = Integer.toString(i1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object[] oa1, int i1, Object o1) {
+ Object obj[] = new Object[4];
+
+ obj[0] = t4props;
+ obj[1] = oa1;
+ obj[2] = Integer.toString(i1);
+ obj[3] = o1;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, Object o2, long l1) {
+ Object obj[] = new Object[4];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = o2;
+ obj[3] = Long.toString(l1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, long l1, Object o2) {
+ Object obj[] = new Object[4];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = Long.toString(l1);
+ obj[3] = o2;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, boolean b1, Object o2) {
+ Object obj[] = new Object[4];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = Boolean.toString(b1);
+ obj[3] = o2;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, int i1, Object obj1, int i2, int i3) {
+ Object obj[] = new Object[5];
+
+ obj[0] = t4props;
+ obj[1] = Integer.toString(i1);
+ obj[2] = obj1;
+ obj[3] = Integer.toString(i2);
+ obj[4] = Integer.toString(i3);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, int i1, int i2) {
+ Object obj[] = new Object[5];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = obj2;
+ obj[3] = Integer.toString(i1);
+ obj[4] = Integer.toString(i2);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, int i1, int i2, int i3) {
+ Object obj[] = new Object[5];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = Integer.toString(i1);
+ obj[3] = Integer.toString(i2);
+ obj[4] = Integer.toString(i3);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, int i1, long l1, Object obj2) {
+ Object obj[] = new Object[5];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = Integer.toString(i1);
+ obj[3] = Long.toString(l1);
+ obj[4] = obj1;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, Object obj3, int i1) {
+ Object obj[] = new Object[5];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = obj2;
+ obj[3] = obj3;
+ obj[4] = Integer.toString(i1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, int i1, Object[] oa1, int i2, Object o1) {
+ Object obj[] = new Object[5];
+
+ obj[0] = t4props;
+ obj[1] = Integer.toString(i1);
+ obj[2] = oa1;
+ obj[3] = Integer.toString(i2);
+ obj[4] = o1;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, Object o2, Object o3, Object o4) {
+ Object obj[] = new Object[5];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = o2;
+ obj[3] = o3;
+ obj[4] = o4;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, int i1, boolean b1, int i2) {
+ Object obj[] = new Object[5];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = Integer.toString(i1);
+ obj[3] = Boolean.toString(b1);
+ obj[4] = Integer.toString(i2);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, Object o2, int i1, Object o3) {
+ Object obj[] = new Object[5];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = o2;
+ obj[3] = Integer.toString(i1);
+ obj[4] = o3;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, long l1, Object o1, int i1, int i2) {
+ Object obj[] = new Object[5];
+
+ obj[0] = t4props;
+ obj[1] = Long.toString(l1);
+ obj[2] = o1;
+ obj[3] = Integer.toString(i1);
+ obj[4] = Integer.toString(i2);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, Object o2, long l1, Object o3) {
+ Object obj[] = new Object[5];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = o2;
+ obj[3] = Long.toString(l1);
+ obj[4] = o3;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, int i1, int i2, int i3) {
+ Object obj[] = new Object[6];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = obj2;
+ obj[3] = Integer.toString(i1);
+ obj[4] = Integer.toString(i2);
+ obj[5] = Integer.toString(i3);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, Object obj3, int i1, int i2) {
+ Object obj[] = new Object[6];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = obj2;
+ obj[3] = obj3;
+ obj[4] = Integer.toString(i1);
+ obj[5] = Integer.toString(i2);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, boolean b1, Object obj3, Object obj4) {
+ Object obj[] = new Object[6];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = obj2;
+ obj[3] = Boolean.toString(b1);
+ obj[4] = obj3;
+ obj[5] = obj4;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, int i1, boolean b1, int i2) {
+ Object obj[] = new Object[6];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = obj2;
+ obj[3] = Integer.toString(i1);
+ obj[4] = Boolean.toString(b1);
+ obj[5] = Integer.toString(i2);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, int i1, int i2, Object[] oa1, int i3, Object o1) {
+ Object obj[] = new Object[6];
+
+ obj[0] = t4props;
+ obj[1] = Integer.toString(i1);
+ obj[2] = Integer.toString(i2);
+ obj[3] = oa1;
+ obj[4] = Integer.toString(i3);
+ obj[5] = o1;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, int i1, long l1, Object obj3) {
+ Object obj[] = new Object[6];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = obj2;
+ obj[3] = Integer.toString(i1);
+ obj[4] = Long.toString(l1);
+ obj[5] = obj3;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, Object o2, Object o3, int i1, boolean b1) {
+ Object obj[] = new Object[6];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = o2;
+ obj[3] = o3;
+ ;
+ obj[4] = Integer.toString(i1);
+ obj[5] = Boolean.toString(b1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, Object o2, Object o3, boolean b1, boolean b2) {
+ Object obj[] = new Object[6];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = o2;
+ obj[3] = o3;
+ ;
+ obj[4] = Boolean.toString(b1);
+ obj[5] = Boolean.toString(b2);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, int i1, int i2, Object o1, int i3, boolean b1) {
+ Object obj[] = new Object[6];
+
+ obj[0] = t4props;
+ obj[1] = Integer.toString(i1);
+ obj[2] = Integer.toString(i2);
+ obj[3] = o1;
+ obj[4] = Integer.toString(i3);
+ obj[5] = Boolean.toString(b1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, Object o2, long l1, Object o3, int i1) {
+ Object obj[] = new Object[6];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = o2;
+ obj[3] = Long.toString(l1);
+ obj[4] = o3;
+ obj[5] = Integer.toString(i1);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, int i1, long l1, Object obj2, int i2, int i3) {
+ Object obj[] = new Object[7];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = Integer.toString(i1);
+ obj[3] = Long.toString(l1);
+ obj[4] = obj2;
+ obj[5] = Integer.toString(i2);
+ obj[6] = Integer.toString(i3);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, Object o2, Object o3, Object o4, Object o5, Object o6) {
+ Object obj[] = new Object[7];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = o2;
+ obj[3] = o3;
+ obj[4] = o4;
+ obj[5] = o5;
+ obj[6] = o6;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, int i1, long l1, Object obj3,
+ boolean b1, int i2) {
+ Object obj[] = new Object[8];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = obj2;
+ obj[3] = Integer.toString(i1);
+ obj[4] = Long.toString(l1);
+ obj[5] = obj3;
+ obj[6] = Boolean.toString(b1);
+ obj[7] = Integer.toString(i2);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, Object obj3, boolean b1, int i1, int i2,
+ Object obj4, int i3) {
+ Object obj[] = new Object[9];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = obj2;
+ obj[3] = obj3;
+ obj[4] = Boolean.toString(b1);
+ obj[5] = Integer.toString(i1);
+ obj[6] = Integer.toString(i2);
+ obj[7] = obj4;
+ obj[8] = Integer.toString(i3);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object obj1, Object obj2, int i1, int i2, int i3, int i4, int i5,
+ int i6)
+
+ {
+ Object obj[] = new Object[9];
+
+ obj[0] = t4props;
+ obj[1] = obj1;
+ obj[2] = obj2;
+ obj[3] = Integer.toString(i1);
+ obj[4] = Integer.toString(i2);
+ obj[5] = Integer.toString(i3);
+ obj[6] = Integer.toString(i4);
+ obj[7] = Integer.toString(i5);
+ obj[8] = Integer.toString(i6);
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, short s1, Object o2, Object o3, Object o4, Object o5,
+ Object o6, int i1, int i2, long l1, int i3, int i4, short s2, int i5, Object o7, Object o8, Object o9) {
+ Object obj[] = new Object[18];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = Short.toString(s1);
+ obj[3] = o2;
+ obj[4] = o3;
+ obj[5] = o4;
+ obj[6] = o5;
+ obj[7] = o6;
+ obj[8] = Integer.toString(i1);
+ obj[9] = Integer.toString(i2);
+ obj[10] = Long.toString(l1);
+ obj[11] = Integer.toString(i3);
+ obj[12] = Integer.toString(i4);
+ obj[13] = Short.toString(s2);
+ obj[14] = Integer.toString(i5);
+ obj[15] = o7;
+ obj[16] = o8;
+ obj[17] = o9;
+
+ return obj;
+ } // end makeParams
+
+ // ----------------------------------------------------------
+ static Object[] makeParams(T4Properties t4props, Object o1, Object o2, Object o3, boolean b1) {
+ Object obj[] = new Object[5];
+
+ obj[0] = t4props;
+ obj[1] = o1;
+ obj[2] = o2;
+ obj[3] = o3;
+ obj[4] = Boolean.toString(b1);
+
+ return obj;
+ } // end makeParams
+
+} // end class T4LogFormatter
[34/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4Desc.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4Desc.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4Desc.java
new file mode 100644
index 0000000..1eec5a3
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4Desc.java
@@ -0,0 +1,542 @@
+// @@@ 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.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.Locale;
+
+class HPT4Desc {
+
+ String getColumnClassName() throws SQLException {
+ switch (dataType_) {
+ case Types.SMALLINT:
+ return "java.lang.Integer";
+ case Types.INTEGER:
+ return "java.lang.Integer";
+ case Types.BIGINT:
+ return "java.lang.Long";
+ case Types.REAL:
+ return "java.lang.Float";
+ case Types.FLOAT:
+ case Types.DOUBLE:
+ return "java.lang.Double";
+ case Types.NUMERIC:
+ case Types.DECIMAL:
+ return "java.math.BigDecimal";
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ return "java.lang.String";
+ case Types.DATE:
+ return "java.sql.Date";
+ case Types.TIME:
+ return "java.sql.Time";
+ case Types.TIMESTAMP:
+ return "java.sql.Timestamp";
+ case Types.OTHER:
+ return "java.sql.String";
+ case Types.CLOB:
+ return "java.sql.Clob";
+ case Types.BLOB:
+ return "java.sql.Blob";
+ case Types.BIT:
+ case Types.TINYINT:
+ default:
+ return null;
+ }
+ } // end getColumnClassName
+
+ // ---------------------------------------------------------------
+ String getColumnTypeName(Locale locale) throws SQLException {
+ switch (dataType_) {
+ case Types.SMALLINT:
+ return "SMALLINT";
+ case Types.INTEGER:
+ return "INTEGER";
+ case Types.BIGINT:
+ return "BIGINT";
+ case Types.REAL:
+ return "REAL";
+ case Types.FLOAT:
+ return "FLOAT";
+ case Types.DOUBLE:
+ return "DOUBLE PRECISION";
+ case Types.NUMERIC:
+ return "NUMERIC";
+ case Types.DECIMAL:
+ return "DECIMAL";
+ case Types.CHAR:
+ return "CHAR";
+ case Types.VARCHAR:
+ return "VARCHAR";
+ case Types.LONGVARCHAR:
+ return "LONG VARCHAR";
+ case Types.DATE:
+ return "DATE";
+ case Types.TIME:
+ return "TIME";
+ case Types.TIMESTAMP:
+ return "TIMESTAMP";
+ case Types.BLOB:
+ return "BLOB";
+ case Types.CLOB:
+ return "CLOB";
+ case Types.OTHER:
+ if (sqlDataType_ == SQLTYPECODE_INTERVAL) {
+ return "INTERVAL";
+ } else {
+ return "UNKNOWN";
+ }
+ case Types.BIT:
+ case Types.TINYINT:
+ default:
+ return null;
+ }
+ } // end getColumnTypeName
+
+ // ---------------------------------------------------------------
+ void checkValidNumericConversion(Locale locale) throws SQLException {
+ switch (dataType_) {
+ case Types.TINYINT:
+ case Types.SMALLINT:
+ case Types.INTEGER:
+ case Types.BIGINT:
+ case Types.REAL:
+ case Types.FLOAT:
+ case Types.DOUBLE:
+ case Types.NUMERIC:
+ case Types.DECIMAL:
+ case Types.BIT:
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.CLOB:
+ case Types.BLOB:
+ break;
+ default:
+ System.out.println("Data type is " + dataType_);
+ throw HPT4Messages.createSQLException(null, locale, "restricted_data_type", null);
+ }
+ return;
+ } // end checkValidNumericConversion
+
+ // ---------------------------------------------------------------
+ // Constructors
+ HPT4Desc(int dataType, short datetimeCode, int maxLen, short precision, short scale, boolean nullInfo,
+ String colName, boolean signType, int odbcDataType, short odbcPrecision, int sqlCharset, int odbcCharset,
+ String catalogName, String schemaName, String tableName, int fsDataType, int intLeadPrec, int paramMode) {
+ catalogName_ = catalogName;
+ schemaName_ = schemaName;
+ tableName_ = tableName;
+ name_ = colName;
+ if (nullInfo) {
+ isNullable_ = ResultSetMetaData.columnNullable;
+ } else {
+ isNullable_ = ResultSetMetaData.columnNoNulls;
+
+ }
+
+ sqlDataType_ = dataType;
+ dataType_ = odbcDataType;
+ sqlDatetimeCode_ = datetimeCode;
+ sqlCharset_ = sqlCharset;
+ odbcCharset_ = odbcCharset;
+ isSigned_ = signType;
+ sqlOctetLength_ = maxLen;
+ scale_ = scale;
+ sqlPrecision_ = precision;
+
+ //
+ // Convert ODBC type to equivalent JDBC type when necessary.
+ //
+ // From SqlUcode.h
+ //
+ // #define SQL_WCHAR (-8)
+ // #define SQL_WVARCHAR (-9)
+ // #define SQL_WLONGVARCHAR (-10)
+ //
+ if (odbcDataType == -8) {
+
+ // ODBC's SQL_WCHAR becomes a Types.CHAR
+ dataType_ = Types.CHAR;
+ } else if (odbcDataType == -9) {
+
+ // ODBC's SQL_WVARCHAR becomes a Types.VARCHAR
+ dataType_ = Types.VARCHAR;
+ } else if (odbcDataType == -10) {
+
+ // ODBC's SQL_WLONGVARCHAR becomes a Types.LONGVARCHAR
+ dataType_ = Types.LONGVARCHAR;
+
+ }
+ if (sqlDataType_ == InterfaceResultSet.SQLTYPECODE_DATETIME) // 9
+ {
+ switch (dataType_) { // ODBC conversion to ODBC2.0
+ case 9: // ODBC2 Date
+
+ // check the datetime code and set appropriately
+ switch (sqlDatetimeCode_) {
+ case SQLDTCODE_YEAR:
+ case SQLDTCODE_YEAR_TO_MONTH:
+ case SQLDTCODE_MONTH:
+ case SQLDTCODE_MONTH_TO_DAY:
+ case SQLDTCODE_DAY:
+ dataType_ = Types.OTHER;
+ precision_ = odbcPrecision;
+ displaySize_ = maxLen;
+ sqlOctetLength_ = maxLen;
+ break;
+ default:
+ dataType_ = Types.DATE;
+ break;
+ }
+ break;
+ case 10: // ODBC2 TIME
+ switch (sqlDatetimeCode_) {
+ case SQLDTCODE_HOUR:
+ case SQLDTCODE_HOUR_TO_MINUTE:
+ case SQLDTCODE_MINUTE:
+ case SQLDTCODE_MINUTE_TO_SECOND:
+ case SQLDTCODE_SECOND:
+ dataType_ = Types.OTHER;
+ precision_ = odbcPrecision;
+ displaySize_ = maxLen;
+ sqlOctetLength_ = maxLen;
+ break;
+ default:
+ dataType_ = Types.TIME;
+ break;
+ }
+ break;
+ case 11: // ODBC2 TIMESTAMP
+ switch (sqlDatetimeCode_) {
+ case SQLDTCODE_YEAR_TO_HOUR:
+ case SQLDTCODE_YEAR_TO_MINUTE:
+ case SQLDTCODE_MONTH_TO_HOUR:
+ case SQLDTCODE_MONTH_TO_MINUTE:
+ case SQLDTCODE_MONTH_TO_SECOND:
+ // case SQLDTCODE_MONTH_TO_FRACTION:
+ case SQLDTCODE_DAY_TO_HOUR:
+ case SQLDTCODE_DAY_TO_MINUTE:
+ case SQLDTCODE_DAY_TO_SECOND:
+ // case SQLDTCODE_DAY_TO_FRACTION:
+ case SQLDTCODE_HOUR_TO_FRACTION: // note: Database
+ // maps to TIME(6)
+ // NCS maps to TIMESTAMP
+ case SQLDTCODE_MINUTE_TO_FRACTION:
+ case SQLDTCODE_SECOND_TO_FRACTION:
+ dataType_ = Types.OTHER;
+ precision_ = odbcPrecision;
+ displaySize_ = maxLen;
+ sqlOctetLength_ = maxLen;
+ break;
+ default:
+ dataType_ = Types.TIMESTAMP;
+ break;
+ }
+ break;
+ default:
+ dataType_ = Types.TIMESTAMP;
+ break;
+ }
+ }
+
+ switch (dataType_) {
+ case Types.NUMERIC:
+ case Types.DECIMAL:
+ precision_ = odbcPrecision;
+ displaySize_ = precision_ + 2; // 1 for dot and 1 for sign
+ // if (scale != 0) // ODBC2.0
+ // isCurrency_ = true;
+ break;
+ case Types.SMALLINT:
+ precision_ = odbcPrecision;
+ if (isSigned_) {
+ displaySize_ = 6;
+ } else {
+ dataType_ = Types.INTEGER;
+ displaySize_ = 5;
+ }
+ break;
+ case Types.INTEGER:
+ precision_ = odbcPrecision;
+ if (isSigned_) {
+ displaySize_ = 11;
+ } else {
+ dataType_ = Types.BIGINT;
+ displaySize_ = 10;
+ }
+ break;
+ case Types.TINYINT:
+ precision_ = odbcPrecision;
+ if (isSigned_) {
+ displaySize_ = 4;
+ } else {
+ displaySize_ = 3;
+ }
+ break;
+ case Types.BIGINT:
+ precision_ = odbcPrecision;
+ if (isSigned_) {
+ displaySize_ = 20;
+ } else {
+ displaySize_ = 19;
+ }
+ break;
+ case Types.REAL:
+ precision_ = odbcPrecision;
+ displaySize_ = 15;
+ break;
+ case Types.DOUBLE:
+ case Types.FLOAT:
+ precision_ = odbcPrecision;
+ displaySize_ = 24;
+ break;
+ case Types.DATE:
+ sqlOctetLength_ = maxLen + 3;
+ displaySize_ = 10;
+ precision_ = 10; // ODBC2.0
+ break;
+ case Types.TIME:
+ sqlOctetLength_ = maxLen + 3;
+ displaySize_ = (precision == 0)?8: precision + 9;
+ precision_ = 8; // ODBC2.0
+ break;
+ case Types.TIMESTAMP:
+ sqlOctetLength_ = maxLen + 3;
+ precision_ = odbcPrecision;
+ displaySize_ = precision_;
+ if (sqlDatetimeCode_ > 3) // if it is more than 3, it is one of
+ // SQL/MP Datetime columns
+ {
+ // like YEAR, YEAR TO MONTH, YEAR TO DAY ...see dfs2rec.h
+ dataType_ = Types.OTHER;
+ }
+ break;
+ case Types.CHAR:
+
+ // sqlOctetLength_ = maxLen+1;
+ sqlOctetLength_ = maxLen;
+ displaySize_ = maxLen;
+ precision_ = maxLen; // ODBC2.0
+ break;
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BLOB:
+ case Types.CLOB:
+ boolean shortLength = maxLen < Math.pow(2, 15);
+ int dataOffset = ((shortLength) ? 2 : 4);
+ if (sqlDataType_ == SQLTYPECODE_VARCHAR) {
+ sqlOctetLength_ = maxLen + 1;
+ } else {
+ sqlOctetLength_ = maxLen + dataOffset + 1;
+ }
+ displaySize_ = maxLen;
+ precision_ = maxLen; // ODBC2.0
+ break;
+ default:
+ if (sqlDataType_ == SQLTYPECODE_INTERVAL) {
+ dataType_ = Types.OTHER;
+ precision_ = odbcPrecision;
+ displaySize_ = maxLen; // Make sure maxLen returns the right
+ // display size for interval
+ // sqlOctetLength_ = maxLen+3;
+ // Swastik - commented above line 02/10/2005 for Interval Data
+ // Type support
+ // 3 was added earlier because interval datatype was handled in
+ // the same
+ // way as varchar and varchar-long were handled. Since we are
+ // separating it
+ // we don't need to add the additional 3
+ sqlOctetLength_ = maxLen;
+ }
+ break;
+ }
+ if (sqlDataType_ == SQLTYPECODE_CHAR || sqlDataType_ == SQLTYPECODE_VARCHAR
+ || sqlDataType_ == SQLTYPECODE_BLOB || sqlDataType_ == SQLTYPECODE_CLOB
+ || sqlDataType_ == SQLTYPECODE_VARCHAR_LONG || sqlDataType_ == SQLTYPECODE_VARCHAR_WITH_LENGTH) {
+ isCaseSensitive_ = true;
+ }
+ isSearchable_ = true;
+ fsDataType_ = fsDataType;
+ intLeadPrec_ = intLeadPrec;
+ paramMode_ = paramMode;
+ } // end HPT4Desc
+
+ // ---------------------------------------------------------------
+ // Constructors
+
+ HPT4Desc(
+ int noNullValue // Descriptor2 only
+ ,
+ int nullValue // Descriptor2 only
+ ,
+ int version // Descriptor2 only
+ , int dataType, short datetimeCode, int maxLen, short precision, short scale, boolean nullInfo,
+ boolean signType // same as signe
+ , int odbcDataType, int odbcPrecision, int sqlCharset, int odbcCharset, String colName // same
+ // as
+ // colHeadingNm
+ , String tableName, String catalogName, String schemaName, String headingName // Descriptor2
+ // only
+ , int intLeadPrec, int paramMode, int fsDataType // fsDataType
+ // seems to be
+ // the same as
+ // dataType (see
+ // old
+ // descriptor)
+ , int rowLength) {
+
+ //
+ // Call the old constructor to set the items that are
+ // in both the old descriptor and the new descriptor.
+ //
+ this(dataType, datetimeCode, maxLen, precision, scale, nullInfo, colName, signType, odbcDataType,
+ (short) odbcPrecision, sqlCharset, odbcCharset, catalogName, schemaName, tableName, fsDataType,
+ intLeadPrec, paramMode);
+ //
+ // Set the items specific to the new descriptor.
+ //
+ noNullValue_ = noNullValue;
+ nullValue_ = nullValue;
+ version_ = version;
+ headingName_ = headingName;
+ rowLength_ = rowLength;
+
+ maxLen_ = maxLen;
+
+ } // end HPT4Desc
+
+ // ---------------------------------------------------------------
+ /***************************************************************************
+ * Returns encoding type for character data types from Database
+ * COLS table.
+ */
+ String getCharacterSetName() throws SQLException {
+ switch (dataType_) {
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BLOB:
+ case Types.CLOB:
+ return (String) InterfaceUtilities.getCharsetName(sqlCharset_);
+ default:
+ return null;
+ }
+ }
+
+ // ---------------------------------------------------------------
+ // Constants
+ public static final int SQLTYPECODE_CHAR = 1;
+ public static final int SQLTYPECODE_VARCHAR = 12;
+ public static final int SQLTYPECODE_VARCHAR_LONG = -1;
+ public static final int SQLTYPECODE_INTERVAL = 10;
+ public static final int SQLTYPECODE_VARCHAR_WITH_LENGTH = -601;
+ public static final int SQLTYPECODE_BLOB = -602;
+ public static final int SQLTYPECODE_CLOB = -603;
+ public static final int SQLTYPECODE_SMALLINT = 5;
+ public static final int SQLTYPECODE_INTEGER = 4;
+
+ // datetime codes taken from NCS - File ....\....\...\Common\DrvrSrvr.h
+ public static final int SQLDTCODE_YEAR = 4;
+ public static final int SQLDTCODE_YEAR_TO_MONTH = 5;
+ // public static final int SQLDTCODE_YEAR_TO_DAY 1 //Database
+ // DATE
+ public static final int SQLDTCODE_YEAR_TO_HOUR = 7; // ODBC TIMESTAMP(0)
+ public static final int SQLDTCODE_YEAR_TO_MINUTE = 8;
+ // public static final int SQLDTCODE_YEAR_TO_SECOND 3 //
+ // DatabaseTIMESTAMP(0)
+ // public static final int SQLDTCODE_YEAR_TO_FRACTION 3 //
+ // Database TIMESTAMP(1 - 5)
+ public static final int SQLDTCODE_MONTH = 10;
+ public static final int SQLDTCODE_MONTH_TO_DAY = 11;
+ public static final int SQLDTCODE_MONTH_TO_HOUR = 12;
+ public static final int SQLDTCODE_MONTH_TO_MINUTE = 13;
+ public static final int SQLDTCODE_MONTH_TO_SECOND = 14;
+ public static final int SQLDTCODE_MONTH_TO_FRACTION = 14;
+ public static final int SQLDTCODE_DAY = 15;
+ public static final int SQLDTCODE_DAY_TO_HOUR = 16;
+ public static final int SQLDTCODE_DAY_TO_MINUTE = 17;
+ public static final int SQLDTCODE_DAY_TO_SECOND = 18;
+ public static final int SQLDTCODE_DAY_TO_FRACTION = 18;
+ public static final int SQLDTCODE_HOUR = 19;
+ public static final int SQLDTCODE_HOUR_TO_MINUTE = 20;
+ // define SQLDTCODE_HOUR_TO_SECOND 2 //Database TIME(0) --> NCS
+ // Maps this to TIME
+ public static final int SQLDTCODE_HOUR_TO_FRACTION = 2; // Database TIME(1 -
+ // 6) // MXCI Maps
+ // this to TIMESTAMP
+ public static final int SQLDTCODE_MINUTE = 22;
+ public static final int SQLDTCODE_MINUTE_TO_SECOND = 23;
+ public static final int SQLDTCODE_MINUTE_TO_FRACTION = 23;
+ public static final int SQLDTCODE_SECOND = 24;
+ public static final int SQLDTCODE_SECOND_TO_FRACTION = 24;
+ public static final int SQLDTCODE_FRACTION_TO_FRACTION = 29;
+
+ // fields
+ int sqlCharset_;
+ int odbcCharset_;
+ int sqlDataType_;
+ int dataType_;
+ short sqlPrecision_;
+ short sqlDatetimeCode_;
+ int sqlOctetLength_;
+ int isNullable_;
+ String name_;
+ short scale_;
+ int precision_;
+ boolean isSigned_;
+ boolean isCurrency_;
+ boolean isCaseSensitive_;
+ String catalogName_;
+ String schemaName_;
+ String tableName_;
+ int fsDataType_;
+ int intLeadPrec_;
+ int paramMode_;
+ int paramIndex_;
+ int paramPos_;
+
+ String columnClassName_;
+ int displaySize_;
+ // fields which are not pouplated now
+ String columnLabel_;
+ boolean isAutoIncrement_;
+ boolean isSearchable_;
+
+ boolean isValueSet_; // To denote if setXXX method is called for this
+ // parameter
+ // String paramValue_; // Contains the value of output parameter value
+ Object paramValue_; // Contains the value of output parameter value
+
+ int noNullValue_; // Descriptor2 only
+ int nullValue_; // Descriptor2 only
+ int version_; // Descriptor2 only
+
+ String headingName_; // Descriptor2 only
+
+ int rowLength_;
+ int maxLen_;
+
+} // end class HPT4Desc
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4Exception.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4Exception.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4Exception.java
new file mode 100644
index 0000000..10c8d18
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4Exception.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;
+
+import java.sql.SQLException;
+
+class HPT4Exception extends SQLException {
+ protected String messageId;
+
+ public HPT4Exception(String reason, String SQLState, int vendorCode, String msgId) {
+ super(reason, SQLState, vendorCode);
+ if (msgId == null) {
+ messageId = "";
+ } else {
+ messageId = msgId;
+ }
+ }
+
+} // end class HPT4Exception
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4Handle.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4Handle.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4Handle.java
new file mode 100644
index 0000000..10a62b9
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4Handle.java
@@ -0,0 +1,84 @@
+// @@@ 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.sql.SQLWarning;
+
+public abstract class HPT4Handle {
+ SQLWarning sqlWarning_;
+
+ public void clearWarnings() throws SQLException {
+ sqlWarning_ = null;
+ }
+
+ public SQLWarning getWarnings() throws SQLException {
+ return sqlWarning_;
+ }
+
+ void setSQLWarning(T4Properties t4props, String messageId, Object[] messageArguments) {
+ SQLWarning sqlWarningLeaf = HPT4Messages.createSQLWarning(t4props, messageId, messageArguments);
+ if (sqlWarning_ == null) {
+ sqlWarning_ = sqlWarningLeaf;
+ } else {
+ sqlWarning_.setNextWarning(sqlWarningLeaf);
+ }
+ }
+
+ // Method used by JNI layer to set the warning
+ void setSqlWarning(SQLWarning sqlWarning) {
+ if (sqlWarning_ == null) {
+ sqlWarning_ = sqlWarning;
+ } else {
+ sqlWarning_.setNextWarning(sqlWarning);
+ }
+ }
+
+ // Method added to check if the connection had any errors
+ // This calls the abstract method closeErroredConnection()
+ //returns true if a connection error occured
+ boolean performConnectionErrorChecks(SQLException se) {
+ if (se instanceof HPT4Exception) {
+ HPT4Exception sqlmx_e = (HPT4Exception) se;
+ if (sqlmx_e.messageId.equals(ERROR_SOCKET_WRITE_ERROR) || sqlmx_e.messageId.equals(ERROR_SOCKET_READ_ERROR)
+ || sqlmx_e.messageId.equals(ERROR_SOCKET_IS_CLOSED_ERROR)
+ || sqlmx_e.messageId.equals(ERROR_INVALID_CONNECTION) || sqlmx_e.messageId.equals(ERROR_IDS_08_S01)
+ || sqlmx_e.messageId.equals(IDS_S1_T00)
+ || sqlmx_e.messageId.equals(ERROR_SOCKET_OPEN)) {
+ closeErroredConnection(sqlmx_e);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ abstract void closeErroredConnection(HPT4Exception se);
+
+ static final String ERROR_IDS_08_S01 = new String("ids_08_s01");
+ static final String ERROR_INVALID_CONNECTION = new String("invalid_connection");
+ static final String ERROR_SOCKET_WRITE_ERROR = new String("socket_write_error");
+ static final String ERROR_SOCKET_READ_ERROR = new String("socket_read_error");
+ static final String ERROR_SOCKET_IS_CLOSED_ERROR = new String("socket_is_closed_error");
+ static final String IDS_S1_T00 = new String("ids_s1_t00");
+ static final String ERROR_SOCKET_OPEN = new String("socket_open_error");
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4Messages.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4Messages.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4Messages.java
new file mode 100644
index 0000000..cf58470
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4Messages.java
@@ -0,0 +1,324 @@
+// @@@ 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.SQLWarning;
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
+import java.util.ResourceBundle;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+class HPT4Messages {
+ static Logger getMessageLogger(T4Properties t4props) {
+ return (t4props != null) ? t4props.t4Logger_ : T4Properties.t4GlobalLogger;
+ }
+
+ static SQLWarning createSQLWarning(T4Properties t4props, String messageId, Object[] messageArguments) {
+ Logger log = getMessageLogger(t4props);
+
+ if (log != null && log.isLoggable(Level.WARNING)) {
+ Object p[] = T4LoggingUtilities.makeParams(t4props, messageId, messageArguments);
+ log.logp(Level.WARNING, "HPT4Messages", "createSQLWarning", "", p);
+ }
+
+ Locale currentLocale = t4props == null ? null : t4props.getLocale();
+ currentLocale = currentLocale == null ? Locale.getDefault() : currentLocale;
+
+ int sqlcode = 1;
+ SQLWarning ret = null;
+
+ try {
+ PropertyResourceBundle messageBundle = (PropertyResourceBundle) ResourceBundle.getBundle("T4Messages",
+ currentLocale);
+
+ 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) {
+ // use 1 as default
+ }
+ }
+
+ ret = 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(",");
+ }
+ }
+ } // end if
+
+ ret = new SQLWarning(message, "01000", 1);
+ }
+
+ return ret;
+ }
+
+ static void setSQLWarning(T4Properties t4props, HPT4Handle handle, SQLWarningOrError[] we1) {
+ Logger log = getMessageLogger(t4props);
+
+ int curErrorNo;
+ SQLWarning sqlWarningLeaf;
+
+ if (we1.length == 0) {
+ handle.setSqlWarning(null);
+ return;
+ }
+
+ for (curErrorNo = 0; curErrorNo < we1.length; curErrorNo++) {
+ if (log != null && log.isLoggable(Level.WARNING)) {
+ Object p[] = new Object[] { t4props, "Text: " + we1[curErrorNo].text,
+ "SQLState: " + we1[curErrorNo].sqlState, "SQLCode: " + we1[curErrorNo].sqlCode };
+ log.logp(Level.WARNING, "HPT4Messages", "setSQLWarning", "", p);
+ }
+
+ sqlWarningLeaf = new SQLWarning(we1[curErrorNo].text, we1[curErrorNo].sqlState, we1[curErrorNo].sqlCode);
+ handle.setSqlWarning(sqlWarningLeaf);
+ } // end for
+ return;
+ }
+
+ static void setSQLWarning(T4Properties t4props, HPT4Handle handle, ERROR_DESC_LIST_def sqlWarning) {
+ Logger log = getMessageLogger(t4props);
+
+ int curErrorNo;
+ ERROR_DESC_def error_desc_def[];
+ SQLWarning sqlWarningLeaf;
+
+ if (sqlWarning.length == 0) {
+ handle.setSqlWarning(null);
+ return;
+ }
+
+ error_desc_def = sqlWarning.buffer;
+ for (curErrorNo = 0; curErrorNo < sqlWarning.length; curErrorNo++) {
+ if (log != null && log.isLoggable(Level.WARNING)) {
+ Object p[] = new Object[] { t4props, "Text: " + error_desc_def[curErrorNo].errorText,
+ "SQLState: " + error_desc_def[curErrorNo].sqlstate,
+ "SQLCode: " + error_desc_def[curErrorNo].sqlcode };
+ log.logp(Level.WARNING, "HPT4Messages", "setSQLWarning", "", p);
+ }
+
+ sqlWarningLeaf = new SQLWarning(error_desc_def[curErrorNo].errorText, error_desc_def[curErrorNo].sqlstate,
+ error_desc_def[curErrorNo].sqlcode);
+ handle.setSqlWarning(sqlWarningLeaf);
+ }
+ return;
+ } // end setSQLWarning
+
+ // ------------------------------------------------------------------------------------------------
+ static void throwSQLException(T4Properties t4props, ERROR_DESC_LIST_def SQLError) throws HPT4Exception {
+ Logger log = getMessageLogger(t4props);
+ Locale locale = (t4props != null) ? t4props.getLocale() : Locale.getDefault();
+
+ HPT4Exception sqlException = null;
+ HPT4Exception sqlExceptionHead = null;
+ int curErrorNo;
+
+ if (SQLError.length == 0) {
+ throw createSQLException(t4props, locale, "No messages in the Error description", null);
+ }
+
+ for (curErrorNo = 0; curErrorNo < SQLError.length; curErrorNo++) {
+ if (log != null && log.isLoggable(Level.SEVERE)) {
+ Object p[] = new Object[] { t4props, "Text: " + SQLError.buffer[curErrorNo].errorText,
+ "SQLState: " + SQLError.buffer[curErrorNo].sqlstate,
+ "SQLCode: " + SQLError.buffer[curErrorNo].sqlcode };
+ log.logp(Level.SEVERE, "HPT4Messages", "throwSQLException", "", p);
+ }
+
+ if (SQLError.buffer[curErrorNo].errorCodeType == TRANSPORT.ESTIMATEDCOSTRGERRWARN) {
+ //
+ // NCS said it was an SQL error, but it really wasn't it was a
+ // NCS resource governing error
+ //
+ sqlException = HPT4Messages.createSQLException(t4props, locale, "resource_governing", null);
+ } else {
+ sqlException = new HPT4Exception(SQLError.buffer[curErrorNo].errorText,
+ SQLError.buffer[curErrorNo].sqlstate, SQLError.buffer[curErrorNo].sqlcode, null);
+ }
+ if (curErrorNo == 0) {
+ sqlExceptionHead = sqlException;
+ } else {
+ sqlExceptionHead.setNextException(sqlException);
+ }
+ }
+
+ throw sqlExceptionHead;
+ }
+
+ // ------------------------------------------------------------------------------------------------
+ static void throwSQLException(T4Properties t4props, SQLWarningOrError[] we1) throws HPT4Exception {
+ Logger log = getMessageLogger(t4props);
+ Locale locale = (t4props != null) ? t4props.getLocale() : Locale.getDefault();
+
+ HPT4Exception sqlException = null;
+ HPT4Exception sqlExceptionHead = null;
+ int curErrorNo;
+
+ if (we1.length == 0) {
+ throw createSQLException(t4props, locale, "No messages in the Error description", null);
+ }
+
+ for (curErrorNo = 0; curErrorNo < we1.length; curErrorNo++) {
+ if (log != null && log.isLoggable(Level.SEVERE)) {
+ Object p[] = new Object[] { t4props, "Text: " + we1[curErrorNo].text,
+ "SQLState: " + we1[curErrorNo].sqlState, "SQLCode: " + we1[curErrorNo].sqlCode };
+ log.logp(Level.SEVERE, "HPT4Messages", "throwSQLException", "", p);
+ }
+
+ sqlException = new HPT4Exception(we1[curErrorNo].text, we1[curErrorNo].sqlState, we1[curErrorNo].sqlCode,
+ null);
+ if (curErrorNo == 0) {
+ sqlExceptionHead = sqlException;
+ } else {
+ sqlExceptionHead.setNextException(sqlException);
+ }
+ } // end for
+
+ throw sqlExceptionHead;
+ } // end throwSQLException
+
+ // ------------------------------------------------------------------------------------------------
+ static HPT4Exception createSQLException(T4Properties t4props, Locale msgLocale, String messageId, Object mA1,
+ Object mA2) {
+
+ Object[] mAs = new Object[2];
+
+ mAs[0] = mA1;
+ mAs[1] = mA2;
+
+ return createSQLException(t4props, msgLocale, messageId, mAs);
+
+ } // end createSQLException
+
+ // ------------------------------------------------------------------------------------------------
+ static HPT4Exception createSQLException(T4Properties t4props, Locale msgLocale, String messageId,
+ Object messageArgument) {
+ Object[] mAs = new Object[1];
+
+ mAs[0] = messageArgument;
+
+ return createSQLException(t4props, msgLocale, messageId, mAs);
+
+ } // end createSQLException
+
+ // ------------------------------------------------------------------------------------------------
+ static HPT4Exception createSQLException(T4Properties t4props, Locale msgLocale, String messageId,
+ Object[] messageArguments) {
+ Logger log = getMessageLogger(t4props);
+
+ if (log != null && log.isLoggable(Level.SEVERE)) {
+ Object p[] = T4LoggingUtilities.makeParams(t4props, messageId, messageArguments);
+ log.logp(Level.SEVERE, "HPT4Messages", "createSQLException", "", p);
+ }
+
+ Locale currentLocale = t4props == null ? null : t4props.getLocale();
+ currentLocale = currentLocale == null ? Locale.getDefault(): currentLocale;
+
+ int sqlcode;
+ try {
+ PropertyResourceBundle messageBundle = (PropertyResourceBundle) ResourceBundle.getBundle("T4Messages",
+ currentLocale);
+
+ 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 HPT4Exception(message, sqlState, sqlcode, messageId);
+ } 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++] + "");
+ if (i >= messageArguments.length) {
+ break;
+ } else {
+ message = message.concat(",");
+ }
+ }
+ } // end if
+
+ return new HPT4Exception(message, "HY000", -1, messageId);
+ } // end catch
+ } // end createSQLException
+
+ // ------------------------------------------------------------------------------------------------
+ static void throwUnsupportedFeatureException(T4Properties t4props, Locale locale, String s) throws HPT4Exception {
+ Object[] messageArguments = new Object[1];
+
+ messageArguments[0] = s;
+ throw HPT4Messages.createSQLException(t4props, locale, "unsupported_feature", messageArguments);
+ } // end throwUnsupportedFeatureException
+
+ // ------------------------------------------------------------------------------------------------
+ static void throwDeprecatedMethodException(T4Properties t4props, Locale locale, String s) throws HPT4Exception {
+ Object[] messageArguments = new Object[1];
+
+ messageArguments[0] = s;
+ throw HPT4Messages.createSQLException(t4props, locale, "deprecated_method", messageArguments);
+ } // end throwDeprecatedMethodException
+
+} // end class HPT4Messages
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4ParameterMetaData.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4ParameterMetaData.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4ParameterMetaData.java
new file mode 100644
index 0000000..b8b3422
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4ParameterMetaData.java
@@ -0,0 +1,243 @@
+// @@@ 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.logging.Level;
+
+public class HPT4ParameterMetaData implements java.sql.ParameterMetaData {
+
+ public String getParameterClassName(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+ return inputDesc[param - 1].getColumnClassName();
+ }
+
+ public int getParameterCount() throws SQLException {
+ return inputDesc.length;
+ }
+
+ public int getParameterMode(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+ return inputDesc[param - 1].paramMode_;
+ }
+
+ public int getParameterType(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+ return inputDesc[param - 1].dataType_;
+ }
+
+ public String getParameterTypeName(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].getColumnTypeName(props.getLocale());
+ }
+
+ public int getPrecision(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].precision_;
+ }
+
+ public int getScale(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].scale_;
+ }
+
+ public int isNullable(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].isNullable_;
+ }
+
+ public boolean isSigned(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+ return inputDesc[param - 1].isSigned_;
+ }
+
+ // ////////////////////////
+ // begin custom accessors//
+ // ////////////////////////
+ public int getRowLength() throws SQLException {
+ // this is the same for all params
+ // only if we have no input params will we throw an error
+ if (inputDesc.length == 0) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[0].rowLength_;
+ }
+
+ public int getDisplaySize(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].displaySize_;
+ }
+
+ public int getFSDataType(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].fsDataType_;
+ }
+
+ public int getMaxLength(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].maxLen_;
+ }
+
+ public int getNoNullOffset(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].noNullValue_;
+ }
+
+ public int getNullOffset(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].nullValue_;
+ }
+
+ public int getOdbcCharset(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].odbcCharset_;
+ }
+
+ public int getSqlCharset(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].sqlCharset_;
+ }
+
+ public int getSqlDataType(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].sqlDataType_;
+ }
+
+ public int getSqlDatetimeCode(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].sqlDatetimeCode_;
+ }
+
+ public int getSqlOctetLength(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].sqlOctetLength_;
+ }
+
+ public int getSqlPrecision(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].sqlPrecision_;
+ }
+
+ // /////////////////////////////////
+ // these are legacy names...do not remove these yet even though they are
+ // duplicate
+ // i will depricate these before 2.3 release
+ // ///////////////////////////////
+
+ /**
+ * @deprecated
+ */
+ public int getSqlTypeCode(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].dataType_;
+ }
+
+ /**
+ * @deprecated
+ */
+ public int getSqlLength(int param) throws SQLException {
+ if (param > inputDesc.length) {
+ throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
+ }
+
+ return inputDesc[param - 1].maxLen_;
+ }
+
+ HPT4ParameterMetaData(TrafT4PreparedStatement stmt, HPT4Desc[] inputDesc) {
+ this.props = stmt.connection_.props_;
+ this.inputDesc = inputDesc;
+
+ if (props.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(stmt.connection_.props_, stmt, inputDesc);
+ stmt.connection_.props_.t4Logger_.logp(Level.FINE, "HPT4ParameterMetaData", "", "", p);
+ }
+ }
+
+ T4Properties props;
+ HPT4Desc[] inputDesc;
+ 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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4PooledConnection.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4PooledConnection.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4PooledConnection.java
new file mode 100644
index 0000000..719d59a
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4PooledConnection.java
@@ -0,0 +1,238 @@
+// @@@ 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.Connection;
+import java.sql.SQLException;
+import java.util.LinkedList;
+import java.util.Locale;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+import javax.sql.ConnectionEvent;
+import javax.sql.ConnectionEventListener;
+import javax.sql.StatementEventListener;
+
+public class HPT4PooledConnection implements javax.sql.PooledConnection {
+
+ public void addConnectionEventListener(ConnectionEventListener listener) {
+ try {
+ if (connection_ != null && connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, listener);
+ connection_.props_.t4Logger_.logp(Level.FINE, "HPT4PooledConnecton", "addConnectionEventListener", "",
+ p);
+ }
+ if (connection_ != null && connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, listener);
+ lr.setParameters(p);
+ lr.setSourceClassName("HPT4PooledConnection");
+ lr.setSourceMethodName("addConnectionEventListener");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+ if (isClosed_ || connection_ == null) {
+ return;
+ }
+ listenerList_.add(listener);
+ }
+
+ public void close() throws SQLException {
+ if (connection_ != null && connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "HPT4PooledConnecton", "close", "", p);
+ }
+ if (connection_ != null && connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("HPT4PooledConnection");
+ lr.setSourceMethodName("close");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ //3196 - NDCS transaction for SPJ
+ if (connection_.ic_.suspendRequest_) {
+ connection_.suspendUDRTransaction();
+ }
+
+ if (isClosed_) {
+ return;
+ }
+ connection_.close(true, true);
+ }
+
+ public Connection getConnection() throws SQLException {
+ if (connection_ != null && connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "HPT4PooledConnecton", "getConnection", "", p);
+ }
+ if (connection_ != null && connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("HPT4PooledConnection");
+ lr.setSourceMethodName("getConnection");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (isClosed_ || connection_ == null) {
+ throw HPT4Messages.createSQLException(connection_.props_, locale_, "invalid_connection", null);
+ }
+ if (LogicalConnectionInUse_) {
+ connection_.close(false, false);
+ }
+ LogicalConnectionInUse_ = true;
+ connection_.reuse();
+ return connection_;
+ }
+
+ public void removeConnectionEventListener(ConnectionEventListener listener) {
+ try {
+ if (connection_ != null && connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, listener);
+ connection_.props_.t4Logger_.logp(Level.FINE, "HPT4PooledConnecton", "removeConnectionEventListener",
+ "", p);
+ }
+ if (connection_ != null && connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, listener);
+ lr.setParameters(p);
+ lr.setSourceClassName("HPT4PooledConnection");
+ lr.setSourceMethodName("removeConnectionEventListener");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+ if (isClosed_ || connection_ == null) {
+ return;
+ }
+ listenerList_.remove(listener);
+ }
+
+ // Called by TrafT4Connection when the connection is closed by the application
+ void logicalClose(boolean sendEvents) {
+ int i;
+ int totalListener;
+ ConnectionEventListener listener;
+
+ LogicalConnectionInUse_ = false;
+
+ try {
+ //3196 - NDCS transaction for SPJ
+ if (connection_.ic_.suspendRequest_) {
+ connection_.suspendUDRTransaction();
+ }
+ }
+ catch (SQLException ex) {}
+
+ if (sendEvents) {
+ totalListener = listenerList_.size();
+ ConnectionEvent event = new ConnectionEvent(this);
+ for (i = 0; i < totalListener; i++) {
+ listener = (ConnectionEventListener) listenerList_.get(i);
+ listener.connectionClosed(event);
+ }
+ }
+ }
+
+ void sendConnectionErrorEvent(SQLException ex) throws SQLException {
+ 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();
+ }
+
+ // Constructor
+ HPT4PooledConnection(HPT4ConnectionPoolDataSource pds, T4Properties t4props) throws SQLException {
+ super();
+
+ T4Properties t4LocalProps;
+
+ pds_ = pds;
+ if (t4props != null) {
+ t4LocalProps = t4props;
+ locale_ = t4props.getLocale();
+ } else {
+ t4LocalProps = new T4Properties();
+ locale_ = Locale.getDefault();
+ }
+ listenerList_ = new LinkedList();
+ connection_ = new TrafT4Connection(this, t4LocalProps);
+ try {
+ if (connection_ != null && connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, pds, t4props);
+ connection_.props_.t4Logger_.logp(Level.FINE, "HPT4PooledConnecton", "", "", p);
+ }
+ if (connection_ != null && connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, pds, t4props);
+ lr.setParameters(p);
+ lr.setSourceClassName("HPT4PooledConnection");
+ lr.setSourceMethodName("");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+ }
+
+ TrafT4Connection getTrafT4ConnectionReference() {
+ return connection_;
+ }
+
+ private LinkedList listenerList_;
+ private boolean isClosed_ = false;
+ private HPT4ConnectionPoolDataSource pds_;
+ private TrafT4Connection connection_;
+ private Locale locale_;
+ private boolean LogicalConnectionInUse_ = false;
+ public void addStatementEventListener(StatementEventListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void removeStatementEventListener(StatementEventListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4PooledConnectionManager.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4PooledConnectionManager.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4PooledConnectionManager.java
new file mode 100644
index 0000000..0657b92
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4PooledConnectionManager.java
@@ -0,0 +1,385 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+import javax.sql.ConnectionEvent;
+import javax.sql.ConnectionPoolDataSource;
+import javax.sql.PooledConnection;
+
+public class HPT4PooledConnectionManager implements javax.sql.ConnectionEventListener {
+
+ public void connectionClosed(ConnectionEvent event) {
+ if (T4Properties.t4GlobalLogger.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null, event);
+ T4Properties.t4GlobalLogger.logp(Level.FINE, "HPT4PooledConnectionManager", "connectionClosed", "", p);
+ }
+ if (out_ != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(null, event);
+ lr.setParameters(p);
+ lr.setSourceClassName("HPT4PooledConnectionManager");
+ lr.setSourceMethodName("connectionClosed");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ out_.println(temp);
+ }
+ if (out_ != null) {
+ if (traceLevel_ != Level.OFF) {
+ out_.println(traceId_ + "connectionClosed(" + event + ")");
+ }
+ }
+ PooledConnection pc;
+
+ pc = (PooledConnection) event.getSource();
+
+ boolean addToFreePool = true;
+ if (minPoolSize_ > 0 && free_.size() >= minPoolSize_) {
+ addToFreePool = false;
+ }
+ // If an initial pool is being created, then ensure that the connection
+ // is
+ // added to the free pool irrespective of minPoolSize being reached
+ if (initialPoolCreationFlag_) {
+ addToFreePool = true;
+ }
+ boolean wasPresent = removeInUseConnection(pc, addToFreePool);
+
+ if (wasPresent && (!addToFreePool)) {
+ try {
+ pc.close();
+ } catch (SQLException e) {
+ // ignore any close error
+ }
+ }
+ }
+
+ public void connectionErrorOccurred(ConnectionEvent event) {
+ if (out_ != null) {
+ if (traceLevel_ != Level.OFF) {
+ out_.println(traceId_ + "connectionErrorOccurred(" + event + ")");
+ }
+ }
+
+ PooledConnection pc;
+
+ pc = (PooledConnection) event.getSource();
+ try {
+ pc.close();
+ } catch (SQLException e) {
+ // ignore any close error
+ }
+ removeInUseConnection(pc, false);
+ }
+
+ public Connection getConnection() throws SQLException {
+ if (out_ != null) {
+ if (traceLevel_ != Level.OFF) {
+ out_.println(traceId_ + "getConnection()");
+ }
+ }
+
+ PooledConnection pc;
+ boolean validConnection = false;
+
+ do {
+ if (free_.size() == 0) {
+ if (maxPoolSize_ == 0 || count_ < maxPoolSize_) {
+ pc = pds_.getPooledConnection();
+ count_++;
+ pc.addConnectionEventListener(this);
+ inUse_.add(pc);
+
+ TrafT4Connection c = (TrafT4Connection) pc.getConnection();
+ try {
+ c.ic_.enforceT4ConnectionTimeout(c);
+ validConnection = true;
+ } catch (SQLException sqlEx) {
+ try {
+ pc.close();
+ } catch (Exception e) {
+ } // cleanup, ignore any errors
+ }
+ } else {
+ throw HPT4Messages.createSQLException(null, null, "max_pool_size_reached", null);
+ }
+ } else {
+ pc = (PooledConnection) free_.get(0);
+ if (removeFreeConnection(pc, true)) {
+ TrafT4Connection c = (TrafT4Connection) pc.getConnection();
+ try {
+ c.ic_.enforceT4ConnectionTimeout(c);
+ validConnection = true;
+ } catch (SQLException sqlEx) {
+ try {
+ pc.close();
+ } catch (Exception e) {
+ } // cleanup, ignore any errors
+ }
+ }
+ }
+ } while (!validConnection);
+
+ return pc.getConnection();
+ }
+
+ private synchronized boolean removeFreeConnection(PooledConnection pc, boolean addToUsePool) {
+ boolean wasPresent = free_.remove(pc);
+ hashTab_.remove(pc);
+ if (wasPresent) {
+ if (addToUsePool) {
+ inUse_.add(pc);
+ } else {
+ count_--;
+ }
+ }
+ return wasPresent;
+ }
+
+ private synchronized boolean removeInUseConnection(PooledConnection pc, boolean addToFreePool) {
+ boolean wasPresent = inUse_.remove(pc);
+ hashTab_.remove(pc);
+ if (wasPresent) {
+ if (addToFreePool) {
+ hashTab_.put(pc, new Long(System.currentTimeMillis() + (1000 * maxIdleTime_)));
+ free_.add(pc);
+ } else {
+ count_--;
+ }
+ }
+ return wasPresent;
+ }
+
+ private void createInitialPool(int initialPoolSize) throws SQLException {
+ if (initialPoolSize <= 0) {
+ return;
+ }
+
+ int limit = initialPoolSize > maxPoolSize_ ? maxPoolSize_ : initialPoolSize;
+ Connection initPool_[] = new Connection[limit];
+ int created = 0;
+ try {
+ // Set initialPoolInCreation to indicate that an initial pool is in
+ // the
+ // process of being created.
+ initialPoolCreationFlag_ = true;
+
+ for (int i = 0; i < limit; i++) {
+ initPool_[i] = getConnection();
+ created++;
+ }
+ } catch (SQLException se) {
+ SQLException head = HPT4Messages.createSQLException(null, null, "initial_pool_creation_error", "" + limit);
+ head.setNextException(se);
+ throw head;
+ } finally {
+ for (int i = 0; i < created; i++) {
+ try {
+ if (initPool_[i] != null)
+ initPool_[i].close();
+ } catch (SQLException se) {
+ // ignore
+ }
+ }
+ // Ensuring that the initialPoolInCreation has been set to false to
+ // indicate
+ // that the initial pool creation process has occured.
+ initialPoolCreationFlag_ = false;
+ }
+ }
+
+ void setLogWriter(PrintWriter out) {
+ out_ = out;
+ }
+
+ HPT4PooledConnectionManager(HPT4ConnectionPoolDataSource pds, Level traceLevel) throws SQLException {
+ String className = getClass().getName();
+ pds_ = pds;
+ inUse_ = Collections.synchronizedList(new LinkedList());
+ free_ = Collections.synchronizedList(new LinkedList());
+ maxPoolSize_ = pds.getMaxPoolSize();
+ minPoolSize_ = pds.getMinPoolSize();
+ maxIdleTime_ = pds.getMaxIdleTime();
+ connectionTimeout_ = pds.getConnectionTimeout();
+ traceLevel_ = traceLevel;
+ timer_ = null;
+ if (maxIdleTime_ > 0 && maxPoolSize_ > 0) {
+ IdleConnectionCleanupTask timerTask_ = new IdleConnectionCleanupTask();
+ timer_ = new Timer(true);
+ timer_.schedule(timerTask_, (maxIdleTime_ * 1000), (maxIdleTime_ * 500));
+ }
+ if (connectionTimeout_ > 0 && maxPoolSize_ > 0) {
+ ConnectionTimeoutCleanupTask timerTask_ = new ConnectionTimeoutCleanupTask();
+ if (timer_ == null) {
+ timer_ = new Timer(true);
+ }
+ timer_.schedule(timerTask_, (connectionTimeout_ * 1000), (connectionTimeout_ * 500));
+ }
+ createInitialPool(pds.getInitialPoolSize());
+ traceId_ = "jdbcTrace:[" + Thread.currentThread() + "]:[" + hashCode() + "]:" + className + ".";
+ }
+
+ ConnectionPoolDataSource pds_;
+ // LinkedList inUse_;
+ // LinkedList free_;
+ List inUse_;
+ List free_;
+ int count_;
+
+ int maxPoolSize_;
+ int minPoolSize_;
+ long maxIdleTime_;
+ int connectionTimeout_;
+ Level traceLevel_;
+ PrintWriter out_;
+ String traceId_;
+ Timer timer_;
+ Hashtable hashTab_ = new java.util.Hashtable(); // synchronized
+ // We keep a flag to indicate to this class that an initial pool is in the
+ // process
+ // of being created
+ boolean initialPoolCreationFlag_ = false;
+
+ /*
+ * Private class used to clean up the connections that have surpassed
+ * maxIdleTime
+ */
+ /* Start TimerTask definition */
+ private class IdleConnectionCleanupTask extends TimerTask {
+ Vector toRemove = null;
+
+ IdleConnectionCleanupTask() {
+ toRemove = new Vector();
+ }
+
+ public void run() {
+ cleanUp();
+ }
+
+ private void cleanUp() {
+ toRemove.clear();
+ synchronized (free_) {
+ try {
+ Iterator it_ = free_.iterator();
+ while (it_.hasNext()) {
+ PooledConnection tempPC = (PooledConnection) it_.next();
+ Long timeOutVal = (Long) hashTab_.get(tempPC);
+ if (System.currentTimeMillis() > timeOutVal.longValue()) {
+ toRemove.add(tempPC);
+ }
+ }
+ } catch (Throwable t) {
+ if (T4Properties.t4GlobalLogger.isLoggable(Level.WARNING) == true) {
+ T4Properties.t4GlobalLogger.logp(Level.WARNING, "IdleConnectionCleanupTask", "cleanUp", t
+ .getMessage());
+ }
+ }
+ } // synchronized block
+ for (int i = 0; i < toRemove.size(); i++) {
+ PooledConnection pc = (PooledConnection) toRemove.get(i);
+ boolean wasPresent = removeFreeConnection(pc, false);
+ if (wasPresent) {
+ // close it to cleanup
+ try {
+ /*
+ * System.out.println("Closing connection : " + (
+ * (HPT4Connection) ( (HPT4PooledConnection)
+ * pc).getConnection()).getDialogueId());
+ */
+ pc.close();
+ } catch (SQLException se) {
+ // Ignore
+ }
+ }
+ }
+ }
+ }
+
+ /* End TimerTask definition */
+ /*
+ * Private class used to clean up the connections that have surpassed
+ * connectionTimeout
+ */
+ /* Start TimerTask definition */
+ private class ConnectionTimeoutCleanupTask extends TimerTask {
+ Vector toRemove = null;
+
+ ConnectionTimeoutCleanupTask() {
+ toRemove = new Vector();
+ }
+
+ public void run() {
+ cleanUp();
+ }
+
+ private void cleanUp() {
+ toRemove.clear();
+ synchronized (inUse_) {
+ Iterator it_ = inUse_.iterator();
+ while (it_.hasNext()) {
+ try {
+ PooledConnection tempPC = (PooledConnection) it_.next();
+ InterfaceConnection ic = ((HPT4PooledConnection) tempPC).getTrafT4ConnectionReference().ic_;
+ if (ic != null) {
+ T4Connection tconn = ic.getT4Connection();
+ if (tconn != null) {
+ if (tconn.connectionIdleTimeoutOccured()) {
+ // System.out.println("********* Found a
+ // timed out connection **********");
+ toRemove.add(tempPC);
+ }
+ }
+ }
+ } catch (Throwable t) {
+ if (T4Properties.t4GlobalLogger.isLoggable(Level.WARNING) == true) {
+ T4Properties.t4GlobalLogger.logp(Level.WARNING, "ConnectionTimeoutCleanupTask", "cleanUp",
+ t.getMessage());
+ }
+ }
+ }
+ } // synchronized block
+ for (int i = 0; i < toRemove.size(); i++) {
+ PooledConnection pc = (PooledConnection) toRemove.get(i);
+ removeInUseConnection(pc, false);
+ // do not close the connections because:
+ // 1.> Corresponding NCS server is already gone
+ // 2.> We need to give a timeout error when user uses this
+ // connection
+ }
+ }
+ }
+ /* End TimerTask definition */
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4ResultSetMetaData.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4ResultSetMetaData.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4ResultSetMetaData.java
new file mode 100644
index 0000000..d1f1f7e
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/HPT4ResultSetMetaData.java
@@ -0,0 +1,309 @@
+// @@@ 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.logging.Level;
+
+public class HPT4ResultSetMetaData implements java.sql.ResultSetMetaData {
+
+ // begin required methods
+ public String getCatalogName(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].catalogName_;
+ }
+
+ public String getColumnClassName(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].getColumnClassName();
+ }
+
+ public int getColumnCount() throws SQLException {
+ return outputDesc_.length;
+ }
+
+ public int getColumnDisplaySize(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].displaySize_;
+ }
+
+ public String getColumnLabel(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+
+ return (outputDesc_[column - 1].columnLabel_ == null) ? outputDesc_[column - 1].name_
+ : outputDesc_[column - 1].columnLabel_;
+ }
+
+ public String getColumnName(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].name_;
+ }
+
+ public int getColumnType(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].dataType_;
+ }
+
+ public String getColumnTypeName(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].getColumnTypeName(connection_.getLocale());
+ }
+
+ public int getPrecision(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].precision_;
+ }
+
+ public int getScale(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].scale_;
+ }
+
+ public String getSchemaName(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].schemaName_;
+ }
+
+ public String getTableName(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].tableName_;
+ }
+
+ public boolean isAutoIncrement(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].isAutoIncrement_;
+ }
+
+ public boolean isCaseSensitive(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].isCaseSensitive_;
+ }
+
+ public boolean isCurrency(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].isCurrency_;
+ }
+
+ public boolean isDefinitelyWritable(int column) throws SQLException {
+ return true;
+ }
+
+ public int isNullable(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].isNullable_;
+ }
+
+ public boolean isReadOnly(int column) throws SQLException {
+ return false;
+ }
+
+ public boolean isSearchable(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].isSearchable_;
+ }
+
+ public boolean isSigned(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].isSigned_;
+ }
+
+ public boolean isWritable(int column) throws SQLException {
+ return true;
+ }
+
+ // ////////////////////////
+ // begin custom accessors//
+ // ////////////////////////
+
+ public int getFSDataType(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].fsDataType_;
+ }
+
+ public int getMaxLength(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].maxLen_;
+ }
+
+ public int getOdbcCharset(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].odbcCharset_;
+ }
+
+ public int getRowLength() throws SQLException {
+ // this is the same for all params
+ // only if we have no input params will we throw an error
+ if (outputDesc_.length == 0) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.props_.getLocale(),
+ "invalid_desc_index", null);
+ }
+
+ return outputDesc_[0].rowLength_;
+ }
+
+ public int getSqlCharset(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].sqlCharset_;
+ }
+
+ public int getSqlPrecision(int column) throws SQLException {
+ if (column > outputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].sqlPrecision_;
+ }
+
+ public int getSqlDatetimeCode(int param) throws SQLException {
+ return stmt_.ist_.pr_.outputDesc[param - 1].datetimeCode_;
+ }
+
+ // /////////////////////////////////
+ // these are legacy names...do not remove these yet even though they are
+ // duplicate
+ // ///////////////////////////////
+
+ /**
+ * @deprecated
+ */
+ public String cpqGetCharacterSet(int column) throws SQLException {
+ if ((column > outputDesc_.length) || (column <= 0)) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
+ null);
+ }
+ return outputDesc_[column - 1].getCharacterSetName();
+ }
+
+ /**
+ * @deprecated
+ */
+ public int getSqlTypeCode(int param) throws SQLException {
+ return stmt_.ist_.pr_.outputDesc[param - 1].dataType_;
+ } // end getSqlTypeCode
+
+ /**
+ * @deprecated
+ */
+ public int getSqlLength(int param) throws SQLException {
+ return stmt_.ist_.pr_.outputDesc[param - 1].maxLen_;
+ } // end getSqlTypeCode
+
+ HPT4ResultSetMetaData(TrafT4Statement stmt, HPT4Desc[] outputDesc) {
+ if (stmt.connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(stmt.connection_.props_, stmt, outputDesc);
+ stmt.connection_.props_.t4Logger_.logp(Level.FINE, "HPT4ResultSetMetaData", "", "", p);
+ }
+
+ connection_ = stmt.connection_;
+ outputDesc_ = outputDesc;
+ stmt_ = stmt;
+ }
+
+ HPT4ResultSetMetaData(TrafT4ResultSet resultSet, HPT4Desc[] outputDesc) {
+ if (resultSet.connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(resultSet.connection_.props_, resultSet, outputDesc);
+ resultSet.connection_.props_.t4Logger_.logp(Level.FINE, "HPT4ResultSetMetaData", "", "", p);
+ }
+
+ resultSet_ = resultSet;
+ connection_ = resultSet_.connection_;
+ outputDesc_ = outputDesc;
+ stmt_ = resultSet.stmt_;
+ }
+
+ TrafT4ResultSet resultSet_;
+ TrafT4Connection connection_;
+ HPT4Desc[] outputDesc_;
+ TrafT4Statement stmt_;
+ 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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Header.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Header.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Header.java
new file mode 100644
index 0000000..41a35a3
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Header.java
@@ -0,0 +1,157 @@
+// @@@ 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 HEADER structure as taken from
+ * TransportBase.h
+ * @version 1.0
+ */
+
+class Header {
+
+ //
+ // Fixed values taken from TransportBase.h
+ //
+ static final short WRITE_REQUEST_FIRST = 1;
+ static final short WRITE_REQUEST_NEXT = (short) (WRITE_REQUEST_FIRST + 1);
+ static final short READ_RESPONSE_FIRST = (short) (WRITE_REQUEST_NEXT + 1);
+ static final short READ_RESPONSE_NEXT = (short) (READ_RESPONSE_FIRST + 1);
+ static final short CLEANUP = (short) (READ_RESPONSE_NEXT + 1);
+ static final short SRVR_TRANSPORT_ERROR = (short) (CLEANUP + 1);
+ static final short CLOSE_TCPIP_SESSION = (short) (SRVR_TRANSPORT_ERROR + 1);
+
+ static final int SIGNATURE = 12345; // 0x3039
+
+ //static final int OLD_VERSION = 100; //pre 2.5 server
+ static final int CLIENT_HEADER_VERSION_BE = 101;
+ //static final int CLIENT_HEADER_VERSION_LE = 102 //not used in JDBC
+ static final int SERVER_HEADER_VERSION_BE = 201;
+ static final int SERVER_HEADER_VERSION_LE = 202;
+
+ static final char TCPIP = 'T';
+
+ static final char NSK = 'N';
+ static final char PC = 'P';
+
+ static final char YES = 'Y';
+ static final char NO = 'N';
+
+ static final char COMP_0 = 0x0;
+ static final char COMP_12 = 0x12;
+ static final char COMP_14 = 0x14;
+
+ //
+ // The Java version of the HEADER structure taken from TransportBase.h
+ //
+ short operation_id_;
+ // + 2 filler
+ int dialogueId_;
+ int total_length_;
+ int cmp_length_;
+ char compress_ind_;
+ char compress_type_;
+ // + 2 filler
+ int hdr_type_;
+ int signature_;
+ int version_;
+ char platform_;
+ char transport_;
+ char swap_;
+ // + 1 filler
+ short error_;
+ short error_detail_;
+
+ Header() {
+ // Do nothing constructor
+ }
+
+ Header(short operation_id, int dialogueId, int total_length, int cmp_length, char compress_ind, char compress_type,
+ int hdr_type, int signature, int version, char platform, char transport, char swap) {
+ operation_id_ = operation_id;
+ dialogueId_ = dialogueId;
+ total_length_ = total_length;
+ cmp_length_ = cmp_length;
+ compress_ind_ = compress_ind;
+ compress_type_ = compress_type;
+ hdr_type_ = hdr_type;
+ signature_ = signature;
+ version_ = version;
+ platform_ = platform;
+ transport_ = transport;
+ swap_ = swap;
+ }
+
+ void reuseHeader(short operation_id, int dialogueId) {
+ operation_id_ = operation_id;
+ dialogueId_ = dialogueId;
+ }
+
+ static int sizeOf() {
+ return 40;
+ }
+
+ void insertIntoByteArray(LogicalByteArray buffer1, Locale locale) throws SQLException {
+
+ buffer1.insertShort(operation_id_);
+ buffer1.insertShort((short) 0); // + 2 filler
+ buffer1.insertInt(dialogueId_);
+ buffer1.insertInt(total_length_);
+ buffer1.insertInt(cmp_length_);
+ buffer1.insertChar(compress_ind_);
+
+ buffer1.insertChar(compress_type_);
+ buffer1.insertShort((short) 0); // + 2 filler
+ buffer1.insertInt(hdr_type_);
+ buffer1.insertInt(signature_);
+ buffer1.insertInt(version_);
+ buffer1.insertChar(platform_);
+ buffer1.insertChar(transport_);
+ buffer1.insertChar(swap_);
+ buffer1.insertByte((byte) 0); // + 2 filler
+ buffer1.insertShort(error_);
+ buffer1.insertShort(error_detail_);
+ }
+
+ void extractFromByteArray(LogicalByteArray buffer1) {
+ operation_id_ = buffer1.extractShort();
+ buffer1.extractShort(); // + 2 filler
+ dialogueId_ = buffer1.extractInt();
+ total_length_ = buffer1.extractInt();
+ cmp_length_ = buffer1.extractInt();
+ compress_ind_ = buffer1.extractChar();
+ compress_type_ = buffer1.extractChar();
+ buffer1.extractShort(); // + 2 filler
+ hdr_type_ = buffer1.extractInt();
+ signature_ = buffer1.extractInt();
+ version_ = buffer1.extractInt();
+ platform_ = buffer1.extractChar();
+ transport_ = buffer1.extractChar();
+ swap_ = buffer1.extractChar();
+ buffer1.extractByte(); // + 1 filler
+ error_ = buffer1.extractShort();
+ error_detail_ = buffer1.extractShort();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InitializeDialogueMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InitializeDialogueMessage.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InitializeDialogueMessage.java
new file mode 100644
index 0000000..39ba2b8
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InitializeDialogueMessage.java
@@ -0,0 +1,66 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class InitializeDialogueMessage {
+ static LogicalByteArray marshal(USER_DESC_def userDesc, CONNECTION_CONTEXT_def inContext, int dialogueId,
+ int optionFlags1, int optionFlags2, String sessionID, InterfaceConnection ic)
+ throws CharacterCodingException, UnsupportedCharsetException {
+ int wlength = Header.sizeOf();
+ LogicalByteArray buf;
+
+ byte[] sessionBytes = ic.encodeString(sessionID, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] clientUserBytes = ic.encodeString(System.getProperty("user.name"), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+
+ wlength += userDesc.sizeOf(ic);
+ wlength += inContext.sizeOf(ic);
+
+ wlength += TRANSPORT.size_int; // dialogueId
+ wlength += TRANSPORT.size_int; // optionFlags1
+ wlength += TRANSPORT.size_int; // optionFlags2
+ wlength += sessionBytes.length;
+ wlength += clientUserBytes.length;
+
+ buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
+
+ userDesc.insertIntoByteArray(buf);
+ inContext.insertIntoByteArray(buf);
+
+ buf.insertInt(dialogueId);
+ buf.insertInt(optionFlags1);
+ buf.insertInt(optionFlags2);
+
+ if((optionFlags1 & T4Connection.INCONTEXT_OPT1_SESSIONNAME) != 0)
+ {
+ buf.insertString(sessionBytes);
+ }
+ if((optionFlags1 & T4Connection.INCONTEXT_OPT1_CLIENT_USERNAME) != 0)
+ {
+ buf.insertString(clientUserBytes);
+ }
+
+ return buf;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InitializeDialogueReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InitializeDialogueReply.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InitializeDialogueReply.java
new file mode 100644
index 0000000..5deb159
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InitializeDialogueReply.java
@@ -0,0 +1,90 @@
+// @@@ 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 InitializeDialogueReply {
+ static final int odbc_SQLSvc_InitializeDialogue_ParamError_exn_ = 1;
+ static final int odbc_SQLSvc_InitializeDialogue_InvalidConnection_exn_ = 2;
+ static final int odbc_SQLSvc_InitializeDialogue_SQLError_exn_ = 3;
+ static final int odbc_SQLSvc_InitializeDialogue_SQLInvalidHandle_exn_ = 4;
+ static final int odbc_SQLSvc_InitializeDialogue_SQLNeedData_exn_ = 5;
+ static final int odbc_SQLSvc_InitializeDialogue_InvalidUser_exn_ = 6;
+
+ static final int SQL_PASSWORD_EXPIRING = 8857;
+ static final int SQL_PASSWORD_GRACEPERIOD = 8837;
+
+ Header m_hdr;
+
+ int exception_nr;
+ int exception_detail;
+ String ParamError;
+ ERROR_DESC_LIST_def SQLError;
+ ERROR_DESC_LIST_def InvalidUser;
+ String clientErrorText;
+
+ OUT_CONNECTION_CONTEXT_def outContext;
+
+ // -------------------------------------------------------------
+ InitializeDialogueReply(LogicalByteArray buf, String addr, InterfaceConnection ic, boolean downloadCert) throws CharacterCodingException,
+ UnsupportedCharsetException, SQLException {
+ buf.setLocation(Header.sizeOf());
+
+ exception_nr = buf.extractInt();
+ exception_detail = buf.extractInt();
+
+ switch (exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ outContext = new OUT_CONNECTION_CONTEXT_def();
+ outContext.extractFromByteArray(buf, ic);
+ break;
+ case odbc_SQLSvc_InitializeDialogue_SQLError_exn_:
+ SQLError = new ERROR_DESC_LIST_def();
+ SQLError.extractFromByteArray(buf, ic);
+
+ if (exception_detail == SQL_PASSWORD_EXPIRING || exception_detail == SQL_PASSWORD_GRACEPERIOD) {
+ outContext = new OUT_CONNECTION_CONTEXT_def();
+ outContext.extractFromByteArray(buf, ic);
+ }
+ break;
+ case odbc_SQLSvc_InitializeDialogue_InvalidUser_exn_:
+ SQLError = new ERROR_DESC_LIST_def();
+ SQLError.extractFromByteArray(buf, ic);
+
+ ic.outContext = new OUT_CONNECTION_CONTEXT_def();
+ ic.outContext.extractFromByteArray(buf, ic);
+ break;
+ //throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_28_000", null);
+ case odbc_SQLSvc_InitializeDialogue_ParamError_exn_:
+ ParamError = ic.decodeBytes(buf.extractString(), 1);
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
+ case odbc_SQLSvc_InitializeDialogue_InvalidConnection_exn_:
+ throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
+ default:
+ clientErrorText = "unknown_initialize_dialogue_reply_error";
+ break;
+ }
+ }
+}
[33/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InputOutput.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InputOutput.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InputOutput.java
new file mode 100644
index 0000000..7062778
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InputOutput.java
@@ -0,0 +1,682 @@
+
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.SocketTimeoutException;
+import java.nio.ByteBuffer;
+import java.nio.channels.Channels;
+import java.nio.channels.WritableByteChannel;
+import java.sql.SQLException;
+import java.util.Locale;
+import java.util.Vector;
+import java.util.logging.Level;
+
+import javax.net.SocketFactory;
+
+class InputOutput {
+ private Address m_addr;
+ private Socket m_socket;
+ private Locale m_locale;
+ private int readHdrLength = Header.sizeOf();
+ private int m_dialogueId;
+ private int m_timeout;
+ private int m_connectionIdleTimeout;
+ private Header m_rheader;
+ private OutputStream m_os;
+ private InputStream m_is;
+ private WritableByteChannel m_wbc;
+ private T4Connection m_t4conn; // trace_connection
+ //private int m_sendBufSize;
+
+ private char compress = Header.NO; //Header.NO means no compression is used.
+ private char compType = Header.COMP_0; //the used compression type. COMP_0 which means no compression
+
+ private static SocketFactory m_factory = SocketFactory.getDefault(); // NRV
+ // -
+ // socket
+ // factory
+
+ static {
+ try {
+ String factStr = System.getProperty("t4jdbc.socketFactoryClass");
+ if (factStr != null) {
+ Class z = Class.forName(factStr);
+ if (SocketFactory.class.isAssignableFrom(z)) {
+ m_factory = (SocketFactory) z.newInstance();
+ } else {
+ m_factory = SocketFactory.getDefault();
+ }
+ }
+ } catch (Throwable t) {
+ m_factory = SocketFactory.getDefault();
+ }
+ }
+
+ public static SocketFactory getSocketFactory() {
+ return m_factory;
+ }
+
+ public static void setSocketFactory(SocketFactory factory) {
+ m_factory = factory;
+ }
+
+ // ----------------------------------------------------------
+ InputOutput(Locale locale, Address addr1) {
+ m_locale = locale;
+ m_addr = addr1;
+ m_dialogueId = 0;
+ m_timeout = 0;
+ m_connectionIdleTimeout = 0;
+
+ if(m_addr.m_t4props.getCompression()) {
+ compress = Header.YES;
+ }
+
+ m_rheader = new Header((short) 0, m_dialogueId, 0, 0, compress, compType, Header.READ_RESPONSE_FIRST,
+ Header.SIGNATURE, Header.CLIENT_HEADER_VERSION_BE, Header.PC, Header.TCPIP, Header.NO);
+
+ } // end InputOutput
+
+ // trace_connection - AM
+ void setT4Connection(T4Connection t4conn) {
+ m_t4conn = t4conn;
+ }
+
+ void setDialogueId(int dialogueId) {
+ m_dialogueId = dialogueId;
+ }
+
+ void setTimeout(int timeout) {
+ m_timeout = timeout;
+ }
+
+ void setConnectionIdleTimeout(int timeout) {
+ m_connectionIdleTimeout = timeout;
+ }
+
+ String getRemoteHost() {
+ return this.m_addr.getIPorName();
+ }
+
+ // ----------------------------------------------------------
+ synchronized void openIO() throws SQLException {
+ // trace_connection - AM
+ if (m_t4conn != null && m_t4conn.m_ic.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(m_t4conn.m_ic.t4props_);
+ String temp = "m_socket=" + m_socket;
+ m_t4conn.m_ic.t4props_.t4Logger_.logp(Level.FINEST, "InputOutput", "openIO", temp, p);
+ }
+ if (m_socket == null) {
+ int numTry = 0;
+ boolean found = false;
+ int i = 0;
+ Vector eList = new Vector();
+
+ //
+ // Sometimes the server isn't ready to be contacted, so we will try
+ // 3 times
+ // before giving up.
+ //
+ while (found == false && numTry < 3) {
+ //
+ // Because each machine name can have multiple IP addresses
+ // associated with it,
+ // we need to go through the entire list of IP addresses until
+ // we can find
+ // one we can connect too, or all address fail.
+ //
+ i = 0;
+ while (found == false && i < m_addr.m_inetAddrs.length) {
+ try {
+ //System.out.println(m_addr.m_inetAddrs[i] + ":" + m_addr.m_portNumber.intValue());
+ m_socket = m_factory.createSocket(m_addr.m_inetAddrs[i], m_addr.m_portNumber.intValue());
+// m_socket = new Socket(InetAddress.getByName("a.b.c.d"),5358);
+ m_socket.setKeepAlive(this.m_addr.m_t4props.getKeepAlive());
+ m_socket.setSoLinger(false, 0); // Make sure the socket
+ m_socket.setKeepAlive(true);
+ // can immediately
+ // reused if connection
+ // is lost.
+ m_socket.setSoTimeout(0);
+ // disable/enable Nagle's algorithm
+ m_socket.setTcpNoDelay(this.m_addr.m_t4props.getTcpNoDelay());
+ //
+ // Note, I have not set a timeout here for either the
+ // conneciton or for
+ // read operations on the socket. I need to figure out
+ // what the
+ // semantics should be, and add this logic.
+ //
+ // Although the user can set a
+ // connection timeout, we
+ // do not set the timeout on the open/connect of the
+ // socket. Instead
+ // we use the default system TCP/IP timeout. In theory,
+ // this may be
+ // longer than the user login timeout. Also, we keep
+ // trying to create/connect
+ // the socket a minimun of 3 times. In theory, this
+ // could really mess up the
+ // user's use of login timeout. For example, if the user
+ // login timeout is
+ // small (e.g. 5 sec.), and the TCP/IP default socket
+ // create/connect timeout
+ // is large (e.g. 10 sec.), and the number of inetAddrs
+ // is large (e.g. 5),
+ // and the correct inetAddr is the last one on the list,
+ // and the AS server
+ // isn't ready until the last try, we could end up
+ // taking way more than
+ // the user specified login time to connect (3 * 10 * 5
+ // = 150 seconds vs.
+ // 5 sec. the user specified!).
+ //
+ //
+ m_os = m_socket.getOutputStream();
+ m_wbc = Channels.newChannel(m_os);
+ m_is = m_socket.getInputStream();
+ //m_sendBufSize = m_socket.getSendBufferSize();
+ found = true;
+ // Swastik: added code to start connection idle timers
+ startConnectionIdleTimeout();
+ // trace_connection - AM
+ if (m_t4conn != null && m_t4conn.m_ic.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(m_t4conn.m_ic.t4props_);
+ String temp = "found=" + found + ",numTry=" + numTry + ",i=" + i
+ + ",m_addr.m_inetAddrs.length=" + m_addr.m_inetAddrs.length;
+ m_t4conn.m_ic.t4props_.t4Logger_.logp(Level.FINEST, "InputOutput", "openIO", temp, p);
+ }
+ } catch (Exception e) {
+ //
+ // Make note of the exception, and keep trying all the
+ // possible addresses.
+ //
+ // If no address works, we will chain all the exceptions
+ // together,
+ // and let the user figure out what went wrong.
+ //
+ eList.addElement(e);
+ found = false;
+ }
+ i = i + 1;
+ } // end while
+ if (found == false) {
+ try {
+ Thread.sleep(100); // wait for 0.1 second before trying
+ // again
+ } catch (Exception e) {
+ // Do nothing.
+ }
+ }
+ numTry = numTry + 1;
+ } // end while
+ if (found == false) {
+ // trace_connection - AM
+ if (m_t4conn != null && m_t4conn.m_ic.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(m_t4conn.m_ic.t4props_);
+ String temp = "found=" + found + ",numTry=" + numTry + ",i=" + i + ",m_addr.m_inetAddrs.length="
+ + m_addr.m_inetAddrs.length;
+ m_t4conn.m_ic.t4props_.t4Logger_.logp(Level.FINEST, "InputOutput", "openIO", temp, p);
+ }
+ //
+ // Couldn't open the socket
+ //
+ Exception eFirst = (Exception) eList.firstElement();
+
+ //
+ // Just add the first exception for now. I'd like to add the
+ // entire list, but
+ // it will take some thought to figure out the best way to put
+ // each exception,
+ // and it's associated exception cause (i.e. chained list)
+ // together.
+ // If there is more than one address, then we must be dealing
+ // with a machine name.
+ // Hopefully, the problem with the first address is
+ // representitive of the problem
+ // with all addresses.
+ //
+ SQLException se = HPT4Messages.createSQLException(null, m_locale, "socket_open_error", eFirst
+ .getMessage());
+
+ se.initCause(eFirst);
+ throw se;
+ }
+ } // end if (p1.m_hSocket == null)
+
+ //
+ // If m_socket is not null, then we will assume it is already open.
+ //
+
+ } // end openIO
+
+ // ----------------------------------------------------------
+ synchronized LogicalByteArray doIO(short odbcAPI, LogicalByteArray buffer) throws SQLException {
+ int cmpLength = 0;
+ int totalLength = buffer.getLength();
+ ByteBuffer dataBuffer = buffer.getDataBuffer();
+ byte[] trailer = buffer.getTrailer();
+ if (dataBuffer != null)
+ totalLength += dataBuffer.limit();
+ if (trailer != null)
+ totalLength += trailer.length;
+
+ if(totalLength > 10000 && compress == Header.YES) //maybe totalLength - readHdrLength > 10000
+ {
+ compType = Header.COMP_14;
+
+ //dont set the databuffer
+ dataBuffer = null;
+ trailer = null;
+ }
+ else
+ {
+ cmpLength = 0;//totalLength - readHdrLength;
+ compType = Header.COMP_0;
+ }
+
+ // trace_connection - AM
+ if (m_t4conn != null && m_t4conn.m_ic.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(m_t4conn.m_ic.t4props_);
+ String temp = "MessageBuffer";
+ m_t4conn.m_ic.t4props_.t4Logger_.logp(Level.FINEST, "InputOutput", "doIO", temp, p);
+ }
+ Header wheader = new Header(odbcAPI, m_dialogueId, totalLength - readHdrLength// minus
+ // the
+ // size
+ // of
+ // the
+ // Header
+ , cmpLength, compress, compType, Header.WRITE_REQUEST_FIRST, Header.SIGNATURE, Header.CLIENT_HEADER_VERSION_BE, Header.PC, Header.TCPIP,
+ Header.NO);
+
+ m_rheader.reuseHeader(odbcAPI, m_dialogueId);
+
+ // Send to the server
+ int buffer_index = 0;
+
+ int wCount = buffer.getLength();
+ /*int tcount;
+ while (wCount > 0) {
+ if (wCount > m_sendBufSize) {
+ tcount = m_sendBufSize;
+ } else {
+ tcount = wCount;
+ }*/
+ TCPIPDoWrite(wheader, buffer, buffer_index, wCount);
+/*
+ wheader.hdr_type_ = Header.WRITE_REQUEST_NEXT;
+ wCount = wCount - tcount;
+ buffer_index = buffer_index + tcount;
+ }*/
+
+ if (dataBuffer != null && trailer != null) {
+ TCPIPWriteByteBuffer(dataBuffer);
+ TCPIPWriteByteBuffer(ByteBuffer.wrap(trailer));
+ }
+
+ // Receive from the server
+ buffer.reset();
+
+ // Read for READ_RESPONSE_FIRST
+ int numRead = 0;
+ int totalNumRead = 0;
+ int whileCount1 = 0;
+ long totalAvailable = 0;
+
+ // Read the first part
+ m_rheader.hdr_type_ = Header.READ_RESPONSE_FIRST;
+ m_rheader.total_length_ = readHdrLength;
+
+ // Keep reading until we have a header, but give up after 3 attempts.
+ while (totalNumRead < readHdrLength && whileCount1 < 3) {
+ numRead = TCPIPDoRead(m_rheader, buffer, totalNumRead);
+ totalNumRead = totalNumRead + numRead;
+ whileCount1 = whileCount1 + 1;
+ // trace_connection - AM
+ if (m_t4conn != null && m_t4conn.m_ic.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(m_t4conn.m_ic.t4props_);
+ String temp = "MessageBuffer whileCount1=" + whileCount1 + ",numRead=" + numRead + ",totalNumRead="
+ + totalNumRead;
+ m_t4conn.m_ic.t4props_.t4Logger_.logp(Level.FINEST, "InputOutput", "doIO", temp, p);
+ }
+ } // end while
+
+ // trace_connection - AM
+ // if (totalNumRead < readHdrLength)
+ if (numRead < readHdrLength) {
+ //
+ // We didn't even get the header back, so something is seriously
+ // wrong.
+ //
+ SQLException se = HPT4Messages.createSQLException(null, m_locale, "problem_with_server_read", null);
+ SQLException se2 = HPT4Messages.createSQLException(null, m_locale, "header_not_long_enough", null);
+
+ se.setNextException(se2);
+ throw se;
+ }
+
+ buffer.setLocation(0);
+ m_rheader.extractFromByteArray(buffer);
+
+ if(odbcAPI == TRANSPORT.AS_API_GETOBJREF) {
+ switch(m_rheader.version_) {
+ case Header.CLIENT_HEADER_VERSION_BE:
+ case Header.SERVER_HEADER_VERSION_BE:
+ buffer.setByteSwap(false);
+ break;
+ case Header.SERVER_HEADER_VERSION_LE:
+ buffer.setByteSwap(true);
+ break;
+ default:
+ SQLException se = HPT4Messages.createSQLException(null, m_locale, "problem_with_server_read", null);
+ SQLException se2 = HPT4Messages.createSQLException(null, m_locale, "wrong_header_version", String.valueOf(m_rheader.version_));
+
+ se.setNextException(se2);
+ throw se;
+ }
+ }
+
+ if (m_rheader.signature_ != Header.SIGNATURE) {
+ SQLException se = HPT4Messages.createSQLException(null, m_locale, "problem_with_server_read", null);
+ SQLException se2 = HPT4Messages.createSQLException(null, m_locale, "wrong_header_signature", String
+ .valueOf(Header.SIGNATURE), String.valueOf(m_rheader.signature_));
+
+ se.setNextException(se2);
+ throw se;
+ }
+
+ if (m_rheader.error_ != 0) {
+ SQLException se = HPT4Messages.createSQLException(null, m_locale, "driver_err_error_from_server", String
+ .valueOf(m_rheader.error_), String.valueOf(m_rheader.error_detail_));
+
+ throw se;
+ }
+
+ if(m_rheader.compress_ind_ == Header.YES && m_rheader.compress_type_ == Header.COMP_14) {
+ totalAvailable = m_rheader.cmp_length_;
+ }
+ else {
+ totalAvailable = m_rheader.total_length_;
+ }
+
+ numRead = 0;
+ buffer.resize(m_rheader.total_length_ + readHdrLength); // make sure the
+ // buffer is big
+ // enough
+
+ while (totalNumRead < (totalAvailable + readHdrLength)) {
+ m_rheader.hdr_type_ = Header.READ_RESPONSE_NEXT;
+
+ numRead = TCPIPDoRead(m_rheader, buffer, totalNumRead);
+ totalNumRead = totalNumRead + numRead;
+ }
+ buffer.setLocation(totalNumRead);
+
+ return buffer;
+ } // end doIO
+
+ // ----------------------------------------------------------
+ synchronized void CloseIO(LogicalByteArray buffer) throws SQLException {
+ /*Header hdr = new Header(Header.CLOSE_TCPIP_SESSION, m_dialogueId, 0, 0, Header.NO, Header.COMP_0,
+ Header.CLOSE_TCPIP_SESSION, Header.SIGNATURE, Header.VERSION, Header.PC, Header.TCPIP, Header.NO);
+
+ TCPIPDoWrite(hdr, buffer, 0, hdr.sizeOf());*/
+ try {
+ m_socket.close();
+ m_socket = null;
+ } catch (Exception e) {
+ SQLException se = HPT4Messages.createSQLException(null, m_locale, "session_close_error", e.getMessage());
+ se.initCause(e);
+ throw se;
+ } finally {
+ closeTimers();
+ }
+ } // end CloseIO
+
+ void TCPIPWriteByteBuffer(ByteBuffer buffer) throws SQLException {
+
+ if (m_socket == null) {
+ SQLException se = HPT4Messages.createSQLException(null, m_locale, "socket_write_error", null);
+ SQLException se2 = HPT4Messages.createSQLException(null, m_locale, "socket_is_closed_error", null);
+
+ se.setNextException(se2);
+ throw se;
+ }
+
+ try {
+ m_wbc.write(buffer);
+ m_os.flush();
+ } catch (Exception e) {
+ SQLException se = HPT4Messages.createSQLException(null, m_locale, "socket_write_error", e.getMessage());
+
+ se.initCause(e);
+ throw se;
+ } finally {
+ resetTimedOutConnection();
+ }
+
+ } // end TCPIPWriteByteBuffer
+
+ // ----------------------------------------------------------
+ void TCPIPDoWrite(Header hdr, LogicalByteArray buffer, int buffer_index, int bufcount) throws SQLException {
+// int error = 0;
+// short error_detail = 0;
+// int wcount = 0;
+ int data_length = 0;
+
+ if (m_socket == null) {
+ SQLException se = HPT4Messages.createSQLException(null, m_locale, "socket_write_error", null);
+ SQLException se2 = HPT4Messages.createSQLException(null, m_locale, "socket_is_closed_error", null);
+
+ se.setNextException(se2);
+ throw se;
+ }
+
+ switch (hdr.hdr_type_) {
+ case Header.WRITE_REQUEST_FIRST:
+ case Header.CLOSE_TCPIP_SESSION:
+ buffer.setLocation(0);
+ hdr.insertIntoByteArray(buffer, m_locale);
+ case Header.WRITE_REQUEST_NEXT:
+ data_length = data_length + bufcount;
+
+ send_nblk(buffer.getBuffer(), buffer_index, data_length);
+ break;
+ default:
+ SQLException se = HPT4Messages.createSQLException(null, m_locale, "unknown_message_type_error", null);
+ SQLException se2 = HPT4Messages.createSQLException(null, m_locale, "internal_error", null);
+ SQLException se3 = HPT4Messages.createSQLException(null, m_locale, "cntact_hp_error", null);
+
+ se.setNextException(se2);
+ se2.setNextException(se3);
+ throw se;
+ // break;
+ } // end switch (hdr.hdr_type)
+
+ } // end TCPIPDoWrite
+
+ // ----------------------------------------------------------
+ int TCPIPDoRead(Header hdr, LogicalByteArray buffer, int buffer_index) throws SQLException {
+ int numRead = 0;
+
+ if (m_socket == null) {
+ SQLException se = HPT4Messages.createSQLException(null, m_locale, "socket_read_error", null);
+ SQLException se2 = HPT4Messages.createSQLException(null, m_locale, "socket_is_closed_error", null);
+
+ se.setNextException(se2);
+ throw se;
+ }
+
+ switch (hdr.hdr_type_) {
+ case Header.READ_RESPONSE_FIRST:
+ case Header.READ_RESPONSE_NEXT:
+ numRead = recv_nblk(buffer.getBuffer(), buffer_index);
+// buffer.setLocation(numRead);
+ break;
+ default:
+ SQLException se = HPT4Messages.createSQLException(null, m_locale, "unknown_message_type_error", null);
+ SQLException se2 = HPT4Messages.createSQLException(null, m_locale, "internal_error", null);
+ SQLException se3 = HPT4Messages.createSQLException(null, m_locale, "cntact_hp_error", null);
+
+ se.setNextException(se2);
+ se2.setNextException(se3);
+ throw se;
+ } // end switch (hdr.hdr_type)
+
+ return numRead;
+
+ } // end TCPIPDoRead
+
+ // ----------------------------------------------------------
+ void send_nblk(byte[] buf, int offset, int len) throws SQLException {
+ try {
+ m_os.write(buf, offset, len);
+ m_os.flush();
+ } catch (Exception e) {
+ SQLException se = HPT4Messages.createSQLException(null, m_locale, "socket_write_error", e.getMessage());
+
+ se.initCause(e);
+ throw se;
+ } finally {
+ resetTimedOutConnection();
+ }
+ } // end send_nblk
+
+ // ----------------------------------------------------------
+ int recv_nblk(byte[] buf, int offset) throws SQLException {
+ int num_read = 0;
+
+ boolean retry = false;
+
+ do {
+ try {
+ m_socket.setSoTimeout(m_timeout * 1000);
+
+ num_read = m_is.read(buf, offset, buf.length - offset);
+
+ // if the socket.read returns -1 then return 0 instead of -1
+ if (num_read < 0) {
+ num_read = 0;
+ }
+ m_socket.setSoTimeout(0); // set timeout back to infinite
+ retry = false;
+
+ } catch (SocketTimeoutException ste) {
+ // the first exception should try to cancel and wait for the cancel message from the server
+ if(retry == false) {
+ this.m_t4conn.m_ic.cancel();
+ retry = true;
+ continue;
+ }
+
+ // if cancel didnt work the first time, clean everything up
+ try {
+ m_socket.close();
+ this.m_t4conn.m_ic.setIsClosed(true);
+ this.m_t4conn.m_ic.cancel();
+
+ throw ste;
+ } catch (Exception e) {
+ SQLException se = HPT4Messages
+ .createSQLException(null, m_locale, "session_close_error", e.getMessage());
+ se.initCause(e);
+ throw se;
+ }
+ } catch (Exception e) {
+ SQLException se = HPT4Messages.createSQLException(null, m_locale, "socket_read_error", e.getMessage());
+
+ se.initCause(e);
+ throw se;
+ } finally {
+ resetTimedOutConnection();
+ }
+ }while(retry);
+
+ return num_read;
+ } // recv_nblk
+
+ /** ***************************************** */
+ // Start of connectino timeout related code //
+ /** ***************************************** */
+ void closeTimers() {
+ if (m_connectionIdleTimeout > 0) {
+ T4TimerThread t = T4TimerThread.getThread(m_dialogueId);
+ if (t != null) {
+ // t.interrupt(); //SB:2/24/05
+ T4TimerThread.removeThread(this.m_dialogueId);
+ }
+ }
+ }
+
+ void resetConnectionIdleTimeout() {
+ if (m_connectionIdleTimeout > 0) {
+ T4TimerThread t = T4TimerThread.getThread(m_dialogueId);
+ if (t != null) {
+ t.reset(m_connectionIdleTimeout * 1000);
+ } else { // first time
+ startConnectionIdleTimeout();
+ }
+ }
+ }
+
+ private void resetTimedOutConnection() {
+ if (m_connectionIdleTimeout > 0) {
+ // check connection idle timeout
+ boolean timedOut = checkConnectionIdleTimeout();
+ if (timedOut) {
+ startConnectionIdleTimeout(); // this closes existing timers
+ // and starts a new one
+ // required for long runnign queries
+ } else {
+ resetConnectionIdleTimeout();
+ }
+ }
+ }
+
+ boolean checkConnectionIdleTimeout() {
+ if (m_connectionIdleTimeout > 0) {
+ T4TimerThread t = T4TimerThread.getThread(m_dialogueId);
+ if (t != null && t.getTimedOut()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ void startConnectionIdleTimeout() {
+ if (m_connectionIdleTimeout > 0 && m_dialogueId > 0) {
+ closeTimers();
+ T4TimerThread m_t4TimerThread = new T4TimerThread(m_dialogueId, m_connectionIdleTimeout * 1000);
+ // m_t4TimerThread.start(); ==> // SB:2/24/05 this class is no
+ // longer
+ // inheriting the thread package
+ // However it can be modified if
+ // need be - see class comments.
+ }
+ }
+} // end class InputOutput
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InsertRow.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InsertRow.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InsertRow.java
new file mode 100644
index 0000000..e569d20
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InsertRow.java
@@ -0,0 +1,82 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.BitSet;
+
+class InsertRow extends BaseRow implements Serializable, Cloneable {
+
+ private BitSet colsInserted;
+ private int cols;
+
+ InsertRow(int i) {
+ origVals = new Object[i];
+ colsInserted = new BitSet(i);
+ cols = i;
+ }
+
+ protected Object getColumnObject(int i) throws SQLException {
+ if (!colsInserted.get(i - 1)) {
+ throw HPT4Messages.createSQLException(null, null, "no_column_value_specified", null);
+ } else {
+ return origVals[i - 1];
+ }
+ }
+
+ protected void initInsertRow() {
+ for (int i = 0; i < cols; i++) {
+ colsInserted.clear(i);
+
+ }
+ }
+
+ /*
+ * protected boolean isCompleteRow(RowSetMetaData rowsetmetadata) throws
+ * SQLException { for(int i = 0; i < cols; i++) if(!colsInserted.get(i) &&
+ * rowsetmetadata.isNullable(i + 1) == 0) return false; return true; }
+ */
+
+ protected void markColInserted(int i) {
+ colsInserted.set(i);
+ }
+
+ protected void setColumnObject(int i, Object obj) {
+ origVals[i - 1] = obj;
+ markColInserted(i - 1);
+ }
+
+ protected void insertRow(PreparedStatement insertStmt, BitSet paramCols) throws SQLException {
+ int i;
+ int j;
+
+ for (i = 0, j = 1; i < cols; i++) {
+ if (paramCols.get(i)) {
+ insertStmt.setObject(j++, origVals[i]);
+ }
+ }
+ insertStmt.execute();
+ initInsertRow();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceConnection.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceConnection.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceConnection.java
new file mode 100644
index 0000000..4c1877f
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceConnection.java
@@ -0,0 +1,1420 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.CharBuffer;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CodingErrorAction;
+import java.nio.charset.UnsupportedCharsetException;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.util.Hashtable;
+import java.util.Locale;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+
+
+class InterfaceConnection {
+ static final int MODE_SQL = 0;
+ static final int MODE_WMS = 1;
+ static final int MODE_CMD = 2;
+
+ static final short SQL_COMMIT = 0;
+ static final short SQL_ROLLBACK = 1;
+ private int txnIsolationLevel = Connection.TRANSACTION_READ_COMMITTED;
+ private boolean autoCommit = true;
+ private boolean isReadOnly = false;
+ private boolean isClosed_;
+ private long txid;
+ private Locale locale;
+ private USER_DESC_def userDesc;
+ private CONNECTION_CONTEXT_def inContext;
+ OUT_CONNECTION_CONTEXT_def outContext;
+ private boolean useArrayBinding_;
+ private short transportBufferSize_;
+ Handler t4FileHandler;
+ private NCSAddress ncsAddr_;
+ private T4Connection t4connection_;
+ private String m_ncsSrvr_ref;
+ private int dialogueId_;
+ private String m_sessionName;
+
+ // character set information
+ private int isoMapping_ = 15;
+ private int termCharset_ = 15;
+ private boolean enforceISO = false;
+ private boolean byteSwap = false;
+ private String _serverDataSource;
+
+ private int _mode = MODE_SQL;
+
+ T4Properties t4props_;
+ SQLWarning sqlwarning_;
+
+ Hashtable encoders = new Hashtable(11);
+ Hashtable decoders = new Hashtable(11);
+
+ // static fields from odbc_common.h and sql.h
+ static final int SQL_TXN_READ_UNCOMMITTED = 1;
+ static final int SQL_TXN_READ_COMMITTED = 2;
+ static final int SQL_TXN_REPEATABLE_READ = 4;
+ static final int SQL_TXN_SERIALIZABLE = 8;
+ static final short SQL_ATTR_CURRENT_CATALOG = 109;
+ static final short SQL_ATTR_ACCESS_MODE = 101;
+ static final short SQL_ATTR_AUTOCOMMIT = 102;
+ static final short SQL_TXN_ISOLATION = 108;
+
+ // spj proxy syntax support
+ static final short SPJ_ENABLE_PROXY = 1040;
+
+ static final int PASSWORD_SECURITY = 0x4000000; //(2^26)
+ static final int ROWWISE_ROWSET = 0x8000000; // (2^27);
+ static final int CHARSET = 0x10000000; // (2^28)
+ static final int STREAMING_DELAYEDERROR_MODE = 0x20000000; // 2^29
+ // Zbig added new attribute on 4/18/2005
+ static final short JDBC_ATTR_CONN_IDLE_TIMEOUT = 3000;
+ static final short RESET_IDLE_TIMER = 1070;
+
+ // for handling WeakReferences
+ static ReferenceQueue refQ_ = new ReferenceQueue();
+ static Hashtable refTosrvrCtxHandle_ = new Hashtable();
+
+ //3196 - NDCS transaction for SPJ
+ static final short SQL_ATTR_JOIN_UDR_TRANSACTION = 1041;
+ static final short SQL_ATTR_SUSPEND_UDR_TRANSACTION = 1042;
+ long transId_ = 0;
+ boolean suspendRequest_ = false;
+
+ private String _roleName = "";
+ private boolean _ignoreCancel;
+
+ private long _seqNum = 0;
+ private SecPwd _security;
+ long currentTime;
+
+ private TrafT4Connection _t4Conn;
+ private String _remoteProcess;
+ private String _connStringHost = "";
+
+ InterfaceConnection(TrafT4Connection conn, T4Properties t4props) throws SQLException {
+ _t4Conn = conn;
+ t4props_ = t4props;
+ _remoteProcess = "";
+
+ // close any weak connections that need to be closed.
+ gcConnections();
+
+ if (t4props.getSQLException() != null) {
+ throw HPT4Messages.createSQLException(t4props_, t4props.getLocale(), "invalid_property", t4props
+ .getSQLException());
+ }
+
+ m_sessionName = t4props_.getSessionName();
+
+ if (m_sessionName != null && m_sessionName.length() > 0) {
+ if (m_sessionName.length() > 24)
+ m_sessionName = m_sessionName.substring(0, 24);
+
+ if (!m_sessionName.matches("\\w+"))
+ throw new SQLException("Invalid sessionName. Session names can only contain alphnumeric characters.");
+ }
+
+ locale = t4props.getLocale();
+ txid = 0;
+ isClosed_ = false;
+ useArrayBinding_ = t4props.getUseArrayBinding();
+ // transportBufferSize_ = t4props.getTransportBufferSize();
+ transportBufferSize_ = 32000;
+
+ userDesc = getUserDescription(t4props.getUser());
+
+ // Connection context details
+ inContext = getInContext(t4props);
+ m_ncsSrvr_ref = t4props.getUrl();
+ _ignoreCancel = false;
+
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(t4props_, t4props);
+ String temp = "url is = " + t4props.getUrl();
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "", temp, p);
+ p = T4LoggingUtilities.makeParams(t4props_, t4props);
+ temp = "user is = " + userDesc.userName;
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "", temp, p);
+ }
+ sqlwarning_ = null;
+ connect();
+ }
+
+ public void setConnStrHost(String host) {
+ this._connStringHost = host;
+ }
+
+ public int getMode() {
+ return this._mode;
+ }
+
+ public void setMode(int mode) {
+ this._mode = mode;
+ }
+
+ public long getSequenceNumber() {
+ if(++_seqNum < 0) {
+ _seqNum = 1;
+ }
+
+ return _seqNum;
+ }
+
+ public String getRemoteProcess() throws SQLException {
+ return _remoteProcess;
+ }
+
+ public boolean isClosed() {
+ return this.isClosed_;
+ }
+
+ String getRoleName() {
+ return this._roleName;
+ }
+
+ CONNECTION_CONTEXT_def getInContext() {
+ return inContext;
+ }
+
+ private CONNECTION_CONTEXT_def getInContext(T4Properties t4props) {
+ inContext = new CONNECTION_CONTEXT_def();
+ inContext.catalog = t4props.getCatalog();
+ inContext.schema = t4props.getSchema();
+ inContext.datasource = t4props.getServerDataSource();
+ inContext.userRole = t4props.getRoleName();
+ inContext.cpuToUse = t4props.getCpuToUse();
+ inContext.cpuToUseEnd = -1; // for future use by DBTransporter
+
+ inContext.accessMode = (short) (isReadOnly ? 1 : 0);
+ inContext.autoCommit = (short) (autoCommit ? 1 : 0);
+
+ inContext.queryTimeoutSec = t4props.getQueryTimeout();
+ inContext.idleTimeoutSec = (short) t4props.getConnectionTimeout();
+ inContext.loginTimeoutSec = (short) t4props.getLoginTimeout();
+ inContext.txnIsolationLevel = (short) SQL_TXN_READ_COMMITTED;
+ inContext.rowSetSize = t4props.getFetchBufferSize();
+ inContext.diagnosticFlag = 0;
+ inContext.processId = (int) System.currentTimeMillis() & 0xFFF;
+
+ try {
+ inContext.computerName = InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException uex) {
+ inContext.computerName = "Unknown Client Host";
+ }
+ inContext.windowText = t4props.getApplicationName();
+
+ inContext.ctxDataLang = 15;
+ inContext.ctxErrorLang = 15;
+
+ inContext.ctxACP = 1252;
+ inContext.ctxCtrlInferNXHAR = -1;
+ inContext.clientVersionList.list = getVersion(inContext.processId);
+ return inContext;
+ }
+
+ private VERSION_def[] getVersion(int pid) {
+ short majorVersion = 3;
+ short minorVersion = 0;
+ int buildId = 0;
+
+ VERSION_def version[] = new VERSION_def[2];
+
+ // Entry [0] is the Driver Version information
+ version[0] = new VERSION_def();
+ version[0].componentId = 20;
+ version[0].majorVersion = majorVersion;
+ version[0].minorVersion = minorVersion;
+ version[0].buildId = buildId | ROWWISE_ROWSET | CHARSET | PASSWORD_SECURITY;
+
+ if (this.t4props_.getDelayedErrorMode())
+ {
+ version[0].buildId |= STREAMING_DELAYEDERROR_MODE;
+ }
+
+ // Entry [1] is the Application Version information
+ version[1] = new VERSION_def();
+ version[1].componentId = 8;
+ version[1].majorVersion = 3;
+ version[1].minorVersion = 0;
+ version[1].buildId = 0;
+
+ return version;
+ }
+
+ USER_DESC_def getUserDescription() {
+ return userDesc;
+ }
+
+ private void setISOMapping(int isoMapping) {
+// if (InterfaceUtilities.getCharsetName(isoMapping) == InterfaceUtilities.SQLCHARSET_UNKNOWN)
+// isoMapping = InterfaceUtilities.getCharsetValue("ISO8859_1");
+
+ isoMapping_ = InterfaceUtilities.getCharsetValue("UTF-8");;
+ }
+
+ String getServerDataSource() {
+ return this._serverDataSource;
+ }
+
+ boolean getEnforceISO() {
+ return enforceISO;
+ }
+
+ int getISOMapping() {
+ return isoMapping_;
+ }
+
+ public String getSessionName() {
+ return m_sessionName;
+ }
+
+ private void setTerminalCharset(int termCharset) {
+// if (InterfaceUtilities.getCharsetName(termCharset) == InterfaceUtilities.SQLCHARSET_UNKNOWN)
+// termCharset = InterfaceUtilities.getCharsetValue("ISO8859_1");
+
+ termCharset_ = InterfaceUtilities.getCharsetValue("UTF-8");;
+ }
+
+ int getTerminalCharset() {
+ return termCharset_;
+ }
+
+ private USER_DESC_def getUserDescription(String user) throws SQLException {
+ userDesc = new USER_DESC_def();
+ userDesc.userDescType = (this.t4props_.getSessionToken()) ? TRANSPORT.PASSWORD_ENCRYPTED_USER_TYPE
+ : TRANSPORT.UNAUTHENTICATED_USER_TYPE;
+ userDesc.userName = (user.length() > 128) ? user.substring(0, 128) : user;
+ userDesc.domainName = "";
+
+ userDesc.userSid = null;
+ userDesc.password = null; //we no longer want to send the password to the MXOAS
+
+ return userDesc;
+ }
+
+ void writeToOutFile(byte[] input, String file)
+ {
+ java.io.DataOutputStream os = null;
+ try {
+ os = new java.io.DataOutputStream
+ (new java.io.FileOutputStream(file));
+ os.write(input, 0, input.length);
+ }catch (java.io.IOException io) {
+ System.out.println("IO exception");
+ }finally {
+ if (os != null)
+ try {
+ os.close();
+ }catch (java.io.IOException io) {
+ System.out.println("IO exception");
+ }
+ }
+ }
+
+ private void oldEncryptPassword() throws SQLException {
+ String pwd = this.t4props_.getPassword();
+
+ if (pwd.length() > 386)
+ pwd = pwd.substring(0, 386);
+
+ byte [] authentication;
+ try {
+ authentication = pwd.getBytes("US-ASCII");
+ } catch (UnsupportedEncodingException uex) {
+ throw HPT4Messages.createSQLException(t4props_, locale, uex.getMessage(), null);
+ }
+
+ if (authentication.length > 0) {
+ Utility.Encryption(authentication, authentication, authentication.length);
+ }
+
+ userDesc.password = authentication;
+ }
+
+ T4Connection getT4Connection() {
+ return t4connection_;
+ }
+
+ int getDialogueId() {
+ return dialogueId_;
+ }
+
+ int getQueryTimeout() {
+ return inContext.queryTimeoutSec;
+ }
+
+ int getLoginTimeout() {
+ return inContext.loginTimeoutSec;
+ }
+
+ int getConnectionTimeout() {
+ return inContext.idleTimeoutSec;
+ }
+
+ String getCatalog() {
+ if (outContext != null) {
+ return outContext.catalog;
+ } else {
+ return inContext.catalog;
+ }
+ }
+
+ boolean getDateConversion() {
+ return ((outContext.versionList.list[0].buildId & 512) > 0);
+ }
+
+ int getServerMajorVersion() {
+ return outContext.versionList.list[1].majorVersion;
+ }
+
+ int getServerMinorVersion() {
+ return outContext.versionList.list[1].minorVersion;
+ }
+
+ String getUid() {
+ return userDesc.userName;
+ }
+
+ String getSchema() {
+ if (outContext != null) {
+ return outContext.schema;
+ } else {
+ return inContext.schema;
+ }
+ }
+
+ void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+ Locale getLocale() {
+ return locale;
+ }
+
+ boolean getByteSwap() {
+ return this.byteSwap;
+ }
+
+ NCSAddress getNCSAddress() {
+ return ncsAddr_;
+ }
+
+ void commit() throws SQLException {
+ endTransaction(SQL_COMMIT);
+ }
+
+ void rollback() throws SQLException {
+ endTransaction(SQL_ROLLBACK);
+ }
+
+ void cancel() throws SQLException {
+ if(!this._ignoreCancel) {
+ String srvrObjRef = "" + ncsAddr_.getPort();
+ // String srvrObjRef = t4props_.getServerID();
+ int srvrType = 2; // AS server
+ CancelReply cr_ = null;
+
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(t4props_);
+ String temp = "cancel request received for " + srvrObjRef;
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "connect", temp, p);
+ }
+
+ //
+ // Send the cancel to the ODBC association server.
+ //
+ String errorText = null;
+ int tryNum = 0;
+ String errorMsg = null;
+ String errorMsg_detail = null;
+ long currentTime = (new java.util.Date()).getTime();
+ long endTime;
+
+ if (inContext.loginTimeoutSec > 0) {
+ endTime = currentTime + inContext.loginTimeoutSec * 1000;
+ } else {
+
+ // less than or equal to 0 implies infinit time out
+ endTime = Long.MAX_VALUE;
+
+ //
+ // Keep trying to contact the Association Server until we run out of
+ // time, or make a connection or we exceed the retry count.
+ //
+ }
+ cr_ = T4_Dcs_Cancel.cancel(t4props_, this, dialogueId_, srvrType, srvrObjRef, 0);
+
+ switch (cr_.m_p1_exception.exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(t4props_);
+ String temp = "Cancel successful";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "connect", temp, p);
+ }
+ break;
+ default:
+
+ //
+ // Some unknown error
+ //
+ if (cr_.m_p1_exception.clientErrorText != null) {
+ errorText = "Client Error text = " + cr_.m_p1_exception.clientErrorText;
+ }
+ errorText = errorText + " :Exception = " + cr_.m_p1_exception.exception_nr;
+ errorText = errorText + " :" + "Exception detail = " + cr_.m_p1_exception.exception_detail;
+ errorText = errorText + " :" + "Error code = " + cr_.m_p1_exception.errorCode;
+
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(t4props_);
+ String temp = errorText;
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "cancel", temp, p);
+ }
+ throw HPT4Messages.createSQLException(t4props_, locale, "as_cancel_message_error", errorText);
+ } // end switch
+
+ currentTime = (new java.util.Date()).getTime();
+ }
+ }
+
+ private void initDiag(boolean setTimestamp, boolean downloadCert) throws SQLException {
+ short retryCount = 3;
+ InitializeDialogueReply idr = null;
+ long endTime = (inContext.loginTimeoutSec > 0) ? currentTime + inContext.loginTimeoutSec * 1000 : Long.MAX_VALUE;
+ int tryNum = 0;
+ boolean done = false;
+
+ boolean socketException = false;
+ SQLException seSave = null;
+
+ do {
+ if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
+ String temp = "Attempting initDiag. Try " + (tryNum + 1) + " of " + retryCount;
+ t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", temp, t4props_);
+ }
+
+ socketException = false;
+ try {
+ t4connection_ = new T4Connection(this);
+ idr = t4connection_.InitializeDialogue(setTimestamp, downloadCert);
+ } catch (SQLException se) {
+ //
+ // We will retry socket exceptions, but will fail on all other
+ // exceptions.
+ //
+ int sc = se.getErrorCode();
+ int s1 = HPT4Messages.createSQLException(t4props_, locale, "socket_open_error", null).getErrorCode();
+ int s2 = HPT4Messages.createSQLException(t4props_, locale, "socket_write_error", null).getErrorCode();
+ int s3 = HPT4Messages.createSQLException(t4props_, locale, "socket_read_error", null).getErrorCode();
+
+ if (sc == s1 || sc == s2 || sc == s3) {
+ if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
+ String temp = "A socket exception occurred: " + se.getMessage();
+ t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", temp, t4props_);
+ }
+
+ socketException = true;
+ seSave = se;
+ } else {
+ if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
+ String temp = "A non-socket fatal exception occurred: " + se.getMessage();
+ t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", temp, t4props_);
+ }
+
+ try {
+ t4connection_.getInputOutput().CloseIO(new LogicalByteArray(1, 0, false));
+ } catch (Exception e) {
+ // ignore error
+ }
+
+ throw se;
+ }
+ }
+
+ if (socketException == false) {
+ if (idr.exception_nr == TRANSPORT.CEE_SUCCESS) {
+ done = true;
+ if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
+ String temp = "initDiag Successful.";
+ t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", temp, t4props_);
+ }
+ } else if (idr.exception_nr == odbc_SQLSvc_InitializeDialogue_exc_.odbc_SQLSvc_InitializeDialogue_SQLError_exn_ ||
+ idr.exception_nr == odbc_SQLSvc_InitializeDialogue_exc_.odbc_SQLSvc_InitializeDialogue_InvalidUser_exn_) {
+ if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
+ String temp = "A SQL Warning or Error occurred during initDiag: " + idr.SQLError;
+ t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", temp, t4props_);
+ }
+
+ int ex_nr = idr.exception_nr;
+ int ex_nr_d = idr.exception_detail;
+
+ if (ex_nr_d == odbc_SQLSvc_InitializeDialogue_exc_.SQL_PASSWORD_EXPIRING ||
+ ex_nr_d == odbc_SQLSvc_InitializeDialogue_exc_.SQL_PASSWORD_GRACEPERIOD) {
+ HPT4Messages.setSQLWarning(this.t4props_, this._t4Conn, idr.SQLError);
+ done = true;
+ } else {
+ HPT4Messages.throwSQLException(t4props_, idr.SQLError);
+ }
+ }
+ }
+
+ currentTime = System.currentTimeMillis();
+ tryNum = tryNum + 1;
+ } while (done == false && endTime > currentTime && tryNum < retryCount);
+
+ if (done == false) {
+ SQLException se1;
+ SQLException se2;
+
+ if (socketException == true) {
+ throw seSave;
+ }
+
+ if (currentTime >= endTime) {
+ se1 = HPT4Messages.createSQLException(t4props_, locale, "ids_s1_t00", null);
+ } else if (tryNum >= retryCount) {
+ se1 = HPT4Messages.createSQLException(t4props_, locale, "as_connect_message_error",
+ "exceeded retry count");
+ } else {
+ se1 = HPT4Messages.createSQLException(t4props_, locale, "as_connect_message_error", null);
+ }
+ throw se1;
+ }
+
+ //
+ // Set the outcontext value returned by the ODBC MX server in the
+ // serverContext
+ //
+ outContext = idr.outContext;
+ enforceISO = outContext._enforceISO;
+ this._roleName = outContext._roleName;
+ this._ignoreCancel = outContext._ignoreCancel;
+
+ t4props_.setDialogueID(Integer.toString(dialogueId_));
+ t4props_.setServerID(m_ncsSrvr_ref);
+
+ t4props_.setNcsMajorVersion(idr.outContext.versionList.list[0].majorVersion);
+ t4props_.setNcsMinorVersion(idr.outContext.versionList.list[0].minorVersion);
+ t4props_.setSqlmxMajorVersion(idr.outContext.versionList.list[1].majorVersion);
+ t4props_.setSqlmxMinorVersion(idr.outContext.versionList.list[1].minorVersion);
+
+ if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
+ String temp = "Connection process successful";
+ t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", temp, t4props_);
+ }
+ }
+
+ private void encryptPassword() throws SecurityException, SQLException {
+ byte [] pwBytes;
+ byte [] roleBytes;
+
+ String roleName = t4props_.getRoleName();
+
+ try {
+ pwBytes = t4props_.getPassword().getBytes("US-ASCII");
+ roleBytes = (roleName != null && roleName.length() > 0)?roleName.getBytes("US-ASCII"):null;
+ }
+ catch (UnsupportedEncodingException uex) {
+ //ERROR MESSAGE
+ throw new SQLException("failed to find encoding");
+ }
+
+ userDesc.password = new byte[_security.getPwdEBufferLen()];
+
+ _security.encryptPwd(pwBytes, roleBytes, userDesc.password);
+ }
+
+ private byte [] createProcInfo(int pid, int nid, byte [] timestamp) throws SQLException {
+ byte [] procInfo;
+
+ procInfo = new byte[16];
+
+ ByteBuffer bb = ByteBuffer.allocate(16);
+ bb.order(ByteOrder.LITTLE_ENDIAN);
+ bb.putInt(pid);
+ bb.putInt(nid);
+ bb.put(timestamp);
+ bb.rewind();
+ bb.get(procInfo, 0, 16);
+
+ return procInfo;
+ }
+
+ private void secureLogin(ConnectReply cr) throws SQLException {
+ try {
+ byte [] procInfo = createProcInfo(cr.processId, cr.serverNode, cr.timestamp);
+ boolean tokenAuth = this.t4props_.getSPJEnv() && this.t4props_.getTokenAuth();
+
+ _security = SecPwd.getInstance(
+ this._t4Conn,
+ this.t4props_.getCertificateDir(),
+ this.t4props_.getCertificateFile(),
+ cr.clusterName,
+ tokenAuth,
+ procInfo
+ );
+ }
+ catch(SecurityException se) {
+ CleanupServer(); //MXOSRVR is expecting InitDiag, clean it up since we failed
+ throw se;
+ }
+
+ try {
+ _security.openCertificate();
+ this.encryptPassword();
+ }catch(SecurityException se) {
+ if(se.getErrorCode() != 29713) {
+ throw se; //we have a fatal error
+ }
+
+ DownloadCertificate(); //otherwise, download and continue
+ }
+
+ try {
+ inContext.connectOptions = new String(_security.getCertExpDate());
+ initDiag(true,false);
+ }catch(SQLException e) {
+ if(outContext != null && outContext.certificate != null) { //we got a certificate back, switch to it, continue
+ _security.switchCertificate(outContext.certificate);
+ }
+ else {
+ throw e;
+ }
+
+ inContext.connectOptions = new String(_security.getCertExpDate());
+ this.encryptPassword(); //re-encrypt
+ this.initDiag(true,false); //re-initdiag
+ }
+ }
+
+ private void CleanupServer() throws SQLException {
+ this.userDesc.userName = null;
+ this.userDesc.password = null;
+
+ try {
+ initDiag(false,false); //send dummy init diag to clean up server
+ }catch(SQLException e) {
+
+ }
+
+ }
+
+ private void DownloadCertificate() throws SQLException {
+ //attempt download
+ this.userDesc.userName = null;
+ this.userDesc.password = null;
+ inContext.connectOptions = null;
+
+ try {
+ initDiag(true,true);
+ }catch(SQLException e) {
+ if(outContext == null || outContext.certificate == null) {
+ SQLException he = HPT4Messages.createSQLException(t4props_, this.locale, "certificate_download_error", e.getMessage());
+ he.setNextException(e);
+ throw he;
+ }
+ }
+
+ this.userDesc.userName = this.t4props_.getUser();
+
+ try {
+ _security.switchCertificate(outContext.certificate);
+ this.encryptPassword();
+ }catch(SecurityException se1) {
+ throw se1;
+ }
+ }
+
+ private void connect() throws SQLException {
+ short retryCount = 3;
+ int srvrType = 2; // AS server
+ ConnectReply cr = null;
+
+ if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
+ String msg = "Association Server URL: " + m_ncsSrvr_ref;
+ t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", msg, t4props_);
+ }
+
+ //
+ // Connect to the association server.
+ //
+ String errorText = null;
+ boolean done = false;
+ int tryNum = 0;
+ String errorMsg = null;
+ String errorMsg_detail = null;
+ currentTime = System.currentTimeMillis();
+ long endTime = (inContext.loginTimeoutSec > 0) ? currentTime + inContext.loginTimeoutSec * 1000
+ : Long.MAX_VALUE;
+
+ do {
+ if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
+ String temp = "Attempting getObjRef. Try " + (tryNum + 1) + " of " + retryCount;
+ t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", temp, t4props_);
+ }
+
+ cr = T4_Dcs_Connect.getConnection(t4props_, this, inContext, userDesc, srvrType,
+ retryCount);
+
+ switch (cr.m_p1_exception.exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ done = true;
+ if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
+ String msg = "getObjRef Successful. Server URL: " + cr.m_p2_srvrObjRef;
+ t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", msg, t4props_);
+ }
+ if (!cr.m_p4_dataSource.equals(t4props_.getServerDataSource())) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = cr.m_p4_dataSource;
+ sqlwarning_ = HPT4Messages.createSQLWarning(t4props_, "connected_to_Default_DS", messageArguments);
+ }
+ break;
+ case odbc_Dcs_GetObjRefHdl_exc_.odbc_Dcs_GetObjRefHdl_ASTryAgain_exn_:
+ done = false;
+ tryNum = tryNum + 1;
+ errorMsg = "as_connect_message_error";
+ errorMsg_detail = "try again request";
+ if(tryNum < retryCount) {
+ try {
+ Thread.sleep(5000);
+ }catch(Exception e) {}
+ }
+ break;
+ case odbc_Dcs_GetObjRefHdl_exc_.odbc_Dcs_GetObjRefHdl_ASNotAvailable_exn_:
+ done = false;
+ tryNum = tryNum + 1;
+ errorMsg = "as_connect_message_error";
+ errorMsg_detail = "association server not available";
+ break;
+ case odbc_Dcs_GetObjRefHdl_exc_.odbc_Dcs_GetObjRefHdl_DSNotAvailable_exn_:
+ done = false;
+ tryNum = tryNum + 1;
+ errorMsg = "as_connect_message_error";
+ errorMsg_detail = "data source not available";
+ break;
+ case odbc_Dcs_GetObjRefHdl_exc_.odbc_Dcs_GetObjRefHdl_PortNotAvailable_exn_:
+ done = false;
+ tryNum = tryNum + 1;
+ errorMsg = "as_connect_message_error";
+ errorMsg_detail = "port not available";
+ break;
+ case odbc_Dcs_GetObjRefHdl_exc_.odbc_Dcs_GetObjRefHdl_ASNoSrvrHdl_exn_:
+ done = false;
+ tryNum = tryNum + 1;
+ errorMsg = "as_connect_message_error";
+ errorMsg_detail = "server handle not available";
+ break;
+ default:
+
+ //
+ // Some unknown error
+ //
+ if (cr.m_p1_exception.clientErrorText != null) {
+ errorText = "Client Error text = " + cr.m_p1_exception.clientErrorText;
+
+ }
+ errorText = errorText + " :Exception = " + cr.m_p1_exception.exception_nr;
+ errorText = errorText + " :" + "Exception detail = " + cr.m_p1_exception.exception_detail;
+ errorText = errorText + " :" + "Error code = " + cr.m_p1_exception.errorCode;
+
+ if (cr.m_p1_exception.ErrorText != null) {
+ errorText = errorText + " :" + "Error text = " + cr.m_p1_exception.ErrorText;
+
+ }
+ throw HPT4Messages.createSQLException(t4props_, locale, "as_connect_message_error", errorText);
+ }
+
+ if (done == false && t4props_.t4Logger_.isLoggable(Level.INFO)) {
+ String msg = "getObjRef Failed. Message from Association Server: " + errorMsg_detail;
+ t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", msg, t4props_);
+ }
+
+ currentTime = System.currentTimeMillis();
+ } while (done == false && endTime > currentTime && tryNum < retryCount);
+
+ if (done == false) {
+ SQLException se1;
+ SQLException se2;
+
+ if (currentTime >= endTime) {
+ se1 = HPT4Messages.createSQLException(t4props_, locale, "ids_s1_t00", null);
+ se2 = HPT4Messages.createSQLException(t4props_, locale, errorMsg, errorMsg_detail);
+ se1.setNextException(se2);
+ } else {
+ se1 = HPT4Messages.createSQLException(t4props_, locale, errorMsg, errorMsg_detail);
+ }
+
+ throw se1;
+ }
+
+ dialogueId_ = cr.m_p3_dialogueId;
+ m_ncsSrvr_ref = cr.m_p2_srvrObjRef;
+ _remoteProcess = "\\" + cr.remoteHost + "." + cr.remoteProcess;
+
+ ncsAddr_ = cr.getNCSAddress();
+ this.byteSwap = cr.byteSwap;
+ this._serverDataSource = cr.m_p4_dataSource;
+
+ setISOMapping(cr.isoMapping);
+
+ if (cr.isoMapping == InterfaceUtilities.getCharsetValue("ISO8859_1")) {
+ setTerminalCharset(InterfaceUtilities.getCharsetValue("ISO8859_1"));
+ this.inContext.ctxDataLang = 0;
+ this.inContext.ctxErrorLang = 0;
+ } else {
+ setTerminalCharset(InterfaceUtilities.getCharsetValue("UTF-8"));
+ }
+
+ if(cr.securityEnabled) {
+ this.secureLogin(cr);
+ }
+ else {
+ this.oldEncryptPassword();
+ this.initDiag(false,false);
+ }
+ }
+
+ // @deprecated
+ void isConnectionClosed() throws SQLException {
+ if (isClosed_ == false) {
+ throw HPT4Messages.createSQLException(t4props_, locale, "invalid_connection", null);
+ }
+ }
+
+ // @deprecated
+ void isConnectionOpen() throws SQLException {
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(t4props_, locale, "invalid_connection", null);
+ }
+ }
+
+ // @deprecated
+ boolean getIsClosed() {
+ return isClosed_;
+ }
+
+ void setIsClosed(boolean isClosed) {
+ this.isClosed_ = isClosed;
+ }
+
+ String getUrl() {
+ return m_ncsSrvr_ref;
+ }
+
+ void setCatalog(TrafT4Connection conn, String catalog) throws SQLException {
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(conn.props_, catalog);
+ String temp = "Setting connection catalog = " + catalog;
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setCatalog", temp, p);
+ }
+ if (catalog != null && catalog.length() == 0) {
+ catalog = T4Properties.DEFAULT_CATALOG;
+ }
+ setConnectionAttr(conn, SQL_ATTR_CURRENT_CATALOG, 0, catalog);
+ outContext.catalog = catalog;
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(conn.props_, catalog);
+ String temp = "Setting connection catalog = " + catalog + " is done.";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setCatalog", temp, p);
+ }
+ };
+
+ // enforces the connection timeout set by the user
+ // to be called by the connection pooling mechanism whenever a connection is
+ // given to the user from the pool
+ void enforceT4ConnectionTimeout(TrafT4Connection conn) throws SQLException {
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(conn.props_, (short) t4props_.getConnectionTimeout());
+ String temp = "Enforcing connection timeout = " + (short) t4props_.getConnectionTimeout();
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "enforceT4ConnectionTimeout", temp, p);
+ }
+ inContext.idleTimeoutSec = (short) t4props_.getConnectionTimeout();
+ setConnectionAttr(conn, JDBC_ATTR_CONN_IDLE_TIMEOUT, inContext.idleTimeoutSec, String
+ .valueOf(inContext.idleTimeoutSec));
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(conn.props_, (short) t4props_.getConnectionTimeout());
+ String temp = "Enforcing connection timeout = " + (short) t4props_.getConnectionTimeout() + " is done.";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "enforceT4ConnectionTimeout", temp, p);
+ }
+ };
+
+ // disregards the T4's connectionTimeout value (set during initialize
+ // dialog) and
+ // enforces the connection timeout set by the NCS datasource settings
+ // to be called by the connection pooling mechanism whenever a connection is
+ // put into the pool (after a user has called connection.close())
+ void disregardT4ConnectionTimeout(TrafT4Connection conn) throws SQLException {
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(conn.props_, "-1");
+ String temp = "Setting connection timeout = -1";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "disregardT4ConnectionTimeout", temp, p);
+ }
+ setConnectionAttr(conn, JDBC_ATTR_CONN_IDLE_TIMEOUT, -1, "-1");
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(conn.props_, "-1");
+ String temp = "Setting connection timeout = -1 is done.";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "disregardT4ConnectionTimeout", temp, p);
+ }
+ };
+
+ void setConnectionAttr(TrafT4Connection conn, short attr, int valueNum, String valueString) throws SQLException {
+ SetConnectionOptionReply scr_;
+ isConnectionOpen();
+
+ try {
+ scr_ = t4connection_.SetConnectionOption(attr, valueNum, valueString);
+ //3196 - NDCS transaction for SPJ
+ if (attr == SQL_ATTR_JOIN_UDR_TRANSACTION) {
+ transId_ = Long.valueOf(valueString);
+ suspendRequest_ = true;
+ }
+ else if (attr == SQL_ATTR_SUSPEND_UDR_TRANSACTION) {
+ transId_ = Long.valueOf(valueString);
+ suspendRequest_ = false;
+ }
+ } catch (SQLException tex) {
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(conn.props_, attr, valueNum, valueString);
+ String temp = "NDCS or SQLException occurred.";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setConnectionAttr", temp, p);
+ }
+ throw tex;
+ }
+
+ switch (scr_.m_p1.exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+
+ // do the warning processing
+ if (scr_.m_p2.length != 0) {
+ HPT4Messages.setSQLWarning(conn.props_, conn, scr_.m_p2);
+ }
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(conn.props_, attr, valueNum, valueString);
+ String temp = "Setting connection attribute is done.";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setConnectionAttr", temp, p);
+ }
+ break;
+ case odbc_SQLSvc_SetConnectionOption_exc_.odbc_SQLSvc_SetConnectionOption_SQLError_exn_:
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(conn.props_, attr, valueNum, valueString);
+ String temp = "odbc_SQLSvc_SetConnectionOption_SQLError_exn_ occurred.";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setConnectionAttr", temp, p);
+ }
+ HPT4Messages.throwSQLException(t4props_, scr_.m_p1.errorList);
+ default:
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(conn.props_, attr, valueNum, valueString);
+ String temp = "UnknownException occurred.";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setConnectionAttr", temp, p);
+ }
+ throw HPT4Messages.createSQLException(conn.props_, locale, "ids_unknown_reply_error", null);
+ }
+ };
+
+ void setTransactionIsolation(TrafT4Connection conn, int level) throws SQLException {
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(conn.props_, level);
+ String temp = "Setting transaction isolation = " + level;
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setTransactionIsolation", temp, p);
+ }
+ isConnectionOpen();
+
+ if (level != Connection.TRANSACTION_NONE && level != Connection.TRANSACTION_READ_COMMITTED
+ && level != Connection.TRANSACTION_READ_UNCOMMITTED && level != Connection.TRANSACTION_REPEATABLE_READ
+ && level != Connection.TRANSACTION_SERIALIZABLE) {
+ throw HPT4Messages.createSQLException(conn.props_, locale, "invalid_transaction_isolation", null);
+ }
+
+ txnIsolationLevel = level;
+
+ switch (txnIsolationLevel) {
+ case Connection.TRANSACTION_NONE:
+ inContext.txnIsolationLevel = (short) SQL_TXN_READ_COMMITTED;
+ break;
+ case Connection.TRANSACTION_READ_COMMITTED:
+ inContext.txnIsolationLevel = (short) SQL_TXN_READ_COMMITTED;
+ break;
+ case Connection.TRANSACTION_READ_UNCOMMITTED:
+ inContext.txnIsolationLevel = (short) SQL_TXN_READ_UNCOMMITTED;
+ break;
+ case Connection.TRANSACTION_REPEATABLE_READ:
+ inContext.txnIsolationLevel = (short) SQL_TXN_REPEATABLE_READ;
+ break;
+ case Connection.TRANSACTION_SERIALIZABLE:
+ inContext.txnIsolationLevel = (short) SQL_TXN_SERIALIZABLE;
+ break;
+ default:
+ inContext.txnIsolationLevel = (short) SQL_TXN_READ_COMMITTED;
+ break;
+ }
+
+ setConnectionAttr(conn, SQL_TXN_ISOLATION, inContext.txnIsolationLevel, String
+ .valueOf(inContext.txnIsolationLevel));
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(conn.props_, level);
+ String temp = "Setting transaction isolation = " + level + " is done.";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setTransactionIsolation", temp, p);
+ }
+ };
+
+ int getTransactionIsolation() throws SQLException {
+ return txnIsolationLevel;
+ }
+
+ long getTxid() {
+ return txid;
+ }
+
+ void setTxid(long txid) {
+ this.txid = txid;
+ }
+
+ boolean getAutoCommit() {
+ return autoCommit;
+ }
+
+ void setAutoCommit(TrafT4Connection conn, boolean autoCommit) throws SQLException {
+ isConnectionOpen();
+ boolean commit = this.autoCommit;
+
+ this.autoCommit = autoCommit;
+
+ if (autoCommit == false) {
+ inContext.autoCommit = 0;
+ } else {
+ inContext.autoCommit = 1;
+
+ }
+ try {
+ setConnectionAttr(conn, SQL_ATTR_AUTOCOMMIT, inContext.autoCommit, String.valueOf(inContext.autoCommit));
+ } catch (SQLException sqle) {
+ this.autoCommit = commit;
+ throw sqle;
+ }
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(conn.props_, autoCommit);
+ String temp = "Setting autoCommit = " + autoCommit + " is done.";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setAutoCommit", temp, p);
+ }
+ }
+
+ void enableNARSupport(TrafT4Connection conn, boolean NARSupport) throws SQLException {
+ int val = NARSupport ? 1 : 0;
+ setConnectionAttr(conn, TRANSPORT.SQL_ATTR_ROWSET_RECOVERY, val, String.valueOf(val));
+ }
+
+ void enableProxySyntax(TrafT4Connection conn) throws SQLException {
+ setConnectionAttr(conn, InterfaceConnection.SPJ_ENABLE_PROXY, 1, "1");
+ }
+
+ boolean isReadOnly() {
+ return isReadOnly;
+ }
+
+ void setReadOnly(boolean readOnly) throws SQLException {
+ isConnectionOpen();
+ this.isReadOnly = readOnly;
+ }
+ void setReadOnly(TrafT4Connection conn, boolean readOnly) throws SQLException {
+ isConnectionOpen();
+ this.isReadOnly = readOnly;
+ if (readOnly == false) {
+ inContext.accessMode = 0;
+ } else {
+ inContext.accessMode = 1;
+
+ }
+ setConnectionAttr(conn, SQL_ATTR_ACCESS_MODE, inContext.accessMode, String.valueOf(inContext.accessMode));
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(conn.props_, readOnly);
+ String temp = "Setting readOnly = " + readOnly + " is done.";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "readOnly", temp, p);
+ }
+
+ }
+
+ void close() throws SQLException {
+ TerminateDialogueReply tdr_ = null;
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(t4props_);
+ String temp = "Terminate Dialogue.";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "close", temp, p);
+ }
+
+ //3196 - NDCS transaction for SPJ
+ if (suspendRequest_) {
+ _t4Conn.suspendUDRTransaction();
+ }
+
+ SecPwd.removeInstance(this._t4Conn);
+
+ try {
+ tdr_ = t4connection_.TerminateDialogue();
+ } catch (SQLException tex) {
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(t4props_);
+ String temp = "SQLException during TerminateDialogue.";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "close", temp, p);
+ }
+ throw tex;
+ }
+
+ switch (tdr_.m_p1.exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ break;
+ case odbc_SQLSvc_TerminateDialogue_exc_.odbc_SQLSvc_TerminateDialogue_SQLError_exn_:
+ //ignore errors
+ }
+
+ // needs work here. This should be proxy destroy. close the logfiles
+ try {
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(t4props_);
+ String temp = "Terminate Dialogue successful.";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "close", temp, p);
+ }
+ } catch (java.lang.SecurityException sex) {
+ }
+ };
+
+ void endTransaction(short commitOption) throws SQLException {
+ EndTransactionReply etr_ = null;
+ if (autoCommit && !_t4Conn.isBeginTransaction()) {
+ throw HPT4Messages.createSQLException(t4props_, locale, "invalid_commit_mode", null);
+ }
+
+ isConnectionOpen();
+ // XA_RESUMETRANSACTION();
+
+ try {
+ etr_ = t4connection_.EndTransaction(commitOption);
+ _t4Conn.setBeginTransaction(false);
+ } catch (SQLException tex) {
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(t4props_, commitOption);
+ String temp = "SQLException during EndTransaction." + tex.toString();
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "endTransaction", temp, p);
+ }
+ throw tex;
+ }
+
+ switch (etr_.m_p1.exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+ break;
+ case odbc_SQLSvc_EndTransaction_exc_.odbc_SQLSvc_EndTransaction_ParamError_exn_:
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(t4props_, commitOption);
+ String temp = "odbc_SQLSvc_EndTransaction_ParamError_exn_ :";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "endTransaction", temp, p);
+ }
+ throw HPT4Messages.createSQLException(t4props_, locale, "ParamError:" + etr_.m_p1.ParamError, null);
+ case odbc_SQLSvc_EndTransaction_exc_.odbc_SQLSvc_EndTransaction_InvalidConnection_exn_:
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(t4props_, commitOption);
+ String temp = "odbc_SQLSvc_EndTransaction_InvalidConnection_exn_:";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "endTransaction", temp, p);
+ }
+ throw new SQLException("odbc_SQLSvc_EndTransaction_InvalidConnection_exn", "HY100002", 10001);
+ case odbc_SQLSvc_EndTransaction_exc_.odbc_SQLSvc_EndTransaction_SQLError_exn_:
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(t4props_, commitOption);
+ String temp = "odbc_SQLSvc_EndTransaction_SQLError_exn_:" + etr_.m_p1.SQLError;
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "endTransaction", temp, p);
+ }
+ HPT4Messages.throwSQLException(t4props_, etr_.m_p1.SQLError);
+ case odbc_SQLSvc_EndTransaction_exc_.odbc_SQLSvc_EndTransaction_SQLInvalidHandle_exn_:
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(t4props_, commitOption);
+ String temp = "odbc_SQLSvc_EndTransaction_SQLInvalidHandle_exn_:";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "endTransaction", temp, p);
+ }
+ throw new SQLException("odbc_SQLSvc_EndTransaction_SQLInvalidHandle_exn", "HY100004", 10001);
+ case odbc_SQLSvc_EndTransaction_exc_.odbc_SQLSvc_EndTransaction_TransactionError_exn_:
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(t4props_, commitOption);
+ String temp = "odbc_SQLSvc_EndTransaction_TransactionError_exn_:";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "endTransaction", temp, p);
+ }
+ throw new SQLException("odbc_SQLSvc_EndTransaction_TransactionError_exn", "HY100005", 10001);
+ default:
+ if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(t4props_, commitOption);
+ String temp = "UnknownError:";
+ t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "endTransaction", temp, p);
+ }
+ throw new SQLException("Unknown Error during EndTransaction", "HY100001", 10001);
+ }
+
+ };
+
+ long beginTransaction() throws SQLException {
+ isConnectionOpen();
+
+ return txid;
+ };
+
+ void reuse() {
+ txnIsolationLevel = Connection.TRANSACTION_READ_COMMITTED;
+ autoCommit = true;
+ isReadOnly = false;
+ isClosed_ = false;
+ txid = 0;
+ t4connection_.reuse();
+ };
+
+ boolean useArrayBinding() {
+ return useArrayBinding_;
+ }
+
+ short getTransportBufferSize() {
+ return transportBufferSize_;
+ }
+
+ // methods for handling weak connections
+ void removeElement(TrafT4Connection conn) {
+ refTosrvrCtxHandle_.remove(conn.pRef_);
+ conn.pRef_.clear();
+ }
+
+ void gcConnections() {
+ Reference pRef;
+ InterfaceConnection ic;
+ while ((pRef = refQ_.poll()) != null) {
+ ic = (InterfaceConnection) refTosrvrCtxHandle_.get(pRef);
+ // All PreparedStatement objects are added to Hashtable
+ // Only Statement objects that produces ResultSet are added to
+ // Hashtable
+ // Hence stmtLabel could be null
+ if (ic != null) {
+ try {
+ ic.close();
+ } catch (SQLException e) {
+ } finally {
+ refTosrvrCtxHandle_.remove(pRef);
+ }
+ }
+ }
+ }
+
+ public byte[] encodeString(String str, int charset) throws CharacterCodingException, UnsupportedCharsetException {
+ Integer key = new Integer(charset);
+ CharsetEncoder ce;
+ byte[] ret = null;
+
+ if (str != null) {
+ if (this.isoMapping_ == InterfaceUtilities.SQLCHARSETCODE_ISO88591 && !this.enforceISO) {
+ ret = str.getBytes(); //convert the old way
+ } else {
+ if ((ce = (CharsetEncoder) encoders.get(key)) == null) { //only create a new encoder if its the first time
+ String charsetName = InterfaceUtilities.getCharsetName(charset);
+
+ //encoder needs to be based on our current swap flag for UTF-16 data
+ //this should be redesigned when we fixup character set issues for SQ
+ if(key == InterfaceUtilities.SQLCHARSETCODE_UNICODE && this.byteSwap == true) {
+ charsetName = "UTF-16LE";
+ }
+
+ Charset c = Charset.forName(charsetName);
+ ce = c.newEncoder();
+ ce.onUnmappableCharacter(CodingErrorAction.REPORT);
+ encoders.put(key, ce);
+ }
+
+ synchronized(ce) { //since one connection shares encoders
+ ce.reset();
+ ByteBuffer buf = ce.encode(CharBuffer.wrap(str));
+ ret = new byte[buf.remaining()];
+ buf.get(ret, 0, ret.length);
+ }
+ }
+ }
+
+ return ret;
+ }
+
+ public String decodeBytes(byte[] data, int charset) throws CharacterCodingException, UnsupportedCharsetException {
+ Integer key = new Integer(charset);
+ CharsetDecoder cd;
+ String str = null;
+
+ // we use this function for USC2 columns as well and we do NOT want to
+ // apply full pass-thru mode for them
+ if (this.isoMapping_ == InterfaceUtilities.SQLCHARSETCODE_ISO88591 && !this.enforceISO
+ && charset != InterfaceUtilities.SQLCHARSETCODE_UNICODE) {
+ str = new String(data);
+ } else {
+ // the following is a fix for JDK 1.4.2 and MS932. For some reason
+ // it does not handle single byte entries properly
+ boolean fix = false;
+ if (charset == 10 && data.length == 1) {
+ data = new byte[] { 0, data[0] };
+ fix = true;
+ }
+
+ if ((cd = (CharsetDecoder) decoders.get(key)) == null) { //only create a decoder if its the first time
+ String charsetName = InterfaceUtilities.getCharsetName(charset);
+
+ //encoder needs to be based on our current swap flag for UTF-16 data
+ //this should be redesigned when we fixup character set issues for SQ
+ if(key == InterfaceUtilities.SQLCHARSETCODE_UNICODE && this.byteSwap == true) {
+ charsetName = "UTF-16LE";
+ }
+
+ Charset c = Charset.forName(charsetName);
+ cd = c.newDecoder();
+ cd.replaceWith(this.t4props_.getReplacementString());
+ cd.onUnmappableCharacter(CodingErrorAction.REPLACE);
+ decoders.put(key, cd);
+ }
+
+ synchronized(cd) { //one decoder for the entire connection
+ cd.reset();
+ str = cd.decode(ByteBuffer.wrap(data)).toString();
+ }
+
+ if (fix)
+ str = str.substring(1);
+ }
+
+ return str;
+ }
+
+ public String getApplicationName() {
+ return this.t4props_.getApplicationName();
+ }
+}
[15/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4PooledConnectionManager.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4PooledConnectionManager.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4PooledConnectionManager.java
deleted file mode 100644
index 0657b92..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4PooledConnectionManager.java
+++ /dev/null
@@ -1,385 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.io.PrintWriter;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.Vector;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-import javax.sql.ConnectionEvent;
-import javax.sql.ConnectionPoolDataSource;
-import javax.sql.PooledConnection;
-
-public class HPT4PooledConnectionManager implements javax.sql.ConnectionEventListener {
-
- public void connectionClosed(ConnectionEvent event) {
- if (T4Properties.t4GlobalLogger.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null, event);
- T4Properties.t4GlobalLogger.logp(Level.FINE, "HPT4PooledConnectionManager", "connectionClosed", "", p);
- }
- if (out_ != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null, event);
- lr.setParameters(p);
- lr.setSourceClassName("HPT4PooledConnectionManager");
- lr.setSourceMethodName("connectionClosed");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- out_.println(temp);
- }
- if (out_ != null) {
- if (traceLevel_ != Level.OFF) {
- out_.println(traceId_ + "connectionClosed(" + event + ")");
- }
- }
- PooledConnection pc;
-
- pc = (PooledConnection) event.getSource();
-
- boolean addToFreePool = true;
- if (minPoolSize_ > 0 && free_.size() >= minPoolSize_) {
- addToFreePool = false;
- }
- // If an initial pool is being created, then ensure that the connection
- // is
- // added to the free pool irrespective of minPoolSize being reached
- if (initialPoolCreationFlag_) {
- addToFreePool = true;
- }
- boolean wasPresent = removeInUseConnection(pc, addToFreePool);
-
- if (wasPresent && (!addToFreePool)) {
- try {
- pc.close();
- } catch (SQLException e) {
- // ignore any close error
- }
- }
- }
-
- public void connectionErrorOccurred(ConnectionEvent event) {
- if (out_ != null) {
- if (traceLevel_ != Level.OFF) {
- out_.println(traceId_ + "connectionErrorOccurred(" + event + ")");
- }
- }
-
- PooledConnection pc;
-
- pc = (PooledConnection) event.getSource();
- try {
- pc.close();
- } catch (SQLException e) {
- // ignore any close error
- }
- removeInUseConnection(pc, false);
- }
-
- public Connection getConnection() throws SQLException {
- if (out_ != null) {
- if (traceLevel_ != Level.OFF) {
- out_.println(traceId_ + "getConnection()");
- }
- }
-
- PooledConnection pc;
- boolean validConnection = false;
-
- do {
- if (free_.size() == 0) {
- if (maxPoolSize_ == 0 || count_ < maxPoolSize_) {
- pc = pds_.getPooledConnection();
- count_++;
- pc.addConnectionEventListener(this);
- inUse_.add(pc);
-
- TrafT4Connection c = (TrafT4Connection) pc.getConnection();
- try {
- c.ic_.enforceT4ConnectionTimeout(c);
- validConnection = true;
- } catch (SQLException sqlEx) {
- try {
- pc.close();
- } catch (Exception e) {
- } // cleanup, ignore any errors
- }
- } else {
- throw HPT4Messages.createSQLException(null, null, "max_pool_size_reached", null);
- }
- } else {
- pc = (PooledConnection) free_.get(0);
- if (removeFreeConnection(pc, true)) {
- TrafT4Connection c = (TrafT4Connection) pc.getConnection();
- try {
- c.ic_.enforceT4ConnectionTimeout(c);
- validConnection = true;
- } catch (SQLException sqlEx) {
- try {
- pc.close();
- } catch (Exception e) {
- } // cleanup, ignore any errors
- }
- }
- }
- } while (!validConnection);
-
- return pc.getConnection();
- }
-
- private synchronized boolean removeFreeConnection(PooledConnection pc, boolean addToUsePool) {
- boolean wasPresent = free_.remove(pc);
- hashTab_.remove(pc);
- if (wasPresent) {
- if (addToUsePool) {
- inUse_.add(pc);
- } else {
- count_--;
- }
- }
- return wasPresent;
- }
-
- private synchronized boolean removeInUseConnection(PooledConnection pc, boolean addToFreePool) {
- boolean wasPresent = inUse_.remove(pc);
- hashTab_.remove(pc);
- if (wasPresent) {
- if (addToFreePool) {
- hashTab_.put(pc, new Long(System.currentTimeMillis() + (1000 * maxIdleTime_)));
- free_.add(pc);
- } else {
- count_--;
- }
- }
- return wasPresent;
- }
-
- private void createInitialPool(int initialPoolSize) throws SQLException {
- if (initialPoolSize <= 0) {
- return;
- }
-
- int limit = initialPoolSize > maxPoolSize_ ? maxPoolSize_ : initialPoolSize;
- Connection initPool_[] = new Connection[limit];
- int created = 0;
- try {
- // Set initialPoolInCreation to indicate that an initial pool is in
- // the
- // process of being created.
- initialPoolCreationFlag_ = true;
-
- for (int i = 0; i < limit; i++) {
- initPool_[i] = getConnection();
- created++;
- }
- } catch (SQLException se) {
- SQLException head = HPT4Messages.createSQLException(null, null, "initial_pool_creation_error", "" + limit);
- head.setNextException(se);
- throw head;
- } finally {
- for (int i = 0; i < created; i++) {
- try {
- if (initPool_[i] != null)
- initPool_[i].close();
- } catch (SQLException se) {
- // ignore
- }
- }
- // Ensuring that the initialPoolInCreation has been set to false to
- // indicate
- // that the initial pool creation process has occured.
- initialPoolCreationFlag_ = false;
- }
- }
-
- void setLogWriter(PrintWriter out) {
- out_ = out;
- }
-
- HPT4PooledConnectionManager(HPT4ConnectionPoolDataSource pds, Level traceLevel) throws SQLException {
- String className = getClass().getName();
- pds_ = pds;
- inUse_ = Collections.synchronizedList(new LinkedList());
- free_ = Collections.synchronizedList(new LinkedList());
- maxPoolSize_ = pds.getMaxPoolSize();
- minPoolSize_ = pds.getMinPoolSize();
- maxIdleTime_ = pds.getMaxIdleTime();
- connectionTimeout_ = pds.getConnectionTimeout();
- traceLevel_ = traceLevel;
- timer_ = null;
- if (maxIdleTime_ > 0 && maxPoolSize_ > 0) {
- IdleConnectionCleanupTask timerTask_ = new IdleConnectionCleanupTask();
- timer_ = new Timer(true);
- timer_.schedule(timerTask_, (maxIdleTime_ * 1000), (maxIdleTime_ * 500));
- }
- if (connectionTimeout_ > 0 && maxPoolSize_ > 0) {
- ConnectionTimeoutCleanupTask timerTask_ = new ConnectionTimeoutCleanupTask();
- if (timer_ == null) {
- timer_ = new Timer(true);
- }
- timer_.schedule(timerTask_, (connectionTimeout_ * 1000), (connectionTimeout_ * 500));
- }
- createInitialPool(pds.getInitialPoolSize());
- traceId_ = "jdbcTrace:[" + Thread.currentThread() + "]:[" + hashCode() + "]:" + className + ".";
- }
-
- ConnectionPoolDataSource pds_;
- // LinkedList inUse_;
- // LinkedList free_;
- List inUse_;
- List free_;
- int count_;
-
- int maxPoolSize_;
- int minPoolSize_;
- long maxIdleTime_;
- int connectionTimeout_;
- Level traceLevel_;
- PrintWriter out_;
- String traceId_;
- Timer timer_;
- Hashtable hashTab_ = new java.util.Hashtable(); // synchronized
- // We keep a flag to indicate to this class that an initial pool is in the
- // process
- // of being created
- boolean initialPoolCreationFlag_ = false;
-
- /*
- * Private class used to clean up the connections that have surpassed
- * maxIdleTime
- */
- /* Start TimerTask definition */
- private class IdleConnectionCleanupTask extends TimerTask {
- Vector toRemove = null;
-
- IdleConnectionCleanupTask() {
- toRemove = new Vector();
- }
-
- public void run() {
- cleanUp();
- }
-
- private void cleanUp() {
- toRemove.clear();
- synchronized (free_) {
- try {
- Iterator it_ = free_.iterator();
- while (it_.hasNext()) {
- PooledConnection tempPC = (PooledConnection) it_.next();
- Long timeOutVal = (Long) hashTab_.get(tempPC);
- if (System.currentTimeMillis() > timeOutVal.longValue()) {
- toRemove.add(tempPC);
- }
- }
- } catch (Throwable t) {
- if (T4Properties.t4GlobalLogger.isLoggable(Level.WARNING) == true) {
- T4Properties.t4GlobalLogger.logp(Level.WARNING, "IdleConnectionCleanupTask", "cleanUp", t
- .getMessage());
- }
- }
- } // synchronized block
- for (int i = 0; i < toRemove.size(); i++) {
- PooledConnection pc = (PooledConnection) toRemove.get(i);
- boolean wasPresent = removeFreeConnection(pc, false);
- if (wasPresent) {
- // close it to cleanup
- try {
- /*
- * System.out.println("Closing connection : " + (
- * (HPT4Connection) ( (HPT4PooledConnection)
- * pc).getConnection()).getDialogueId());
- */
- pc.close();
- } catch (SQLException se) {
- // Ignore
- }
- }
- }
- }
- }
-
- /* End TimerTask definition */
- /*
- * Private class used to clean up the connections that have surpassed
- * connectionTimeout
- */
- /* Start TimerTask definition */
- private class ConnectionTimeoutCleanupTask extends TimerTask {
- Vector toRemove = null;
-
- ConnectionTimeoutCleanupTask() {
- toRemove = new Vector();
- }
-
- public void run() {
- cleanUp();
- }
-
- private void cleanUp() {
- toRemove.clear();
- synchronized (inUse_) {
- Iterator it_ = inUse_.iterator();
- while (it_.hasNext()) {
- try {
- PooledConnection tempPC = (PooledConnection) it_.next();
- InterfaceConnection ic = ((HPT4PooledConnection) tempPC).getTrafT4ConnectionReference().ic_;
- if (ic != null) {
- T4Connection tconn = ic.getT4Connection();
- if (tconn != null) {
- if (tconn.connectionIdleTimeoutOccured()) {
- // System.out.println("********* Found a
- // timed out connection **********");
- toRemove.add(tempPC);
- }
- }
- }
- } catch (Throwable t) {
- if (T4Properties.t4GlobalLogger.isLoggable(Level.WARNING) == true) {
- T4Properties.t4GlobalLogger.logp(Level.WARNING, "ConnectionTimeoutCleanupTask", "cleanUp",
- t.getMessage());
- }
- }
- }
- } // synchronized block
- for (int i = 0; i < toRemove.size(); i++) {
- PooledConnection pc = (PooledConnection) toRemove.get(i);
- removeInUseConnection(pc, false);
- // do not close the connections because:
- // 1.> Corresponding NCS server is already gone
- // 2.> We need to give a timeout error when user uses this
- // connection
- }
- }
- }
- /* End TimerTask definition */
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4ResultSetMetaData.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4ResultSetMetaData.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4ResultSetMetaData.java
deleted file mode 100644
index d1f1f7e..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4ResultSetMetaData.java
+++ /dev/null
@@ -1,309 +0,0 @@
-// @@@ 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.logging.Level;
-
-public class HPT4ResultSetMetaData implements java.sql.ResultSetMetaData {
-
- // begin required methods
- public String getCatalogName(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].catalogName_;
- }
-
- public String getColumnClassName(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].getColumnClassName();
- }
-
- public int getColumnCount() throws SQLException {
- return outputDesc_.length;
- }
-
- public int getColumnDisplaySize(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].displaySize_;
- }
-
- public String getColumnLabel(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
-
- return (outputDesc_[column - 1].columnLabel_ == null) ? outputDesc_[column - 1].name_
- : outputDesc_[column - 1].columnLabel_;
- }
-
- public String getColumnName(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].name_;
- }
-
- public int getColumnType(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].dataType_;
- }
-
- public String getColumnTypeName(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].getColumnTypeName(connection_.getLocale());
- }
-
- public int getPrecision(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].precision_;
- }
-
- public int getScale(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].scale_;
- }
-
- public String getSchemaName(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].schemaName_;
- }
-
- public String getTableName(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].tableName_;
- }
-
- public boolean isAutoIncrement(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].isAutoIncrement_;
- }
-
- public boolean isCaseSensitive(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].isCaseSensitive_;
- }
-
- public boolean isCurrency(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].isCurrency_;
- }
-
- public boolean isDefinitelyWritable(int column) throws SQLException {
- return true;
- }
-
- public int isNullable(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].isNullable_;
- }
-
- public boolean isReadOnly(int column) throws SQLException {
- return false;
- }
-
- public boolean isSearchable(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].isSearchable_;
- }
-
- public boolean isSigned(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].isSigned_;
- }
-
- public boolean isWritable(int column) throws SQLException {
- return true;
- }
-
- // ////////////////////////
- // begin custom accessors//
- // ////////////////////////
-
- public int getFSDataType(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].fsDataType_;
- }
-
- public int getMaxLength(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].maxLen_;
- }
-
- public int getOdbcCharset(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].odbcCharset_;
- }
-
- public int getRowLength() throws SQLException {
- // this is the same for all params
- // only if we have no input params will we throw an error
- if (outputDesc_.length == 0) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.props_.getLocale(),
- "invalid_desc_index", null);
- }
-
- return outputDesc_[0].rowLength_;
- }
-
- public int getSqlCharset(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].sqlCharset_;
- }
-
- public int getSqlPrecision(int column) throws SQLException {
- if (column > outputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].sqlPrecision_;
- }
-
- public int getSqlDatetimeCode(int param) throws SQLException {
- return stmt_.ist_.pr_.outputDesc[param - 1].datetimeCode_;
- }
-
- // /////////////////////////////////
- // these are legacy names...do not remove these yet even though they are
- // duplicate
- // ///////////////////////////////
-
- /**
- * @deprecated
- */
- public String cpqGetCharacterSet(int column) throws SQLException {
- if ((column > outputDesc_.length) || (column <= 0)) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_desc_index",
- null);
- }
- return outputDesc_[column - 1].getCharacterSetName();
- }
-
- /**
- * @deprecated
- */
- public int getSqlTypeCode(int param) throws SQLException {
- return stmt_.ist_.pr_.outputDesc[param - 1].dataType_;
- } // end getSqlTypeCode
-
- /**
- * @deprecated
- */
- public int getSqlLength(int param) throws SQLException {
- return stmt_.ist_.pr_.outputDesc[param - 1].maxLen_;
- } // end getSqlTypeCode
-
- HPT4ResultSetMetaData(TrafT4Statement stmt, HPT4Desc[] outputDesc) {
- if (stmt.connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(stmt.connection_.props_, stmt, outputDesc);
- stmt.connection_.props_.t4Logger_.logp(Level.FINE, "HPT4ResultSetMetaData", "", "", p);
- }
-
- connection_ = stmt.connection_;
- outputDesc_ = outputDesc;
- stmt_ = stmt;
- }
-
- HPT4ResultSetMetaData(TrafT4ResultSet resultSet, HPT4Desc[] outputDesc) {
- if (resultSet.connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(resultSet.connection_.props_, resultSet, outputDesc);
- resultSet.connection_.props_.t4Logger_.logp(Level.FINE, "HPT4ResultSetMetaData", "", "", p);
- }
-
- resultSet_ = resultSet;
- connection_ = resultSet_.connection_;
- outputDesc_ = outputDesc;
- stmt_ = resultSet.stmt_;
- }
-
- TrafT4ResultSet resultSet_;
- TrafT4Connection connection_;
- HPT4Desc[] outputDesc_;
- TrafT4Statement stmt_;
- 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;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Header.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Header.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Header.java
deleted file mode 100644
index 41a35a3..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Header.java
+++ /dev/null
@@ -1,157 +0,0 @@
-// @@@ 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 HEADER structure as taken from
- * TransportBase.h
- * @version 1.0
- */
-
-class Header {
-
- //
- // Fixed values taken from TransportBase.h
- //
- static final short WRITE_REQUEST_FIRST = 1;
- static final short WRITE_REQUEST_NEXT = (short) (WRITE_REQUEST_FIRST + 1);
- static final short READ_RESPONSE_FIRST = (short) (WRITE_REQUEST_NEXT + 1);
- static final short READ_RESPONSE_NEXT = (short) (READ_RESPONSE_FIRST + 1);
- static final short CLEANUP = (short) (READ_RESPONSE_NEXT + 1);
- static final short SRVR_TRANSPORT_ERROR = (short) (CLEANUP + 1);
- static final short CLOSE_TCPIP_SESSION = (short) (SRVR_TRANSPORT_ERROR + 1);
-
- static final int SIGNATURE = 12345; // 0x3039
-
- //static final int OLD_VERSION = 100; //pre 2.5 server
- static final int CLIENT_HEADER_VERSION_BE = 101;
- //static final int CLIENT_HEADER_VERSION_LE = 102 //not used in JDBC
- static final int SERVER_HEADER_VERSION_BE = 201;
- static final int SERVER_HEADER_VERSION_LE = 202;
-
- static final char TCPIP = 'T';
-
- static final char NSK = 'N';
- static final char PC = 'P';
-
- static final char YES = 'Y';
- static final char NO = 'N';
-
- static final char COMP_0 = 0x0;
- static final char COMP_12 = 0x12;
- static final char COMP_14 = 0x14;
-
- //
- // The Java version of the HEADER structure taken from TransportBase.h
- //
- short operation_id_;
- // + 2 filler
- int dialogueId_;
- int total_length_;
- int cmp_length_;
- char compress_ind_;
- char compress_type_;
- // + 2 filler
- int hdr_type_;
- int signature_;
- int version_;
- char platform_;
- char transport_;
- char swap_;
- // + 1 filler
- short error_;
- short error_detail_;
-
- Header() {
- // Do nothing constructor
- }
-
- Header(short operation_id, int dialogueId, int total_length, int cmp_length, char compress_ind, char compress_type,
- int hdr_type, int signature, int version, char platform, char transport, char swap) {
- operation_id_ = operation_id;
- dialogueId_ = dialogueId;
- total_length_ = total_length;
- cmp_length_ = cmp_length;
- compress_ind_ = compress_ind;
- compress_type_ = compress_type;
- hdr_type_ = hdr_type;
- signature_ = signature;
- version_ = version;
- platform_ = platform;
- transport_ = transport;
- swap_ = swap;
- }
-
- void reuseHeader(short operation_id, int dialogueId) {
- operation_id_ = operation_id;
- dialogueId_ = dialogueId;
- }
-
- static int sizeOf() {
- return 40;
- }
-
- void insertIntoByteArray(LogicalByteArray buffer1, Locale locale) throws SQLException {
-
- buffer1.insertShort(operation_id_);
- buffer1.insertShort((short) 0); // + 2 filler
- buffer1.insertInt(dialogueId_);
- buffer1.insertInt(total_length_);
- buffer1.insertInt(cmp_length_);
- buffer1.insertChar(compress_ind_);
-
- buffer1.insertChar(compress_type_);
- buffer1.insertShort((short) 0); // + 2 filler
- buffer1.insertInt(hdr_type_);
- buffer1.insertInt(signature_);
- buffer1.insertInt(version_);
- buffer1.insertChar(platform_);
- buffer1.insertChar(transport_);
- buffer1.insertChar(swap_);
- buffer1.insertByte((byte) 0); // + 2 filler
- buffer1.insertShort(error_);
- buffer1.insertShort(error_detail_);
- }
-
- void extractFromByteArray(LogicalByteArray buffer1) {
- operation_id_ = buffer1.extractShort();
- buffer1.extractShort(); // + 2 filler
- dialogueId_ = buffer1.extractInt();
- total_length_ = buffer1.extractInt();
- cmp_length_ = buffer1.extractInt();
- compress_ind_ = buffer1.extractChar();
- compress_type_ = buffer1.extractChar();
- buffer1.extractShort(); // + 2 filler
- hdr_type_ = buffer1.extractInt();
- signature_ = buffer1.extractInt();
- version_ = buffer1.extractInt();
- platform_ = buffer1.extractChar();
- transport_ = buffer1.extractChar();
- swap_ = buffer1.extractChar();
- buffer1.extractByte(); // + 1 filler
- error_ = buffer1.extractShort();
- error_detail_ = buffer1.extractShort();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InitializeDialogueMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InitializeDialogueMessage.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InitializeDialogueMessage.java
deleted file mode 100644
index 39ba2b8..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InitializeDialogueMessage.java
+++ /dev/null
@@ -1,66 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class InitializeDialogueMessage {
- static LogicalByteArray marshal(USER_DESC_def userDesc, CONNECTION_CONTEXT_def inContext, int dialogueId,
- int optionFlags1, int optionFlags2, String sessionID, InterfaceConnection ic)
- throws CharacterCodingException, UnsupportedCharsetException {
- int wlength = Header.sizeOf();
- LogicalByteArray buf;
-
- byte[] sessionBytes = ic.encodeString(sessionID, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] clientUserBytes = ic.encodeString(System.getProperty("user.name"), InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- wlength += userDesc.sizeOf(ic);
- wlength += inContext.sizeOf(ic);
-
- wlength += TRANSPORT.size_int; // dialogueId
- wlength += TRANSPORT.size_int; // optionFlags1
- wlength += TRANSPORT.size_int; // optionFlags2
- wlength += sessionBytes.length;
- wlength += clientUserBytes.length;
-
- buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
-
- userDesc.insertIntoByteArray(buf);
- inContext.insertIntoByteArray(buf);
-
- buf.insertInt(dialogueId);
- buf.insertInt(optionFlags1);
- buf.insertInt(optionFlags2);
-
- if((optionFlags1 & T4Connection.INCONTEXT_OPT1_SESSIONNAME) != 0)
- {
- buf.insertString(sessionBytes);
- }
- if((optionFlags1 & T4Connection.INCONTEXT_OPT1_CLIENT_USERNAME) != 0)
- {
- buf.insertString(clientUserBytes);
- }
-
- return buf;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InitializeDialogueReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InitializeDialogueReply.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InitializeDialogueReply.java
deleted file mode 100644
index 5deb159..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InitializeDialogueReply.java
+++ /dev/null
@@ -1,90 +0,0 @@
-// @@@ 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 InitializeDialogueReply {
- static final int odbc_SQLSvc_InitializeDialogue_ParamError_exn_ = 1;
- static final int odbc_SQLSvc_InitializeDialogue_InvalidConnection_exn_ = 2;
- static final int odbc_SQLSvc_InitializeDialogue_SQLError_exn_ = 3;
- static final int odbc_SQLSvc_InitializeDialogue_SQLInvalidHandle_exn_ = 4;
- static final int odbc_SQLSvc_InitializeDialogue_SQLNeedData_exn_ = 5;
- static final int odbc_SQLSvc_InitializeDialogue_InvalidUser_exn_ = 6;
-
- static final int SQL_PASSWORD_EXPIRING = 8857;
- static final int SQL_PASSWORD_GRACEPERIOD = 8837;
-
- Header m_hdr;
-
- int exception_nr;
- int exception_detail;
- String ParamError;
- ERROR_DESC_LIST_def SQLError;
- ERROR_DESC_LIST_def InvalidUser;
- String clientErrorText;
-
- OUT_CONNECTION_CONTEXT_def outContext;
-
- // -------------------------------------------------------------
- InitializeDialogueReply(LogicalByteArray buf, String addr, InterfaceConnection ic, boolean downloadCert) throws CharacterCodingException,
- UnsupportedCharsetException, SQLException {
- buf.setLocation(Header.sizeOf());
-
- exception_nr = buf.extractInt();
- exception_detail = buf.extractInt();
-
- switch (exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
- outContext = new OUT_CONNECTION_CONTEXT_def();
- outContext.extractFromByteArray(buf, ic);
- break;
- case odbc_SQLSvc_InitializeDialogue_SQLError_exn_:
- SQLError = new ERROR_DESC_LIST_def();
- SQLError.extractFromByteArray(buf, ic);
-
- if (exception_detail == SQL_PASSWORD_EXPIRING || exception_detail == SQL_PASSWORD_GRACEPERIOD) {
- outContext = new OUT_CONNECTION_CONTEXT_def();
- outContext.extractFromByteArray(buf, ic);
- }
- break;
- case odbc_SQLSvc_InitializeDialogue_InvalidUser_exn_:
- SQLError = new ERROR_DESC_LIST_def();
- SQLError.extractFromByteArray(buf, ic);
-
- ic.outContext = new OUT_CONNECTION_CONTEXT_def();
- ic.outContext.extractFromByteArray(buf, ic);
- break;
- //throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_28_000", null);
- case odbc_SQLSvc_InitializeDialogue_ParamError_exn_:
- ParamError = ic.decodeBytes(buf.extractString(), 1);
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_program_error", ParamError, addr);
- case odbc_SQLSvc_InitializeDialogue_InvalidConnection_exn_:
- throw HPT4Messages.createSQLException(null, ic.getLocale(), "ids_08_s01", null);
- default:
- clientErrorText = "unknown_initialize_dialogue_reply_error";
- break;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InputOutput.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InputOutput.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InputOutput.java
deleted file mode 100644
index 7062778..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InputOutput.java
+++ /dev/null
@@ -1,682 +0,0 @@
-
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.Socket;
-import java.net.SocketTimeoutException;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channels;
-import java.nio.channels.WritableByteChannel;
-import java.sql.SQLException;
-import java.util.Locale;
-import java.util.Vector;
-import java.util.logging.Level;
-
-import javax.net.SocketFactory;
-
-class InputOutput {
- private Address m_addr;
- private Socket m_socket;
- private Locale m_locale;
- private int readHdrLength = Header.sizeOf();
- private int m_dialogueId;
- private int m_timeout;
- private int m_connectionIdleTimeout;
- private Header m_rheader;
- private OutputStream m_os;
- private InputStream m_is;
- private WritableByteChannel m_wbc;
- private T4Connection m_t4conn; // trace_connection
- //private int m_sendBufSize;
-
- private char compress = Header.NO; //Header.NO means no compression is used.
- private char compType = Header.COMP_0; //the used compression type. COMP_0 which means no compression
-
- private static SocketFactory m_factory = SocketFactory.getDefault(); // NRV
- // -
- // socket
- // factory
-
- static {
- try {
- String factStr = System.getProperty("t4jdbc.socketFactoryClass");
- if (factStr != null) {
- Class z = Class.forName(factStr);
- if (SocketFactory.class.isAssignableFrom(z)) {
- m_factory = (SocketFactory) z.newInstance();
- } else {
- m_factory = SocketFactory.getDefault();
- }
- }
- } catch (Throwable t) {
- m_factory = SocketFactory.getDefault();
- }
- }
-
- public static SocketFactory getSocketFactory() {
- return m_factory;
- }
-
- public static void setSocketFactory(SocketFactory factory) {
- m_factory = factory;
- }
-
- // ----------------------------------------------------------
- InputOutput(Locale locale, Address addr1) {
- m_locale = locale;
- m_addr = addr1;
- m_dialogueId = 0;
- m_timeout = 0;
- m_connectionIdleTimeout = 0;
-
- if(m_addr.m_t4props.getCompression()) {
- compress = Header.YES;
- }
-
- m_rheader = new Header((short) 0, m_dialogueId, 0, 0, compress, compType, Header.READ_RESPONSE_FIRST,
- Header.SIGNATURE, Header.CLIENT_HEADER_VERSION_BE, Header.PC, Header.TCPIP, Header.NO);
-
- } // end InputOutput
-
- // trace_connection - AM
- void setT4Connection(T4Connection t4conn) {
- m_t4conn = t4conn;
- }
-
- void setDialogueId(int dialogueId) {
- m_dialogueId = dialogueId;
- }
-
- void setTimeout(int timeout) {
- m_timeout = timeout;
- }
-
- void setConnectionIdleTimeout(int timeout) {
- m_connectionIdleTimeout = timeout;
- }
-
- String getRemoteHost() {
- return this.m_addr.getIPorName();
- }
-
- // ----------------------------------------------------------
- synchronized void openIO() throws SQLException {
- // trace_connection - AM
- if (m_t4conn != null && m_t4conn.m_ic.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(m_t4conn.m_ic.t4props_);
- String temp = "m_socket=" + m_socket;
- m_t4conn.m_ic.t4props_.t4Logger_.logp(Level.FINEST, "InputOutput", "openIO", temp, p);
- }
- if (m_socket == null) {
- int numTry = 0;
- boolean found = false;
- int i = 0;
- Vector eList = new Vector();
-
- //
- // Sometimes the server isn't ready to be contacted, so we will try
- // 3 times
- // before giving up.
- //
- while (found == false && numTry < 3) {
- //
- // Because each machine name can have multiple IP addresses
- // associated with it,
- // we need to go through the entire list of IP addresses until
- // we can find
- // one we can connect too, or all address fail.
- //
- i = 0;
- while (found == false && i < m_addr.m_inetAddrs.length) {
- try {
- //System.out.println(m_addr.m_inetAddrs[i] + ":" + m_addr.m_portNumber.intValue());
- m_socket = m_factory.createSocket(m_addr.m_inetAddrs[i], m_addr.m_portNumber.intValue());
-// m_socket = new Socket(InetAddress.getByName("a.b.c.d"),5358);
- m_socket.setKeepAlive(this.m_addr.m_t4props.getKeepAlive());
- m_socket.setSoLinger(false, 0); // Make sure the socket
- m_socket.setKeepAlive(true);
- // can immediately
- // reused if connection
- // is lost.
- m_socket.setSoTimeout(0);
- // disable/enable Nagle's algorithm
- m_socket.setTcpNoDelay(this.m_addr.m_t4props.getTcpNoDelay());
- //
- // Note, I have not set a timeout here for either the
- // conneciton or for
- // read operations on the socket. I need to figure out
- // what the
- // semantics should be, and add this logic.
- //
- // Although the user can set a
- // connection timeout, we
- // do not set the timeout on the open/connect of the
- // socket. Instead
- // we use the default system TCP/IP timeout. In theory,
- // this may be
- // longer than the user login timeout. Also, we keep
- // trying to create/connect
- // the socket a minimun of 3 times. In theory, this
- // could really mess up the
- // user's use of login timeout. For example, if the user
- // login timeout is
- // small (e.g. 5 sec.), and the TCP/IP default socket
- // create/connect timeout
- // is large (e.g. 10 sec.), and the number of inetAddrs
- // is large (e.g. 5),
- // and the correct inetAddr is the last one on the list,
- // and the AS server
- // isn't ready until the last try, we could end up
- // taking way more than
- // the user specified login time to connect (3 * 10 * 5
- // = 150 seconds vs.
- // 5 sec. the user specified!).
- //
- //
- m_os = m_socket.getOutputStream();
- m_wbc = Channels.newChannel(m_os);
- m_is = m_socket.getInputStream();
- //m_sendBufSize = m_socket.getSendBufferSize();
- found = true;
- // Swastik: added code to start connection idle timers
- startConnectionIdleTimeout();
- // trace_connection - AM
- if (m_t4conn != null && m_t4conn.m_ic.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(m_t4conn.m_ic.t4props_);
- String temp = "found=" + found + ",numTry=" + numTry + ",i=" + i
- + ",m_addr.m_inetAddrs.length=" + m_addr.m_inetAddrs.length;
- m_t4conn.m_ic.t4props_.t4Logger_.logp(Level.FINEST, "InputOutput", "openIO", temp, p);
- }
- } catch (Exception e) {
- //
- // Make note of the exception, and keep trying all the
- // possible addresses.
- //
- // If no address works, we will chain all the exceptions
- // together,
- // and let the user figure out what went wrong.
- //
- eList.addElement(e);
- found = false;
- }
- i = i + 1;
- } // end while
- if (found == false) {
- try {
- Thread.sleep(100); // wait for 0.1 second before trying
- // again
- } catch (Exception e) {
- // Do nothing.
- }
- }
- numTry = numTry + 1;
- } // end while
- if (found == false) {
- // trace_connection - AM
- if (m_t4conn != null && m_t4conn.m_ic.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(m_t4conn.m_ic.t4props_);
- String temp = "found=" + found + ",numTry=" + numTry + ",i=" + i + ",m_addr.m_inetAddrs.length="
- + m_addr.m_inetAddrs.length;
- m_t4conn.m_ic.t4props_.t4Logger_.logp(Level.FINEST, "InputOutput", "openIO", temp, p);
- }
- //
- // Couldn't open the socket
- //
- Exception eFirst = (Exception) eList.firstElement();
-
- //
- // Just add the first exception for now. I'd like to add the
- // entire list, but
- // it will take some thought to figure out the best way to put
- // each exception,
- // and it's associated exception cause (i.e. chained list)
- // together.
- // If there is more than one address, then we must be dealing
- // with a machine name.
- // Hopefully, the problem with the first address is
- // representitive of the problem
- // with all addresses.
- //
- SQLException se = HPT4Messages.createSQLException(null, m_locale, "socket_open_error", eFirst
- .getMessage());
-
- se.initCause(eFirst);
- throw se;
- }
- } // end if (p1.m_hSocket == null)
-
- //
- // If m_socket is not null, then we will assume it is already open.
- //
-
- } // end openIO
-
- // ----------------------------------------------------------
- synchronized LogicalByteArray doIO(short odbcAPI, LogicalByteArray buffer) throws SQLException {
- int cmpLength = 0;
- int totalLength = buffer.getLength();
- ByteBuffer dataBuffer = buffer.getDataBuffer();
- byte[] trailer = buffer.getTrailer();
- if (dataBuffer != null)
- totalLength += dataBuffer.limit();
- if (trailer != null)
- totalLength += trailer.length;
-
- if(totalLength > 10000 && compress == Header.YES) //maybe totalLength - readHdrLength > 10000
- {
- compType = Header.COMP_14;
-
- //dont set the databuffer
- dataBuffer = null;
- trailer = null;
- }
- else
- {
- cmpLength = 0;//totalLength - readHdrLength;
- compType = Header.COMP_0;
- }
-
- // trace_connection - AM
- if (m_t4conn != null && m_t4conn.m_ic.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(m_t4conn.m_ic.t4props_);
- String temp = "MessageBuffer";
- m_t4conn.m_ic.t4props_.t4Logger_.logp(Level.FINEST, "InputOutput", "doIO", temp, p);
- }
- Header wheader = new Header(odbcAPI, m_dialogueId, totalLength - readHdrLength// minus
- // the
- // size
- // of
- // the
- // Header
- , cmpLength, compress, compType, Header.WRITE_REQUEST_FIRST, Header.SIGNATURE, Header.CLIENT_HEADER_VERSION_BE, Header.PC, Header.TCPIP,
- Header.NO);
-
- m_rheader.reuseHeader(odbcAPI, m_dialogueId);
-
- // Send to the server
- int buffer_index = 0;
-
- int wCount = buffer.getLength();
- /*int tcount;
- while (wCount > 0) {
- if (wCount > m_sendBufSize) {
- tcount = m_sendBufSize;
- } else {
- tcount = wCount;
- }*/
- TCPIPDoWrite(wheader, buffer, buffer_index, wCount);
-/*
- wheader.hdr_type_ = Header.WRITE_REQUEST_NEXT;
- wCount = wCount - tcount;
- buffer_index = buffer_index + tcount;
- }*/
-
- if (dataBuffer != null && trailer != null) {
- TCPIPWriteByteBuffer(dataBuffer);
- TCPIPWriteByteBuffer(ByteBuffer.wrap(trailer));
- }
-
- // Receive from the server
- buffer.reset();
-
- // Read for READ_RESPONSE_FIRST
- int numRead = 0;
- int totalNumRead = 0;
- int whileCount1 = 0;
- long totalAvailable = 0;
-
- // Read the first part
- m_rheader.hdr_type_ = Header.READ_RESPONSE_FIRST;
- m_rheader.total_length_ = readHdrLength;
-
- // Keep reading until we have a header, but give up after 3 attempts.
- while (totalNumRead < readHdrLength && whileCount1 < 3) {
- numRead = TCPIPDoRead(m_rheader, buffer, totalNumRead);
- totalNumRead = totalNumRead + numRead;
- whileCount1 = whileCount1 + 1;
- // trace_connection - AM
- if (m_t4conn != null && m_t4conn.m_ic.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(m_t4conn.m_ic.t4props_);
- String temp = "MessageBuffer whileCount1=" + whileCount1 + ",numRead=" + numRead + ",totalNumRead="
- + totalNumRead;
- m_t4conn.m_ic.t4props_.t4Logger_.logp(Level.FINEST, "InputOutput", "doIO", temp, p);
- }
- } // end while
-
- // trace_connection - AM
- // if (totalNumRead < readHdrLength)
- if (numRead < readHdrLength) {
- //
- // We didn't even get the header back, so something is seriously
- // wrong.
- //
- SQLException se = HPT4Messages.createSQLException(null, m_locale, "problem_with_server_read", null);
- SQLException se2 = HPT4Messages.createSQLException(null, m_locale, "header_not_long_enough", null);
-
- se.setNextException(se2);
- throw se;
- }
-
- buffer.setLocation(0);
- m_rheader.extractFromByteArray(buffer);
-
- if(odbcAPI == TRANSPORT.AS_API_GETOBJREF) {
- switch(m_rheader.version_) {
- case Header.CLIENT_HEADER_VERSION_BE:
- case Header.SERVER_HEADER_VERSION_BE:
- buffer.setByteSwap(false);
- break;
- case Header.SERVER_HEADER_VERSION_LE:
- buffer.setByteSwap(true);
- break;
- default:
- SQLException se = HPT4Messages.createSQLException(null, m_locale, "problem_with_server_read", null);
- SQLException se2 = HPT4Messages.createSQLException(null, m_locale, "wrong_header_version", String.valueOf(m_rheader.version_));
-
- se.setNextException(se2);
- throw se;
- }
- }
-
- if (m_rheader.signature_ != Header.SIGNATURE) {
- SQLException se = HPT4Messages.createSQLException(null, m_locale, "problem_with_server_read", null);
- SQLException se2 = HPT4Messages.createSQLException(null, m_locale, "wrong_header_signature", String
- .valueOf(Header.SIGNATURE), String.valueOf(m_rheader.signature_));
-
- se.setNextException(se2);
- throw se;
- }
-
- if (m_rheader.error_ != 0) {
- SQLException se = HPT4Messages.createSQLException(null, m_locale, "driver_err_error_from_server", String
- .valueOf(m_rheader.error_), String.valueOf(m_rheader.error_detail_));
-
- throw se;
- }
-
- if(m_rheader.compress_ind_ == Header.YES && m_rheader.compress_type_ == Header.COMP_14) {
- totalAvailable = m_rheader.cmp_length_;
- }
- else {
- totalAvailable = m_rheader.total_length_;
- }
-
- numRead = 0;
- buffer.resize(m_rheader.total_length_ + readHdrLength); // make sure the
- // buffer is big
- // enough
-
- while (totalNumRead < (totalAvailable + readHdrLength)) {
- m_rheader.hdr_type_ = Header.READ_RESPONSE_NEXT;
-
- numRead = TCPIPDoRead(m_rheader, buffer, totalNumRead);
- totalNumRead = totalNumRead + numRead;
- }
- buffer.setLocation(totalNumRead);
-
- return buffer;
- } // end doIO
-
- // ----------------------------------------------------------
- synchronized void CloseIO(LogicalByteArray buffer) throws SQLException {
- /*Header hdr = new Header(Header.CLOSE_TCPIP_SESSION, m_dialogueId, 0, 0, Header.NO, Header.COMP_0,
- Header.CLOSE_TCPIP_SESSION, Header.SIGNATURE, Header.VERSION, Header.PC, Header.TCPIP, Header.NO);
-
- TCPIPDoWrite(hdr, buffer, 0, hdr.sizeOf());*/
- try {
- m_socket.close();
- m_socket = null;
- } catch (Exception e) {
- SQLException se = HPT4Messages.createSQLException(null, m_locale, "session_close_error", e.getMessage());
- se.initCause(e);
- throw se;
- } finally {
- closeTimers();
- }
- } // end CloseIO
-
- void TCPIPWriteByteBuffer(ByteBuffer buffer) throws SQLException {
-
- if (m_socket == null) {
- SQLException se = HPT4Messages.createSQLException(null, m_locale, "socket_write_error", null);
- SQLException se2 = HPT4Messages.createSQLException(null, m_locale, "socket_is_closed_error", null);
-
- se.setNextException(se2);
- throw se;
- }
-
- try {
- m_wbc.write(buffer);
- m_os.flush();
- } catch (Exception e) {
- SQLException se = HPT4Messages.createSQLException(null, m_locale, "socket_write_error", e.getMessage());
-
- se.initCause(e);
- throw se;
- } finally {
- resetTimedOutConnection();
- }
-
- } // end TCPIPWriteByteBuffer
-
- // ----------------------------------------------------------
- void TCPIPDoWrite(Header hdr, LogicalByteArray buffer, int buffer_index, int bufcount) throws SQLException {
-// int error = 0;
-// short error_detail = 0;
-// int wcount = 0;
- int data_length = 0;
-
- if (m_socket == null) {
- SQLException se = HPT4Messages.createSQLException(null, m_locale, "socket_write_error", null);
- SQLException se2 = HPT4Messages.createSQLException(null, m_locale, "socket_is_closed_error", null);
-
- se.setNextException(se2);
- throw se;
- }
-
- switch (hdr.hdr_type_) {
- case Header.WRITE_REQUEST_FIRST:
- case Header.CLOSE_TCPIP_SESSION:
- buffer.setLocation(0);
- hdr.insertIntoByteArray(buffer, m_locale);
- case Header.WRITE_REQUEST_NEXT:
- data_length = data_length + bufcount;
-
- send_nblk(buffer.getBuffer(), buffer_index, data_length);
- break;
- default:
- SQLException se = HPT4Messages.createSQLException(null, m_locale, "unknown_message_type_error", null);
- SQLException se2 = HPT4Messages.createSQLException(null, m_locale, "internal_error", null);
- SQLException se3 = HPT4Messages.createSQLException(null, m_locale, "cntact_hp_error", null);
-
- se.setNextException(se2);
- se2.setNextException(se3);
- throw se;
- // break;
- } // end switch (hdr.hdr_type)
-
- } // end TCPIPDoWrite
-
- // ----------------------------------------------------------
- int TCPIPDoRead(Header hdr, LogicalByteArray buffer, int buffer_index) throws SQLException {
- int numRead = 0;
-
- if (m_socket == null) {
- SQLException se = HPT4Messages.createSQLException(null, m_locale, "socket_read_error", null);
- SQLException se2 = HPT4Messages.createSQLException(null, m_locale, "socket_is_closed_error", null);
-
- se.setNextException(se2);
- throw se;
- }
-
- switch (hdr.hdr_type_) {
- case Header.READ_RESPONSE_FIRST:
- case Header.READ_RESPONSE_NEXT:
- numRead = recv_nblk(buffer.getBuffer(), buffer_index);
-// buffer.setLocation(numRead);
- break;
- default:
- SQLException se = HPT4Messages.createSQLException(null, m_locale, "unknown_message_type_error", null);
- SQLException se2 = HPT4Messages.createSQLException(null, m_locale, "internal_error", null);
- SQLException se3 = HPT4Messages.createSQLException(null, m_locale, "cntact_hp_error", null);
-
- se.setNextException(se2);
- se2.setNextException(se3);
- throw se;
- } // end switch (hdr.hdr_type)
-
- return numRead;
-
- } // end TCPIPDoRead
-
- // ----------------------------------------------------------
- void send_nblk(byte[] buf, int offset, int len) throws SQLException {
- try {
- m_os.write(buf, offset, len);
- m_os.flush();
- } catch (Exception e) {
- SQLException se = HPT4Messages.createSQLException(null, m_locale, "socket_write_error", e.getMessage());
-
- se.initCause(e);
- throw se;
- } finally {
- resetTimedOutConnection();
- }
- } // end send_nblk
-
- // ----------------------------------------------------------
- int recv_nblk(byte[] buf, int offset) throws SQLException {
- int num_read = 0;
-
- boolean retry = false;
-
- do {
- try {
- m_socket.setSoTimeout(m_timeout * 1000);
-
- num_read = m_is.read(buf, offset, buf.length - offset);
-
- // if the socket.read returns -1 then return 0 instead of -1
- if (num_read < 0) {
- num_read = 0;
- }
- m_socket.setSoTimeout(0); // set timeout back to infinite
- retry = false;
-
- } catch (SocketTimeoutException ste) {
- // the first exception should try to cancel and wait for the cancel message from the server
- if(retry == false) {
- this.m_t4conn.m_ic.cancel();
- retry = true;
- continue;
- }
-
- // if cancel didnt work the first time, clean everything up
- try {
- m_socket.close();
- this.m_t4conn.m_ic.setIsClosed(true);
- this.m_t4conn.m_ic.cancel();
-
- throw ste;
- } catch (Exception e) {
- SQLException se = HPT4Messages
- .createSQLException(null, m_locale, "session_close_error", e.getMessage());
- se.initCause(e);
- throw se;
- }
- } catch (Exception e) {
- SQLException se = HPT4Messages.createSQLException(null, m_locale, "socket_read_error", e.getMessage());
-
- se.initCause(e);
- throw se;
- } finally {
- resetTimedOutConnection();
- }
- }while(retry);
-
- return num_read;
- } // recv_nblk
-
- /** ***************************************** */
- // Start of connectino timeout related code //
- /** ***************************************** */
- void closeTimers() {
- if (m_connectionIdleTimeout > 0) {
- T4TimerThread t = T4TimerThread.getThread(m_dialogueId);
- if (t != null) {
- // t.interrupt(); //SB:2/24/05
- T4TimerThread.removeThread(this.m_dialogueId);
- }
- }
- }
-
- void resetConnectionIdleTimeout() {
- if (m_connectionIdleTimeout > 0) {
- T4TimerThread t = T4TimerThread.getThread(m_dialogueId);
- if (t != null) {
- t.reset(m_connectionIdleTimeout * 1000);
- } else { // first time
- startConnectionIdleTimeout();
- }
- }
- }
-
- private void resetTimedOutConnection() {
- if (m_connectionIdleTimeout > 0) {
- // check connection idle timeout
- boolean timedOut = checkConnectionIdleTimeout();
- if (timedOut) {
- startConnectionIdleTimeout(); // this closes existing timers
- // and starts a new one
- // required for long runnign queries
- } else {
- resetConnectionIdleTimeout();
- }
- }
- }
-
- boolean checkConnectionIdleTimeout() {
- if (m_connectionIdleTimeout > 0) {
- T4TimerThread t = T4TimerThread.getThread(m_dialogueId);
- if (t != null && t.getTimedOut()) {
- return true;
- }
- }
- return false;
- }
-
- void startConnectionIdleTimeout() {
- if (m_connectionIdleTimeout > 0 && m_dialogueId > 0) {
- closeTimers();
- T4TimerThread m_t4TimerThread = new T4TimerThread(m_dialogueId, m_connectionIdleTimeout * 1000);
- // m_t4TimerThread.start(); ==> // SB:2/24/05 this class is no
- // longer
- // inheriting the thread package
- // However it can be modified if
- // need be - see class comments.
- }
- }
-} // end class InputOutput
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InsertRow.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InsertRow.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InsertRow.java
deleted file mode 100644
index e569d20..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InsertRow.java
+++ /dev/null
@@ -1,82 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.io.Serializable;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.BitSet;
-
-class InsertRow extends BaseRow implements Serializable, Cloneable {
-
- private BitSet colsInserted;
- private int cols;
-
- InsertRow(int i) {
- origVals = new Object[i];
- colsInserted = new BitSet(i);
- cols = i;
- }
-
- protected Object getColumnObject(int i) throws SQLException {
- if (!colsInserted.get(i - 1)) {
- throw HPT4Messages.createSQLException(null, null, "no_column_value_specified", null);
- } else {
- return origVals[i - 1];
- }
- }
-
- protected void initInsertRow() {
- for (int i = 0; i < cols; i++) {
- colsInserted.clear(i);
-
- }
- }
-
- /*
- * protected boolean isCompleteRow(RowSetMetaData rowsetmetadata) throws
- * SQLException { for(int i = 0; i < cols; i++) if(!colsInserted.get(i) &&
- * rowsetmetadata.isNullable(i + 1) == 0) return false; return true; }
- */
-
- protected void markColInserted(int i) {
- colsInserted.set(i);
- }
-
- protected void setColumnObject(int i, Object obj) {
- origVals[i - 1] = obj;
- markColInserted(i - 1);
- }
-
- protected void insertRow(PreparedStatement insertStmt, BitSet paramCols) throws SQLException {
- int i;
- int j;
-
- for (i = 0, j = 1; i < cols; i++) {
- if (paramCols.get(i)) {
- insertStmt.setObject(j++, origVals[i]);
- }
- }
- insertStmt.execute();
- initInsertRow();
- }
-}
[38/60] incubator-trafodion git commit: including the missing files
in previous commit
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/AppTest.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/AppTest.java b/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/AppTest.java
new file mode 100644
index 0000000..0a07e0b
--- /dev/null
+++ b/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/AppTest.java
@@ -0,0 +1,38 @@
+package org.trafodion.jdbc.t4;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest
+ extends TestCase
+{
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public AppTest( String testName )
+ {
+ super( testName );
+ }
+
+ /**
+ * @return the suite of tests being tested
+ */
+ public static Test suite()
+ {
+ return new TestSuite( AppTest.class );
+ }
+
+ /**
+ * Rigourous Test :-)
+ */
+ public void testApp()
+ {
+ assertTrue( true );
+ }
+}
[17/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CONNECTION_CONTEXT_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CONNECTION_CONTEXT_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CONNECTION_CONTEXT_def.java
deleted file mode 100644
index d38b178..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CONNECTION_CONTEXT_def.java
+++ /dev/null
@@ -1,149 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class CONNECTION_CONTEXT_def {
- String datasource = "";
- String catalog = "";
- String schema = "";
- String location = "";
- String userRole = "";
-
- short accessMode;
- short autoCommit;
- short queryTimeoutSec;
- short idleTimeoutSec;
- short loginTimeoutSec;
- short txnIsolationLevel;
- short rowSetSize;
-
- int diagnosticFlag;
- int processId;
-
- String computerName = "";
- String windowText = "";
-
- int ctxACP;
- int ctxDataLang;
- int ctxErrorLang;
- short ctxCtrlInferNXHAR;
-
- short cpuToUse = -1;
- short cpuToUseEnd = -1; // for future use by DBTransporter
-
- String connectOptions = "";
-
- VERSION_LIST_def clientVersionList = new VERSION_LIST_def();
-
- byte[] datasourceBytes;
- byte[] catalogBytes;
- byte[] schemaBytes;
- byte[] locationBytes;
- byte[] userRoleBytes;
- byte[] computerNameBytes;
- byte[] windowTextBytes;
- byte[] connectOptionsBytes;
-
- // ----------------------------------------------------------
- int sizeOf(InterfaceConnection ic) throws CharacterCodingException, UnsupportedCharsetException {
- int size = 0;
-
- datasourceBytes = ic.encodeString(datasource, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- catalogBytes = ic.encodeString(catalog, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- schemaBytes = ic.encodeString(schema, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- locationBytes = ic.encodeString(location, 1);
- userRoleBytes = ic.encodeString(userRole, 1);
- computerNameBytes = ic.encodeString(computerName, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- windowTextBytes = ic.encodeString(windowText, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- connectOptionsBytes = ic.encodeString(connectOptions, 1);
-
- size = TRANSPORT.size_bytes(datasourceBytes);
- size += TRANSPORT.size_bytes(catalogBytes);
- size += TRANSPORT.size_bytes(schemaBytes);
- size += TRANSPORT.size_bytes(locationBytes);
- size += TRANSPORT.size_bytes(userRoleBytes);
-
- size += TRANSPORT.size_short; // accessMode
- size += TRANSPORT.size_short; // autoCommit
- size += TRANSPORT.size_int; // queryTimeoutSec
- size += TRANSPORT.size_int; // idleTimeoutSec
- size += TRANSPORT.size_int; // loginTimeoutSec
- size += TRANSPORT.size_short; // txnIsolationLevel
- size += TRANSPORT.size_short; // rowSetSize
-
- size += TRANSPORT.size_short; // diagnosticFlag
- size += TRANSPORT.size_int; // processId
-
- size += TRANSPORT.size_bytes(computerNameBytes);
- size += TRANSPORT.size_bytes(windowTextBytes);
-
- size += TRANSPORT.size_int; // ctxACP
- size += TRANSPORT.size_int; // ctxDataLang
- size += TRANSPORT.size_int; // ctxErrorLang
- size += TRANSPORT.size_short; // ctxCtrlInferNCHAR
-
- size += TRANSPORT.size_short; // cpuToUse
- size += TRANSPORT.size_short; // cpuToUseEnd
- size += TRANSPORT.size_bytes(connectOptionsBytes);
-
- size += clientVersionList.sizeOf();
-
- return size;
- }
-
- // ----------------------------------------------------------
- void insertIntoByteArray(LogicalByteArray buf) {
- buf.insertString(datasourceBytes);
- buf.insertString(catalogBytes);
- buf.insertString(schemaBytes);
- buf.insertString(locationBytes);
- buf.insertString(userRoleBytes);
-
- buf.insertShort(accessMode);
- buf.insertShort(autoCommit);
- buf.insertInt(queryTimeoutSec);
- buf.insertInt(idleTimeoutSec);
- buf.insertInt(loginTimeoutSec);
- buf.insertShort(txnIsolationLevel);
- buf.insertShort(rowSetSize);
-
- buf.insertInt(diagnosticFlag);
- buf.insertInt(processId);
-
- buf.insertString(computerNameBytes);
- buf.insertString(windowTextBytes);
-
- buf.insertInt(ctxACP);
- buf.insertInt(ctxDataLang);
- buf.insertInt(ctxErrorLang);
- buf.insertShort(ctxCtrlInferNXHAR);
-
- buf.insertShort(cpuToUse);
- buf.insertShort(cpuToUseEnd);
- buf.insertString(connectOptionsBytes);
-
- clientVersionList.insertIntoByteArray(buf);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CachedPreparedStatement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CachedPreparedStatement.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CachedPreparedStatement.java
deleted file mode 100644
index 5866e04..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CachedPreparedStatement.java
+++ /dev/null
@@ -1,67 +0,0 @@
-// @@@ 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.PreparedStatement;
-import java.sql.SQLException;
-
-public class CachedPreparedStatement {
-
- PreparedStatement getPreparedStatement() {
- inUse_ = true;
- return pstmt_;
- }
-
- void setLastUsedInfo() {
- lastUsedTime_ = System.currentTimeMillis();
- noOfTimesUsed_++;
- }
-
- long getLastUsedTime() {
- return lastUsedTime_;
- }
-
- String getLookUpKey() {
- return key_;
- }
-
- void close(boolean hardClose) throws SQLException {
- inUse_ = false;
- pstmt_.close(hardClose);
- }
-
- CachedPreparedStatement(PreparedStatement pstmt, String key) {
- pstmt_ = (TrafT4PreparedStatement) pstmt;
- key_ = key;
- creationTime_ = System.currentTimeMillis();
- lastUsedTime_ = creationTime_;
- noOfTimesUsed_ = 1;
- inUse_ = true;
- }
-
- private TrafT4PreparedStatement pstmt_;
- private String key_;
- private long lastUsedTime_;
- private long creationTime_;
- private long noOfTimesUsed_;
- boolean inUse_;
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CancelMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CancelMessage.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CancelMessage.java
deleted file mode 100644
index b8347a2..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CancelMessage.java
+++ /dev/null
@@ -1,49 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class CancelMessage {
- static LogicalByteArray marshal(int dialogueId, int srvrType, String srvrObjRef, int stopType,
- InterfaceConnection ic) throws UnsupportedCharsetException, CharacterCodingException {
- int wlength = Header.sizeOf();
- LogicalByteArray buf = null;
-
- byte[] srvrObjRefBytes = ic.encodeString(srvrObjRef, 1);
-
- wlength += TRANSPORT.size_int; // dialogueId
- wlength += TRANSPORT.size_int; // srvrType
- wlength += TRANSPORT.size_bytes(srvrObjRefBytes); // srvrObjReference
- wlength += TRANSPORT.size_int; // stopType
-
- buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
-
- buf.insertInt(dialogueId);
- buf.insertInt(srvrType);
- buf.insertString(srvrObjRefBytes);
- buf.insertInt(stopType);
-
- return buf;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CancelReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CancelReply.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CancelReply.java
deleted file mode 100644
index b3eb6f0..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CancelReply.java
+++ /dev/null
@@ -1,38 +0,0 @@
-// @@@ 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 CancelReply {
- odbc_Dcs_StopSrvr_exc_ m_p1_exception;
-
- // -------------------------------------------------------------
- CancelReply(LogicalByteArray buf, InterfaceConnection ic) throws SQLException, CharacterCodingException,
- UnsupportedCharsetException {
- buf.setLocation(Header.sizeOf());
-
- m_p1_exception = new odbc_Dcs_StopSrvr_exc_();
- m_p1_exception.extractFromByteArray(buf, ic);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Certificate.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Certificate.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Certificate.java
deleted file mode 100644
index eedc663..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Certificate.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/**********************************************************************
-// @@@ 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 @@@
- //
- **********************************************************************/
-/**
- * Certificate.java
- * This class get the x509 certificate from an input file and stores
- * the certificate in the m_cert member.
- */
-
-package org.trafodion.jdbc.t4;
-
-import java.security.cert.X509Certificate;
-import java.security.cert.CertificateFactory;
-import java.security.cert.CertificateException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.util.Date;
-import java.text.SimpleDateFormat;
-import java.util.TimeZone;
-
-public class Certificate
-{
- /**
- * Ctor - Gets certificate and the certificate's expiration
- * date from the certificate file.
- * @param certFile - the certificate file which stores the
- * public key.
- * @throws SecurityException
- */
- public Certificate(File certFile)
- throws SecurityException
- {
- InputStream inStream = null;
- try
- {
- inStream = new FileInputStream(certFile);
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- m_cert = (X509Certificate) cf.generateCertificate(inStream);
- // Get certificate expiration date
- Date expDate = m_cert.getNotAfter();
-
- SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmss");
- sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
- String fDate = sdf.format(expDate);
- m_certExpDate = fDate.getBytes();
- }
- catch (CertificateException cex)
- {
- throw new SecurityException(SecClientMsgKeys.FILE_CORRUPTION, new Object[]{certFile.getName()} );
- }
- catch (Exception ex)
- {
- // This should never happen
- throw new SecurityException(SecClientMsgKeys.FILE_NOTFOUND, new Object[]{certFile.getName()} );
- }
- finally
- {
- try
- {
- if (inStream != null) inStream.close();
- }
- catch (IOException io)
- {
- // Notmuch to do at this point
- }
- }
- }
-
- /**
- * returns the expiration date of the certificate
- * @return an array of byte representing the expiration
- * date of the certificate in the String format
- * "yyMMddHHmmss"
- */
- public byte[] getCertExpDate()
- {
- return m_certExpDate;
- }
-
- /**
- * @return the X509Certificate
- */
- public X509Certificate getCert()
- {
- return m_cert;
- }
-
- private X509Certificate m_cert;
- private byte[] m_certExpDate;
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Cipher.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Cipher.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Cipher.java
deleted file mode 100644
index 32c0ef9..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Cipher.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/**********************************************************************
-// @@@ 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 @@@
-//
-**********************************************************************/
-
-/**
- * class Cipher - Encrypts and decrypts data and password using
- * symmetric key and key pair
- *
- */
-
-package org.trafodion.jdbc.t4;
-
-import javax.crypto.spec.IvParameterSpec;
-import javax.crypto.SecretKey;
-
-
-
-public class Cipher
-{
- private static class Holder
- {
- private static Cipher instance = new Cipher();
- }
-
- /**
- *
- * @return Cipher
- */
- public static Cipher getInstance()
- {
- return Holder.instance;
- }
-
- /** Encrypts plain text and stores the
- * cipher text in cipherText using public key for password encryption.
- * @param plainText - plain text to be encrypted
- * @param cipherText - encrypted plain text is returned
- * @param key - password encryption: public key
- * @Return the length of the cipher text or -1 in case of error
- * @throws SecurityException
- */
- public int encrypt(byte[] plainText, byte[] cipherText,
- java.security.Key key) throws SecurityException
- {
- int len = 0;
-
- if (plainText == null)
- throw new SecurityException(SecClientMsgKeys.
- INPUT_PARAMETER_IS_NULL, new Object[]{"plainText"});
- if (cipherText == null)
- throw new SecurityException(SecClientMsgKeys.
- INPUT_PARAMETER_IS_NULL, new Object[]{"cipherText"});
- if (key == null)
- throw new SecurityException(SecClientMsgKeys.
- INPUT_PARAMETER_IS_NULL, new Object[]{"key"});
-
- try {
- // Obtain a RSA Cipher Object
- // RSA algorithm, ECB:Electronic Codebook Mode mode,
- // PKCS1Padding: PKCS1 padding
- javax.crypto.Cipher cipher = javax.crypto.Cipher.
- getInstance("RSA/ECB/PKCS1Padding");
- byte[] tmpCipherText;
- synchronized(cipher) {
- cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, key);
-
- tmpCipherText = cipher.doFinal(plainText);
- }
-
- System.arraycopy(tmpCipherText, 0, cipherText, 0, tmpCipherText.length);
-
- len = cipherText.length;
- }catch (Exception ex) {
- throw new SecurityException(SecClientMsgKeys.ENCRYPTION_FAILED, null);
- }
- return len;
- }
-
- public static javax.crypto.Cipher getEASInstance(String algorithm) throws SecurityException
- {
- if (algorithm == null)
- throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"algorithm"});
- try {
- // Obtain a AES Cipher Object
- // AES algorithm using a cryptographic key of 128 bits
- // to encrypt data in blocks of 128 bits,
- // CBC cipher mode, PKCS5Padding padding
-
- return javax.crypto.Cipher.getInstance("AES/CBC/PKCS5Padding");
- } catch (Exception ex) {
- throw new SecurityException(SecClientMsgKeys.ENCRYPTION_FAILED, null);
- }
- }
-
- /** Encrypts the plain text data message using "EAS256/CBC/PKCS7"
- * @param plainText - plain text to be encrypted
- * @param key - session key is used as secret key
- * @param iv - 16 lower bytes of the nonce is used as the initial vector.
- * Can't use the whole 32 bytes nonce because the IV size has
- * to be equal to the block size which is a Java requirement.
- * @Return the cipher text in byte
- * @throws SecurityException
- */
- public static byte[] encryptData(byte[] plainText, SecretKey key, byte[] iv,
- javax.crypto.Cipher cipher)
- throws SecurityException
- {
- if (plainText == null)
- throw new SecurityException(SecClientMsgKeys.
- INPUT_PARAMETER_IS_NULL, new Object[]{"plainText"});
- if (key == null)
- throw new SecurityException(SecClientMsgKeys.
- INPUT_PARAMETER_IS_NULL, new Object[]{"key"});
- if (iv == null)
- throw new SecurityException(SecClientMsgKeys.
- INPUT_PARAMETER_IS_NULL, new Object[]{"iv"});
-
- try {
- IvParameterSpec initialVector = new IvParameterSpec(iv);
-
- synchronized (cipher) {
- cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, key, initialVector);
-
- return cipher.doFinal(plainText);
- }
-
- }catch (Exception ex) {
- throw new SecurityException(SecClientMsgKeys.DATA_ENCRYPTION_FAILED, null);
- }
- }
-
- /** Decrypts cipherText and stores the
- * plain text in plainText using private key for password
- * decryption or symmetric key for data decryption
- *
- * @param cipherText cipher text to be decrypted
- * @param plainText decrypted cipher text is returned
- * @param key password decryption: private key
- * message encryption: session key
- * @param iv 8 sequence nonce is used as the initial vector for symmetric
- * key encryption. Null if is private key encryption
- * @return the length of the plain text or -1 in case of error
- * @throws SecurityException
- */
- public int decrypt(byte[] cipherText, byte[] plainText,
- java.security.Key key, byte[] iv) throws SecurityException
- {
- int len = 0;
- if (iv == null) //Private key decyption
- {
- if (plainText == null)
- throw new SecurityException(SecClientMsgKeys.
- INPUT_PARAMETER_IS_NULL, new Object[]{"plainText"});
- if (cipherText == null)
- throw new SecurityException(SecClientMsgKeys.
- INPUT_PARAMETER_IS_NULL, new Object[]{"cipherText"});
- if (key == null)
- throw new SecurityException(SecClientMsgKeys.
- INPUT_PARAMETER_IS_NULL, new Object[]{"key"});
- try {
- // Obtain a RSA Cipher Object
- // RSA algorithm, ECB:Electronic Code book Mode mode,
- // PKCS1Padding: PKCS1 padding
- javax.crypto.Cipher cipher = javax.crypto.Cipher.
- getInstance("RSA/ECB/PKCS1Padding");
- byte[] tmpPlainText ;
- synchronized (cipher) {
- cipher.init(javax.crypto.Cipher.DECRYPT_MODE, key);
- tmpPlainText = cipher.doFinal(cipherText);
- }
- System.arraycopy(tmpPlainText, 0, plainText, 0, tmpPlainText.length);
-
- len = plainText.length;
- }catch (Exception ex) {
- throw new SecurityException(SecClientMsgKeys.DECRYPTION_FAILED, null);
- }
- }
-
- return len;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CloseMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CloseMessage.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CloseMessage.java
deleted file mode 100644
index 30c23fe..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CloseMessage.java
+++ /dev/null
@@ -1,48 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class CloseMessage {
- // ----------------------------------------------------------
- static LogicalByteArray marshal(int dialogueId, String stmtLabel, short freeResourceOpt, InterfaceConnection ic)
- throws UnsupportedCharsetException, CharacterCodingException {
- int wlength = Header.sizeOf();
- LogicalByteArray buf;
-
- byte[] stmtLabelBytes = ic.encodeString(stmtLabel, InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- wlength += TRANSPORT.size_int; // dialogueId
- wlength += TRANSPORT.size_bytes(stmtLabelBytes);
- wlength += TRANSPORT.size_short; // freeResourceOpt
-
- buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
-
- buf.insertInt(dialogueId);
- buf.insertString(stmtLabelBytes);
- buf.insertShort(freeResourceOpt);
-
- return buf;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CloseReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CloseReply.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CloseReply.java
deleted file mode 100644
index 91bb2a7..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/CloseReply.java
+++ /dev/null
@@ -1,48 +0,0 @@
-// @@@ 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 CloseReply {
- odbc_SQLSvc_Close_exc_ m_p1;
- int m_p2;
- ERROR_DESC_LIST_def m_p3;
-
- // -------------------------------------------------------------
- CloseReply(LogicalByteArray buf, String addr, InterfaceConnection ic) throws CharacterCodingException,
- UnsupportedCharsetException, SQLException {
- buf.setLocation(Header.sizeOf());
-
- m_p1 = new odbc_SQLSvc_Close_exc_();
- m_p1.extractFromByteArray(buf, addr, ic);
-
- if (m_p1.exception_nr != TRANSPORT.CEE_SUCCESS) {
- m_p2 = buf.extractInt();
-
- m_p3 = new ERROR_DESC_LIST_def();
- m_p3.extractFromByteArray(buf, ic);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Compression.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Compression.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Compression.java
deleted file mode 100644
index bb2bb8f..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Compression.java
+++ /dev/null
@@ -1,149 +0,0 @@
-// @@@ 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;
-
-public class Compression {
- private static int MAXCOUNT = 0xFF;
- // private static int MAXUCOUNT = 0xFFFF;
- private static int EOFCHAR = -1;
-
-
-
- public static int compress(int alg, byte [][] sbuf, int [] sstart, int [] slen, byte[] dbuf, int dstart) {
- int ret = 0;
-
- switch(alg) {
- case 1:
- ret = compress_whitespace(sbuf, sstart, slen, dbuf, dstart);
- break;
- }
-
- return ret;
- }
-
- public static int uncompress(int alg, byte [] sbuf, int sstart, int slen, byte [] dbuf, int dstart) {
- int ret = 0;
-
- switch(alg) {
- case 1:
- ret = uncompress_whitespace(sbuf, sstart, slen, dbuf, dstart);
- break;
- }
-
- return ret;
- }
-
- // encodes repeated bytes in the byte form <b><b><#>
- // b = byte which is repeated
- // # = number of repetitions (max 255)
- // source buffers, source lengths, destination buffer
- private static int compress_whitespace(byte [][] param_sbuf, int [] param_sstart, int [] param_slen, byte[] dbuf, int dstart) {
- int c = EOFCHAR, p = EOFCHAR;
- int si = 0, di = dstart; // source, destination indexes
- int cnt = 0; // count of repetition
-
- byte []sbuf; //current source buffer
- int slen; //current source length
-
- for(int i=0;i<param_sbuf.length;i++) {
- sbuf = param_sbuf[i];
- slen = param_slen[i];
- si = param_sstart[i];
-
- while(si < slen) {
- c = sbuf[si++]; // get the next byte from source
- dbuf[di++] = (byte)c; // copy the byte to destination
- cnt = 0;
-
- if(c == p) { // check repetition
- if(si == slen) {
- c = EOFCHAR;
- }
- while(si < slen) {
- if ((c = sbuf[si++]) == p) { // found repetition
- cnt++;
- if (cnt == MAXCOUNT) { // we can only store 255 in
- // a byte
- dbuf[di++] = (byte)cnt;
-
- p = EOFCHAR; // move on
- break;
- }
- }
- else {
- dbuf[di++] = (byte)cnt;
- dbuf[di++] = (byte) c;
-
- p = c;
- break;
- }
-
- if (si == slen) {
- c = EOFCHAR;
- }
- }
- }
- else {
- p = c; // set our current as our previous
- }
-
- if (c == EOFCHAR) {
- dbuf[di++] = (byte)cnt;
- /*
- * ADDED
- */
- p = EOFCHAR;
- }
- }
- }
-
- return di - dstart;
- }
-
- private static int uncompress_whitespace(byte [] sbuf, int sstart, int slen, byte [] dbuf, int dstart) {
- int c = EOFCHAR, p = EOFCHAR;
- int si = sstart, di = dstart, i = 0; // source, dest, and generic indexes
- int cnt = 0;
-
- while(si < slen ) {
- c = sbuf[si++] & 0xFF;
-
- /*if(di >= dbuf.length) {
- System.out.println("%%%%%failed at " + di);
- }*/
- dbuf[di++] = (byte) c;
-
- if(c == p) {
- cnt = sbuf[si++] & 0xFF;
-
- for(i=0;i<cnt;++i) {
- dbuf[di++] = (byte)c;
- }
- p = EOFCHAR;
- }
- else {
- p = c;
- }
- }
-
- return di;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ConnectMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ConnectMessage.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ConnectMessage.java
deleted file mode 100644
index fd594d5..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ConnectMessage.java
+++ /dev/null
@@ -1,62 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class ConnectMessage {
- static LogicalByteArray marshal(CONNECTION_CONTEXT_def inContext, USER_DESC_def userDesc, int srvrType,
- short retryCount, int optionFlags1, int optionFlags2, String vproc, InterfaceConnection ic)
- throws CharacterCodingException, UnsupportedCharsetException {
- int wlength = Header.sizeOf();
- LogicalByteArray buf = null;
-
- byte[] vprocBytes = ic.encodeString(vproc, 1);
- byte[] clientUserBytes = ic.encodeString(System.getProperty("user.name"), 1);
-
- wlength += inContext.sizeOf(ic);
- wlength += userDesc.sizeOf(ic);
-
- wlength += TRANSPORT.size_int; // srvrType
- wlength += TRANSPORT.size_short; // retryCount
- wlength += TRANSPORT.size_int; // optionFlags1
- wlength += TRANSPORT.size_int; // optionFlags2
- wlength += TRANSPORT.size_bytes(vprocBytes);
-
- buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
-
- inContext.insertIntoByteArray(buf);
- userDesc.insertIntoByteArray(buf);
-
- buf.insertInt(srvrType);
- buf.insertShort(retryCount);
- buf.insertInt(optionFlags1);
- buf.insertInt(optionFlags2);
- buf.insertString(vprocBytes);
-
- //TODO: restructure all the flags and this new param
- buf.insertString(clientUserBytes);
-
- return buf;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ConnectReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ConnectReply.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ConnectReply.java
deleted file mode 100644
index f11b5d5..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ConnectReply.java
+++ /dev/null
@@ -1,148 +0,0 @@
-// @@@ 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 ConnectReply {
- odbc_Dcs_GetObjRefHdl_exc_ m_p1_exception;
- String m_p2_srvrObjRef;
- int m_p3_dialogueId;
- String m_p4_dataSource;
- byte[] m_p5_userSid;
- VERSION_LIST_def m_p6_versionList;
- int isoMapping;
- boolean byteSwap;
-
- boolean securityEnabled;
- int serverNode;
- int processId;
- byte [] timestamp;
- String clusterName;
-
- String serverHostName="";
- Integer serverNodeId=0;
- Integer serverProcessId=0;
- String serverProcessName="";
- String serverIpAddress="";
- Integer serverPort=0;
-
- String remoteHost;
- String remoteProcess;
-
- private NCSAddress m_ncsAddr_;
-
- // -------------------------------------------------------------
- ConnectReply(LogicalByteArray buf, InterfaceConnection ic) throws SQLException, UnsupportedCharsetException,
- CharacterCodingException {
- buf.setLocation(Header.sizeOf());
-
- m_p1_exception = new odbc_Dcs_GetObjRefHdl_exc_();
- m_p1_exception.extractFromByteArray(buf, ic);
-
- this.byteSwap = buf.getByteSwap();
-
- if (m_p1_exception.exception_nr == TRANSPORT.CEE_SUCCESS) {
- m_p3_dialogueId = buf.extractInt();
- m_p4_dataSource = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- m_p5_userSid = buf.extractByteString(); // byteString -- only place
- // used -- packed length
- // does not include the null
- // term
- m_p6_versionList = new VERSION_LIST_def();
-
- //buf.setByteSwap(false);
- m_p6_versionList.extractFromByteArray(buf);
- //buf.setByteSwap(this.byteSwap);
-
- buf.extractInt(); //old iso mapping
-
- /*if ((m_p6_versionList.list[0].buildId & InterfaceConnection.CHARSET) > 0) {
- isoMapping =
- } else {*/
- isoMapping = 15;
- //}
- serverHostName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- serverNodeId = buf.extractInt();
- serverProcessId = buf.extractInt();
- serverProcessName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- serverIpAddress = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- serverPort = buf.extractInt();
-
- m_p2_srvrObjRef = String.format("TCP:%s:%d.%s,%s/%d:ODBC", serverHostName, serverNodeId, serverProcessName, serverIpAddress, serverPort);
-
- if((m_p6_versionList.list[0].buildId & InterfaceConnection.PASSWORD_SECURITY) > 0) {
- securityEnabled = true;
- serverNode = serverNodeId;
- processId = serverProcessId;
- timestamp = buf.extractByteArray(8);
- clusterName = ic.decodeBytes(buf.extractString(), 1);
- }
- else {
- securityEnabled = false;
- }
- }
- }
-
- // -------------------------------------------------------------
- void fixupSrvrObjRef(T4Properties t4props, Locale locale, String name) throws SQLException {
- //
- // This method will replace the domain name returned from the
- // Association server, with a new name.
- //
- m_ncsAddr_ = null;
-
- if (m_p2_srvrObjRef != null) {
- remoteHost = m_p2_srvrObjRef.substring(4,m_p2_srvrObjRef.indexOf('$') - 1);
- remoteProcess = m_p2_srvrObjRef.substring(m_p2_srvrObjRef.indexOf('$'), m_p2_srvrObjRef.indexOf(','));
-
- try {
- m_ncsAddr_ = new NCSAddress(t4props, locale, m_p2_srvrObjRef);
- } catch (SQLException e) {
- throw e;
- }
-
- // use your best guess if m_machineName was not found
- if (m_ncsAddr_.m_machineName == null) {
- if (m_ncsAddr_.m_ipAddress == null) {
- m_ncsAddr_.m_machineName = name;
- } else {
- m_ncsAddr_.m_machineName = m_ncsAddr_.m_ipAddress;
- }
- }
-
- m_p2_srvrObjRef = m_ncsAddr_.recreateAddress();
- m_ncsAddr_.validateAddress();
- m_ncsAddr_.setInputOutput();
-
- return;
- } // end if
-
- } // end fixupSrvrObjRef
-
- NCSAddress getNCSAddress() {
- return m_ncsAddr_;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Descriptor2.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Descriptor2.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Descriptor2.java
deleted file mode 100644
index fd25f51..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Descriptor2.java
+++ /dev/null
@@ -1,85 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class Descriptor2 {
- int noNullValue_;
- int nullValue_;
- int version_;
- int dataType_;
- int datetimeCode_;
- int maxLen_;
- int precision_;
- int scale_;
- int nullInfo_;
- int signed_;
- int odbcDataType_;
- int odbcPrecision_;
- int sqlCharset_;
- int odbcCharset_;
- String colHeadingNm_;
- String tableName_;
- String catalogName_;
- String schemaName_;
- String headingName_;
- int intLeadPrec_;
- int paramMode_;
-
- private int rowLength;
-
- public void setRowLength(int len) {
- rowLength = len;
- }
-
- public int getRowLength() {
- return rowLength;
- }
-
- public Descriptor2(LogicalByteArray buf, InterfaceConnection ic) throws CharacterCodingException,
- UnsupportedCharsetException {
- noNullValue_ = buf.extractInt();
- nullValue_ = buf.extractInt();
- version_ = buf.extractInt();
- dataType_ = buf.extractInt();
- datetimeCode_ = buf.extractInt();
- maxLen_ = buf.extractInt();
- precision_ = buf.extractInt();
- scale_ = buf.extractInt();
- nullInfo_ = buf.extractInt();
- signed_ = buf.extractInt();
- odbcDataType_ = buf.extractInt();
- odbcPrecision_ = buf.extractInt();
- sqlCharset_ = buf.extractInt();
- odbcCharset_ = buf.extractInt();
-
- colHeadingNm_ = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- tableName_ = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- catalogName_ = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- schemaName_ = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- headingName_ = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- intLeadPrec_ = buf.extractInt();
- paramMode_ = buf.extractInt();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ERROR_DESC_LIST_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ERROR_DESC_LIST_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ERROR_DESC_LIST_def.java
deleted file mode 100644
index 039fae3..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ERROR_DESC_LIST_def.java
+++ /dev/null
@@ -1,42 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class ERROR_DESC_LIST_def {
- int length;
- ERROR_DESC_def[] buffer;
-
- // ----------------------------------------------------------
- void extractFromByteArray(LogicalByteArray buf, InterfaceConnection ic) throws CharacterCodingException,
- UnsupportedCharsetException {
- length = buf.extractInt();
- buffer = new ERROR_DESC_def[length];
-
- for (int i = 0; i < length; i++) {
- buffer[i] = new ERROR_DESC_def();
- buffer[i].extractFromByteArray(buf, ic);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ERROR_DESC_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ERROR_DESC_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ERROR_DESC_def.java
deleted file mode 100644
index 48ebba2..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ERROR_DESC_def.java
+++ /dev/null
@@ -1,65 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class ERROR_DESC_def {
- int rowId;
- int errorDiagnosticId;
- int sqlcode;
- String sqlstate;
- String errorText;
- int operationAbortId;
- int errorCodeType;
- String Param1;
- String Param2;
- String Param3;
- String Param4;
- String Param5;
- String Param6;
- String Param7;
-
- // ----------------------------------------------------------
- void extractFromByteArray(LogicalByteArray buffer1, InterfaceConnection ic) throws CharacterCodingException,
- UnsupportedCharsetException {
- rowId = buffer1.extractInt();
- errorDiagnosticId = buffer1.extractInt();
- sqlcode = buffer1.extractInt();
-
- // Note, SQLSTATE is logically 5 bytes, but ODBC uses 6 bytes for some
- // reason.
- sqlstate = ic.decodeBytes(buffer1.extractByteArray(6), 1);
- errorText = ic.decodeBytes(buffer1.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- operationAbortId = buffer1.extractInt();
- errorCodeType = buffer1.extractInt();
- Param1 = ic.decodeBytes(buffer1.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- Param2 = ic.decodeBytes(buffer1.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- Param3 = ic.decodeBytes(buffer1.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- Param4 = ic.decodeBytes(buffer1.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- Param5 = ic.decodeBytes(buffer1.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- Param6 = ic.decodeBytes(buffer1.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- Param7 = ic.decodeBytes(buffer1.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/EndTransactionMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/EndTransactionMessage.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/EndTransactionMessage.java
deleted file mode 100644
index 98a60d4..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/EndTransactionMessage.java
+++ /dev/null
@@ -1,49 +0,0 @@
-// @@@ 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 EndTransactionMessage {
- int m_dialogueId;
- short m_transactionOpt;
-
- // ----------------------------------------------------------
- EndTransactionMessage(int dialogueId, short transactionOpt) {
- m_dialogueId = dialogueId;
- m_transactionOpt = transactionOpt;
- }
-
- // ----------------------------------------------------------
- static LogicalByteArray marshal(int dialogueId, short transactionOpt, InterfaceConnection ic) {
- int wlength = Header.sizeOf();
- LogicalByteArray buf;
-
- wlength += TRANSPORT.size_int; // dialogueId
- wlength += TRANSPORT.size_short; // transactionOpt
-
- buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
-
- buf.insertInt(dialogueId);
- buf.insertShort(transactionOpt);
-
- return buf;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/EndTransactionReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/EndTransactionReply.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/EndTransactionReply.java
deleted file mode 100644
index b85ce2f..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/EndTransactionReply.java
+++ /dev/null
@@ -1,49 +0,0 @@
-// @@@ 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 EndTransactionReply {
- odbc_SQLSvc_EndTransaction_exc_ m_p1;
- ERROR_DESC_LIST_def m_p2;
-
- // -------------------------------------------------------------
- EndTransactionReply(LogicalByteArray buf, String addr, InterfaceConnection ic) throws CharacterCodingException,
- UnsupportedCharsetException, SQLException {
- buf.setLocation(Header.sizeOf());
-
- m_p1 = new odbc_SQLSvc_EndTransaction_exc_();
- m_p1.extractFromByteArray(buf, addr, ic);
-
- if (m_p1.exception_nr != TRANSPORT.CEE_SUCCESS) {
- int totalLen = buf.extractInt();
-
- if(totalLen > 0) {
- m_p2 = new ERROR_DESC_LIST_def();
- m_p2.extractFromByteArray(buf, ic);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ExecuteMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ExecuteMessage.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ExecuteMessage.java
deleted file mode 100644
index 2911bf9..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ExecuteMessage.java
+++ /dev/null
@@ -1,107 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class ExecuteMessage {
- // ----------------------------------------------------------
- static LogicalByteArray marshal(int dialogueId, int sqlAsyncEnable, int queryTimeout, int inputRowCnt,
- int maxRowsetSize, int sqlStmtType, int stmtHandle, int stmtType, String sqlString, int sqlStringCharset,
- String cursorName, int cursorNameCharset, String stmtLabel, int stmtLabelCharset, String stmtExplainLabel,
- SQL_DataValue_def inputDataValue, SQLValueList_def inputValueList, byte[] txId, boolean isUserBuffer,
- InterfaceConnection ic
-
- ) throws CharacterCodingException, UnsupportedCharsetException
-
- {
- int wlength = Header.sizeOf();
- LogicalByteArray buf;
-
- byte[] sqlStringBytes = ic.encodeString(sqlString, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] cursorNameBytes = ic.encodeString(cursorName, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] stmtLabelBytes = ic.encodeString(stmtLabel, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] stmtExplainLabelBytes = ic.encodeString(stmtExplainLabel, InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- wlength += TRANSPORT.size_int; // dialogueId
- wlength += TRANSPORT.size_int; // sqlAsyncEnable
- wlength += TRANSPORT.size_int; // queryTimeout
- wlength += TRANSPORT.size_int; // inputRowCnt
- wlength += TRANSPORT.size_int; // maxRowsetSize
- wlength += TRANSPORT.size_int; // sqlStmtType
- wlength += TRANSPORT.size_int; // stmtHandle
- wlength += TRANSPORT.size_int; // stmtType
- wlength += TRANSPORT.size_bytesWithCharset(sqlStringBytes); // +sqlStringCharset
- wlength += TRANSPORT.size_bytesWithCharset(cursorNameBytes); // +cursorNameCharset
- wlength += TRANSPORT.size_bytesWithCharset(stmtLabelBytes); // +stmtLabelCharset
- wlength += TRANSPORT.size_bytes(stmtExplainLabelBytes);
-
- if (!isUserBuffer) {
- wlength += inputDataValue.sizeof();
- wlength += TRANSPORT.size_bytes(txId); // transId
- }
- buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
-
- buf.insertInt(dialogueId);
- buf.insertInt(sqlAsyncEnable);
- buf.insertInt(queryTimeout);
- buf.insertInt(inputRowCnt);
- buf.insertInt(maxRowsetSize);
- buf.insertInt(sqlStmtType);
- buf.insertInt(stmtHandle);
- buf.insertInt(stmtType);
- buf.insertStringWithCharset(sqlStringBytes, sqlStringCharset);
- buf.insertStringWithCharset(cursorNameBytes, cursorNameCharset);
- buf.insertStringWithCharset(stmtLabelBytes, stmtLabelCharset);
- buf.insertString(stmtExplainLabelBytes);
-
- if (isUserBuffer) {
- buf.setDataBuffer(inputDataValue.userBuffer);
-
- byte[] trailer = null;
- if (txId == null || txId.length == 0) {
- trailer = new byte[4];
- for (int i = 0; i < 4; ++i) {
- trailer[i] = (byte) 0;
- }
- } else {
- int len = txId.length + 1;
- trailer = new byte[4 + txId.length + 1];
-
- trailer[0] = (byte) ((len >>> 24) & 0xff);
- trailer[1] = (byte) ((len >>> 16) & 0xff);
- trailer[2] = (byte) ((len >>> 8) & 0xff);
- trailer[3] = (byte) ((len) & 0xff);
- System.arraycopy(txId, 0, trailer, 4, txId.length);
- trailer[len + 4 - 1] = '\0';
- }
-
- buf.setTrailer(trailer);
- } else {
- inputDataValue.insertIntoByteArray(buf);
- buf.insertString(txId);
- }
-
- return buf;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ExecuteReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ExecuteReply.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ExecuteReply.java
deleted file mode 100644
index 664c71f..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/ExecuteReply.java
+++ /dev/null
@@ -1,127 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class ExecuteReply {
- int returnCode;
- int totalErrorLength;
- SQLWarningOrError[] errorList;
- long rowsAffected;
- int queryType;
- int estimatedCost;
- byte[] outValues;
-
- int numResultSets;
- Descriptor2[][] outputDesc;
- String stmtLabels[];
-
- int outputParamLength;
- int outputNumberParams;
-
- String[] proxySyntax;
-
- // ----------------------------------------------------------
- ExecuteReply(LogicalByteArray buf, InterfaceConnection ic) throws CharacterCodingException,
- UnsupportedCharsetException {
-
- buf.setLocation(Header.sizeOf());
-
- returnCode = buf.extractInt();
-
- totalErrorLength = buf.extractInt();
-
- if (totalErrorLength > 0) {
- errorList = new SQLWarningOrError[buf.extractInt()];
- for (int i = 0; i < errorList.length; i++) {
- errorList[i] = new SQLWarningOrError(buf, ic, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- }
- }
-
- int outputDescLength = buf.extractInt();
- if (outputDescLength > 0) {
- outputDesc = new Descriptor2[1][];
-
- outputParamLength = buf.extractInt();
- outputNumberParams = buf.extractInt();
-
- outputDesc[0] = new Descriptor2[outputNumberParams];
- for (int i = 0; i < outputNumberParams; i++) {
- outputDesc[0][i] = new Descriptor2(buf, ic);
- outputDesc[0][i].setRowLength(outputParamLength);
- }
- }
- rowsAffected = buf.extractUnsignedInt();
- queryType = buf.extractInt();
- estimatedCost = buf.extractInt();
-
- // 64 bit rowsAffected
- // this is a horrible hack because we cannot change the protocol yet
- // rowsAffected should be made a regular 64 bit value when possible
- rowsAffected |= ((long) estimatedCost) << 32;
-
- outValues = buf.extractByteArray();
-
- numResultSets = buf.extractInt();
-
- if (numResultSets > 0) {
- outputDesc = new Descriptor2[numResultSets][];
- stmtLabels = new String[numResultSets];
- proxySyntax = new String[numResultSets];
-
- for (int i = 0; i < numResultSets; i++) {
- buf.extractInt(); // int stmt_handle
-
- stmtLabels[i] = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- buf.extractInt(); // long stmt_label_charset
- outputDescLength = buf.extractInt();
-
- int outputParamsLength = 0;
- int outputNumberParams = 0;
- Descriptor2[] outputParams = null;
-
- if (outputDescLength > 0) {
- outputParamsLength = buf.extractInt();
- outputNumberParams = buf.extractInt();
-
- outputParams = new Descriptor2[outputNumberParams];
- for (int j = 0; j < outputNumberParams; j++) {
- outputParams[j] = new Descriptor2(buf, ic);
- outputParams[j].setRowLength(outputParamsLength);
- }
- }
- outputDesc[i] = outputParams;
- proxySyntax[i] = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- }
- }
-
- String singleSyntax = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- if (proxySyntax == null) {
- proxySyntax = new String[1];
- proxySyntax[0] = singleSyntax;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/FetchMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/FetchMessage.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/FetchMessage.java
deleted file mode 100644
index 0f7d702..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/FetchMessage.java
+++ /dev/null
@@ -1,63 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class FetchMessage {
- // ----------------------------------------------------------
- static LogicalByteArray marshal(int dialogueId, int sqlAsyncEnable, int queryTimeout, int stmtHandle,
- String stmtLabel, int stmtCharset, int maxRowCnt, int maxRowLen, String cursorName, int cursorCharset,
- String stmtOptions, InterfaceConnection ic) throws CharacterCodingException, UnsupportedCharsetException {
- int wlength = Header.sizeOf();
- LogicalByteArray buf;
-
- byte[] stmtLabelBytes = ic.encodeString(stmtLabel, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] cursorNameBytes = ic.encodeString(cursorName, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] stmtOptionsBytes = ic.encodeString(stmtOptions, InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- wlength += TRANSPORT.size_int; // dialogueId
- wlength += TRANSPORT.size_int; // sqlAsyncEnable
- wlength += TRANSPORT.size_int; // queryTimeout
- wlength += TRANSPORT.size_int; // stmtHandle
- wlength += TRANSPORT.size_bytesWithCharset(stmtLabelBytes);
- wlength += TRANSPORT.size_long; // maxRowCnt
- wlength += TRANSPORT.size_long; // maxRowLen
- wlength += TRANSPORT.size_bytesWithCharset(cursorNameBytes);
- wlength += TRANSPORT.size_bytes(stmtOptionsBytes);
-
- buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
-
- buf.insertInt(dialogueId);
- buf.insertInt(sqlAsyncEnable);
- buf.insertInt(queryTimeout);
- buf.insertInt(stmtHandle);
- buf.insertStringWithCharset(stmtLabelBytes, stmtCharset);
- buf.insertLong(maxRowCnt);
- buf.insertLong(maxRowLen);
- buf.insertStringWithCharset(cursorNameBytes, cursorCharset);
- buf.insertString(stmtOptionsBytes);
-
- return buf;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/FetchReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/FetchReply.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/FetchReply.java
deleted file mode 100644
index 5e82439..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/FetchReply.java
+++ /dev/null
@@ -1,63 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class FetchReply {
- int returnCode;
- int totalErrorLength;
- SQLWarningOrError[] errorList;
- int rowsAffected;
- int outValuesFormat;
- byte[] outValues;
-
- // -------------------------------------------------------------
- public FetchReply(LogicalByteArray buf, InterfaceConnection ic) throws CharacterCodingException,
- UnsupportedCharsetException {
- buf.setLocation(Header.sizeOf());
-
- returnCode = buf.extractInt();
-
- if (returnCode != TRANSPORT.SQL_SUCCESS && returnCode != TRANSPORT.NO_DATA_FOUND) {
- totalErrorLength = buf.extractInt();
- if (totalErrorLength > 0) {
- errorList = new SQLWarningOrError[buf.extractInt()];
- for (int i = 0; i < errorList.length; i++) {
- errorList[i] = new SQLWarningOrError(buf, ic, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- }
- }
- }
-
- if (errorList == null) {
- errorList = new SQLWarningOrError[0];
- }
-
- rowsAffected = buf.extractInt();
- outValuesFormat = buf.extractInt();
-
- if (returnCode == TRANSPORT.SQL_SUCCESS || returnCode == TRANSPORT.SQL_SUCCESS_WITH_INFO) {
- outValues = buf.extractByteArray();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/GenericMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/GenericMessage.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/GenericMessage.java
deleted file mode 100644
index 3558872..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/GenericMessage.java
+++ /dev/null
@@ -1,45 +0,0 @@
-// @@@ 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;
-
-class GenericMessage {
- // ----------------------------------------------------------
- static LogicalByteArray marshal(Locale locale, byte[] messageBuffer, InterfaceConnection ic) throws SQLException
-
- {
- int wlength = Header.sizeOf();
- LogicalByteArray buf;
-
- if (messageBuffer != null)
- wlength += messageBuffer.length;
- buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
- if (messageBuffer != null)
- buf.insertByteArray(messageBuffer, messageBuffer.length);
-
- return buf;
- } // end marshal
-
-} // end class GenericMessage
-
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/GenericReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/GenericReply.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/GenericReply.java
deleted file mode 100644
index 1aa2e8e..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/GenericReply.java
+++ /dev/null
@@ -1,43 +0,0 @@
-// @@@ 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;
-
-class GenericReply {
- byte[] replyBuffer;
-
- // ----------------------------------------------------------
- GenericReply(Locale locale, LogicalByteArray buf) throws SQLException {
- Header header = new Header();
- long bufferLength = 0;
-
- buf.setLocation(0);
- header.extractFromByteArray(buf);
- buf.setLocation(Header.sizeOf());
- bufferLength = header.total_length_;
- replyBuffer = buf.extractByteArray(bufferLength);
-
- } // end marshal
-
-} // end class GenericReply
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/GetSQLCatalogsMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/GetSQLCatalogsMessage.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/GetSQLCatalogsMessage.java
deleted file mode 100644
index 17296f6..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/GetSQLCatalogsMessage.java
+++ /dev/null
@@ -1,88 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class GetSQLCatalogsMessage {
- static LogicalByteArray marshal(int dialogueId, String stmtLabel, short APIType, String catalogNm, String schemaNm,
- String tableNm, String tableTypeList, String columnNm, int columnType, int rowIdScope, int nullable,
- int uniqueness, int accuracy, short sqlType, int metadataId, String fkCatalogNm, String fkSchemaNm,
- String fkTableNm, InterfaceConnection ic) throws CharacterCodingException, UnsupportedCharsetException {
- int wlength = Header.sizeOf();
- LogicalByteArray buf;
-
- byte[] stmtLabelBytes = ic.encodeString(stmtLabel, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] catalogNmBytes = ic.encodeString(catalogNm, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] schemaNmBytes = ic.encodeString(schemaNm, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] tableNmBytes = ic.encodeString(tableNm, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] tableTypeListBytes = ic.encodeString(tableTypeList, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] columnNmBytes = ic.encodeString(columnNm, InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- byte[] fkCatalogNmBytes = ic.encodeString(fkCatalogNm, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] fkSchemaNmBytes = ic.encodeString(fkSchemaNm, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] fkTableNmBytes = ic.encodeString(fkTableNm, InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- wlength += TRANSPORT.size_int; // dialogueId
- wlength += TRANSPORT.size_bytes(stmtLabelBytes);
- wlength += TRANSPORT.size_short; // APIType
- wlength += TRANSPORT.size_bytes(catalogNmBytes, true);
- wlength += TRANSPORT.size_bytes(schemaNmBytes, true);
- wlength += TRANSPORT.size_bytes(tableNmBytes, true);
- wlength += TRANSPORT.size_bytes(tableTypeListBytes, true);
- wlength += TRANSPORT.size_bytes(columnNmBytes, true);
- wlength += TRANSPORT.size_int; // columnType
- wlength += TRANSPORT.size_int; // rowIdScope
- wlength += TRANSPORT.size_int; // nullable
- wlength += TRANSPORT.size_int; // uniqueness
- wlength += TRANSPORT.size_int; // accuracy
- wlength += TRANSPORT.size_short; // sqlType
- wlength += TRANSPORT.size_int; // metadataId
- wlength += TRANSPORT.size_bytes(fkCatalogNmBytes, true);
- wlength += TRANSPORT.size_bytes(fkSchemaNmBytes, true);
- wlength += TRANSPORT.size_bytes(fkTableNmBytes, true);
-
- buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
-
- buf.insertInt(dialogueId);
- buf.insertString(stmtLabelBytes);
- buf.insertShort(APIType);
- buf.insertString(catalogNmBytes, true);
- buf.insertString(schemaNmBytes, true);
- buf.insertString(tableNmBytes, true);
- buf.insertString(tableTypeListBytes, true);
- buf.insertString(columnNmBytes, true);
- buf.insertInt(columnType);
- buf.insertInt(rowIdScope);
- buf.insertInt(nullable);
- buf.insertInt(uniqueness);
- buf.insertInt(accuracy);
- buf.insertShort(sqlType);
- buf.insertInt(metadataId);
- buf.insertString(fkCatalogNmBytes, true);
- buf.insertString(fkSchemaNmBytes, true);
- buf.insertString(fkTableNmBytes, true);
-
- return buf;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/GetSQLCatalogsReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/GetSQLCatalogsReply.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/GetSQLCatalogsReply.java
deleted file mode 100644
index 9736d47..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/GetSQLCatalogsReply.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// @@@ 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 GetSQLCatalogsReply {
- odbc_SQLSvc_GetSQLCatalogs_exc_ m_p1;
- String m_p2;
- SQLItemDescList_def m_p3;
- ERROR_DESC_LIST_def m_p4;
- String proxySyntax = "";
-
- // -------------------------------------------------------------
- GetSQLCatalogsReply(LogicalByteArray buf, String addr, InterfaceConnection ic) throws CharacterCodingException,
- UnsupportedCharsetException, SQLException {
- buf.setLocation(Header.sizeOf());
-
- m_p1 = new odbc_SQLSvc_GetSQLCatalogs_exc_();
- m_p1.extractFromByteArray(buf, addr, ic);
-
- if (m_p1.exception_nr == TRANSPORT.CEE_SUCCESS) {
- m_p2 = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- m_p3 = new SQLItemDescList_def(buf, true, ic);
-
- m_p4 = new ERROR_DESC_LIST_def();
- m_p4.extractFromByteArray(buf, ic);
-
- proxySyntax = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- }
- }
-}
[46/60] incubator-trafodion git commit: Additional jdbcT4 changes in
other components
Posted by db...@apache.org.
Additional jdbcT4 changes in other components
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/3253e723
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/3253e723
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/3253e723
Branch: refs/heads/master
Commit: 3253e7231f7d01a444643069d2ac7fd7cd1912b2
Parents: a0f21cd
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Fri Apr 22 00:17:06 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Fri Apr 22 00:17:06 2016 +0000
----------------------------------------------------------------------
core/Makefile | 2 +-
core/conn/trafci/build.xml | 4 ++--
core/conn/trafci/utils/trafci_install.sh | 2 +-
core/sqf/sql/scripts/install_traf_components | 8 ++++----
dcs/src/test/jdbc_test/jdbc_test.py | 4 ++--
tests/phx/phoenix_test.py | 5 ++---
6 files changed, 12 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3253e723/core/Makefile
----------------------------------------------------------------------
diff --git a/core/Makefile b/core/Makefile
index 6c4b865..89740c9 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -141,7 +141,7 @@ pkg-sql-regress: all
cd sqf && $(MAKE) package-regress 2>&1 | sed -e "s/$$/ ##(Package sql regress)/";exit $${PIPESTATUS[0]}
# Package Phoenix test
-pkg-phx-tests: all
+pkg-phx-tests:
cd sqf && $(MAKE) package-phx 2>&1 | sed -e "s/$$/ ##(Package phoenix)/";exit $${PIPESTATUS[0]}
# Package dcs tests
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3253e723/core/conn/trafci/build.xml
----------------------------------------------------------------------
diff --git a/core/conn/trafci/build.xml b/core/conn/trafci/build.xml
index 62f2b25..50030e2 100644
--- a/core/conn/trafci/build.xml
+++ b/core/conn/trafci/build.xml
@@ -32,9 +32,10 @@
</exec>
<property file="buildId"/>
+ <property environment="my_env"/>
<property name="source.version" value="1.7" />
<property id="base.dir" name="base.dir" value="."/>
- <property name="jdbcT4" value="${base.dir}/../../sqf/export/lib/jdbcT4.jar"/>
+ <property name="jdbcT4" value="${base.dir}/../../sqf/export/lib/jdbcT4-${my_env.TRAFODION_VER}.jar"/>
<property name="platform-install.dir" value="${base.dir}/../../sqf/trafci"/>
<property name="temp.dir" value="${base.dir}/temp"/>
<property name="tempsrc.dir" value="${temp.dir}/src"/>
@@ -64,7 +65,6 @@
<property name="tar.file" value="trafci.tar" />
<property name="installer.zipfile" value="trafci.zip" />
<property name="vproc.version" value="TrafCI_Build_${bldId}"/>
- <property environment="my_env"/>
<target name="ProductVersion">
<echo>
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3253e723/core/conn/trafci/utils/trafci_install.sh
----------------------------------------------------------------------
diff --git a/core/conn/trafci/utils/trafci_install.sh b/core/conn/trafci/utils/trafci_install.sh
index 81192f8..76fc152 100644
--- a/core/conn/trafci/utils/trafci_install.sh
+++ b/core/conn/trafci/utils/trafci_install.sh
@@ -39,7 +39,7 @@ EXPORTLIBDIR=$MY_SQROOT/export/lib
CP=/bin/cp
TEMPSRC=../temp
-sed 's/\#\#TRAFCI_CLASSPATH\#\#/\${MY_SQROOT}\/export\/lib\/jdbcT4.jar:\${MY_SQROOT}\/trafci\/lib\/trafci.jar/g' trafci.sh > lnxplatform.sh
+sed 's/\#\#TRAFCI_CLASSPATH\#\#/\${MY_SQROOT}\/export\/lib\/jdbcT4-${TRAFODION_VER}.jar:\${MY_SQROOT}\/trafci\/lib\/trafci.jar/g' trafci.sh > lnxplatform.sh
mv -f lnxplatform.sh $TEMPSRC/trafci.sh
echo "Creating trafci install folder in $MY_SQROOT "
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3253e723/core/sqf/sql/scripts/install_traf_components
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/install_traf_components b/core/sqf/sql/scripts/install_traf_components
index a84f026..921de71 100755
--- a/core/sqf/sql/scripts/install_traf_components
+++ b/core/sqf/sql/scripts/install_traf_components
@@ -110,7 +110,7 @@ else
elif [[ -d $DCS_SRC ]]; then
echo "DCS tar file was not found in $TRAF_TARS" | tee -a ${MY_LOG_FILE}
echo "Building DCS tar file" | tee -a ${MY_LOG_FILE}
- if [[ -f $MY_SQROOT/export/lib/jdbcT4.jar ]]; then
+ if [[ -f $MY_SQROOT/export/lib/jdbcT4-${TRAFODION_VER}.jar ]]; then
echo "JDBCT4 jar file exist. Proceeding to build DCS from $DCS_SRC" | tee -a ${MY_LOG_FILE}
cd $DCS_SRC
${MAVEN:-mvn} clean site package >>${MY_LOG_FILE} 2>&1
@@ -193,7 +193,7 @@ else
elif [[ -d $REST_SRC ]]; then
echo "REST tar file was not found in $TRAF_TARS" | tee -a ${MY_LOG_FILE}
echo "Building REST tar file" | tee -a ${MY_LOG_FILE}
- if [[ -f $MY_SQROOT/export/lib/jdbcT4.jar ]]; then
+ if [[ -f $MY_SQROOT/export/lib/jdbcT4-${TRAFODION_VER}.jar ]]; then
echo "JDBCT4 jar file exist. Proceeding to build REST from $REST_SRC" | tee -a ${MY_LOG_FILE}
cd $REST_SRC
${MAVEN:-mvn} clean site package >>${MY_LOG_FILE} 2>&1
@@ -329,7 +329,7 @@ cd $PHXDIR
if [[ \$1 == "t4" ]]
then
./phoenix_test.py --target=localhost:$MY_DCS_MASTER_PORT --user=dontcare --pw=dontcare \\
- --targettype=TR --javahome=\$JAVA_HOME --jdbccp=\$MY_SQROOT/export/lib/jdbcT4.jar
+ --targettype=TR --javahome=\$JAVA_HOME --jdbccp=\$MY_SQROOT/export/lib/jdbcT4-${TRAFODION_VER}.jar
elif [[ \$1 == "t2" ]]
then
export LD_PRELOAD=\$JAVA_HOME/jre/lib/amd64/libjsig.so:\$MY_SQROOT/export/lib\$SQ_MBTYPE/libseabasesig.so
@@ -494,7 +494,7 @@ else
cd $JDBCTEST_DIR
./jdbc_test.py --appid=jdbc_test --user=SOMEUSER --pw=SOMEPASSWORD --javahome=\$JAVA_HOME \\
--target=localhost:$MY_DCS_MASTER_PORT --dbmaj=\$TRAFODION_VER_MAJOR --dbmin=\$TRAFODION_VER_MINOR \\
- --jdbctype=T4 --jdbccp=\$MY_SQROOT/export/lib/jdbcT4.jar "\$@"
+ --jdbctype=T4 --jdbccp=\$MY_SQROOT/export/lib/jdbcT4-${TRAFODION_VER}.jar "\$@"
EOF
chmod +x $MY_SQROOT/sql/scripts/swjdbc
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3253e723/dcs/src/test/jdbc_test/jdbc_test.py
----------------------------------------------------------------------
diff --git a/dcs/src/test/jdbc_test/jdbc_test.py b/dcs/src/test/jdbc_test/jdbc_test.py
index 4835c3d..743f767 100755
--- a/dcs/src/test/jdbc_test/jdbc_test.py
+++ b/dcs/src/test/jdbc_test/jdbc_test.py
@@ -203,7 +203,7 @@ def prog_parse_args():
info = inspect.getframeinfo(frame)
gvars.my_ROOT = os.path.dirname(os.path.abspath(info.filename))
- DEFAULT_JDBC_CLASSPATH = '${project.basedir}/lib/jdbcT4.jar'
+ DEFAULT_JDBC_CLASSPATH = '${project.basedir}/lib/jdbcT4-${TRAFODION_VER}.jar'
DEFAULT_PROP_FILE = os.path.join(gvars.my_ROOT, 'jdbcprop')
# alas, the more powerful argparse module only exists in >= 2.7 and >= 3.2,
@@ -241,7 +241,7 @@ def prog_parse_args():
help='java program (version 1.7 required) location, defaulted to \'/usr\''),
optparse.make_option('', '--jdbccp', action='store', type='string',
dest='jdbccp', default=DEFAULT_JDBC_CLASSPATH,
- help='jdbc classpath, defaulted to \'${project.basedir}/lib/jdbcT4.jar\', <test_root> is where this program is.'),
+ help='jdbc classpath, defaulted to \'${project.basedir}/lib/jdbcT4-${TRAFODION_VER}.jar\', <test_root> is where this program is.'),
optparse.make_option('', '--propfile', action='store', type='string',
dest='propfile', default=DEFAULT_PROP_FILE,
help='property file, defaulted to automatically generated \'<test root>/jdbcprop\', <test root> is where this program is.'),
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3253e723/tests/phx/phoenix_test.py
----------------------------------------------------------------------
diff --git a/tests/phx/phoenix_test.py b/tests/phx/phoenix_test.py
index e7a5ff2..d4c288f 100755
--- a/tests/phx/phoenix_test.py
+++ b/tests/phx/phoenix_test.py
@@ -429,9 +429,8 @@ def prog_parse_args():
frame = rec[0]
info = inspect.getframeinfo(frame)
gvars.my_ROOT = os.path.dirname(os.path.abspath(info.filename))
-
DEFAULT_RESULTS_DIR = os.path.join(gvars.my_ROOT, 'results')
- DEFAULT_JDBC_CLASSPATH = '${project.basedir}/lib/jdbcT4.jar'
+ DEFAULT_JDBC_CLASSPATH = '${project.basedir}/lib/jdbcT4-${TRAFODION_VER}.jar'
DEFAULT_PROP_FILE = os.path.join(gvars.my_ROOT, 'jdbcprop')
# alas, the more powerful argparse module only exists in >= 2.7 and >= 3.2,
@@ -469,7 +468,7 @@ def prog_parse_args():
optparse.make_option('', '--jdbccp', action='store', type='string',
dest='jdbccp', default=DEFAULT_JDBC_CLASSPATH,
help="jdbc classpath, defaulted to " +
- "'${project.basedir}/lib/jdbcT4.jar', \t\t "
+ "'${project.basedir}/lib/jdbcT4-${TRAFODION_VER}.jar', \t\t "
"<test_root> is where this program is"),
optparse.make_option('', '--resultdir', action='store', type='string',
dest='resultdir', default=DEFAULT_RESULTS_DIR,
[39/60] incubator-trafodion git commit: including the missing files
in previous commit
Posted by db...@apache.org.
including the missing files in previous commit
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/500d2076
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/500d2076
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/500d2076
Branch: refs/heads/master
Commit: 500d20767fad083cc0fda1c1ef9d895b295ed412
Parents: 5ac5a9f
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Mon Apr 18 16:35:58 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Mon Apr 18 16:35:58 2016 +0000
----------------------------------------------------------------------
core/conn/jdbcT4/.gitignore | 2 +
core/conn/jdbcT4/Makefile | 38 +
core/conn/jdbcT4/pom.xml | 170 ++++
core/conn/jdbcT4/src/assembly/all.xml | 56 ++
.../CallableStatementSample.java | 83 ++
.../CallableStatementSample/IntegerSPJ.java | 28 +
.../main/samples/CallableStatementSample/README | 42 +
.../main/samples/DBMetaSample/DBMetaSample.java | 132 +++
.../jdbcT4/src/main/samples/DBMetaSample/README | 904 +++++++++++++++++++
.../PreparedStatementSample.java | 151 ++++
.../main/samples/PreparedStatementSample/README | 232 +++++
core/conn/jdbcT4/src/main/samples/README | 47 +
.../src/main/samples/ResultSetSample/README | 91 ++
.../ResultSetSample/ResultSetSample.java | 104 +++
.../src/main/samples/StatementSample/README | 92 ++
.../StatementSample/StatementSample.java | 104 +++
.../src/main/samples/common/sampleUtils.java | 268 ++++++
.../jdbcT4/src/main/samples/t4jdbc.properties | 26 +
.../java/org/trafodion/jdbc/t4/AppTest.java | 38 +
19 files changed, 2608 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/.gitignore
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/.gitignore b/core/conn/jdbcT4/.gitignore
new file mode 100644
index 0000000..6d90c7e
--- /dev/null
+++ b/core/conn/jdbcT4/.gitignore
@@ -0,0 +1,2 @@
+/target/
+build_jdbct4.log
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/Makefile
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/Makefile b/core/conn/jdbcT4/Makefile
new file mode 100644
index 0000000..b6c23d7
--- /dev/null
+++ b/core/conn/jdbcT4/Makefile
@@ -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 @@@
+
+# This Makefile is just a thin shell to Maven, which is used to do the real build
+
+include ../../macros.gmk #top level
+
+all: build_all
+
+build_all:
+ echo "$(MAVEN) package -DskipTests"
+ set -o pipefail && $(MAVEN) package -DskipTests | tee build_jdbct4.log | grep --line-buffered -E -e '^\[[^WId]' -e '^\[INFO\] B[Uu][Ii][Ll][Dd]' -e 'to compile'
+ cp target/jdbcT4-${TRAFODION_VER}.jar ${MY_SQROOT}/export/lib/jdbcT4.jar
+ mkdir -p ../clients
+ mv target/jdbcT4-${TRAFODION_VER}.zip ../clients
+
+
+clean:
+ -$(MAVEN) clean | grep ERROR
+ $(RM) build_jdbct4.log ${MY_SQROOT}/export/lib/jdbcT4.jar
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/pom.xml
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/pom.xml b/core/conn/jdbcT4/pom.xml
new file mode 100644
index 0000000..e46ffd5
--- /dev/null
+++ b/core/conn/jdbcT4/pom.xml
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+<!--
+ @@@ 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 @@@
+-->
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.trafodion.jdbc.t4</groupId>
+ <artifactId>jdbcT4</artifactId>
+ <packaging>jar</packaging>
+ <version>${env.TRAFODION_VER}</version>
+ <name>Trafodion JDBC Type4 Driver</name>
+ <url>http://wiki.trafodion.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ <includes>
+ <include> **/*.properties</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <configuration>
+ <tasks>
+ <copy file="src/main/java/org/trafodion/jdbc/t4/Vproc.java-tmpl" tofile="src/main/java/org/trafodion/jdbc/t4/Vproc.java"/>
+ <replace token= "@@@@"
+ value="Traf_JDBC_Type4_Build_${mvngit.commit.abbrev}"
+ file="src/main/java/org/trafodion/jdbc/t4/Vproc.java">
+ </replace>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.github.koraktor</groupId>
+ <artifactId>mavanagaiata</artifactId>
+ <version>0.7.2</version>
+ <configuration>
+ <dirtyFlag>false</dirtyFlag>
+ <dirtyIgnoreUntracked>false</dirtyIgnoreUntracked>
+ <gitDir>${project.base.dir}/../../../../.git</gitDir>
+ <dateFormat>ddMMMyyyy</dateFormat>
+ </configuration>
+ <executions>
+ <execution>
+ <id>git-commit</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>commit</goal>
+ <goal>branch</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.trafodion.jdbc.t4.Vproc</mainClass>
+ <classpathPrefix>dependency-jars/</classpathPrefix>
+ </manifest>
+ <manifestEntries>
+ <!-- <Implementation-Version-1>${TRAFODION_VER_PROD}</Implementation-Version-1> -->
+ <Implementation-Version-1>Version ${project.version}</Implementation-Version-1>
+ <Implementation-Version-2>Release ${project.version}</Implementation-Version-2>
+ <Implementation-Version-3>Build release</Implementation-Version-3>
+ <Implementation-Version-4>[${user.name}]</Implementation-Version-4>
+ <Implementation-Version-5>branch ${mvngit.commit.abbrev}-${mvngit.branch}</Implementation-Version-5>
+ <Implementation-Version-6>date ${maven.build.timestamp}</Implementation-Version-6>
+ <Product-Name>${project.name}</Product-Name>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.5.3</version>
+ <configuration>
+ <descriptor>src/assembly/all.xml</descriptor>
+ <appendAssemblyId>false</appendAssemblyId>
+ </configuration>
+ <executions>
+ <execution>
+ <id>create-archive</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.5.1</version>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>
+ ${project.build.directory}/dependency-jars/
+ </outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <properties>
+ <maven.build.timestamp.format>ddMMMyy</maven.build.timestamp.format>
+ <buildDate>${maven.build.timestamp}</buildDate>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/src/assembly/all.xml
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/assembly/all.xml b/core/conn/jdbcT4/src/assembly/all.xml
new file mode 100644
index 0000000..5358510
--- /dev/null
+++ b/core/conn/jdbcT4/src/assembly/all.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 http://maven.apache.org/xsd/assembly-1.1.1.xsd">
+
+<!--
+ @@@ 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 @@@
+-->
+ <!--This 'all' id is not appended to the produced bundle because we do this:
+ http://maven.apache.org/plugins/maven-assembly-plugin/faq.html#required-classifiers
+ -->
+ <id>all</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <fileSets>
+ <fileSet>
+ <includes>
+ <include>${project.basedir}/NOTICE</include>
+ <include>${project.basedir}/LICENSE</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory>lib</outputDirectory>
+ <includes>
+ <include>*.jar</include>
+ </includes>
+ <fileMode>0644</fileMode>
+ <directoryMode>0755</directoryMode>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/samples</directory>
+ <outputDirectory>samples</outputDirectory>
+ <fileMode>0644</fileMode>
+ <directoryMode>0755</directoryMode>
+ </fileSet>
+ </fileSets>
+</assembly>
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/src/main/samples/CallableStatementSample/CallableStatementSample.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/samples/CallableStatementSample/CallableStatementSample.java b/core/conn/jdbcT4/src/main/samples/CallableStatementSample/CallableStatementSample.java
new file mode 100755
index 0000000..d96864d
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/samples/CallableStatementSample/CallableStatementSample.java
@@ -0,0 +1,83 @@
+// @@@ 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 @@@
+import common.*;
+
+import java.sql.*;
+public class CallableStatementSample
+{
+ public static void main(String args[]) throws Exception
+ {
+ try
+ {
+ Connection conn = sampleUtils.getPropertiesConnection();
+ Statement stmt = conn.createStatement();
+
+ try
+ {
+ String st = "drop procedure CallableStatementSample";
+ try {
+ stmt.executeUpdate(st);
+ } catch (Exception e) {}
+
+ st = "drop library qaspj";
+ try {
+ stmt.executeUpdate(st);
+ } catch (Exception e) {}
+
+
+ String path = System.getProperty("serverJarPath");
+
+ st = "create library qaspj file '" + path + "/qaspj.jar'";
+ stmt.executeUpdate(st);
+
+ st = "create procedure CallableStatementSample(out OUT_PARAM INTEGER) EXTERNAL NAME 'IntegerSPJ.Integer_Proc(int[])' LANGUAGE JAVA PARAMETER STYLE JAVA NO ISOLATE LIBRARY QASPJ";
+ stmt.executeUpdate(st);
+ stmt.close();
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace();
+ System.exit(0);
+ }
+
+
+ // get the CallableStatement object
+ CallableStatement cstmt = conn.prepareCall("{call CallableStatementSample(?)}");
+ //System.out.println("The Callable Statement " + cstmt);
+
+ //register the output parameters
+ cstmt.registerOutParameter(1, java.sql.Types.VARCHAR);
+
+ //execute the procedure
+ cstmt.execute();
+
+ //invoke getInt method
+ int nRetVal = cstmt.getInt(1);
+
+ System.out.println("Out parameter is " + cstmt.getInt(1));
+ }
+ catch(Exception ex)
+ {
+ System.err.println("Unexpected Exception" + ex.getMessage());
+ throw new Exception("Call to getWarnings is Failed!");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/src/main/samples/CallableStatementSample/IntegerSPJ.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/samples/CallableStatementSample/IntegerSPJ.java b/core/conn/jdbcT4/src/main/samples/CallableStatementSample/IntegerSPJ.java
new file mode 100755
index 0000000..1b64ee9
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/samples/CallableStatementSample/IntegerSPJ.java
@@ -0,0 +1,28 @@
+// @@@ 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 @@@
+public class IntegerSPJ
+{
+ public static void Integer_Proc (int[] out_param)
+ {
+
+ out_param[0] = 100;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/src/main/samples/CallableStatementSample/README
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/samples/CallableStatementSample/README b/core/conn/jdbcT4/src/main/samples/CallableStatementSample/README
new file mode 100755
index 0000000..3fdfa2b
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/samples/CallableStatementSample/README
@@ -0,0 +1,42 @@
+This sample demonstrates the invocation of a stored procedure in Java (SPJ).
+
+
+Statement
+===========================================
+ "/tmp" is a server-side path where the SPJ jar files are located.
+
+
+Generate the jar file by running build.xml, which is located in the samples directory.
+===========================================
+ ant build.xml
+
+Copy the jar file to the system where your instance is running.
+===========================================
+ cp samples/target/qaspj.jar /tmp
+Note:
+ 1.The sample will create and drop the SPJ via the CREATE/DROP PROCEDURE statement by indirectly using qaspj.jar.
+ 2.The jar file must be copied to all nodes in a cluster environment.
+
+Compiling the Java files
+===========================================
+ On Windows Platform:
+ cd samples\CallableStatementSample
+ %JAVA_HOME%\bin\javac -classpath ..\..\lib\jdbcT4.jar *.java ..\common\*.java
+ On Linux:
+ cd samples/CallableStatementSample
+ $JAVA_HOME/bin/javac -classpath ../../lib/jdbcT4.jar *.java ../common/*.java
+Note: Make sure there are no compilation errors displayed on the screen.
+
+Executing CallableStatementSample
+===========================================
+ On Windows Platform:
+ cd samples\CallableStatementSample
+ %JAVA_HOME%\bin\java -classpath ..\..\lib\jdbcT4.jar;..;. -Dt4jdbc.properties=..\t4jdbc.properties -DserverJarPath=/tmp CallableStatementSample
+ On Linux:
+ cd samples/CallableStatementSample
+ $JAVA_HOME/bin/java -classpath ../../lib/jdbcT4.jar:..:. -Dt4jdbc.properties=../t4jdbc.properties -DserverJarPath=/tmp CallableStatementSample
+
+ A successful execution of the sample will produce output similar to the following:
+ <DATE, TIME> common.sampleUtils getPropertiesConnection
+ INFO: DriverManager.getConnection(url, props) passed
+ Out parameter is 100
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/src/main/samples/DBMetaSample/DBMetaSample.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/samples/DBMetaSample/DBMetaSample.java b/core/conn/jdbcT4/src/main/samples/DBMetaSample/DBMetaSample.java
new file mode 100755
index 0000000..8f0a2b7
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/samples/DBMetaSample/DBMetaSample.java
@@ -0,0 +1,132 @@
+// @@@ 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 @@@
+import common.*;
+
+import java.sql.*;
+import java.math.BigDecimal;
+
+public class DBMetaSample
+{
+ public static void main(String args[])
+ {
+
+ Connection connection;
+ Statement stmt;
+ PreparedStatement pStmt;
+ ResultSet rs;
+ DatabaseMetaData dbMeta;
+ int rowNo;
+ String table = "DBMETASAMPLE";
+
+ try
+ {
+ connection = sampleUtils.getPropertiesConnection();
+ sampleUtils.dropTable(connection, table);
+ sampleUtils.initialData(connection, table);
+ sampleUtils.initialCurrentData(connection, table);
+
+
+ System.out.println("");
+
+
+ for (int i = 0; i < 6; i++)
+ {
+ switch (i)
+ {
+ case 0:
+ System.out.println("");
+ System.out.println("getTypeInfo() ");
+ dbMeta = connection.getMetaData();
+ rs = dbMeta.getTypeInfo();
+ break;
+ case 2:
+ System.out.println("");
+ System.out.println("getCatalogs()");
+ dbMeta = connection.getMetaData();
+ rs = dbMeta.getCatalogs();
+ break;
+ case 3:
+ System.out.println("");
+ System.out.println("getTables() ");
+ dbMeta = connection.getMetaData();
+ rs = dbMeta.getTables(connection.getCatalog(), sampleUtils.props.getProperty("schema"), "DBMETASAMPLE", null);
+ break;
+ case 4:
+ System.out.println("");
+ System.out.println("getColumns()");
+ dbMeta = connection.getMetaData();
+ rs = dbMeta.getColumns(connection.getCatalog(), sampleUtils.props.getProperty("schema"), "DBMETASAMPLE", "C1");
+ break;
+ case 5:
+ System.out.println("");
+ System.out.println("getProcedures()");
+ dbMeta = connection.getMetaData();
+ rs = dbMeta.getProcedures(connection.getCatalog(), sampleUtils.props.getProperty("schema"), "Integer_Proc");
+ break;
+ default:
+ rs = null;
+ continue;
+ }
+
+ ResultSetMetaData rsMD = rs.getMetaData();
+ System.out.println("");
+ System.out.println("Printing ResultSetMetaData ...");
+ System.out.println("No. of Columns " + rsMD.getColumnCount());
+ for (int j = 1; j <= rsMD.getColumnCount(); j++)
+ {
+ System.out.println("Column " + j + " Data Type: " + rsMD.getColumnTypeName(j) + " Name: " + rsMD.getColumnName(j));
+ }
+ System.out.println("");
+ System.out.println("Fetching rows...");
+ rowNo = 0;
+ while (rs.next())
+ {
+ rowNo++;
+ System.out.println("");
+ System.out.println("Printing Row " + rowNo + " using getString(), getObject()");
+ for (int j=1; j <= rsMD.getColumnCount(); j++)
+ {
+ System.out.println("Column " + j + " - " + rs.getString(j) + "," + rs.getObject(j));
+ }
+
+ }
+ System.out.println("");
+ System.out.println("End of Data");
+ rs.close();
+ }
+
+ sampleUtils.dropTable(connection, table);
+ connection.close();
+ }
+ catch (SQLException e)
+ {
+ SQLException nextException;
+
+ nextException = e;
+ do
+ {
+ System.out.println(nextException.getMessage());
+ System.out.println("SQLState " + nextException.getSQLState());
+ System.out.println("Error Code " + nextException.getErrorCode());
+ } while ((nextException = nextException.getNextException()) != null);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/src/main/samples/DBMetaSample/README
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/samples/DBMetaSample/README b/core/conn/jdbcT4/src/main/samples/DBMetaSample/README
new file mode 100755
index 0000000..77dc3a3
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/samples/DBMetaSample/README
@@ -0,0 +1,904 @@
+Compiling the Java files
+========================
+On Windows Platform:
+%JAVA_HOME%\bin\javac -classpath ..\..\lib\jdbcT4.jar *.java ..\common\*.java
+
+On Linux:
+$JAVA_HOME/bin/javac -classpath ../../lib/jdbcT4.jar *.java ../common/*.java
+
+Note: Make sure there are no compilation errors displayed on
+ the screen.
+
+
+Executing DBMetaSample
+======================
+On Windows Platform:
+%JAVA_HOME%\bin\java -classpath ..\..\lib\jdbcT4.jar;..;. -Dt4jdbc.properties=..\t4jdbc.properties DBMetaSample
+
+On Linux:
+$JAVA_HOME/bin/java -classpath ../../lib/jdbcT4.jar:..:. -Dt4jdbc.properties=../t4jdbc.properties DBMetaSample
+
+
+Output of the execution would look like:
+========================================
+<DATE, TIME> common.sampleUtils getPropertiesConnection
+INFO: DriverManager.getConnection(url, props) passed
+
+Inserting TimeStamp
+
+INFO: DriverManager.getConnection(url, props) passed
+
+Inserting TimeStamp
+
+
+getTypeInfo()
+
+Printing ResultSetMetaData ...
+No. of Columns 19
+Column 1 Data Type: VARCHAR Name: TYPE_NAME
+Column 2 Data Type: SMALLINT Name: DATA_TYPE
+Column 3 Data Type: INTEGER Name: PRECISION
+Column 4 Data Type: VARCHAR Name: LITERAL_PREFIX
+Column 5 Data Type: VARCHAR Name: LITERAL_SUFFIX
+Column 6 Data Type: VARCHAR Name: CREATE_PARAMS
+Column 7 Data Type: SMALLINT Name: NULLABLE
+Column 8 Data Type: SMALLINT Name: CASE_SENSITIVE
+Column 9 Data Type: SMALLINT Name: SEARCHABLE
+Column 10 Data Type: SMALLINT Name: UNSIGNED_ATTRIBUTE
+Column 11 Data Type: SMALLINT Name: FIXED_PREC_SCALE
+Column 12 Data Type: SMALLINT Name: AUTO_INCREMENT
+Column 13 Data Type: VARCHAR Name: LOCAL_TYPE_NAME
+Column 14 Data Type: SMALLINT Name: MINIMUM_SCALE
+Column 15 Data Type: SMALLINT Name: MAXIMUM_SCALE
+Column 16 Data Type: SMALLINT Name: SQL_DATA_TYPE
+Column 17 Data Type: SMALLINT Name: SQL_DATETIME_SUB
+Column 18 Data Type: SMALLINT Name: NUM_PREC_RADIX
+Column 19 Data Type: SMALLINT Name: INTERVAL_PRECISION
+
+Fetching rows...
+
+Printing Row 1 using getString(), getObject()
+Column 1 - BIGINT,BIGINT
+Column 2 - -5,-5
+Column 3 - 19,19
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - LARGEINT,LARGEINT
+Column 14 - null,null
+Column 15 - null,null
+Column 16 - -402,-402
+Column 17 - null,null
+Column 18 - 10,10
+Column 19 - null,null
+
+Printing Row 2 using getString(), getObject()
+Column 1 - BIGINT SIGNED,BIGINT SIGNED
+Column 2 - -5,-5
+Column 3 - 19,19
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - LARGEINT,LARGEINT
+Column 14 - null,null
+Column 15 - null,null
+Column 16 - -402,-402
+Column 17 - null,null
+Column 18 - 10,10
+Column 19 - null,null
+
+Printing Row 3 using getString(), getObject()
+Column 1 - CHAR,CHAR
+Column 2 - 1,1
+Column 3 - 32000,32000
+Column 4 - ','
+Column 5 - ','
+Column 6 - max length,max length
+Column 7 - 1,1
+Column 8 - 1,1
+Column 9 - 3,3
+Column 10 - null,null
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - CHARACTER,CHARACTER
+Column 14 - null,null
+Column 15 - null,null
+Column 16 - 1,1
+Column 17 - null,null
+Column 18 - null,null
+Column 19 - null,null
+
+Printing Row 4 using getString(), getObject()
+Column 1 - NUMERIC,NUMERIC
+Column 2 - 2,2
+Column 3 - 128,128
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - precision,scale,precision,scale
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - NUMERIC,NUMERIC
+Column 14 - 0,0
+Column 15 - 128,128
+Column 16 - 2,2
+Column 17 - null,null
+Column 18 - 10,10
+Column 19 - null,null
+
+Printing Row 5 using getString(), getObject()
+Column 1 - NUMERIC SIGNED,NUMERIC SIGNED
+Column 2 - 2,2
+Column 3 - 128,128
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - precision,scale,precision,scale
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - NUMERIC,NUMERIC
+Column 14 - 0,0
+Column 15 - 128,128
+Column 16 - 2,2
+Column 17 - null,null
+Column 18 - 10,10
+Column 19 - null,null
+
+Printing Row 6 using getString(), getObject()
+Column 1 - NUMERIC UNSIGNED,NUMERIC UNSIGNED
+Column 2 - 2,2
+Column 3 - 128,128
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - precision,scale,precision,scale
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 1,1
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - NUMERIC,NUMERIC
+Column 14 - 0,0
+Column 15 - 128,128
+Column 16 - 2,2
+Column 17 - null,null
+Column 18 - 10,10
+Column 19 - null,null
+
+Printing Row 7 using getString(), getObject()
+Column 1 - DECIMAL,DECIMAL
+Column 2 - 3,3
+Column 3 - 18,18
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - precision,scale,precision,scale
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - DECIMAL,DECIMAL
+Column 14 - 0,0
+Column 15 - 18,18
+Column 16 - 3,3
+Column 17 - null,null
+Column 18 - 10,10
+Column 19 - null,null
+
+Printing Row 8 using getString(), getObject()
+Column 1 - DECIMAL SIGNED,DECIMAL SIGNED
+Column 2 - 3,3
+Column 3 - 18,18
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - precision,scale,precision,scale
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - DECIMAL,DECIMAL
+Column 14 - 0,0
+Column 15 - 18,18
+Column 16 - 3,3
+Column 17 - null,null
+Column 18 - 10,10
+Column 19 - null,null
+
+Printing Row 9 using getString(), getObject()
+Column 1 - DECIMAL UNSIGNED,DECIMAL UNSIGNED
+Column 2 - 3,3
+Column 3 - 18,18
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - precision,scale,precision,scale
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 1,1
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - DECIMAL,DECIMAL
+Column 14 - 0,0
+Column 15 - 18,18
+Column 16 - -301,-301
+Column 17 - null,null
+Column 18 - 10,10
+Column 19 - null,null
+
+Printing Row 10 using getString(), getObject()
+Column 1 - INTEGER,INTEGER
+Column 2 - 4,4
+Column 3 - 10,10
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - INTEGER,INTEGER
+Column 14 - null,null
+Column 15 - null,null
+Column 16 - 4,4
+Column 17 - null,null
+Column 18 - 10,10
+Column 19 - null,null
+
+Printing Row 11 using getString(), getObject()
+Column 1 - INTEGER SIGNED,INTEGER SIGNED
+Column 2 - 4,4
+Column 3 - 10,10
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - INTEGER,INTEGER
+Column 14 - null,null
+Column 15 - null,null
+Column 16 - 4,4
+Column 17 - null,null
+Column 18 - 10,10
+Column 19 - null,null
+
+Printing Row 12 using getString(), getObject()
+Column 1 - INTEGER UNSIGNED,INTEGER UNSIGNED
+Column 2 - 4,4
+Column 3 - 10,10
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 1,1
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - INTEGER,INTEGER
+Column 14 - null,null
+Column 15 - null,null
+Column 16 - -401,-401
+Column 17 - null,null
+Column 18 - 10,10
+Column 19 - null,null
+
+Printing Row 13 using getString(), getObject()
+Column 1 - SMALLINT,SMALLINT
+Column 2 - 5,5
+Column 3 - 5,5
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - SMALLINT,SMALLINT
+Column 14 - null,null
+Column 15 - null,null
+Column 16 - 5,5
+Column 17 - null,null
+Column 18 - 10,10
+Column 19 - null,null
+
+Printing Row 14 using getString(), getObject()
+Column 1 - SMALLINT SIGNED,SMALLINT SIGNED
+Column 2 - 5,5
+Column 3 - 5,5
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - SMALLINT,SMALLINT
+Column 14 - null,null
+Column 15 - null,null
+Column 16 - 5,5
+Column 17 - null,null
+Column 18 - 10,10
+Column 19 - null,null
+
+Printing Row 15 using getString(), getObject()
+Column 1 - SMALLINT UNSIGNED,SMALLINT UNSIGNED
+Column 2 - 5,5
+Column 3 - 5,5
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 1,1
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - SMALLINT,SMALLINT
+Column 14 - null,null
+Column 15 - null,null
+Column 16 - -502,-502
+Column 17 - null,null
+Column 18 - 10,10
+Column 19 - null,null
+
+Printing Row 16 using getString(), getObject()
+Column 1 - FLOAT,FLOAT
+Column 2 - 6,6
+Column 3 - 15,15
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - FLOAT,FLOAT
+Column 14 - null,null
+Column 15 - null,null
+Column 16 - 6,6
+Column 17 - null,null
+Column 18 - 2,2
+Column 19 - null,null
+
+Printing Row 17 using getString(), getObject()
+Column 1 - REAL,REAL
+Column 2 - 7,7
+Column 3 - 7,7
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - REAL,REAL
+Column 14 - null,null
+Column 15 - null,null
+Column 16 - 7,7
+Column 17 - null,null
+Column 18 - 2,2
+Column 19 - null,null
+
+Printing Row 18 using getString(), getObject()
+Column 1 - DOUBLE PRECISION,DOUBLE PRECISION
+Column 2 - 8,8
+Column 3 - 15,15
+Column 4 - null,null
+Column 5 - null,null
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - 0,0
+Column 13 - DOUBLE,DOUBLE
+Column 14 - null,null
+Column 15 - null,null
+Column 16 - 8,8
+Column 17 - null,null
+Column 18 - 2,2
+Column 19 - null,null
+
+Printing Row 19 using getString(), getObject()
+Column 1 - VARCHAR,VARCHAR
+Column 2 - 12,12
+Column 3 - 32000,32000
+Column 4 - ','
+Column 5 - ','
+Column 6 - max length,max length
+Column 7 - 1,1
+Column 8 - 1,1
+Column 9 - 3,3
+Column 10 - null,null
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - VARCHAR,VARCHAR
+Column 14 - null,null
+Column 15 - null,null
+Column 16 - 12,12
+Column 17 - null,null
+Column 18 - null,null
+Column 19 - null,null
+
+Printing Row 20 using getString(), getObject()
+Column 1 - DATE,DATE
+Column 2 - 91,91
+Column 3 - 10,10
+Column 4 - {d ',{d '
+Column 5 - '},'}
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - null,null
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - DATE,DATE
+Column 14 - null,null
+Column 15 - null,null
+Column 16 - 9,9
+Column 17 - 1,1
+Column 18 - null,null
+Column 19 - null,null
+
+Printing Row 21 using getString(), getObject()
+Column 1 - TIME,TIME
+Column 2 - 92,92
+Column 3 - 8,8
+Column 4 - {t ',{t '
+Column 5 - '},'}
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - null,null
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - TIME,TIME
+Column 14 - null,null
+Column 15 - null,null
+Column 16 - 9,9
+Column 17 - 2,2
+Column 18 - null,null
+Column 19 - null,null
+
+Printing Row 22 using getString(), getObject()
+Column 1 - TIMESTAMP,TIMESTAMP
+Column 2 - 93,93
+Column 3 - 26,26
+Column 4 - {ts ',{ts '
+Column 5 - '},'}
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - null,null
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - TIMESTAMP,TIMESTAMP
+Column 14 - 0,0
+Column 15 - 6,6
+Column 16 - 9,9
+Column 17 - 3,3
+Column 18 - null,null
+Column 19 - null,null
+
+Printing Row 23 using getString(), getObject()
+Column 1 - INTERVAL,INTERVAL
+Column 2 - 101,101
+Column 3 - 0,0
+Column 4 - {INTERVAL ',{INTERVAL '
+Column 5 - ' YEAR},' YEAR}
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - INTERVAL,INTERVAL
+Column 14 - 0,0
+Column 15 - 0,0
+Column 16 - 100,100
+Column 17 - 1,1
+Column 18 - null,null
+Column 19 - 2,2
+
+Printing Row 24 using getString(), getObject()
+Column 1 - INTERVAL,INTERVAL
+Column 2 - 102,102
+Column 3 - 0,0
+Column 4 - {INTERVAL ',{INTERVAL '
+Column 5 - ' MONTH},' MONTH}
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - INTERVAL,INTERVAL
+Column 14 - 0,0
+Column 15 - 0,0
+Column 16 - 100,100
+Column 17 - 2,2
+Column 18 - null,null
+Column 19 - 2,2
+
+Printing Row 25 using getString(), getObject()
+Column 1 - INTERVAL,INTERVAL
+Column 2 - 103,103
+Column 3 - 0,0
+Column 4 - {INTERVAL ',{INTERVAL '
+Column 5 - ' DAY},' DAY}
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - INTERVAL,INTERVAL
+Column 14 - 0,0
+Column 15 - 0,0
+Column 16 - 100,100
+Column 17 - 3,3
+Column 18 - null,null
+Column 19 - 2,2
+
+Printing Row 26 using getString(), getObject()
+Column 1 - INTERVAL,INTERVAL
+Column 2 - 104,104
+Column 3 - 0,0
+Column 4 - {INTERVAL ',{INTERVAL '
+Column 5 - ' HOUR},' HOUR}
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - INTERVAL,INTERVAL
+Column 14 - 0,0
+Column 15 - 0,0
+Column 16 - 100,100
+Column 17 - 4,4
+Column 18 - null,null
+Column 19 - 2,2
+
+Printing Row 27 using getString(), getObject()
+Column 1 - INTERVAL,INTERVAL
+Column 2 - 105,105
+Column 3 - 0,0
+Column 4 - {INTERVAL ',{INTERVAL '
+Column 5 - ' MINUTE},' MINUTE}
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - INTERVAL,INTERVAL
+Column 14 - 0,0
+Column 15 - 0,0
+Column 16 - 100,100
+Column 17 - 5,5
+Column 18 - null,null
+Column 19 - 2,2
+
+Printing Row 28 using getString(), getObject()
+Column 1 - INTERVAL,INTERVAL
+Column 2 - 106,106
+Column 3 - 0,0
+Column 4 - {INTERVAL ',{INTERVAL '
+Column 5 - ' SECOND},' SECOND}
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - INTERVAL,INTERVAL
+Column 14 - 0,0
+Column 15 - 0,0
+Column 16 - 100,100
+Column 17 - 6,6
+Column 18 - null,null
+Column 19 - 2,2
+
+Printing Row 29 using getString(), getObject()
+Column 1 - INTERVAL,INTERVAL
+Column 2 - 107,107
+Column 3 - 0,0
+Column 4 - {INTERVAL ',{INTERVAL '
+Column 5 - ' YEAR TO MONTH},' YEAR TO MONTH}
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - INTERVAL,INTERVAL
+Column 14 - 0,0
+Column 15 - 0,0
+Column 16 - 100,100
+Column 17 - 7,7
+Column 18 - null,null
+Column 19 - 2,2
+
+Printing Row 30 using getString(), getObject()
+Column 1 - INTERVAL,INTERVAL
+Column 2 - 108,108
+Column 3 - 0,0
+Column 4 - {INTERVAL ',{INTERVAL '
+Column 5 - ' DAY TO HOUR},' DAY TO HOUR}
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - INTERVAL,INTERVAL
+Column 14 - 0,0
+Column 15 - 0,0
+Column 16 - 100,100
+Column 17 - 8,8
+Column 18 - null,null
+Column 19 - 2,2
+
+Printing Row 31 using getString(), getObject()
+Column 1 - INTERVAL,INTERVAL
+Column 2 - 109,109
+Column 3 - 0,0
+Column 4 - {INTERVAL ',{INTERVAL '
+Column 5 - ' DAY TO MINUTE},' DAY TO MINUTE}
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - INTERVAL,INTERVAL
+Column 14 - 0,0
+Column 15 - 0,0
+Column 16 - 100,100
+Column 17 - 9,9
+Column 18 - null,null
+Column 19 - 2,2
+
+Printing Row 32 using getString(), getObject()
+Column 1 - INTERVAL,INTERVAL
+Column 2 - 110,110
+Column 3 - 0,0
+Column 4 - {INTERVAL ',{INTERVAL '
+Column 5 - ' DAY TO SECOND},' DAY TO SECOND}
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - INTERVAL,INTERVAL
+Column 14 - 0,0
+Column 15 - 0,0
+Column 16 - 100,100
+Column 17 - 10,10
+Column 18 - null,null
+Column 19 - 2,2
+
+Printing Row 33 using getString(), getObject()
+Column 1 - INTERVAL,INTERVAL
+Column 2 - 111,111
+Column 3 - 0,0
+Column 4 - {INTERVAL ',{INTERVAL '
+Column 5 - ' HOUR TO MINUTE},' HOUR TO MINUTE}
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - INTERVAL,INTERVAL
+Column 14 - 0,0
+Column 15 - 0,0
+Column 16 - 100,100
+Column 17 - 11,11
+Column 18 - null,null
+Column 19 - 2,2
+
+Printing Row 34 using getString(), getObject()
+Column 1 - INTERVAL,INTERVAL
+Column 2 - 112,112
+Column 3 - 0,0
+Column 4 - {INTERVAL ',{INTERVAL '
+Column 5 - ' HOUR TO SECOND},' HOUR TO SECOND}
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - INTERVAL,INTERVAL
+Column 14 - 0,0
+Column 15 - 0,0
+Column 16 - 100,100
+Column 17 - 12,12
+Column 18 - null,null
+Column 19 - 2,2
+
+Printing Row 35 using getString(), getObject()
+Column 1 - INTERVAL,INTERVAL
+Column 2 - 113,113
+Column 3 - 0,0
+Column 4 - {INTERVAL ',{INTERVAL '
+Column 5 - ' MINUTE TO SECOND},' MINUTE TO SECOND}
+Column 6 - null,null
+Column 7 - 1,1
+Column 8 - 0,0
+Column 9 - 2,2
+Column 10 - 0,0
+Column 11 - 0,0
+Column 12 - null,null
+Column 13 - INTERVAL,INTERVAL
+Column 14 - 0,0
+Column 15 - 0,0
+Column 16 - 100,100
+Column 17 - 13,13
+Column 18 - null,null
+Column 19 - 2,2
+
+End of Data
+
+getCatalogs()
+
+Printing ResultSetMetaData ...
+No. of Columns 1
+Column 1 Data Type: VARCHAR Name: TABLE_CAT
+
+Fetching rows...
+
+Printing Row 1 using getString(), getObject()
+Column 1 - TRAFODION,TRAFODION
+
+End of Data
+
+getTables()
+
+Printing ResultSetMetaData ...
+No. of Columns 10
+Column 1 Data Type: VARCHAR Name: TABLE_CAT
+Column 2 Data Type: VARCHAR Name: TABLE_SCHEM
+Column 3 Data Type: VARCHAR Name: TABLE_NAME
+Column 4 Data Type: VARCHAR Name: TABLE_TYPE
+Column 5 Data Type: VARCHAR Name: REMARKS
+Column 6 Data Type: VARCHAR Name: TYPE_CAT
+Column 7 Data Type: VARCHAR Name: TYPE_SCHEM
+Column 8 Data Type: VARCHAR Name: TYPE_NAME
+Column 9 Data Type: VARCHAR Name: SELF_REFERENCING_COL_NAME
+Column 10 Data Type: VARCHAR Name: REF_GENERATION
+
+Fetching rows...
+
+Printing Row 1 using getString(), getObject()
+Column 1 - TRAFODION,TRAFODION
+Column 2 - SEABASE,SEABASE
+Column 3 - DBMETASAMPLE,DBMETASAMPLE
+Column 4 - TABLE,TABLE
+Column 5 - null,null
+Column 6 - null,null
+Column 7 - null,null
+Column 8 - null,null
+Column 9 - null,null
+Column 10 - null,null
+
+End of Data
+
+getColumns()
+
+Printing ResultSetMetaData ...
+No. of Columns 18
+Column 1 Data Type: VARCHAR Name: TABLE_CAT
+Column 2 Data Type: VARCHAR Name: TABLE_SCHEM
+Column 3 Data Type: VARCHAR Name: TABLE_NAME
+Column 4 Data Type: VARCHAR Name: COLUMN_NAME
+Column 5 Data Type: SMALLINT Name: DATA_TYPE
+Column 6 Data Type: VARCHAR Name: TYPE_NAME
+Column 7 Data Type: INTEGER Name: COLUMN_SIZE
+Column 8 Data Type: INTEGER Name: BUFFER_LENGTH
+Column 9 Data Type: SMALLINT Name: DECIMAL_DIGITS
+Column 10 Data Type: SMALLINT Name: NUM_PREC_RADIX
+Column 11 Data Type: SMALLINT Name: NULLABLE
+Column 12 Data Type: VARCHAR Name: REMARKS
+Column 13 Data Type: VARCHAR Name: COLUMN_DEF
+Column 14 Data Type: SMALLINT Name: SQL_DATA_TYPE
+Column 15 Data Type: SMALLINT Name: SQL_DATETIME_SUB
+Column 16 Data Type: INTEGER Name: CHAR_OCTET_LENGTH
+Column 17 Data Type: INTEGER Name: ORDINAL_POSITION
+Column 18 Data Type: VARCHAR Name: IS_NULLABLE
+
+Fetching rows...
+
+Printing Row 1 using getString(), getObject()
+Column 1 - TRAFODION,TRAFODION
+Column 2 - SEABASE,SEABASE
+Column 3 - DBMETASAMPLE,DBMETASAMPLE
+Column 4 - C1,C1
+Column 5 - 1,1
+Column 6 - CHAR,CHAR
+Column 7 - 20,20
+Column 8 - 20,20
+Column 9 - 0,0
+Column 10 - null,null
+Column 11 - 2,2
+Column 12 - null,null
+Column 13 - ,
+Column 14 - 1,1
+Column 15 - null,null
+Column 16 - 20,20
+Column 17 - 1,1
+Column 18 - YES,YES
+
+End of Data
+
+getProcedures()
+
+Printing ResultSetMetaData ...
+No. of Columns 8
+Column 1 Data Type: VARCHAR Name: PROCEDURE_CAT
+Column 2 Data Type: VARCHAR Name: PROCEDURE_SCHEM
+Column 3 Data Type: VARCHAR Name: PROCEDURE_NAME
+Column 4 Data Type: SMALLINT Name: NUM_INPUT_PARAMS
+Column 5 Data Type: SMALLINT Name: NUM_OUTPUT_PARAMS
+Column 6 Data Type: SMALLINT Name: NUM_RESULT_SETS
+Column 7 Data Type: VARCHAR Name: REMARKS
+Column 8 Data Type: SMALLINT Name: PROCEDURE_TYPE
+
+Fetching rows...
+
+End of Data
+=======================================================
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/src/main/samples/PreparedStatementSample/PreparedStatementSample.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/samples/PreparedStatementSample/PreparedStatementSample.java b/core/conn/jdbcT4/src/main/samples/PreparedStatementSample/PreparedStatementSample.java
new file mode 100755
index 0000000..b086103
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/samples/PreparedStatementSample/PreparedStatementSample.java
@@ -0,0 +1,151 @@
+// @@@ 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 @@@
+import common.*;
+
+import java.sql.*;
+import java.math.BigDecimal;
+
+public class PreparedStatementSample
+{
+ public static void main(String args[])
+ {
+
+ Connection connection;
+ Statement stmt;
+ PreparedStatement pStmt;
+ ResultSet rs;
+ DatabaseMetaData dbMeta;
+ int rowNo;
+ String table = "PreparedStatementSample";
+
+ try
+ {
+ connection = sampleUtils.getPropertiesConnection();
+ sampleUtils.dropTable(connection, table);
+ sampleUtils.initialData(connection, table);
+ sampleUtils.initialCurrentData(connection, table);
+
+
+ for (int i = 0; i < 7; i++)
+ {
+ switch (i)
+ {
+ case 0:
+ System.out.println("");
+ System.out.println("Simple Select ");
+ stmt = connection.createStatement();
+ rs = stmt.executeQuery("select * from " + table);
+ break;
+ case 1:
+ System.out.println("");
+ System.out.println("Parameterized Select - CHAR");
+ pStmt = connection.prepareStatement("select c1, c2 from " + table + " where c1 = ?");
+ pStmt.setString(1, "Selva");
+ rs = pStmt.executeQuery();
+ break;
+ case 2:
+ System.out.println("");
+ System.out.println("Parameterized Select - INT");
+ pStmt = connection.prepareStatement("select c1, c2, c3 from " + table + " where c2 = ? or c2 = ?");
+ pStmt.setInt(1, 100);
+ pStmt.setInt(2, -100);
+ rs = pStmt.executeQuery();
+ break;
+ case 3:
+ System.out.println("");
+ System.out.println("Parameterized Select - TIMESTAMP");
+ pStmt = connection.prepareStatement("select c1, c2, c3, c10 from " + table + " where c10 = ?");
+ pStmt.setTimestamp(1, Timestamp.valueOf("2000-05-06 10:11:12.0"));
+ rs = pStmt.executeQuery();
+ break;
+ case 4:
+ System.out.println("");
+ System.out.println("Parameterized Select - DECIMAL");
+ pStmt = connection.prepareStatement("select c1, c2, c3, c7 from " + table + " where c7 = ? or c7 = ?");
+ pStmt.setBigDecimal(1, new BigDecimal("100.12"));
+ pStmt.setBigDecimal(2, new BigDecimal("-100.12"));
+ rs = pStmt.executeQuery();
+ break;
+ case 5:
+ System.out.println("");
+ System.out.println("Parameterized Select - NUMERIC");
+ pStmt = connection.prepareStatement("select c1, c2, c3, c6 from " + table + " where c6 = ? or c6 = ?");
+ pStmt.setBigDecimal(1, new BigDecimal("100.12"));
+ pStmt.setBigDecimal(2, new BigDecimal("-100.12"));
+ rs = pStmt.executeQuery();
+ break;
+ case 6:
+ System.out.println("");
+ System.out.println("Parameterized Select - DATE");
+ pStmt = connection.prepareStatement(
+ "select c11, c12 from " + table + " where c8 = ?");
+ pStmt.setDate(1, Date.valueOf("2000-05-06"));
+ rs = pStmt.executeQuery();
+ break;
+ default:
+ rs = null;
+ continue;
+ }
+
+ ResultSetMetaData rsMD = rs.getMetaData();
+ System.out.println("");
+ System.out.println("Printing ResultSetMetaData ...");
+ System.out.println("No. of Columns " + rsMD.getColumnCount());
+ for (int j = 1; j <= rsMD.getColumnCount(); j++)
+ {
+ System.out.println("Column " + j + " Data Type: " + rsMD.getColumnTypeName(j) + " Name: " + rsMD.getColumnName(j));
+ }
+ System.out.println("");
+ System.out.println("Fetching rows...");
+ rowNo = 0;
+ while (rs.next())
+ {
+ rowNo++;
+ System.out.println("");
+ System.out.println("Printing Row " + rowNo + " using getString(), getObject()");
+ for (int j=1; j <= rsMD.getColumnCount(); j++)
+ {
+ System.out.println("Column " + j + " - " + rs.getString(j) + "," + rs.getObject(j));
+ }
+
+ }
+ System.out.println("");
+ System.out.println("End of Data");
+ rs.close();
+ }
+
+ sampleUtils.dropTable(connection, table);
+ connection.close();
+ }
+ catch (SQLException e)
+ {
+ SQLException nextException;
+
+ nextException = e;
+ do
+ {
+ System.out.println(nextException.getMessage());
+ System.out.println("SQLState " + nextException.getSQLState());
+ System.out.println("Error Code " + nextException.getErrorCode());
+ } while ((nextException = nextException.getNextException()) != null);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/src/main/samples/PreparedStatementSample/README
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/samples/PreparedStatementSample/README b/core/conn/jdbcT4/src/main/samples/PreparedStatementSample/README
new file mode 100755
index 0000000..55c7252
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/samples/PreparedStatementSample/README
@@ -0,0 +1,232 @@
+
+Compiling the Java files
+========================
+On Windows Platform:
+%JAVA_HOME%\bin\javac -classpath ..\..\lib\jdbcT4.jar *.java ..\common\*.java
+
+On Linux:
+$JAVA_HOME/bin/javac -classpath ../../lib/jdbcT4.jar *.java ../common/*.java
+
+Note: Make sure there are no compilation errors displayed on
+ the screen.
+
+
+Executing PreparedStatementSample
+=========================
+On Windows Platform:
+%JAVA_HOME%\bin\java -classpath ..\..\lib\jdbcT4.jar;..;. -Dt4jdbc.properties=..\t4jdbc.properties PreparedStatementSample
+
+On Linux:
+$JAVA_HOME/bin/java -classpath ../../lib/jdbcT4.jar:..:. -Dt4jdbc.properties=../t4jdbc.properties PreparedStatementSample
+
+
+Output of the execution would look like:
+========================================
+<DATE, TITME> common.sampleUtils getPropertiesConnection
+INFO: DriverManager.getConnection(url, props) passed
+
+Inserting TimeStamp
+
+Simple Select
+
+Printing ResultSetMetaData ...
+No. of Columns 12
+Column 1 Data Type: CHAR Name: C1
+Column 2 Data Type: SMALLINT Name: C2
+Column 3 Data Type: INTEGER Name: C3
+Column 4 Data Type: BIGINT Name: C4
+Column 5 Data Type: VARCHAR Name: C5
+Column 6 Data Type: NUMERIC Name: C6
+Column 7 Data Type: DECIMAL Name: C7
+Column 8 Data Type: DATE Name: C8
+Column 9 Data Type: TIME Name: C9
+Column 10 Data Type: TIMESTAMP Name: C10
+Column 11 Data Type: REAL Name: C11
+Column 12 Data Type: DOUBLE PRECISION Name: C12
+
+Fetching rows...
+
+Printing Row 1 using getString(), getObject()
+Column 1 - Row1 ,Row1
+Column 2 - 100,100
+Column 3 - 12345678,12345678
+Column 4 - 123456789012,123456789012
+Column 5 - Selva,Selva
+Column 6 - 100.12,100.12
+Column 7 - 100.12,100.12
+Column 8 - 2000-05-06,2000-05-06
+Column 9 - 10:11:12,10:11:12
+Column 10 - 2000-05-06 10:11:12.0,2000-05-06 10:11:12.0
+Column 11 - 100.12,100.12
+Column 12 - 100.12,100.12
+
+Printing Row 2 using getString(), getObject()
+Column 1 - Row2 ,Row2
+Column 2 - -100,-100
+Column 3 - -12345678,-12345678
+Column 4 - -123456789012,-123456789012
+Column 5 - Selva,Selva
+Column 6 - -100.12,-100.12
+Column 7 - -100.12,-100.12
+Column 8 - 2000-05-16,2000-05-16
+Column 9 - 10:11:12,10:11:12
+Column 10 - 2000-05-06 10:11:12.0,2000-05-06 10:11:12.0
+Column 11 - -100.12,-100.12
+Column 12 - -100.12,-100.12
+
+Printing Row 3 using getString(), getObject()
+Column 1 - TimeStamp ,TimeStamp
+Column 2 - -100,-100
+Column 3 - -12345678,-12345678
+Column 4 - -123456789012,-123456789012
+Column 5 - Selva,Selva
+Column 6 - -100.12,-100.12
+Column 7 - -100.12,-100.12
+Column 8 - 2004-04-14,2004-04-14
+Column 9 - 17:46:02,17:46:02
+Column 10 - 2004-04-14 17:46:02.74,2004-04-14 17:46:02.74
+Column 11 - -100.12,-100.12
+Column 12 - -100.12,-100.12
+
+End of Data
+
+Parameterized Select - CHAR
+
+Printing ResultSetMetaData ...
+No. of Columns 2
+Column 1 Data Type: CHAR Name: C1
+Column 2 Data Type: SMALLINT Name: C2
+
+Fetching rows...
+
+End of Data
+
+Parameterized Select - INT
+
+Printing ResultSetMetaData ...
+No. of Columns 3
+Column 1 Data Type: CHAR Name: C1
+Column 2 Data Type: SMALLINT Name: C2
+Column 3 Data Type: INTEGER Name: C3
+
+Fetching rows...
+
+Printing Row 1 using getString(), getObject()
+Column 1 - Row1 ,Row1
+Column 2 - 100,100
+Column 3 - 12345678,12345678
+
+Printing Row 2 using getString(), getObject()
+Column 1 - Row2 ,Row2
+Column 2 - -100,-100
+Column 3 - -12345678,-12345678
+
+Printing Row 3 using getString(), getObject()
+Column 1 - TimeStamp ,TimeStamp
+Column 2 - -100,-100
+Column 3 - -12345678,-12345678
+
+End of Data
+
+Parameterized Select - TIMESTAMP
+
+Printing ResultSetMetaData ...
+No. of Columns 4
+Column 1 Data Type: CHAR Name: C1
+Column 2 Data Type: SMALLINT Name: C2
+Column 3 Data Type: INTEGER Name: C3
+Column 4 Data Type: TIMESTAMP Name: C10
+
+Fetching rows...
+
+Printing Row 1 using getString(), getObject()
+Column 1 - Row1 ,Row1
+Column 2 - 100,100
+Column 3 - 12345678,12345678
+Column 4 - 2000-05-06 10:11:12.0,2000-05-06 10:11:12.0
+
+Printing Row 2 using getString(), getObject()
+Column 1 - Row2 ,Row2
+Column 2 - -100,-100
+Column 3 - -12345678,-12345678
+Column 4 - 2000-05-06 10:11:12.0,2000-05-06 10:11:12.0
+
+End of Data
+
+Parameterized Select - DECIMAL
+
+Printing ResultSetMetaData ...
+No. of Columns 4
+Column 1 Data Type: CHAR Name: C1
+Column 2 Data Type: SMALLINT Name: C2
+Column 3 Data Type: INTEGER Name: C3
+Column 4 Data Type: DECIMAL Name: C7
+
+Fetching rows...
+
+Printing Row 1 using getString(), getObject()
+Column 1 - Row1 ,Row1
+Column 2 - 100,100
+Column 3 - 12345678,12345678
+Column 4 - 100.12,100.12
+
+Printing Row 2 using getString(), getObject()
+Column 1 - Row2 ,Row2
+Column 2 - -100,-100
+Column 3 - -12345678,-12345678
+Column 4 - -100.12,-100.12
+
+Printing Row 3 using getString(), getObject()
+Column 1 - TimeStamp ,TimeStamp
+Column 2 - -100,-100
+Column 3 - -12345678,-12345678
+Column 4 - -100.12,-100.12
+
+End of Data
+
+Parameterized Select - NUMERIC
+
+Printing ResultSetMetaData ...
+No. of Columns 4
+Column 1 Data Type: CHAR Name: C1
+Column 2 Data Type: SMALLINT Name: C2
+Column 3 Data Type: INTEGER Name: C3
+Column 4 Data Type: NUMERIC Name: C6
+
+Fetching rows...
+
+Printing Row 1 using getString(), getObject()
+Column 1 - Row1 ,Row1
+Column 2 - 100,100
+Column 3 - 12345678,12345678
+Column 4 - 100.12,100.12
+
+Printing Row 2 using getString(), getObject()
+Column 1 - Row2 ,Row2
+Column 2 - -100,-100
+Column 3 - -12345678,-12345678
+Column 4 - -100.12,-100.12
+
+Printing Row 3 using getString(), getObject()
+Column 1 - TimeStamp ,TimeStamp
+Column 2 - -100,-100
+Column 3 - -12345678,-12345678
+Column 4 - -100.12,-100.12
+
+End of Data
+
+Parameterized Select - DATE
+
+Printing ResultSetMetaData ...
+No. of Columns 2
+Column 1 Data Type: REAL Name: C11
+Column 2 Data Type: DOUBLE PRECISION Name: C12
+
+Fetching rows...
+
+Printing Row 1 using getString(), getObject()
+Column 1 - 100.12,100.12
+Column 2 - 100.12,100.12
+
+End of Data
+===============================================
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/src/main/samples/README
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/samples/README b/core/conn/jdbcT4/src/main/samples/README
new file mode 100755
index 0000000..916c8d2
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/samples/README
@@ -0,0 +1,47 @@
+This is samples README file.
+
+To setup the enviornment
+========================
+ On UNIX platform:
+ 1. export JAVA_HOME=<java home on your system>
+
+ On WINDOWS platform command windows:
+ 1. set JAVA_HOME=<java home on your system>
+
+
+To Configure samples
+====================
+ Edit t4jdbc.properties file. Set the following values to your environment.
+
+ catalog : SQL catalog - must exist on the database
+ Please refer to the SQL documentation on how to create the catalog.
+ schema : SQL schema - must exist on the database
+ Please refer to the SQL documentation on how to create the schema.
+
+ Example of creating catalog/schema:
+ >>create catalog mycat;
+ >>create schema mycat.myschema;
+
+ user : Database user name
+ password : Database text password
+ url : jdbc:t4jdbc://<Database ip or name>:<port number where DCS is running>/:
+
+ Example of a t4jdbc.properties file:
+
+ catalog = CAT
+ schema = SCH
+ url = jdbc:t4jdbc://www.mymachine.net:61234/:
+ user = software.john
+ password = abcd
+
+
+
+To run the samples
+==================
+ Follow the README file instructions in the following directories.
+ 1. StatementSample
+ 2. PreparedStatementSample
+ 3. ResultSetSample
+ 4. DBMetaSample
+
+ NOTE: All samples create, populate and drop sample tables.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/src/main/samples/ResultSetSample/README
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/samples/ResultSetSample/README b/core/conn/jdbcT4/src/main/samples/ResultSetSample/README
new file mode 100755
index 0000000..5a1d99e
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/samples/ResultSetSample/README
@@ -0,0 +1,91 @@
+Compiling the Java files
+========================
+On Windows Platform:
+%JAVA_HOME%\bin\javac -classpath ..\..\lib\jdbcT4.jar *.java ..\common\*.java
+
+On Linux:
+$JAVA_HOME/bin/javac -classpath ../../lib/jdbcT4.jar *.java ../common/*.java
+
+Note: Make sure there are no compilation errors displayed on
+ the screen.
+
+
+Executing ResultSetSample
+=========================
+On Windows Platform:
+%JAVA_HOME%\bin\java -classpath ..\..\lib\jdbcT4.jar;..;. -Dt4jdbc.properties=..\t4jdbc.properties ResultSetSample
+
+On Linux:
+$JAVA_HOME/bin/java -classpath ../../lib/jdbcT4.jar:..:. -Dt4jdbc.properties=../t4jdbc.properties ResultSetSample
+
+
+Output of the execution would look like:
+========================================
+<DATE, TIME> common.sampleUtils getPropertiesConnection
+INFO: DriverManager.getConnection(url, props) passed
+
+Inserting TimeStamp
+
+Simple Select
+
+Printing ResultSetMetaData ...
+No. of Columns 12
+Column 1 Data Type: CHAR Name: C1
+Column 2 Data Type: SMALLINT Name: C2
+Column 3 Data Type: INTEGER Name: C3
+Column 4 Data Type: BIGINT Name: C4
+Column 5 Data Type: VARCHAR Name: C5
+Column 6 Data Type: NUMERIC Name: C6
+Column 7 Data Type: DECIMAL Name: C7
+Column 8 Data Type: DATE Name: C8
+Column 9 Data Type: TIME Name: C9
+Column 10 Data Type: TIMESTAMP Name: C10
+Column 11 Data Type: REAL Name: C11
+Column 12 Data Type: DOUBLE PRECISION Name: C12
+
+Fetching rows...
+
+Printing Row 1 using getString(), getObject()
+Column 1 - Row1 ,Row1
+Column 2 - 100,100
+Column 3 - 12345678,12345678
+Column 4 - 123456789012,123456789012
+Column 5 - Selva,Selva
+Column 6 - 100.12,100.12
+Column 7 - 100.12,100.12
+Column 8 - 2000-05-06,2000-05-06
+Column 9 - 10:11:12,10:11:12
+Column 10 - 2000-05-06 10:11:12.0,2000-05-06 10:11:12.0
+Column 11 - 100.12,100.12
+Column 12 - 100.12,100.12
+
+Printing Row 2 using getString(), getObject()
+Column 1 - Row2 ,Row2
+Column 2 - -100,-100
+Column 3 - -12345678,-12345678
+Column 4 - -123456789012,-123456789012
+Column 5 - Selva,Selva
+Column 6 - -100.12,-100.12
+Column 7 - -100.12,-100.12
+Column 8 - 2000-05-16,2000-05-16
+Column 9 - 10:11:12,10:11:12
+Column 10 - 2000-05-06 10:11:12.0,2000-05-06 10:11:12.0
+Column 11 - -100.12,-100.12
+Column 12 - -100.12,-100.12
+
+Printing Row 3 using getString(), getObject()
+Column 1 - TimeStamp ,TimeStamp
+Column 2 - -100,-100
+Column 3 - -12345678,-12345678
+Column 4 - -123456789012,-123456789012
+Column 5 - Selva,Selva
+Column 6 - -100.12,-100.12
+Column 7 - -100.12,-100.12
+Column 8 - 2004-04-14,2004-04-14
+Column 9 - 16:19:47,16:19:47
+Column 10 - 2004-04-14 16:19:47.003,2004-04-14 16:19:47.003
+Column 11 - -100.12,-100.12
+Column 12 - -100.12,-100.12
+
+End of Data
+========================================
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/src/main/samples/ResultSetSample/ResultSetSample.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/samples/ResultSetSample/ResultSetSample.java b/core/conn/jdbcT4/src/main/samples/ResultSetSample/ResultSetSample.java
new file mode 100755
index 0000000..47b0b4c
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/samples/ResultSetSample/ResultSetSample.java
@@ -0,0 +1,104 @@
+// @@@ 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 @@@
+import common.*;
+
+import java.sql.*;
+import java.math.BigDecimal;
+
+public class ResultSetSample
+{
+ public static void main(String args[])
+ {
+
+ Connection connection;
+ Statement stmt;
+ PreparedStatement pStmt;
+ ResultSet rs;
+ DatabaseMetaData dbMeta;
+ int rowNo;
+ String table = "ResultSetSample";
+
+ try
+ {
+ connection = sampleUtils.getPropertiesConnection();
+ sampleUtils.dropTable(connection, table);
+ sampleUtils.initialData(connection, table);
+ sampleUtils.initialCurrentData(connection, table);
+
+ for (int i = 0; i < 10; i++)
+ {
+ switch (i)
+ {
+ case 0:
+ System.out.println("");
+ System.out.println("Simple Select ");
+ stmt = connection.createStatement();
+ rs = stmt.executeQuery("select * from " + table);
+ break;
+ default:
+ rs = null;
+ continue;
+ }
+
+ ResultSetMetaData rsMD = rs.getMetaData();
+ System.out.println("");
+ System.out.println("Printing ResultSetMetaData ...");
+ System.out.println("No. of Columns " + rsMD.getColumnCount());
+ for (int j = 1; j <= rsMD.getColumnCount(); j++)
+ {
+ System.out.println("Column " + j + " Data Type: " + rsMD.getColumnTypeName(j) + " Name: " + rsMD.getColumnName(j));
+ }
+ System.out.println("");
+ System.out.println("Fetching rows...");
+ rowNo = 0;
+ while (rs.next())
+ {
+ rowNo++;
+ System.out.println("");
+ System.out.println("Printing Row " + rowNo + " using getString(), getObject()");
+ for (int j=1; j <= rsMD.getColumnCount(); j++)
+ {
+ System.out.println("Column " + j + " - " + rs.getString(j) + "," + rs.getObject(j));
+ }
+
+ }
+ System.out.println("");
+ System.out.println("End of Data");
+ rs.close();
+ }
+
+ sampleUtils.dropTable(connection, table);
+ connection.close();
+ }
+ catch (SQLException e)
+ {
+ SQLException nextException;
+
+ nextException = e;
+ do
+ {
+ System.out.println(nextException.getMessage());
+ System.out.println("SQLState " + nextException.getSQLState());
+ System.out.println("Error Code " + nextException.getErrorCode());
+ } while ((nextException = nextException.getNextException()) != null);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/src/main/samples/StatementSample/README
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/samples/StatementSample/README b/core/conn/jdbcT4/src/main/samples/StatementSample/README
new file mode 100755
index 0000000..159f349
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/samples/StatementSample/README
@@ -0,0 +1,92 @@
+Compiling the Java files
+========================
+On Windows Platform:
+%JAVA_HOME%\bin\javac -classpath ..\..\lib\jdbcT4.jar *.java ..\common\*.java
+
+On Linux:
+$JAVA_HOME/bin/javac -classpath ../../lib/jdbcT4.jar *.java ../common/*.java
+
+Note: Make sure there are no compilation errors displayed on
+ the screen.
+
+
+Executing StatementSample
+=========================
+On Windows Platform:
+%JAVA_HOME%\bin\java -classpath ..\..\lib\jdbcT4.jar;..;. -Dt4jdbc.properties=..\t4jdbc.properties StatementSample
+
+On Linux:
+$JAVA_HOME/bin/java -classpath ../../lib/jdbcT4.jar:..:. -Dt4jdbc.properties=../t4jdbc.properties StatementSample
+
+
+Output of the execution would look like:
+========================================
+
+<DATE, TIME> common.sampleUtils getPropertiesConnection
+INFO: DriverManager.getConnection(url, props) passed
+
+Inserting TimeStamp
+
+Simple Select
+
+Printing ResultSetMetaData ...
+No. of Columns 12
+Column 1 Data Type: CHAR Name: C1
+Column 2 Data Type: SMALLINT Name: C2
+Column 3 Data Type: INTEGER Name: C3
+Column 4 Data Type: BIGINT Name: C4
+Column 5 Data Type: VARCHAR Name: C5
+Column 6 Data Type: NUMERIC Name: C6
+Column 7 Data Type: DECIMAL Name: C7
+Column 8 Data Type: DATE Name: C8
+Column 9 Data Type: TIME Name: C9
+Column 10 Data Type: TIMESTAMP Name: C10
+Column 11 Data Type: REAL Name: C11
+Column 12 Data Type: DOUBLE PRECISION Name: C12
+
+Fetching rows...
+
+Printing Row 1 using getString(), getObject()
+Column 1 - Row1 ,Row1
+Column 2 - 100,100
+Column 3 - 12345678,12345678
+Column 4 - 123456789012,123456789012
+Column 5 - Selva,Selva
+Column 6 - 100.12,100.12
+Column 7 - 100.12,100.12
+Column 8 - 2000-05-06,2000-05-06
+Column 9 - 10:11:12,10:11:12
+Column 10 - 2000-05-06 10:11:12.0,2000-05-06 10:11:12.0
+Column 11 - 100.12,100.12
+Column 12 - 100.12,100.12
+
+Printing Row 2 using getString(), getObject()
+Column 1 - Row2 ,Row2
+Column 2 - -100,-100
+Column 3 - -12345678,-12345678
+Column 4 - -123456789012,-123456789012
+Column 5 - Selva,Selva
+Column 6 - -100.12,-100.12
+Column 7 - -100.12,-100.12
+Column 8 - 2000-05-16,2000-05-16
+Column 9 - 10:11:12,10:11:12
+Column 10 - 2000-05-06 10:11:12.0,2000-05-06 10:11:12.0
+Column 11 - -100.12,-100.12
+Column 12 - -100.12,-100.12
+
+Printing Row 3 using getString(), getObject()
+Column 1 - TimeStamp ,TimeStamp
+Column 2 - -100,-100
+Column 3 - -12345678,-12345678
+Column 4 - -123456789012,-123456789012
+Column 5 - Selva,Selva
+Column 6 - -100.12,-100.12
+Column 7 - -100.12,-100.12
+Column 8 - 2004-04-14,2004-04-14
+Column 9 - 15:43:36,15:43:36
+Column 10 - 2004-04-14 15:43:36.167,2004-04-14 15:43:36.167
+Column 11 - -100.12,-100.12
+Column 12 - -100.12,-100.12
+
+End of Data
+-------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/src/main/samples/StatementSample/StatementSample.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/samples/StatementSample/StatementSample.java b/core/conn/jdbcT4/src/main/samples/StatementSample/StatementSample.java
new file mode 100755
index 0000000..765d9d4
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/samples/StatementSample/StatementSample.java
@@ -0,0 +1,104 @@
+// @@@ 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 @@@
+import common.*;
+
+import java.sql.*;
+import java.math.BigDecimal;
+
+public class StatementSample
+{
+ public static void main(String args[])
+ {
+
+ Connection connection;
+ Statement stmt;
+ PreparedStatement pStmt;
+ ResultSet rs;
+ DatabaseMetaData dbMeta;
+ int rowNo;
+ String table = "StatementSample";
+
+ try
+ {
+ connection = sampleUtils.getPropertiesConnection();
+ sampleUtils.dropTable(connection, table);
+ sampleUtils.initialData(connection, table);
+ sampleUtils.initialCurrentData(connection, table);
+
+ for (int i = 0; i < 1; i++)
+ {
+ switch (i)
+ {
+ case 0:
+ System.out.println("");
+ System.out.println("Simple Select ");
+ stmt = connection.createStatement();
+ rs = stmt.executeQuery("select * from " + table);
+ break;
+ default:
+ rs = null;
+ continue;
+ }
+
+ ResultSetMetaData rsMD = rs.getMetaData();
+ System.out.println("");
+ System.out.println("Printing ResultSetMetaData ...");
+ System.out.println("No. of Columns " + rsMD.getColumnCount());
+ for (int j = 1; j <= rsMD.getColumnCount(); j++)
+ {
+ System.out.println("Column " + j + " Data Type: " + rsMD.getColumnTypeName(j) + " Name: " + rsMD.getColumnName(j));
+ }
+ System.out.println("");
+ System.out.println("Fetching rows...");
+ rowNo = 0;
+ while (rs.next())
+ {
+ rowNo++;
+ System.out.println("");
+ System.out.println("Printing Row " + rowNo + " using getString(), getObject()");
+ for (int j=1; j <= rsMD.getColumnCount(); j++)
+ {
+ System.out.println("Column " + j + " - " + rs.getString(j) + "," + rs.getObject(j));
+ }
+
+ }
+ System.out.println("");
+ System.out.println("End of Data");
+ rs.close();
+ }
+
+ sampleUtils.dropTable(connection, table);
+ connection.close();
+ }
+ catch (SQLException e)
+ {
+ SQLException nextException;
+
+ nextException = e;
+ do
+ {
+ System.out.println(nextException.getMessage());
+ System.out.println("SQLState " + nextException.getSQLState());
+ System.out.println("Error Code " + nextException.getErrorCode());
+ } while ((nextException = nextException.getNextException()) != null);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/src/main/samples/common/sampleUtils.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/samples/common/sampleUtils.java b/core/conn/jdbcT4/src/main/samples/common/sampleUtils.java
new file mode 100755
index 0000000..f234d28
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/samples/common/sampleUtils.java
@@ -0,0 +1,268 @@
+// @@@ 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 common;
+
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.PreparedStatement;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.*;
+import java.io.*;
+import java.util.logging.*;
+import java.net.*;
+
+
+public class sampleUtils
+{
+ static String url;
+ static String usr;
+ static String pwd;
+ public static Properties props;
+
+ //------------------------------------------------------------------------
+ static
+ {
+ try
+ {
+ String propFile = System.getProperty("t4jdbc.properties");
+ if (propFile != null)
+ {
+ FileInputStream fs = new FileInputStream(new File(propFile));
+ props = new Properties();
+ props.load(fs);
+
+ url = props.getProperty("url");
+ usr = props.getProperty("user");
+ pwd = props.getProperty("password");
+ } else {
+ System.out.println("Error: t4jdbc.properties is not set. Exiting.");
+ System.exit(0);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ System.out.println(e.getMessage());
+ }
+
+ try
+ {
+ Class.forName("org.trafodion.jdbc.t4.T4Driver");
+ Logger.global.setLevel(Level.FINEST);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println(e.getMessage());
+ System.exit(0);
+ }
+ }
+
+ //------------------------------------------------------------------------
+ static void checkprops() throws SQLException
+ {
+ if (props == null)
+ throw new SQLException ("Error: t4jdbc.properties is null. Exiting.");
+ }
+
+ //------------------------------------------------------------------------
+ public static Connection getUserConnection() throws SQLException
+ {
+ Connection connection = null;
+ checkprops();
+
+ Logger.global.log(Level.FINE,"DriverManager.getConnection(url, usr, pwd)");
+ connection = DriverManager.getConnection(url, usr, pwd);
+ Logger.global.log(Level.INFO, "DriverManager.getConnection(url, usr, pwd) passed");
+ Logger.global.log(Level.FINE, "==============\n\n");
+
+ return connection;
+ }
+
+
+ //------------------------------------------------------------------------
+ public static Connection getPropertiesConnection() throws SQLException
+ {
+
+ Connection connection = null;
+ checkprops();
+
+ Logger.global.log(Level.FINE, "DriverManager.getConnection(url, props)");
+ Logger.global.log(Level.FINEST, "Properties = " + props);
+ connection = DriverManager.getConnection(url, props);
+ Logger.global.log(Level.INFO, "DriverManager.getConnection(url, props) passed");
+ Logger.global.log(Level.FINE, "==============\n\n");
+
+ return connection;
+ }
+
+ //------------------------------------------------------------------------
+ public static Connection getUrlConnection() throws SQLException
+ {
+ Connection connection = null;
+ checkprops();
+
+ Logger.global.log(Level.FINE, "DriverManager.getConnection(url)");
+ connection = DriverManager.getConnection(url);
+ Logger.global.log(Level.INFO, "DriverManager.getConnection(url) passed");
+ Logger.global.log(Level.FINE, "==============\n\n");
+
+ return connection;
+ }
+
+ //------------------------------------------------------------------------
+ public static Connection getUrlConnection(String newUrl) throws SQLException
+ {
+ Connection connection = null;
+ checkprops();
+
+ Logger.global.log(Level.FINE, "DriverManager.getConnection(newUrl) newUrl = " + newUrl);
+ connection = DriverManager.getConnection(newUrl);
+ Logger.global.log(Level.INFO, "DriverManager.getConnection(newUrl) passed mewUrl = " + newUrl);
+ Logger.global.log(Level.FINE, "==============\n\n");
+
+ return connection;
+ }
+
+ //------------------------------------------------------------------------
+ public static void main(String args[])
+ {
+
+ Connection connection, connection1, connection2;
+
+ try
+ {
+ connection = getUserConnection();
+ connection1 = getPropertiesConnection();
+ connection2 = getUrlConnection();
+
+ Logger.global.log(Level.INFO, "testing valid setCatalog");
+ connection.setCatalog("Velu");
+ Logger.global.log(Level.INFO, "testing valid setCatalog done");
+
+ Logger.global.log(Level.INFO, "testing invalid setTransactionIsolation");
+ connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
+ Logger.global.log(Level.INFO, "testing invalid TransactionIsolation done");
+
+ Logger.global.log(Level.FINE, "testing connection.close for (url)");
+ connection.close();
+ Logger.global.log(Level.INFO, "testing connection.close for (url) passed");
+ Logger.global.log(Level.FINE, "==============\n\n");
+
+ Logger.global.log(Level.FINE, "testing connection.close for (url, usr, pwd)");
+ connection1.close();
+ Logger.global.log(Level.INFO, "testing connection.close for (url) passed");
+ Logger.global.log(Level.FINE, "==============\n\n");
+
+ Logger.global.log(Level.FINE, "testing connection.close for (url, info)");
+ connection2.close();
+ Logger.global.log(Level.INFO, "testing connection.close for (url) passed");
+ Logger.global.log(Level.FINE, "==============\n\n");
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public static void dropTable(Connection conn, String table)
+ {
+ Statement stmt = null;
+
+ try
+ {
+ stmt = conn.createStatement();
+ stmt.executeUpdate("drop table " + table);
+ }
+ catch (SQLException e)
+ {
+ Logger.global.log(Level.FINE, "Drop table failed for = " + table);
+ Logger.global.log(Level.FINE, "==============\n\n");
+ } finally {
+ try {
+ stmt.close();
+ } catch (Exception ex) {}
+ }
+ }
+
+ public static void initialData(Connection conn, String table) throws SQLException
+ {
+ Statement stmt = null;
+
+ try
+ {
+ stmt = conn.createStatement();
+ stmt.executeUpdate("create table " + table + " (c1 char(20), c2 smallint, c3 integer, c4 largeint, c5 varchar(120), c6 numeric(10,2), c7 decimal(10,2),c8 date, c9 time, c10 timestamp, c11 real, c12 double precision) NO PARTITION");
+
+ stmt.executeUpdate("insert into " + table + " values('Row1', 100, 12345678, 123456789012, 'Selva', 100.12, 100.12, {d '2000-05-06'}, {t '10:11:12'}, {ts '2000-05-06 10:11:12.0'}, 100.12, 100.12)");
+
+ stmt.executeUpdate("insert into " + table + " values('Row2', -100, -12345678, -123456789012, 'Selva', -100.12, -100.12, {d '2000-05-16'}, {t '10:11:12'}, {ts '2000-05-06 10:11:12'}, -100.12, -100.12)");
+ stmt.close();
+
+ }
+ catch (SQLException e)
+ {
+ Logger.global.log(Level.FINE, "InitialData failed = " + e);
+ Logger.global.log(Level.FINE, "==============\n\n");
+ try {
+ stmt.close();
+ } catch (Exception ex) {}
+ throw e;
+ }
+ }
+
+ public static void initialCurrentData(Connection conn, String table) throws SQLException
+ {
+ PreparedStatement pStmt = null;
+
+ try
+ {
+ System.out.println("");
+ System.out.println("Inserting TimeStamp ");
+ pStmt = conn.prepareStatement(
+ "insert into " + table + " values('TimeStamp', -100, -12345678, -123456789012, 'Selva', -100.12, -100.12, ?, ?, ?, -100.12, -100.12)"
+ );
+
+ pStmt.setDate(1, new Date(new java.util.Date().getTime()));
+ pStmt.setTime(2, new Time(new java.util.Date().getTime()));
+ Timestamp t1 = new Timestamp( (new java.util.Date()).getTime());
+ pStmt.setTimestamp(3, t1);
+ if (pStmt.executeUpdate() != 1)
+ {
+ System.out.println("executeUpdate of TimeStamp failed");
+ }
+ pStmt.close();
+
+ }
+ catch (SQLException e)
+ {
+ Logger.global.log(Level.FINE, "InitialCurrentData failed =" + e);
+ Logger.global.log(Level.FINE, "==============\n\n");
+ try {
+ pStmt.close();
+ } catch (Exception ex) {}
+ throw e;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/500d2076/core/conn/jdbcT4/src/main/samples/t4jdbc.properties
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/samples/t4jdbc.properties b/core/conn/jdbcT4/src/main/samples/t4jdbc.properties
new file mode 100755
index 0000000..d4c1f98
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/samples/t4jdbc.properties
@@ -0,0 +1,26 @@
+# @@@ 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 @@@
+
+catalog = TRAFODION
+schema = SCH
+url = jdbc:t4jdbc://server:port/:
+user = usr
+password = pwd
[48/60] incubator-trafodion git commit: fixed the dependency
Posted by db...@apache.org.
fixed the dependency
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/842caed8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/842caed8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/842caed8
Branch: refs/heads/master
Commit: 842caed8b8c1616e22c0f49aa240994ce62b6b45
Parents: 8a8d2ad
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Fri Apr 22 03:46:45 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Fri Apr 22 03:46:45 2016 +0000
----------------------------------------------------------------------
core/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/842caed8/core/Makefile
----------------------------------------------------------------------
diff --git a/core/Makefile b/core/Makefile
index 89740c9..e07de36 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -141,7 +141,7 @@ pkg-sql-regress: all
cd sqf && $(MAKE) package-regress 2>&1 | sed -e "s/$$/ ##(Package sql regress)/";exit $${PIPESTATUS[0]}
# Package Phoenix test
-pkg-phx-tests:
+pkg-phx-tests: all
cd sqf && $(MAKE) package-phx 2>&1 | sed -e "s/$$/ ##(Package phoenix)/";exit $${PIPESTATUS[0]}
# Package dcs tests
[13/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InterfaceStatement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InterfaceStatement.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InterfaceStatement.java
deleted file mode 100644
index e6c7af8..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InterfaceStatement.java
+++ /dev/null
@@ -1,1392 +0,0 @@
-// @@@ 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;
-import java.sql.DataTruncation;
-import java.sql.Date;
-import java.sql.SQLException;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Locale;
-import java.util.logging.Level;
-
-class InterfaceStatement {
- InterfaceConnection ic_;
- private long rowCount_;
- static final short SQL_DROP = 1;
- static short EXTERNAL_STMT = 0;
- int sqlStmtType_ = TRANSPORT.TYPE_UNKNOWN;
- int stmtType_ = 0;
- T4Statement t4statement_;
- int queryTimeout_;
- String stmtLabel_;
- String cursorName_;
- TrafT4Statement stmt_;
-
- int sqlQueryType_;
- int stmtHandle_;
- int estimatedCost_;
- boolean prepare2 = false;
- boolean stmtIsLock = false;
-
- // used for SPJ transaction
- static Class LmUtility_class_ = null;
- static java.lang.reflect.Method LmUtility_getTransactionId_ = null;
-
- PrepareReply pr_;
-
- // ----------------------------------------------------------------------
- InterfaceStatement(TrafT4Statement stmt) throws SQLException {
- this.ic_ = ((TrafT4Connection) stmt.getConnection()).getServerHandle();
- queryTimeout_ = stmt.queryTimeout_;
- stmtLabel_ = stmt.stmtLabel_;
- cursorName_ = stmt.cursorName_;
- t4statement_ = new T4Statement(this);
- stmt_ = stmt;
- };
-
- public int getSqlQueryType() {
- return sqlQueryType_;
- }
-
- private String convertDateFormat(String dt) {
- String tokens[] = dt.split("[/]", 3);
-
- if (tokens.length != 3) {
- return dt;
- }
- StringBuffer sb = new StringBuffer();
- sb.append(tokens[0]).append("-").append(tokens[1]).append("-").append(tokens[2]);
- return sb.toString();
- }
-
- // ----------------------------------------------------------------------
- /**
- * This method will take an object and convert it to the approperite format
- * for sending to TrafT4.
- *
- * @param locale
- * The locale for this operation
- * @param pstmt
- * The prepared statement associated with the object
- * @param paramValue
- * The object to convert
- * @param paramNumber
- * The parameter number associated with this object
- * @param values
- * The array to place the converted object into
- */
- void convertObjectToSQL2(Locale locale, TrafT4Statement pstmt, Object paramValue, int paramRowCount, int paramNumber,
- byte[] values, int rowNumber) throws SQLException {
- byte[] tmpBarray = null;
- int i;
- BigDecimal tmpbd;
-
- int precision = pstmt.inputDesc_[paramNumber].precision_;
- int scale = pstmt.inputDesc_[paramNumber].scale_;
- int sqlDatetimeCode = pstmt.inputDesc_[paramNumber].sqlDatetimeCode_;
- int FSDataType = pstmt.inputDesc_[paramNumber].fsDataType_;
- int OdbcDataType = pstmt.inputDesc_[paramNumber].dataType_;
- int maxLength = pstmt.inputDesc_[paramNumber].sqlOctetLength_;
- int dataType = pstmt.inputDesc_[paramNumber].sqlDataType_;
- int dataCharSet = pstmt.inputDesc_[paramNumber].sqlCharset_;
- int dataLen;
-
- // setup the offsets
- int noNullValue = pstmt.inputDesc_[paramNumber].noNullValue_;
- int nullValue = pstmt.inputDesc_[paramNumber].nullValue_;
- int dataLength = pstmt.inputDesc_[paramNumber].maxLen_;
-
- boolean shortLength = precision < Math.pow(2, 15);
- int dataOffset = ((shortLength) ? 2 : 4);
-
- if ((dataType == InterfaceResultSet.SQLTYPECODE_VARCHAR_WITH_LENGTH)
- || (dataType == InterfaceResultSet.SQLTYPECODE_BLOB)
- || (dataType == InterfaceResultSet.SQLTYPECODE_CLOB)) {
- dataLength += dataOffset;
-
- if (dataLength % 2 != 0)
- dataLength++;
- }
-
- noNullValue = (noNullValue * paramRowCount) + (rowNumber * dataLength);
-
- if (nullValue != -1)
- nullValue = (nullValue * paramRowCount) + (rowNumber * 2);
-
- if (paramValue == null) {
- if (nullValue == -1) {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale,
- "null_parameter_for_not_null_column", new Integer(paramNumber));
- }
-
- // values[nullValue] = -1;
- Bytes.insertShort(values, nullValue, (short) -1, this.ic_.getByteSwap());
- return;
- }
-
- switch (dataType) {
- case InterfaceResultSet.SQLTYPECODE_CHAR:
- if (paramValue == null) {
- // Note for future optimization. We can probably remove the next
- // line,
- // because the array is already initialized to 0.
- Bytes.insertShort(values, noNullValue, (short) 0, this.ic_.getByteSwap());
- } else if (paramValue instanceof byte[]) {
- tmpBarray = (byte[]) paramValue;
- } else if (paramValue instanceof String) {
- String charSet = "";
-
- try {
- if (this.ic_.getISOMapping() == InterfaceUtilities.SQLCHARSETCODE_ISO88591
- && !this.ic_.getEnforceISO() && dataCharSet == InterfaceUtilities.SQLCHARSETCODE_ISO88591)
- charSet = ic_.t4props_.getISO88591();
- else
- {
- if(dataCharSet == InterfaceUtilities.SQLCHARSETCODE_UNICODE && this.ic_.getByteSwap())
- charSet = "UTF-16LE";
- else
- charSet = InterfaceUtilities.getCharsetName(dataCharSet);
- }
- tmpBarray = ((String) paramValue).getBytes(charSet);
- } catch (Exception e) {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
- charSet);
- }
- } // end if (paramValue instanceof String)
- else {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_parameter_value",
- "CHAR data should be either bytes or String for column: " + paramNumber);
- }
-
- //
- // We now have a byte array containing the parameter
- //
-
- dataLen = tmpBarray.length;
- if (maxLength >= dataLen) {
- System.arraycopy(tmpBarray, 0, values, noNullValue, dataLen);
- // Blank pad for rest of the buffer
- if (maxLength > dataLen) {
- if (dataCharSet == InterfaceUtilities.SQLCHARSETCODE_UNICODE) {
- // pad with Unicode spaces (0x00 0x32)
- int i2 = dataLen;
- while (i2 < maxLength) {
- values[noNullValue + i2] = (byte) ' ';
- values[noNullValue + (i2 + 1)] = (byte) 0 ;
- i2 = i2 + 2;
- }
- } else {
- Arrays.fill(values, (noNullValue + dataLen), (noNullValue + maxLength), (byte) ' ');
- }
- }
- } else {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_string_parameter",
- "CHAR input data is longer than the length for column: " + paramNumber);
- }
-
- break;
- case InterfaceResultSet.SQLTYPECODE_VARCHAR:
- if (paramValue instanceof byte[]) {
- tmpBarray = (byte[]) paramValue;
- } else if (paramValue instanceof String) {
- String charSet = "";
-
- try {
- if (this.ic_.getISOMapping() == InterfaceUtilities.SQLCHARSETCODE_ISO88591
- && !this.ic_.getEnforceISO() && dataCharSet == InterfaceUtilities.SQLCHARSETCODE_ISO88591)
- charSet = ic_.t4props_.getISO88591();
- else
- {
- if(dataCharSet == InterfaceUtilities.SQLCHARSETCODE_UNICODE && this.ic_.getByteSwap())
- charSet = "UTF-16LE";
- else
- charSet = InterfaceUtilities.getCharsetName(dataCharSet);
- }
- tmpBarray = ((String) paramValue).getBytes(charSet);
- } catch (Exception e) {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
- charSet);
- }
-
- } // end if (paramValue instanceof String)
- else {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_parameter_value",
- "VARCHAR data should be either bytes or String for column: " + paramNumber);
- }
-
- dataLen = tmpBarray.length;
- if (maxLength > dataLen) {
- Bytes.insertShort(values, noNullValue, (short) dataLen, this.ic_.getByteSwap());
- System.arraycopy(tmpBarray, 0, values, noNullValue + 2, dataLen);
- } else {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_parameter_value",
- "VARCHAR input data is longer than the length for column: " + paramNumber);
- }
- break;
- case InterfaceResultSet.SQLTYPECODE_DATETIME:
- Date tmpdate = null;
- switch (sqlDatetimeCode) {
- case InterfaceResultSet.SQLDTCODE_DATE:
- try {
- if (((String) paramValue)
- .matches("(\\d{4}-\\d{1,2}-\\d{1,2})|(\\d{1,2}\\.\\d{1,2}\\.\\d{4})|(\\d{1,2}/\\d{1,2}/\\d{4})")) {
- tmpdate = Date.valueOf((String) ((String) paramValue)
- .replaceFirst("(\\d{1,2})\\.(\\d{1,2})\\.(\\d{4})", "$3-$2-$1")
- .replaceFirst("(\\d{1,2})/(\\d{1,2})/(\\d{4})", "$3-$1-$2"));
- }else{
- throw new IllegalArgumentException();
- }
- } catch (IllegalArgumentException iex) {
- throw HPT4Messages
- .createSQLException(
- pstmt.connection_.props_,
- locale,
- "invalid_parameter_value",
- "["+paramValue+"] Date format is incorrect or date value is invalide. "
- + " Supported format: YYYY-MM-DD, MM/DD/YYYY, DD.MM.YYYY");
- }
- try {
- byte[] temp1 = tmpdate.toString().getBytes("ASCII");
- System.arraycopy(temp1, 0, values, noNullValue, temp1.length);
- } catch (java.io.UnsupportedEncodingException e) {
- Object[] messageArguments = new Object[1];
- messageArguments[0] = e.getMessage();
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
- messageArguments);
- }
- break;
- case InterfaceResultSet.SQLDTCODE_TIMESTAMP:
- Timestamp tmpts;
- try {
- tmpts = Timestamp.valueOf((String) paramValue);
- } catch (IllegalArgumentException iex) {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_parameter_value",
- "Timestamp data format is incorrect for column: " + paramNumber + " = " + paramValue);
- }
-
- // ODBC precision is nano secs. JDBC precision is micro secs
- // so substract 3 from ODBC precision.
- maxLength = maxLength - 3;
- try {
- tmpBarray = tmpts.toString().getBytes("ASCII");
- } catch (java.io.UnsupportedEncodingException e) {
- Object[] messageArguments = new Object[1];
- messageArguments[0] = e.getMessage();
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
- messageArguments);
- }
- dataLen = tmpBarray.length;
-
- if (maxLength > dataLen) {
- System.arraycopy(tmpBarray, 0, values, noNullValue, dataLen);
-
- // Don't know when we need this. padding blanks. Legacy??
- Arrays.fill(values, (noNullValue + dataLen), (noNullValue + maxLength), (byte) ' ');
- } else {
- System.arraycopy(tmpBarray, 0, values, noNullValue, maxLength);
- }
- break;
- case InterfaceResultSet.SQLDTCODE_TIME:
- // If the OdbcDataType is equal to Types.Other, that means
- // that this is HOUR_TO_FRACTION and should be treated
- // as a Type.Other --> see in SQLDesc.java
- if (OdbcDataType != java.sql.Types.OTHER) // do the processing
- // for TIME
- {
- Time tmptime;
- try {
- if (paramValue instanceof byte[]) {
- tmptime = Time.valueOf(new String((byte[]) paramValue, "ASCII"));
- } else {
- tmptime = Time.valueOf(paramValue.toString());
- }
- byte[] tempb1 = tmptime.toString().getBytes("ASCII");
- System.arraycopy(tempb1, 0, values, noNullValue, tempb1.length);
- } catch (IllegalArgumentException iex) {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale,
- "invalid_parameter_value", "Time data format is incorrect for column: " + paramNumber
- + " = " + paramValue);
- } catch (java.io.UnsupportedEncodingException e) {
- Object[] messageArguments = new Object[1];
- messageArguments[0] = e.getMessage();
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
- messageArguments);
- }
- break;
- } else {
- // HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION data type!!!
- // let the next case structure handle it
- }
- case HPT4Desc.SQLDTCODE_YEAR:
- case HPT4Desc.SQLDTCODE_YEAR_TO_MONTH:
- case HPT4Desc.SQLDTCODE_MONTH:
- case HPT4Desc.SQLDTCODE_MONTH_TO_DAY:
- case HPT4Desc.SQLDTCODE_DAY:
- case HPT4Desc.SQLDTCODE_HOUR:
- case HPT4Desc.SQLDTCODE_HOUR_TO_MINUTE:
- case HPT4Desc.SQLDTCODE_MINUTE:
- case HPT4Desc.SQLDTCODE_MINUTE_TO_SECOND:
- // case HPT4Desc.SQLDTCODE_MINUTE_TO_FRACTION:
- case HPT4Desc.SQLDTCODE_SECOND:
- // case HPT4Desc.SQLDTCODE_SECOND_TO_FRACTION:
- case HPT4Desc.SQLDTCODE_YEAR_TO_HOUR:
- case HPT4Desc.SQLDTCODE_YEAR_TO_MINUTE:
- case HPT4Desc.SQLDTCODE_MONTH_TO_HOUR:
- case HPT4Desc.SQLDTCODE_MONTH_TO_MINUTE:
- case HPT4Desc.SQLDTCODE_MONTH_TO_SECOND:
- // case HPT4Desc.SQLDTCODE_MONTH_TO_FRACTION:
- case HPT4Desc.SQLDTCODE_DAY_TO_HOUR:
- case HPT4Desc.SQLDTCODE_DAY_TO_MINUTE:
- case HPT4Desc.SQLDTCODE_DAY_TO_SECOND:
- // case HPT4Desc.SQLDTCODE_DAY_TO_FRACTION:
- default:
- if (paramValue instanceof String) {
- try {
- tmpBarray = ((String) paramValue).getBytes("ASCII");
- } catch (Exception e) {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
- "ASCII");
- }
- } else if (paramValue instanceof byte[]) {
- tmpBarray = (byte[]) paramValue;
- } else {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale,
- "invalid_cast_specification", "DATETIME data should be either bytes or String for column: "
- + paramNumber);
- }
- dataLen = tmpBarray.length;
- if (maxLength == dataLen) {
- System.arraycopy(tmpBarray, 0, values, noNullValue, maxLength);
- } else if (maxLength > dataLen) {
- System.arraycopy(tmpBarray, 0, values, noNullValue, dataLen);
-
- // Don't know when we need this. padding blanks. Legacy??
- Arrays.fill(values, (noNullValue + dataLen), (noNullValue + maxLength), (byte) ' ');
- } else {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_parameter_value",
- "DATETIME data longer than column length: " + paramNumber);
- }
- break;
- }
- break;
- case InterfaceResultSet.SQLTYPECODE_INTERVAL:
- if (paramValue instanceof byte[]) {
- tmpBarray = (byte[]) paramValue;
- } else if (paramValue instanceof String) {
- try {
- tmpBarray = ((String) paramValue).getBytes("ASCII");
- } catch (Exception e) {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
- "ASCII");
- }
- } else {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_cast_specification",
- "INTERVAL data should be either bytes or String for column: " + paramNumber);
- }
-
- dataLen = tmpBarray.length;
- if (maxLength >= dataLen) {
- dataLen = tmpBarray.length;
- if (maxLength == dataLen) {
- System.arraycopy(tmpBarray, 0, values, noNullValue, maxLength);
- } else if (maxLength > dataLen) {
- System.arraycopy(tmpBarray, 0, values, noNullValue, dataLen);
-
- // Don't know when we need this. padding blanks. Legacy??
- Arrays.fill(values, (noNullValue + dataLen), (noNullValue + maxLength), (byte) ' ');
- }
- } else {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_parameter_value",
- "INTERVAL data longer than column length: " + paramNumber);
- }
-
- break;
- case InterfaceResultSet.SQLTYPECODE_VARCHAR_WITH_LENGTH:
- case InterfaceResultSet.SQLTYPECODE_VARCHAR_LONG:
- case InterfaceResultSet.SQLTYPECODE_BLOB:
- case InterfaceResultSet.SQLTYPECODE_CLOB:
- if (paramValue instanceof byte[]) {
- tmpBarray = (byte[]) paramValue;
- } else if (paramValue instanceof String) {
- String charSet = "";
-
- try {
- if (this.ic_.getISOMapping() == InterfaceUtilities.SQLCHARSETCODE_ISO88591
- && !this.ic_.getEnforceISO() && dataCharSet == InterfaceUtilities.SQLCHARSETCODE_ISO88591)
- charSet = ic_.t4props_.getISO88591();
- else
- {
- if(dataCharSet == InterfaceUtilities.SQLCHARSETCODE_UNICODE && this.ic_.getByteSwap())
- charSet = "UTF-16LE";
- else
- charSet = InterfaceUtilities.getCharsetName(dataCharSet);
- }
- tmpBarray = ((String) paramValue).getBytes(charSet);
- } catch (Exception e) {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
- charSet);
- }
- } // end if (paramValue instanceof String)
- else {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_cast_specification",
- "VARCHAR data should be either bytes or String for column: " + paramNumber);
- }
-
- dataLen = tmpBarray.length;
- if (maxLength > (dataLen + dataOffset)) {
- maxLength = dataLen + dataOffset;
-
- if (shortLength) {
- System.arraycopy(Bytes.createShortBytes((short) dataLen, this.ic_.getByteSwap()), 0, values, noNullValue, dataOffset);
- } else {
- System.arraycopy(Bytes.createIntBytes((int) dataLen, this.ic_.getByteSwap()), 0, values, noNullValue, dataOffset);
- }
- System.arraycopy(tmpBarray, 0, values, (noNullValue + dataOffset), dataLen);
- } else {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_string_parameter",
- "VARCHAR data longer than column length: " + paramNumber);
- }
- break;
- case InterfaceResultSet.SQLTYPECODE_INTEGER:
- tmpbd = Utility.getBigDecimalValue(locale, paramValue);
- if (scale > 0) {
- tmpbd = tmpbd.movePointRight(scale);
- }
-
- // data truncation check
- if (pstmt.roundingMode_ == BigDecimal.ROUND_UNNECESSARY) {
- Utility.checkLongTruncation(paramNumber, tmpbd);
-
- }
- Utility.checkIntegerBoundary(locale, tmpbd);
-
- // check boundary condition for Numeric.
- Utility.checkDecimalBoundary(locale, tmpbd, precision);
-
- Bytes.insertInt(values, noNullValue, tmpbd.intValue(), this.ic_.getByteSwap());
- break;
- case InterfaceResultSet.SQLTYPECODE_INTEGER_UNSIGNED:
- tmpbd = Utility.getBigDecimalValue(locale, paramValue);
- if (scale > 0) {
- tmpbd = tmpbd.movePointRight(scale);
- }
-
- // data truncation check
- if (pstmt.roundingMode_ == BigDecimal.ROUND_UNNECESSARY) {
- Utility.checkLongTruncation(paramNumber, tmpbd);
-
- // range checking
- }
- Utility.checkUnsignedIntegerBoundary(locale, tmpbd);
-
- // check boundary condition for Numeric.
- Utility.checkDecimalBoundary(locale, tmpbd, precision);
-
- Bytes.insertInt(values, noNullValue, tmpbd.intValue(), this.ic_.getByteSwap());
- break;
- case InterfaceResultSet.SQLTYPECODE_SMALLINT:
- tmpbd = Utility.getBigDecimalValue(locale, paramValue);
- if (scale > 0) {
- tmpbd = tmpbd.movePointRight(scale);
- }
-
- // data truncation check
- if (pstmt.roundingMode_ == BigDecimal.ROUND_UNNECESSARY) {
- Utility.checkLongTruncation(paramNumber, tmpbd);
-
- // range checking
- }
- Utility.checkShortBoundary(locale, tmpbd);
-
- // check boundary condition for Numeric.
- Utility.checkDecimalBoundary(locale, tmpbd, precision);
-
- Bytes.insertShort(values, noNullValue, tmpbd.shortValue(), this.ic_.getByteSwap());
- break;
- case InterfaceResultSet.SQLTYPECODE_SMALLINT_UNSIGNED:
- tmpbd = Utility.getBigDecimalValue(locale, paramValue);
- if (scale > 0) {
- tmpbd = tmpbd.movePointRight(scale);
- }
-
- // data truncation check
- if (pstmt.roundingMode_ == BigDecimal.ROUND_UNNECESSARY) {
- Utility.checkLongTruncation(paramNumber, tmpbd);
-
- // range checking
- }
- Utility.checkSignedShortBoundary(locale, tmpbd);
-
- // check boundary condition for Numeric.
- Utility.checkDecimalBoundary(locale, tmpbd, precision);
-
- Bytes.insertShort(values, noNullValue, tmpbd.shortValue(), this.ic_.getByteSwap());
- break;
- case InterfaceResultSet.SQLTYPECODE_LARGEINT:
- tmpbd = Utility.getBigDecimalValue(locale, paramValue);
-
- if (scale > 0) {
- tmpbd = tmpbd.movePointRight(scale);
-
- // check boundary condition for Numeric.
- }
- Utility.checkDecimalBoundary(locale, tmpbd, precision);
- Bytes.insertLong(values, noNullValue, tmpbd.longValue(), this.ic_.getByteSwap());
- break;
- case InterfaceResultSet.SQLTYPECODE_DECIMAL:
- case InterfaceResultSet.SQLTYPECODE_DECIMAL_UNSIGNED:
-
- // create an parameter with out "."
- try {
- tmpbd = Utility.getBigDecimalValue(locale, paramValue);
- if (scale > 0) {
- tmpbd = tmpbd.movePointRight(scale);
-
- }
-
- tmpbd = Utility.setScale(tmpbd, scale, pstmt.roundingMode_);
-
- // data truncation check.
- if (pstmt.roundingMode_ == BigDecimal.ROUND_UNNECESSARY) {
- Utility.checkLongTruncation(paramNumber, tmpbd);
-
- // get only the mantissa part
- }
- try {
- tmpBarray = String.valueOf(tmpbd.longValue()).getBytes("ASCII");
- } catch (java.io.UnsupportedEncodingException e) {
- Object[] messageArguments = new Object[1];
- messageArguments[0] = e.getMessage();
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
- messageArguments);
- }
- } catch (NumberFormatException nex) {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_parameter_value",
- "DECIMAL data format incorrect for column: " + paramNumber + ". Error is: " + nex.getMessage());
- }
-
- dataLen = tmpBarray.length;
-
- // pad leading zero's if datalen < maxLength
- int desPos = 0;
- int srcPos = 0;
- boolean minus = false;
-
- // check if data is negative.
- if (tmpbd.signum() == -1) {
- minus = true;
- srcPos++;
- dataLen--;
- }
-
- // pad beginning 0 for empty space.
- int numOfZeros = maxLength - dataLen;
-
- // DataTruncation is happening.
- if (numOfZeros < 0) {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "data_truncation_exceed", new int[]{dataLen, maxLength});
- }
-
- for (i = 0; i < numOfZeros; i++) {
- values[noNullValue + desPos] = (byte) '0';
- desPos = desPos + 1;
- }
- System.arraycopy(tmpBarray, srcPos, values, noNullValue + desPos, dataLen);
-
- // handling minus sign in decimal. OR -80 with the first byte for
- // minus
- if (minus) {
- values[noNullValue] = (byte) ((byte) (-80) | values[noNullValue]);
- }
- break;
- case InterfaceResultSet.SQLTYPECODE_REAL:
- tmpbd = Utility.getBigDecimalValue(locale, paramValue);
- Utility.checkFloatBoundary(locale, tmpbd);
- float fvalue = tmpbd.floatValue();
- int bits = Float.floatToIntBits(fvalue);
-
- Bytes.insertInt(values, noNullValue, bits, this.ic_.getByteSwap());
- break;
- case InterfaceResultSet.SQLTYPECODE_FLOAT:
- tmpbd = Utility.getBigDecimalValue(locale, paramValue);
- Utility.checkFloatBoundary(locale, tmpbd);
- Bytes.insertLong(values, noNullValue, Double.doubleToLongBits(tmpbd.doubleValue()), this.ic_.getByteSwap());
- break;
- case InterfaceResultSet.SQLTYPECODE_DOUBLE:
- tmpbd = Utility.getBigDecimalValue(locale, paramValue);
- Utility.checkDoubleBoundary(locale, tmpbd);
- Bytes.insertLong(values, noNullValue, Double.doubleToLongBits(tmpbd.doubleValue()), this.ic_.getByteSwap());
- break;
- case InterfaceResultSet.SQLTYPECODE_NUMERIC:
- case InterfaceResultSet.SQLTYPECODE_NUMERIC_UNSIGNED:
- tmpbd = Utility.getBigDecimalValue(locale, paramValue);
- byte[] b = InterfaceUtilities.convertBigDecimalToSQLBigNum(tmpbd, maxLength, scale);
- System.arraycopy(b, 0, values, noNullValue, maxLength);
- break;
- // You will not get this type, since server internally converts it
- // SMALLINT, INTERGER or LARGEINT
- case InterfaceResultSet.SQLTYPECODE_DECIMAL_LARGE:
- case InterfaceResultSet.SQLTYPECODE_DECIMAL_LARGE_UNSIGNED:
- case InterfaceResultSet.SQLTYPECODE_BIT:
- case InterfaceResultSet.SQLTYPECODE_BITVAR:
- case InterfaceResultSet.SQLTYPECODE_BPINT_UNSIGNED:
- default:
- if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(stmt_.connection_.props_, locale, pstmt, paramValue,
- paramNumber);
- String temp = "Restricted_Datatype_Error";
- ic_.t4props_.t4Logger_.logp(Level.FINEST, "InterfaceStatement", "convertObjectToSQL2", temp, p);
- }
-
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, locale, "restricted_data_type", null);
- }
- if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities
- .makeParams(stmt_.connection_.props_, locale, pstmt, paramValue, paramNumber);
- String temp = "datatype = " + dataType;
- ic_.t4props_.t4Logger_.logp(Level.FINEST, "InterfaceStatement", "convertObjectToSQL2", temp, p);
- }
-
- } // end convertObjectToSQL2
-
- private SQLWarningOrError[] mergeErrors(SQLWarningOrError[] client, SQLWarningOrError[] server) {
- SQLWarningOrError[] target = new SQLWarningOrError[client.length + server.length];
-
- int si = 0; // server index
- int ci = 0; // client index
- int ti = 0; // target index
-
- int sr; // server rowId
- int cr; // client rowId
-
- int so = 0; // server offset
-
- while (ci < client.length && si < server.length) {
- cr = client[ci].rowId;
- sr = server[si].rowId + so;
-
- if (cr <= sr || server[si].rowId == 0) {
- so++;
- target[ti++] = client[ci++];
- } else {
- server[si].rowId += so;
- target[ti++] = server[si++];
- }
- }
-
- // we only have one array left
- while (ci < client.length) {
- target[ti++] = client[ci++];
- }
-
- while (si < server.length) {
- if (server[si].rowId != 0)
- server[si].rowId += so;
- target[ti++] = server[si++];
- }
-
- return target;
- }
-
- SQL_DataValue_def fillInSQLValues2(Locale locale, TrafT4Statement stmt, int paramRowCount, int paramCount,
- Object[] paramValues, ArrayList clientErrors) throws SQLException
-
- {
- SQL_DataValue_def dataValue = new SQL_DataValue_def();
-
- if (paramRowCount == 0 && paramValues != null && paramValues.length > 0)
- paramRowCount = 1; // fake a single row if we are doing inputParams
- // for an SPJ
-
- // TODO: we should really figure out WHY this could happen
- if (stmt.inputParamsLength_ < 0) {
- dataValue.buffer = new byte[0];
- dataValue.length = 0;
- } else {
- int bufLen = stmt.inputParamsLength_ * paramRowCount;
-
- dataValue.buffer = new byte[bufLen];
-
- for (int row = 0; row < paramRowCount; row++) {
- for (int col = 0; col < paramCount; col++) {
- try {
- convertObjectToSQL2(locale, stmt, paramValues[row * paramCount + col], paramRowCount, col,
- dataValue.buffer, row - clientErrors.size());
- } catch (HPT4Exception e) {
- if (paramRowCount == 1) // for single rows we need to
- // throw immediately
- throw e;
-
- clientErrors.add(new SQLWarningOrError(row + 1, e.getErrorCode(), e.getMessage(), e
- .getSQLState()));
- break; // skip the rest of the row
- }
- }
- }
-
- // fix the column offsets if we had errors
- if (clientErrors.size() > 0) {
- int oldOffset;
- int newOffset;
- int noNullValue;
- int nullValue;
- int colLength;
- int dataType;
-
- for (int i = 1; i < paramCount; i++) // skip the first col
- {
- noNullValue = stmt.inputDesc_[i].noNullValue_;
- nullValue = stmt.inputDesc_[i].nullValue_;
- colLength = stmt.inputDesc_[i].maxLen_;
- dataType = stmt.inputDesc_[i].dataType_;
- if (dataType == InterfaceResultSet.SQLTYPECODE_VARCHAR_WITH_LENGTH
- || dataType == InterfaceResultSet.SQLTYPECODE_BLOB
- || dataType == InterfaceResultSet.SQLTYPECODE_CLOB
- || dataType == InterfaceResultSet.SQLTYPECODE_VARCHAR_LONG
- || dataType == InterfaceResultSet.SQLTYPECODE_VARCHAR) {
- boolean shortLength = colLength < Math.pow(2, 15);
- int dataOffset = ((shortLength) ? 2 : 4);
- colLength += dataOffset;
-
- if (colLength % 2 != 0)
- colLength++;
- }
-
- if (nullValue != -1) {
- oldOffset = nullValue * paramRowCount;
- newOffset = oldOffset - (nullValue * clientErrors.size());
- System.arraycopy(dataValue.buffer, oldOffset, dataValue.buffer, newOffset,
- 2 * (paramRowCount - clientErrors.size()));
- }
-
- oldOffset = noNullValue * paramRowCount;
- newOffset = oldOffset - (noNullValue * clientErrors.size());
- System.arraycopy(dataValue.buffer, oldOffset, dataValue.buffer, newOffset, colLength
- * (paramRowCount - clientErrors.size()));
- }
- }
-
- dataValue.length = stmt.inputParamsLength_ * (paramRowCount - clientErrors.size());
- }
- return dataValue;
- }
-
- boolean hasParameters(String sql) {
- boolean foundParam = false;
-
- String[] s = sql.split("\"[^\"]*\"|'[^']*'");
- for (int i = 0; i < s.length; i++) {
- if (s[i].indexOf('?') != -1) {
- foundParam = true;
- break;
- }
- }
-
- return foundParam;
- }
-
- /**
- * Get the transaction status
- *
- * @param sql
- * @return
- */
- private short getTransactionStatus(String sql) {
- String tokens[] = sql.split("[^a-zA-Z]+", 3);
- short rt1 = 0;
- if (tokens.length > 1 && tokens[1].equalsIgnoreCase("WORK")) {
- if (tokens[0].equalsIgnoreCase("BEGIN"))
- rt1 = TRANSPORT.TYPE_BEGIN_TRANSACTION;
- } else if (tokens[0].equalsIgnoreCase("COMMIT")
- || tokens[0].equalsIgnoreCase("ROLLBACK")) {
- rt1 = TRANSPORT.TYPE_END_TRANSACTION;
- }
-
- return rt1;
- }
-
- // -------------------------------------------------------------
- //TODO: this whole function needs to be rewritten
- short getSqlStmtType(String str) {
- str=str.replaceAll("\\n"," ");
- str=str.replaceAll("\\s*/\\*.*?\\*/\\s*", " ").trim();
-
- // 7708
- stmtIsLock = false;
-
- String tokens[] = str.split("[^a-zA-Z]+", 3);
- short rt1 = TRANSPORT.TYPE_UNKNOWN;
- String str3 = "";
-
- if (tokens[0].length() > 0)
- str3 = tokens[0].toUpperCase();
- else
- str3 = tokens[1].toUpperCase();
-
- if(str3.equals("JOINXATXN")){
- rt1 = TRANSPORT.TYPE_SELECT;
- }
- else if(str3.equals("WMSOPEN")) {
- rt1 = TRANSPORT.TYPE_QS_OPEN;
- }
- else if(str3.equals("WMSCLOSE")) {
- rt1 = TRANSPORT.TYPE_QS_CLOSE;
- }
- else if(str3.equals("CMDOPEN")) {
- rt1 = TRANSPORT.TYPE_CMD_OPEN;
- }
- else if(str3.equals("CMDCLOSE")) {
- rt1 = TRANSPORT.TYPE_CMD_CLOSE;
- }
- else {
- switch(this.ic_.getMode()) {
- case InterfaceConnection.MODE_SQL:
- if ((str3.equals("SELECT")) || (str3.equals("SHOWSHAPE")) || (str3.equals("INVOKE"))
- || (str3.equals("SHOWCONTROL")) || (str3.equals("SHOWDDL")) || (str3.equals("EXPLAIN"))
- || (str3.equals("SHOWPLAN")) || (str3.equals("REORGANIZE")) || (str3.equals("MAINTAIN"))
- || (str3.equals("SHOWLABEL")) || (str3.equals("VALUES"))
- || (str3.equals("REORG")) || (str3.equals("SEL")) || (str3.equals("GET")) || (str3.equals("SHOWSTATS"))
- || str3.equals("GIVE") || str3.equals("STATUS") || str3.equals("INFO") || str3.equals("LIST")
- ) {
- rt1 = TRANSPORT.TYPE_SELECT;
- }
- else if (str3.equals("UPDATE") || str3.equals("MERGE")) {
- rt1 = TRANSPORT.TYPE_UPDATE;
- } else if (str3.equals("DELETE") || str3.equals("STOP") || str3.equals("START")) {
- rt1 = TRANSPORT.TYPE_DELETE;
- } else if (str3.equals("INSERT") || str3.equals("INS") || str3.equals("UPSERT")) {
- if (hasParameters(str)) {
- rt1 = TRANSPORT.TYPE_INSERT_PARAM;
- } else {
- rt1 = TRANSPORT.TYPE_INSERT;
- }
- }
- else if (str3.equals("CREATE")) {
- rt1 = TRANSPORT.TYPE_CREATE;
- } else if (str3.equals("GRANT")) {
- rt1 = TRANSPORT.TYPE_GRANT;
- } else if (str3.equals("DROP")) {
- rt1 = TRANSPORT.TYPE_DROP;
- } else if (str3.equals("CALL")) {
- rt1 = TRANSPORT.TYPE_CALL;
- } else if (str3.equals("EXPLAIN")) {
- rt1 = TRANSPORT.TYPE_EXPLAIN;
- } else if (str3.equals("INFOSTATS")) {
- rt1 = TRANSPORT.TYPE_STATS;
- }
- break;
- case InterfaceConnection.MODE_WMS:
- if (str3.equals("STATUS") || str3.equals("INFO")) {
- rt1 = TRANSPORT.TYPE_SELECT;
- }
- break;
- /* FROM ODBC
- if (_strnicmp(token, "STATUS", 6) == 0)
- m_StmtType = TYPE_SELECT;
- else if (_strnicmp(token, "CANCEL", 6) == 0)
- m_StmtType = TYPE_UNKNOWN;
- else if (_strnicmp(token, "SUSPEND", 7) == 0)
- m_StmtType = TYPE_UNKNOWN;
- else if (_strnicmp(token, "RESUME", 6) == 0)
- m_StmtType = TYPE_UNKNOWN;
- else if (_strnicmp(token, "ALTPRI", 6) == 0)
- m_StmtType = TYPE_UNKNOWN;
- else if (_strnicmp(token, "ADD", 3) == 0)
- m_StmtType = TYPE_UNKNOWN;
- else if (_strnicmp(token, "ALTER", 5) == 0)
- m_StmtType = TYPE_UNKNOWN;
- else if (_strnicmp(token, "DELETE", 6) == 0)
- m_StmtType = TYPE_UNKNOWN;
- else if (_strnicmp(token, "INFO", 4) == 0)
- m_StmtType = TYPE_SELECT;
- else
- m_StmtType = TYPE_UNKNOWN;
- }*/
- case InterfaceConnection.MODE_CMD:
- if (str3.equals("STATUS") || str3.equals("INFO") || str3.equals("LIST")) {
- rt1 = TRANSPORT.TYPE_SELECT;
- }
- else if(str3.equals("ADD") || str3.equals("ALTER")) {
- rt1 = TRANSPORT.TYPE_INSERT;
- }
- else if(str3.equals("DELETE") || str3.equals("STOP") || str3.equals("START")) {
- rt1 = TRANSPORT.TYPE_DELETE;
- }
- break;
- }
- }
-
- return rt1;
-
- } // end getSqlStmtType
-
- // -------------------------------------------------------------
- long getRowCount() {
- return rowCount_;
- }
-
- // -------------------------------------------------------------
- void setRowCount(long rowCount) {
- if (rowCount < 0) {
- rowCount_ = -1;
- } else {
- rowCount_ = rowCount;
- }
- }
-
- // -------------------------------------------------------------
- static HPT4Desc[] NewDescArray(SQLItemDescList_def desc) {
- int index;
- HPT4Desc[] HPT4DescArray;
- SQLItemDesc_def SQLDesc;
-
- if (desc.list == null || desc.list.length == 0) {
- return null;
- }
-
- HPT4DescArray = new HPT4Desc[desc.list.length];
-
- for (index = 0; index < desc.list.length; index++) {
- SQLDesc = desc.list[index];
- boolean nullInfo = (((new Byte(SQLDesc.nullInfo)).shortValue()) == 1) ? true : false;
- boolean signType = (((new Byte(SQLDesc.signType)).shortValue()) == 1) ? true : false;
- HPT4DescArray[index] = new HPT4Desc(SQLDesc.dataType, (short) SQLDesc.datetimeCode, SQLDesc.maxLen,
- SQLDesc.precision, SQLDesc.scale, nullInfo, SQLDesc.colHeadingNm, signType, SQLDesc.ODBCDataType,
- SQLDesc.ODBCPrecision, SQLDesc.SQLCharset, SQLDesc.ODBCCharset, SQLDesc.CatalogName,
- SQLDesc.SchemaName, SQLDesc.TableName, SQLDesc.dataType, SQLDesc.intLeadPrec, SQLDesc.paramMode);
- }
- return HPT4DescArray;
- }
-
- // -------------------------------------------------------------
- static HPT4Desc[] NewDescArray(Descriptor2[] descArray) {
- int index;
- HPT4Desc[] HPT4DescArray;
- Descriptor2 desc;
-
- if (descArray == null || descArray.length == 0) {
- return null;
- }
-
- HPT4DescArray = new HPT4Desc[descArray.length];
-
- for (index = 0; index < descArray.length; index++) {
- desc = descArray[index];
- boolean nullInfo = false;
- boolean signType = false;
-
- if (desc.nullInfo_ != 0) {
- nullInfo = true;
- }
- if (desc.signed_ != 0) {
- signType = true;
-
- }
- HPT4DescArray[index] = new HPT4Desc(desc.noNullValue_, desc.nullValue_, desc.version_, desc.dataType_,
- (short) desc.datetimeCode_, desc.maxLen_, (short) desc.precision_, (short) desc.scale_, nullInfo,
- signType, desc.odbcDataType_, desc.odbcPrecision_, desc.sqlCharset_, desc.odbcCharset_,
- desc.colHeadingNm_, desc.tableName_, desc.catalogName_, desc.schemaName_, desc.headingName_,
- desc.intLeadPrec_, desc.paramMode_, desc.dataType_, desc.getRowLength());
- }
- return HPT4DescArray;
- }
-
- // -------------------------------------------------------------
- // Interface methods
- void executeDirect(int queryTimeout, TrafT4Statement stmt) throws SQLException {
- short executeAPI = stmt.getOperationID();
- byte[] messageBuffer = stmt.getOperationBuffer();
- GenericReply gr = null;
-
- gr = t4statement_.ExecuteGeneric(executeAPI, messageBuffer);
- stmt.operationReply_ = gr.replyBuffer;
-
- if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(stmt_.connection_.props_, queryTimeout, stmt);
- String temp = "Exiting ExecDirect.";
- ic_.t4props_.t4Logger_.logp(Level.FINEST, "InterfaceStatement", "executeDirect", temp, p);
- }
- } // end executeDirect
-
- // --------------------------------------------------------------------------
- int close() throws SQLException {
- int rval = 0;
- CloseReply cry_ = null;
- ic_.isConnectionOpen();
- if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(stmt_.connection_.props_);
- String temp = "Closing = " + stmtLabel_;
- ic_.t4props_.t4Logger_.logp(Level.FINEST, "InterfaceStatement", "close", temp, p);
- }
-
- cry_ = t4statement_.Close();
- switch (cry_.m_p1.exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
-
- // ignore the SQLWarning for the static close
- break;
- case odbc_SQLSvc_Close_exc_.odbc_SQLSvc_Close_SQLError_exn_:
- HPT4Messages.throwSQLException(stmt_.connection_.props_, cry_.m_p1.SQLError);
- default:
- throw HPT4Messages.createSQLException(stmt_.connection_.props_, ic_.getLocale(), "ids_unknown_reply_error",
- null);
- } // end switch
-
- return cry_.m_p2; // rowsAffected
- } // end close
-
- // --------------------------------------------------------------------------
- void cancel() throws SQLException {
- ic_.cancel();
- }
-
- // --------------------------------------------------------------------------
- // Interface methods for prepared statement
- void prepare(String sql, int queryTimeout, TrafT4PreparedStatement pstmt) throws SQLException {
- int sqlAsyncEnable = 0;
- this.stmtType_ = this.EXTERNAL_STMT;
- this.sqlStmtType_ = getSqlStmtType(sql);
- this.setTransactionStatus(pstmt.connection_, sql);
- int stmtLabelCharset = 1;
- String cursorName = pstmt.cursorName_;
- int cursorNameCharset = 1;
- String moduleName = pstmt.moduleName_;
- int moduleNameCharset = 1;
- long moduleTimestamp = pstmt.moduleTimestamp_;
- String sqlString = sql;
- int sqlStringCharset = 1;
- String stmtOptions = "";
- int maxRowsetSize = pstmt.getMaxRows();
-
- byte[] txId;
-
-//3196 - NDCS transaction for SPJ
-// if (ic_.t4props_.getSPJEnv())
-// txId = getUDRTransaction(this.ic_.getByteSwap());
-// else
-// txId = Bytes.createIntBytes(0, false);
- txId = Bytes.createIntBytes(0, false);
-
- if (sqlStmtType_ == TRANSPORT.TYPE_STATS) {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, ic_.getLocale(), "infostats_invalid_error",
- null);
- } else if (sqlStmtType_ == TRANSPORT.TYPE_CONFIG) {
- throw HPT4Messages.createSQLException(pstmt.connection_.props_, ic_.getLocale(),
- "config_cmd_invalid_error", null);
- }
-
- PrepareReply pr = t4statement_.Prepare(sqlAsyncEnable, (short) this.stmtType_, this.sqlStmtType_,
- pstmt.stmtLabel_, stmtLabelCharset, cursorName, cursorNameCharset, moduleName, moduleNameCharset,
- moduleTimestamp, sqlString, sqlStringCharset, stmtOptions, maxRowsetSize, txId);
-
- pr_ = pr;
- this.sqlQueryType_ = pr.sqlQueryType;
-
- switch (pr.returnCode) {
- case TRANSPORT.SQL_SUCCESS:
- case TRANSPORT.SQL_SUCCESS_WITH_INFO:
- HPT4Desc[] OutputDesc = InterfaceStatement.NewDescArray(pr.outputDesc);
- HPT4Desc[] InputDesc = InterfaceStatement.NewDescArray(pr.inputDesc);
- pstmt.setPrepareOutputs2(InputDesc, OutputDesc, pr.inputNumberParams, pr.outputNumberParams,
- pr.inputParamLength, pr.outputParamLength, pr.inputDescLength, pr.outputDescLength);
-
- if (pr.errorList != null && pr.errorList.length > 0) {
- HPT4Messages.setSQLWarning(stmt_.connection_.props_, pstmt, pr.errorList);
- }
-
- this.stmtHandle_ = pr.stmtHandle;
-
- break;
-
- case odbc_SQLSvc_Prepare_exc_.odbc_SQLSvc_Prepare_SQLError_exn_:
-
- default:
- HPT4Messages.throwSQLException(stmt_.connection_.props_, pr.errorList);
- }
-
- if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(stmt_.connection_.props_, sql, queryTimeout, pstmt);
- String temp = "Exiting prepare...";
- ic_.t4props_.t4Logger_.logp(Level.FINEST, "InterfaceStatement", "prepare", temp, p);
- }
- };
-
- // used to keep the same transaction inside an SPJ. we call out to the UDR
- // server and use their transaction for all executes.
- byte[] getUDRTransaction(boolean swapBytes) throws SQLException {
- byte[] ret = null;
-
- try {
- // To get references to method
- InterfaceStatement.LmUtility_class_ = Class.forName("com.tandem.sqlmx.LmUtility");
- InterfaceStatement.LmUtility_getTransactionId_ = InterfaceStatement.LmUtility_class_.getMethod(
- "getTransactionId", new Class[] {});
-
- // To invoke the method
- short[] tId = (short[]) InterfaceStatement.LmUtility_getTransactionId_.invoke(null, new Object[] {});
-
- ret = new byte[tId.length * 2];
-
- for (int i = 0; i < tId.length; i++) {
- Bytes.insertShort(ret, i * 2, tId[i], swapBytes);
- }
- } catch (Exception e) {
- ic_.t4props_.t4Logger_.logp(Level.FINEST, "InterfaceStatement", "getUDRTransaction",
- "Error calling UDR for transaction id");
-
- String s = e.toString() + "\r\n";
- StackTraceElement[] st = e.getStackTrace();
-
- for (int i = 0; i < st.length; i++) {
- s += st[i].toString() + "\r\n";
- }
-
- throw new SQLException(s);
- }
-
- return ret;
- }
-
- // -------------------------------------------------------------------
- void execute(short executeAPI, int paramRowCount, int paramCount, Object[] paramValues, int queryTimeout
- // executeDirect
- , String sql, TrafT4Statement stmt
-
- ) throws SQLException {
- cursorName_ = stmt.cursorName_;
- rowCount_ = 0;
-
- int sqlAsyncEnable = (stmt.getResultSetHoldability() == TrafT4ResultSet.HOLD_CURSORS_OVER_COMMIT) ? 1 : 0;
- int inputRowCnt = paramRowCount;
- int maxRowsetSize = stmt.getMaxRows();
- String sqlString = (sql == null) ? stmt.getSQL() : sql;
- int sqlStringCharset = 1;
- int cursorNameCharset = 1;
- int stmtLabelCharset = 1;
- byte[] txId;
- ArrayList clientErrors = new ArrayList();
-
-//3196 - NDCS transaction for SPJ
-// if (ic_.t4props_.getSPJEnv())
-// txId = getUDRTransaction(this.ic_.getByteSwap());
-// else if (stmt.transactionToJoin != null)
-// txId = stmt.transactionToJoin;
-// else if (stmt.connection_.transactionToJoin != null)
-// txId = stmt.connection_.transactionToJoin;
-// else
-// txId = Bytes.createIntBytes(0, false); // 0 length, no data
- if (stmt.transactionToJoin != null)
- txId = stmt.transactionToJoin;
- else if (stmt.connection_.transactionToJoin != null)
- txId = stmt.connection_.transactionToJoin;
- else
- txId = Bytes.createIntBytes(0, false); // 0 length, no data
-
- SQL_DataValue_def inputDataValue;
- SQLValueList_def inputValueList = new SQLValueList_def();
- byte[] inputParams = null;
-
- if (executeAPI == TRANSPORT.SRVR_API_SQLEXECDIRECT) {
- sqlStmtType_ = getSqlStmtType(sql);
- setTransactionStatus(stmt.connection_, sql);
- stmt.outputDesc_ = null; // clear the output descriptors
- }
-
- if (stmt.usingRawRowset_ == true) {
- executeAPI = TRANSPORT.SRVR_API_SQLEXECUTE2;
- inputDataValue = new SQL_DataValue_def();
- inputDataValue.userBuffer = stmt.rowwiseRowsetBuffer_;
- inputDataValue.length = stmt.rowwiseRowsetBuffer_.limit() - 4;
-
- if (this.sqlQueryType_ == 16) // use the param values
- {
- try {
- inputRowCnt = Integer.parseInt(paramValues[0].toString());
- maxRowsetSize = Integer.parseInt(paramValues[1].toString());
- } catch (Exception e) {
- throw new SQLException(
- "Error setting inputRowCnt and maxRowsetSize. Parameters not set or invalid.");
- }
- } else {
- inputRowCnt = paramRowCount - 1;
- }
-
- } else {
- inputDataValue = fillInSQLValues2(ic_.getLocale(), stmt, inputRowCnt, paramCount, paramValues, clientErrors);
-
- if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(stmt_.connection_.props_, paramRowCount, paramCount,
- paramValues, queryTimeout, stmt);
- String temp = "invoke ==> Execute2";
- ic_.t4props_.t4Logger_.logp(Level.FINEST, "InterfaceStatement", "execute", temp, p);
- }
- }
-
- ExecuteReply er = t4statement_.Execute(executeAPI, sqlAsyncEnable, inputRowCnt - clientErrors.size(),
- maxRowsetSize, this.sqlStmtType_, this.stmtHandle_, sqlString, sqlStringCharset, this.cursorName_,
- cursorNameCharset, stmt.stmtLabel_, stmtLabelCharset, inputDataValue, inputValueList, txId,
- stmt.usingRawRowset_);
-
- if (executeAPI == TRANSPORT.SRVR_API_SQLEXECDIRECT) {
- this.sqlQueryType_ = er.queryType;
- }
-
- if (clientErrors.size() > 0) {
- if (er.errorList == null)
- er.errorList = (SQLWarningOrError[]) clientErrors.toArray(new SQLWarningOrError[clientErrors.size()]);
- else
- er.errorList = mergeErrors((SQLWarningOrError[]) clientErrors
- .toArray(new SQLWarningOrError[clientErrors.size()]), er.errorList);
- }
-
- stmt_.result_set_offset = 0;
- rowCount_ = er.rowsAffected;
-
- int numStatus;
-
- if (stmt_.connection_.props_.getDelayedErrorMode())
- {
- if (stmt_._lastCount > 0) {
- numStatus = stmt_._lastCount;
- }
- else {
- numStatus = inputRowCnt;
- }
- }
- else
- {
- numStatus = inputRowCnt;
- }
-
- if (numStatus < 1)
- {
- numStatus = 1;
- }
-
- stmt.batchRowCount_ = new int[numStatus];
- boolean batchException = false; //3164
-
- if (stmt_.connection_.props_.getDelayedErrorMode() && stmt_._lastCount < 1) {
- Arrays.fill(stmt.batchRowCount_, -2); // fill with success
- }
- else if (er.returnCode == TRANSPORT.SQL_SUCCESS || er.returnCode == TRANSPORT.SQL_SUCCESS_WITH_INFO
- || er.returnCode == TRANSPORT.NO_DATA_FOUND) {
- Arrays.fill(stmt.batchRowCount_, -2); // fill with success
- if (er.errorList != null) // if we had errors with valid rowIds,
- // update the array
- {
- for (int i = 0; i < er.errorList.length; i++) {
- int row = er.errorList[i].rowId - 1;
- if (row >= 0 && row < stmt.batchRowCount_.length) {
- stmt.batchRowCount_[row] = -3;
- batchException = true; //3164
- }
- }
- }
-
- //set the statement mode as the command succeeded
- if (sqlStmtType_ == TRANSPORT.TYPE_QS_OPEN) {
- this.ic_.setMode(InterfaceConnection.MODE_WMS);
- } else if (sqlStmtType_ == TRANSPORT.TYPE_QS_CLOSE) {
- this.ic_.setMode(InterfaceConnection.MODE_SQL);
- } else if(sqlStmtType_ == TRANSPORT.TYPE_CMD_OPEN) {
- this.ic_.setMode(InterfaceConnection.MODE_CMD);
- } else if(sqlStmtType_ == TRANSPORT.TYPE_CMD_CLOSE) {
- this.ic_.setMode(InterfaceConnection.MODE_SQL);
- }
-
- // set the statement label if we didnt get one back.
- if (er.stmtLabels == null || er.stmtLabels.length == 0) {
- er.stmtLabels = new String[1];
- er.stmtLabels[0] = stmt.stmtLabel_;
- }
-
- // get the descriptors from the proper location
- HPT4Desc[][] desc = null;
-
- // try from execute data first
- if (er.outputDesc != null && er.outputDesc.length > 0) {
- desc = new HPT4Desc[er.outputDesc.length][];
-
- for (int i = 0; i < er.outputDesc.length; i++) {
- desc[i] = InterfaceStatement.NewDescArray(er.outputDesc[i]);
- }
- }
- // try from the prepare data
- else if (stmt.outputDesc_ != null && stmt.outputDesc_.length > 0) {
- desc = new HPT4Desc[1][];
- desc[0] = stmt.outputDesc_;
- }
-
- if (this.sqlStmtType_ == TRANSPORT.TYPE_CALL) {
- TrafT4CallableStatement cstmt = (TrafT4CallableStatement) stmt;
- Object[] outputValueArray;
- if(er.returnCode == TRANSPORT.NO_DATA_FOUND) { //this should really only happen with LAST0 specified
- outputValueArray = new Object[cstmt.outputDesc_.length];
- }
- else {
- outputValueArray = InterfaceResultSet.getExecute2Outputs(cstmt.connection_, cstmt.outputDesc_,
- er.outValues, this.ic_.getByteSwap());
- }
-
- cstmt.setExecuteCallOutputs(outputValueArray, (short) er.rowsAffected);
- stmt.setMultipleResultSets(er.numResultSets, desc, er.stmtLabels, er.proxySyntax);
- } else {
- // fix until we start returning numResultsets for more than just
- // SPJs
- if (desc != null && desc.length > 0 && er.numResultSets == 0) {
- er.numResultSets = 1;
- }
-
- if (er.outValues != null && er.outValues.length > 0) {
- stmt.setExecute2Outputs(er.outValues, (short) er.rowsAffected, false, er.proxySyntax, desc[0]);
- } else {
- stmt.setMultipleResultSets(er.numResultSets, desc, er.stmtLabels, er.proxySyntax);
- }
- }
- if (er.errorList != null) {
- HPT4Messages.setSQLWarning(stmt_.connection_.props_, stmt, er.errorList);
- }
- } else {
- Arrays.fill(stmt.batchRowCount_, -3); // fill with failed
- HPT4Messages.throwSQLException(stmt_.connection_.props_, er.errorList);
- }
- //3164
- if (batchException) {
- HPT4Messages.throwSQLException(stmt_.connection_.props_, er.errorList);
- }
- }
-
- protected void setTransactionStatus(TrafT4Connection conn, String sql) {
- short tranStatus = getTransactionStatus(sql);
- if(tranStatus == TRANSPORT.TYPE_BEGIN_TRANSACTION){
- conn.setBeginTransaction(true);
- }else if (tranStatus == TRANSPORT.TYPE_END_TRANSACTION){
- conn.setBeginTransaction(false);
- }
-
- }
-} // end class InterfaceStatement
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InterfaceUtilities.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InterfaceUtilities.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InterfaceUtilities.java
deleted file mode 100644
index 95fa7f9..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InterfaceUtilities.java
+++ /dev/null
@@ -1,235 +0,0 @@
-// @@@ 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;
-import java.math.BigInteger;
-import java.util.Hashtable;
-
-public class InterfaceUtilities {
- static private Hashtable valueToCharset;
- static {
- valueToCharset = new Hashtable(11);
- valueToCharset.put(new Integer(1), "ISO8859_1"); // ISO
- valueToCharset.put(new Integer(10), "MS932"); // SJIS
- valueToCharset.put(new Integer(11), "UTF-16BE"); // UCS2
- valueToCharset.put(new Integer(12), "EUCJP"); // EUCJP
- valueToCharset.put(new Integer(13), "MS950"); // BIG5
- valueToCharset.put(new Integer(14), "GB18030"); // GB18030
- valueToCharset.put(new Integer(15), "UTF-8"); // UTF8
- valueToCharset.put(new Integer(16), "MS949"); // MB_KSC5601
- valueToCharset.put(new Integer(17), "GB2312"); // GB2312
- }
- static private Hashtable charsetToValue;
- static {
- charsetToValue = new Hashtable(11);
- charsetToValue.put("ISO8859_1", new Integer(1)); // ISO
- charsetToValue.put("MS932", new Integer(10)); // SJIS
- charsetToValue.put("UTF-16BE", new Integer(11)); // UCS2
- charsetToValue.put("EUCJP", new Integer(12)); // EUCJP
- charsetToValue.put("MS950", new Integer(13)); // BIG5
- charsetToValue.put("GB18030", new Integer(14)); // GB18030
- charsetToValue.put("UTF-8", new Integer(15)); // UTF8
- charsetToValue.put("MS949", new Integer(16)); // MB_KSC5601
- charsetToValue.put("GB2312", new Integer(17)); // GB2312
- }
-
- static final int SQLCHARSETCODE_UNKNOWN = 0;
- static final String SQLCHARSET_UNKNOWN = "UNKNOWN";
-
- // these are the only real column types
- static final int SQLCHARSETCODE_ISO88591 = 1;
- static final String SQLCHARSET_ISO88591 = "ISO88591";
- static final int SQLCHARSETCODE_UNICODE = 11;
- static final String SQLCHARSET_UNICODE = "UCS2";
-
- // ISO_MAPPING values
- static final int SQLCHARSETCODE_SJIS = 10;
- static final int SQLCHARSETCODE_UTF8 = 15;
-
- static String getCharsetName(int charset) {
- String ret = (String) valueToCharset.get(new Integer(charset));
-
- if (ret == null)
- ret = SQLCHARSET_UNKNOWN;
-
- return ret;
- }
-
- static int getCharsetValue(String charset) {
- Integer i = (Integer) charsetToValue.get(charset);
- int ret;
-
- if (i == null)
- ret = SQLCHARSETCODE_UNKNOWN;
- else
- ret = i.intValue();
-
- return ret;
- }
-
- static private final int[] powersOfTen = { 10, 100, 1000, 10000 };
-
- public static byte[] convertBigDecimalToSQLBigNum(BigDecimal bd, int targetLength, int targetScale) {
- byte[] sourceData = bd.setScale(targetScale, BigDecimal.ROUND_DOWN).unscaledValue().toString().getBytes(); // add
- // trailing
- // 0s,
- // remove decimal point,
- // get the chars
- byte[] targetData = new byte[targetLength];
- int[] targetInShorts = new int[targetLength / 2];
-
- int length;
- int temp;
- int tarPos = 1;
-
- // remove leading 0s and sign character
- int zeros = 0;
- while (zeros < sourceData.length && (sourceData[zeros] == '0' || sourceData[zeros] == '-'))
- zeros++;
-
- // convert from characters to values
- for (int i = zeros; i < sourceData.length; i++)
- sourceData[i] -= '0';
-
- length = sourceData.length - zeros; // we have a new length
-
- // iterate through 4 bytes at a time
- for (int i = 0; i < length; i += 4) {
- int temp1 = 0;
- int j = 0;
-
- // get 4 bytes worth of data or as much that is left
- for (j = 0; j < 4 && i + j < length; j++)
- temp1 = temp1 * 10 + sourceData[zeros + i + j];
-
- int power = powersOfTen[j - 1]; // get the power of ten based on how
- // many digits we got
-
- temp = targetInShorts[0] * power + temp1; // move the current
- // digits over and then
- // add our new value in
- targetInShorts[0] = temp & 0xFFFF; // we save only up to 16bits --
- // the rest gets carried over
-
- // we do the same thing for the rest of the digits now that we have
- // an upper bound
- for (j = 1; j < targetInShorts.length; j++) {
- int t = (temp & 0xFFFF0000) >> 16;
- temp = targetInShorts[j] * power + t;
-
- targetInShorts[j] = temp & 0xFFFF;
- }
-
- int carry = (temp & 0xFFFF0000) >> 16;
- if (carry > 0) {
- targetInShorts[tarPos++] = carry;
- }
- }
-
- // convert the data back to bytes
- for (int i = 0; i < targetInShorts.length; i++) {
-// targetData[i * 2] = (byte) ((targetInShorts[i] & 0xFF00) >> 8);
-// targetData[i * 2 + 1] = (byte) (targetInShorts[i] & 0xFF);
- targetData[i * 2 ] = (byte) (targetInShorts[i] & 0xFF);
- targetData[i * 2 + 1] = (byte) ((targetInShorts[i] & 0xFF00) >> 8);
- }
-
- // add sign
- if ((bd.signum() < 0))
- targetData[targetData.length - 2] |= 0x80;
-
- return targetData;
- }
-
- public static BigDecimal convertSQLBigNumToBigDecimal(byte[] sourceData, int scale, boolean swap) {
- String strVal = ""; // our final String
-
- // we need the data in an array which can hold UNSIGNED 16 bit values
- // in java we dont have unsigned datatypes so 32-bit signed is the best
- // we can do
- int[] dataInShorts = new int[sourceData.length / 2];
- for (int i = 0; i < dataInShorts.length; i++)
- dataInShorts[i] = Bytes.extractUShort(sourceData, i * 2, swap); // copy
- // the
- // data
-
- boolean negative = ((dataInShorts[dataInShorts.length - 1] & 0x8000) > 0);
- dataInShorts[dataInShorts.length - 1] &= 0x7FFF; // force sign to 0, continue
- // normally
-
- int curPos = dataInShorts.length - 1; // start at the end
- while (curPos >= 0 && dataInShorts[curPos] == 0)
- // get rid of any trailing 0's
- curPos--;
-
- int remainder = 0;
- long temp; // we need to use a LONG since we will have to hold up to
- // 32-bit UNSIGNED values
-
- // we now have the huge value stored in 2 bytes chunks
- // we will divide by 10000 many times, converting the remainder to
- // String
- // when we are left with a single chunk <10000 we will handle it using a
- // special case
- while (curPos >= 0 || dataInShorts[0] >= 10000) {
- // start on the right, divide the 16 bit value by 10000
- // use the remainder as the upper 16 bits for the next division
- for (int j = curPos; j >= 0; j--) {
- // these operations got messy when java tried to infer what size
- // to store the value in
- // leave these as separate operations for now...always casting
- // back to a 64 bit value to avoid sign problems
- temp = remainder;
- temp &= 0xFFFF;
- temp = temp << 16;
- temp += dataInShorts[j];
-
- dataInShorts[j] = (int) (temp / 10000);
- remainder = (int) (temp % 10000);
- }
-
- // if we are done with the current 16bits, move on
- if (dataInShorts[curPos] == 0)
- curPos--;
-
- // go through the remainder and add each digit to the final String
- for (int j = 0; j < 4; j++) {
- strVal = (remainder % 10) + strVal;
- remainder /= 10;
- }
- }
-
- // when we finish the above loop we still have 1 <10000 value to include
- remainder = dataInShorts[0];
- for (int j = 0; j < 4; j++) {
- strVal = (remainder % 10) + strVal;
- remainder /= 10;
- }
-
- BigInteger bi = new BigInteger(strVal); // create a java BigInt
- if (negative)
- bi = bi.negate();
-
- return new BigDecimal(bi, scale); // create a new BigDecimal with the
- // descriptor's scale
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Key.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Key.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Key.java
deleted file mode 100644
index b143866..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Key.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**********************************************************************
-// @@@ 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 @@@
-//
-**********************************************************************/
-
-/**
- * Key.java
- */
-
-package org.trafodion.jdbc.t4;
-
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.security.cert.X509Certificate;
-import java.security.KeyFactory;
-import java.security.interfaces.RSAPublicKey;
-import java.security.interfaces.RSAPrivateKey;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.security.NoSuchAlgorithmException;
-import java.security.spec.InvalidKeySpecException;
-import javax.crypto.SecretKey;
-import javax.crypto.spec.SecretKeySpec;
-import javax.crypto.KeyGenerator;
-
-
-public class Key {
- public Key(){}
-
- /** Reads the public key from the certificate file and
- * stores the key and the length of the public key
- * in member data.
- * @param X509Certificate - The certificate stored
- * the public key
- */
- public void getPubKeyFromFile(X509Certificate cert)
- {
- m_pubKey = (RSAPublicKey) cert.getPublicKey();
- if (((m_pubKey.getModulus().bitLength()) / 8) > 128)
- m_pubKeyLen = 256;
- else
- m_pubKeyLen = 128;
- }
-
- /** Reads the private key from certificate file and
- * stores the key in the member data.
- * @param String - The file stored the private key
- * @throw SecurityException
- */
- public void getPrivKeyFromFile(String inFile) throws SecurityException
- {
- InputStream inStream=null;
-
- try{
- // Loading private key file
- inStream=new FileInputStream(inFile);
- byte[] keyBytes=new byte[inStream.available()];
- inStream.read(keyBytes);
- inStream.close();
-
- // Read the private key from file
- PKCS8EncodedKeySpec privKeySpec=new PKCS8EncodedKeySpec(keyBytes);
- KeyFactory keyFactory = KeyFactory.getInstance("RSA");
- m_privKey= (RSAPrivateKey) keyFactory.generatePrivate
- (privKeySpec);
-
- }catch (FileNotFoundException fnf) {
- throw new SecurityException(SecClientMsgKeys.FILE_NOTFOUND, new Object[]{inFile});
- }catch (IOException io) {
- throw new SecurityException(SecClientMsgKeys.ERR_OPEN_INPUT_FILE, new Object[]{inFile});
- }catch (Exception e) {
- throw new SecurityException(SecClientMsgKeys.ERR_RETRIEVE_KEY_FROM_FILE, new Object[]{inFile});
- }finally {
- try {
- if (inStream != null)
- inStream.close();
- }catch (IOException io) {
- // not much we can do at this point
- }
- }
- }
-
- /**
- * Generates a secret key using AES algorithm and 128 bits key
- * @param sessionKey the session key byte array used for symmetric key
- * generation
- * @return the SecretKey
- * @throws SecurityException
- */
- static SecretKey generateSymmetricKey(byte [] sKey) throws SecurityException
- {
- if (sKey == null)
- throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"sKey"});
- try {
- // Get the KeyGenerator
- KeyGenerator kgen = KeyGenerator.getInstance("AES");
- synchronized(kgen) {
- kgen.init(128);
- }
- // Use the lower 16 bytes of the session key to generate the 128 bits secret
- // key used for data encryption
-
- SecretKey skey = new SecretKeySpec(sKey, kgen.getAlgorithm());
-
- return skey;
- }catch (NoSuchAlgorithmException nae) {
- throw new SecurityException(SecClientMsgKeys.ERR_CREATE_SYMMETRIC_KEY, null);
- }
- }
-
- /**
- *
- * @return the public key
- */
- public RSAPublicKey getPubKey()
- {
- return m_pubKey;
- }
-
- /**
- *
- * @return the private key
- */
- public RSAPrivateKey getPrivKey()
- {
- return m_privKey;
- }
-
- /**
- *
- * @return the length of the public key
- */
- public int getPubKeyLen()
- {
- return m_pubKeyLen;
- }
-
- private RSAPublicKey m_pubKey;
- private RSAPrivateKey m_privKey;
- private int m_pubKeyLen;
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/LogicalByteArray.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/LogicalByteArray.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/LogicalByteArray.java
deleted file mode 100644
index ce0e3ac..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/LogicalByteArray.java
+++ /dev/null
@@ -1,345 +0,0 @@
-// @@@ 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.ByteBuffer;
-
-class LogicalByteArray {
- static private java.lang.ThreadLocal threadArray = new java.lang.ThreadLocal();
-
- private byte[] array;
- private ByteBuffer dataBuffer;
- private byte[] trailer;
-
- private boolean swap; // should we swap byte order
- private int loc; // current position
- private int length; // current bytes being used
-
- LogicalByteArray(int size, int startingLoc, boolean byteSwap) {
- loc = startingLoc;
- length = 0;
- swap = byteSwap;
-
- // TRANSPORT.IO_BUFFER_LENGTH is our minimum length so it is always safe
- // to read with the buffer
- resize((size > TRANSPORT.IO_BUFFER_LENGTH) ? size : TRANSPORT.IO_BUFFER_LENGTH);
- }
-
- void resize(long l) {
- byte[] old = (byte[]) threadArray.get();
-
- if (old == null || old.length < l) {
- array = new byte[(int) l];
- if (old != null)
- System.arraycopy(old, 0, array, 0, old.length);
-
- threadArray.set(array);
- } else {
- array = old;
- }
- }
-
- void reset() {
- length = 0;
- loc = 0;
- }
-
- byte[] getBuffer() {
- return array;
- }
-
- int getTotalAllocated() {
- return array.length;
- }
-
- int getLength() {
- if (length < loc) {
- length = loc;
- }
-
- return length;
- }
-
- int getLocation() {
- return loc;
- }
-
- public void setLocation(int newLoc) {
- if (newLoc > length) {
- length = newLoc;
- }
-
- loc = newLoc;
- }
-
- void insertByte(byte value) {
- array[loc++] = value;
- }
-
- void insertByteArray(byte[] value, int len) {
- System.arraycopy(value, 0, array, loc, len);
-
- loc += len;
- }
-
- void insertChar(char value) {
- array[loc++] = (byte) value;
- }
-
- void insertShort(short value) {
- if (swap) {
- array[loc + 1] = (byte) ((value >>> 8) & 0xff);
- array[loc] = (byte) ((value) & 0xff);
- } else {
- array[loc] = (byte) ((value >>> 8) & 0xff);
- array[loc + 1] = (byte) ((value) & 0xff);
- }
-
- loc += 2;
- }
-
- void insertInt(int value) {
- if (swap) {
- array[loc + 3] = (byte) ((value >>> 24) & 0xff);
- array[loc + 2] = (byte) ((value >>> 16) & 0xff);
- array[loc + 1] = (byte) ((value >>> 8) & 0xff);
- array[loc] = (byte) ((value) & 0xff);
- } else {
- array[loc] = (byte) ((value >>> 24) & 0xff);
- array[loc + 1] = (byte) ((value >>> 16) & 0xff);
- array[loc + 2] = (byte) ((value >>> 8) & 0xff);
- array[loc + 3] = (byte) ((value) & 0xff);
- }
-
- loc += 4;
- }
-
- void insertLong(long value) {
- if (swap) {
- array[loc + 7] = (byte) ((value >>> 56) & 0xff);
- array[loc + 6] = (byte) ((value >>> 48) & 0xff);
- array[loc + 5] = (byte) ((value >>> 40) & 0xff);
- array[loc + 4] = (byte) ((value >>> 32) & 0xff);
- array[loc + 3] = (byte) ((value >>> 24) & 0xff);
- array[loc + 2] = (byte) ((value >>> 16) & 0xff);
- array[loc + 1] = (byte) ((value >>> 8) & 0xff);
- array[loc] = (byte) ((value) & 0xff);
- } else {
- array[loc] = (byte) ((value >>> 56) & 0xff);
- array[loc + 1] = (byte) ((value >>> 48) & 0xff);
- array[loc + 2] = (byte) ((value >>> 40) & 0xff);
- array[loc + 3] = (byte) ((value >>> 32) & 0xff);
- array[loc + 4] = (byte) ((value >>> 24) & 0xff);
- array[loc + 5] = (byte) ((value >>> 16) & 0xff);
- array[loc + 6] = (byte) ((value >>> 8) & 0xff);
- array[loc + 7] = (byte) ((value) & 0xff);
- }
-
- loc += 8;
- }
-
- void insertStringWithCharset(byte[] str, int charset) {
- if (str != null && str.length > 0) {
- this.insertString(str);
- this.insertInt(charset);
- } else {
- this.insertInt(0);
- }
- }
-
- void insertFixedString(byte[] buf, int len) {
- int dataLength;
-
- if(buf != null) {
- dataLength = (buf.length > len-1)?len-1:buf.length; //-1 for the null, max dataLength is (len-1)
- this.insertByteArray(buf, dataLength);
- } else {
- dataLength = 0;
- }
-
- byte [] padding = new byte[len-dataLength]; //this will always be at least 1 for the null padding
- this.insertByteArray(padding, padding.length);
- }
-
- void insertString(byte[] buf) {
- if (buf != null && buf.length > 0) {
- this.insertInt(buf.length + 1);
- this.insertByteArray(buf, buf.length);
- this.insertByte((byte) 0);
- } else { // buffer is null or length 0
- this.insertInt(0);
- }
- }
-
- void insertString(byte[] str, boolean fixForServer) {
- if (str != null && str.length > 0) {
- this.insertInt(str.length + 1); // +1 null term
- this.insertByteArray(str, str.length);
- this.insertByte((byte) 0);
- } else {
- this.insertInt(1);
- this.insertByte((byte) 0);
- }
- }
-
- // /////////////////////////////////////////////////////////////////
- // /////////////////////////////////////////////////////////////////
-
- boolean extractBoolean() {
- return (extractByte() == 0) ? false : true;
- }
-
- byte extractByte() {
- return array[loc++];
- }
-
- byte[] extractByteArray(long bufferLength) {
- byte[] a = new byte[(int) bufferLength];
-
- System.arraycopy(array, loc, a, 0, (int) bufferLength);
- loc += bufferLength;
-
- return a;
- }
-
- byte[] extractByteArray() {
- return extractByteArray(this.extractInt());
- }
-
- char extractChar() {
- return (char) extractByte();
- }
-
- short extractShort() {
- int value;
-
- if (swap) {
- value = ((array[loc]) & 0x00ff) | ((array[loc + 1] << 8) & 0xff00);
- } else {
- value = ((array[loc + 1]) & 0x00ff) | ((array[loc] << 8) & 0xff00);
- }
-
- loc += 2;
-
- return (short) value;
- }
-
- int extractInt() {
- int value;
-
- if (swap) {
- value = ((array[loc]) & 0x000000ff) | ((array[loc + 1] << 8) & 0x0000ff00)
- | ((array[loc + 2] << 16) & 0x00ff0000) | ((array[loc + 3] << 24) & 0xff000000);
- } else {
- value = ((array[loc + 3]) & 0x000000ff) | ((array[loc + 2] << 8) & 0x0000ff00)
- | ((array[loc + 1] << 16) & 0x00ff0000) | ((array[loc] << 24) & 0xff000000);
- }
-
- loc += 4;
-
- return value;
- }
-
- long extractLong() {
- long value;
-
- if (swap) {
- value = ((array[loc]) & 0x00000000000000ffL) | ((array[loc + 1] << 8) & 0x000000000000ff00L)
- | ((array[loc + 2] << 16) & 0x0000000000ff0000L) | ((array[loc + 3] << 24) & 0x00000000ff000000L)
- | ((array[loc + 4] << 32) & 0x000000ff00000000L) | ((array[loc + 5] << 40) & 0x0000ff0000000000L)
- | ((array[loc + 6] << 48) & 0x00ff000000000000L) | ((array[loc + 7] << 56) & 0xff00000000000000L);
- } else {
- value = ((array[loc + 7]) & 0x00000000000000ffL) | ((array[loc + 6] << 8) & 0x000000000000ff00L)
- | ((array[loc + 5] << 16) & 0x0000000000ff0000L) | ((array[loc + 4] << 24) & 0x00000000ff000000L)
- | ((array[loc + 3] << 32) & 0x000000ff00000000L) | ((array[loc + 2] << 40) & 0x0000ff0000000000L)
- | ((array[loc + 1] << 48) & 0x00ff000000000000L) | ((array[loc] << 56) & 0xff00000000000000L);
- }
-
- loc += 8;
-
- return value;
- }
-
- long extractUnsignedInt() {
- long value;
-
- if(swap) {
- value = ((array[loc]) & 0x000000ff) | ((array[loc + 1] << 8) & 0x0000ff00)
- | ((array[loc + 2] << 16) & 0x00ff0000) | ((array[loc + 3] << 24) & 0xff000000);
- } else {
- value = ((array[loc + 3]) & 0x000000ff) | ((array[loc + 2] << 8) & 0x0000ff00)
- | ((array[loc + 1] << 16) & 0x00ff0000) | ((array[loc] << 24) & 0xff000000);
- }
-
- loc += 4;
-
- return value & 0xffffffffL;
- }
-
- byte[] extractString() {
- int len = extractInt();
- byte[] str = new byte[0];
-
- if (len > 0) {
- str = extractByteArray(len - 1);
- extractByte(); // trailing null
- }
- return str;
- }
-
- byte[] extractByteString() {
- int len = extractInt();
- byte[] b = new byte[0];
-
- if (len > 0) {
- b = extractByteArray(len); // the packed length DOES NOT include
- // the null character
- extractByte(); // trailing null
- }
-
- return b;
- }
-
- void setDataBuffer(ByteBuffer buf) {
- this.dataBuffer = buf;
- }
-
- void setTrailer(byte[] buf) {
- this.trailer = buf;
- }
-
- ByteBuffer getDataBuffer() {
- return this.dataBuffer;
- }
-
- byte[] getTrailer() {
- return this.trailer;
- }
-
- void setByteSwap(boolean byteSwap) {
- this.swap = byteSwap;
- }
-
- boolean getByteSwap() {
- return this.swap;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/MessageDigest.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/MessageDigest.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/MessageDigest.java
deleted file mode 100644
index 4484076..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/MessageDigest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**********************************************************************
-// @@@ 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 @@@
-//
-**********************************************************************/
-
-/**
- * class MessageDigest - Computes the message authentication code using
- * the SHA256 hash function
- */
-
-package org.trafodion.jdbc.t4;
-
-public class MessageDigest
-{
- private static class Holder
- {
- private static MessageDigest instance = new MessageDigest();
- }
-
- /**
- *
- * @return MessageDigest
- */
- public static MessageDigest getInstance()
- {
- return Holder.instance;
- }
-
- /**Digests message using HmacSHA256 algorithm.
- * @param key - session key to use for create secret key used in HMAC digest
- * @param data - The data used to create the digest
- * @param md - returns the digested message
- * @return the digested message's length or -1 in case of failure
- * @throw SecurityException
- */
- public int digest(byte[] key, byte[] data, byte[] md) throws SecurityException
- {
- if (key == null)
- throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL,
- new Object[]{"key"});
- if (data == null)
- throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL,
- new Object[]{"data"});
- if (md == null)
- throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL,
- new Object[]{"md"});
- try {
- javax.crypto.spec.SecretKeySpec keySpec =
- new javax.crypto.spec.SecretKeySpec(key, "HmacSHA256");
- javax.crypto.Mac mac = javax.crypto.Mac.getInstance("HmacSHA256");
- byte[] tmpMd;
- synchronized (mac) {
- mac.init(keySpec);
-
- tmpMd = mac.doFinal(data);
- }
- System.arraycopy(tmpMd, 0, md, 0, tmpMd.length);
-
- return tmpMd.length;
- }catch (Exception ex) {
- throw new SecurityException(SecClientMsgKeys.HMAC_FAILED, null);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/NCSAddress.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/NCSAddress.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/NCSAddress.java
deleted file mode 100644
index a23c7e6..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/NCSAddress.java
+++ /dev/null
@@ -1,220 +0,0 @@
-// @@@ 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;
-
-/**********************************************************
- * This class represents an address reference.
- *
- * @version 1.0
- **********************************************************/
-
-import java.sql.SQLException;
-import java.util.Locale;
-
-final class NCSAddress extends Address {
-
- private static final String ODBCServerPrefix = "TCP:";
- private static final String ODBCServerSuffix = ":ODBC";
- private static final int minODBCServerAddrLen = ODBCServerPrefix.length() + 7 + ODBCServerSuffix.length();
-
- static final int OS_type = 2; // TCP:\<Machine Name>.<Process
-
- // Name>/<port>:ODBC
-
- /**
- * The constructor.
- *
- * @param addr
- * The addr has the format:
- *
- * ODBC server connect format returned by the ODBC Association Server.
- *
- * TCP:\<{IP Address|Machine Name}>.<Process Name>/<port>:ODBC
- *
- *
- */
- NCSAddress(T4Properties t4props, Locale locale, String addr) throws SQLException {
- super(t4props, locale, addr);
- int index0;
- int index1;
- int index2;
- int index3;
-
- m_locale = locale;
-
- if (addr == null) {
- SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_null_error", null);
- throw se;
- }
-
- if (acceptsURL(addr) == true) {
- //
- // We are dealing with an address of the form:
- //
- // TCP:\<{IP Address|Machine Name}>.<Process
- // Name>/<port>:ODBC
- //
- m_type = OS_type;
- if (addr.endsWith(ODBCServerSuffix) == false) {
- SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", addr);
- SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "odbc_server_suffix_error",
- ODBCServerSuffix);
-
- se.setNextException(se2);
- throw se;
- }
- if (addr.length() < minODBCServerAddrLen) {
- SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", addr);
- SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "min_address_length_error",
- null);
-
- se.setNextException(se2);
- throw se;
- }
-
- addr = addr.substring(ODBCServerPrefix.length());
- addr = addr.substring(0, addr.length() - ODBCServerSuffix.length());
-
- if (addr.indexOf(",") > 0)
- interpretNEOAddress(t4props, locale, addr);
- else
- interpretAddress(t4props, locale, addr);
-
- if ((m_machineName == null && m_ipAddress == null) || m_processName == null || m_portNumber == null) {
- SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", addr);
- SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "address_format_1_error", null);
-
- se.setNextException(se2);
- throw se;
- }
- }
- } // end Address
-
- // ----------------------------------------------------------
- void interpretAddress(T4Properties t4props, Locale locale, String addr) throws SQLException {
- //
- // We are now expecting addr = "\<machine name>.<process name>/<port
- // number>"
- //
-
- int index1 = addr.indexOf("\\");
- int index3 = addr.indexOf("/");
-
- //
- // Find <{IP Address|Machine Name}>
- //
- int index2 = addr.lastIndexOf(".", index3);
-
- if ((-1 < index1 && index1 < index2 && index2 < index3 && index3 < addr.length()) == false) {
- SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", addr);
- SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "address_format_1_error", null);
-
- se.setNextException(se2);
- throw se;
- }
-
- String temp4 = addr.substring((index1 + 1), index2);
-
- if (Character.isDigit(temp4.charAt(0)) || temp4.substring(0, 1).equals("[")) {
- //
- // If first letter is a digit or "[" (i.e. IPv6), I'll assume it is
- // an IP address
- //
- m_ipAddress = temp4;
- } else {
- m_machineName = temp4;
- }
-
- m_processName = addr.substring((index2 + 1), index3);
- m_portNumber = new Integer(addr.substring((index3 + 1), addr.length()));
- }
-
- void interpretNEOAddress(T4Properties t4props, Locale locale, String addr) throws SQLException {
- //
- // We are now expecting addr = "\<machine name>.<process name>,<{IP
- // Address|Machine Name}>/<port number>"
- //
- //int index1 = addr.indexOf("\\");
- int index3 = addr.indexOf("/");
- int index4 = addr.indexOf(",");
- //
- // Find <{IP Address|Machine Name}>
- //
- int index2 = addr.indexOf(".", 0);
-
- if ((/*-1 < index1 && index1 < index2 &&*/ index2 < index4 && index4 < index3 && index3 < addr.length()) == false) {
- SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", addr);
- SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "address_format_1_error", null);
-
- se.setNextException(se2);
- throw se;
- }
-
- String temp4 = addr.substring((index4 + 1), index3);
-
- if (Character.isDigit(temp4.charAt(0)) || temp4.substring(0, 1).equals("[")) {
- //
- // If first letter is a digit or "[" (i.e. IPv6), I'll assume it is
- // an IP address
- //
- m_ipAddress = temp4;
- } else {
- m_machineName = temp4;
- }
-
- m_processName = addr.substring((index2 + 1), index4);
- m_portNumber = new Integer(addr.substring((index3 + 1), addr.length()));
- }
-
- // ----------------------------------------------------------
- String recreateAddress() {
- String addr = ODBCServerPrefix + "\\";
-
- if (m_machineName != null) {
- addr = addr + m_machineName;
- }
- addr = addr + ".";
-
- if (m_processName != null) {
- addr = addr + m_processName;
-
- }
- addr = addr + "/";
-
- if (m_portNumber != null) {
- addr = addr + m_portNumber;
-
- }
- addr = addr + ODBCServerSuffix;
-
- return addr;
- } // end recreateAddress
-
- static boolean acceptsURL(String url) throws SQLException {
- try {
- return (url.toUpperCase().startsWith(ODBCServerPrefix));
- } catch (Exception ex) {
- throw new SQLException(ex.toString());
- }
- }
-
-} // end class Address
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/OUT_CONNECTION_CONTEXT_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/OUT_CONNECTION_CONTEXT_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/OUT_CONNECTION_CONTEXT_def.java
deleted file mode 100644
index b7b07dc..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/OUT_CONNECTION_CONTEXT_def.java
+++ /dev/null
@@ -1,97 +0,0 @@
-// @@@ 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 OUT_CONNECTION_CONTEXT_def {
- static final long OUTCONTEXT_OPT1_ENFORCE_ISO88591 = 1; // (2^0)
- static final long OUTCONTEXT_OPT1_IGNORE_SQLCANCEL = 1073741824; // (2^30)
- static final long OUTCONTEXT_OPT1_EXTRA_OPTIONS = 2147483648L; // (2^31)
- static final long OUTCONTEXT_OPT1_DOWNLOAD_CERTIFICATE = 536870912; //(2^29)
-
- VERSION_LIST_def versionList;
-
- short nodeId;
- int processId;
-
- String computerName;
- String catalog;
- String schema;
-
- int optionFlags1;
- int optionFlags2;
-
- String _roleName;
- boolean _enforceISO;
- boolean _ignoreCancel;
-
- byte [] certificate;
-
- void extractFromByteArray(LogicalByteArray buf, InterfaceConnection ic) throws SQLException,
- UnsupportedCharsetException, CharacterCodingException {
- versionList = new VERSION_LIST_def();
- versionList.extractFromByteArray(buf);
-
- nodeId = buf.extractShort();
- processId = buf.extractInt();
- computerName = ic.decodeBytes(buf.extractString(), 1);
-
- catalog = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- schema = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- optionFlags1 = buf.extractInt();
- optionFlags2 = buf.extractInt();
-
- this._enforceISO = (optionFlags1 & OUTCONTEXT_OPT1_ENFORCE_ISO88591) > 0;
- this._ignoreCancel = (optionFlags1 & OUTCONTEXT_OPT1_IGNORE_SQLCANCEL) > 0;
- if((optionFlags1 & OUTCONTEXT_OPT1_DOWNLOAD_CERTIFICATE) > 0) {
- certificate = buf.extractByteArray();
- }
- else if ((optionFlags1 & OUTCONTEXT_OPT1_EXTRA_OPTIONS) > 0) {
- try {
- this.decodeExtraOptions(ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8));
- } catch (Exception e) {
- ic.t4props_.logger.warning("An error occurred parsing OutConnectionContext: " + e.getMessage());
- }
- }
- }
-
- public void decodeExtraOptions(String options) {
- String[] opts = options.split(";");
- String token;
- String value;
- int index;
-
- for (int i = 0; i < opts.length; i++) {
- index = opts[i].indexOf('=');
- token = opts[i].substring(0, index).toUpperCase();
- value = opts[i].substring(index + 1);
-
- if (token.equals("RN")) {
- this._roleName = value;
- }
- }
- }
-}
[16/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4ConnectionPoolDataSource.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4ConnectionPoolDataSource.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4ConnectionPoolDataSource.java
deleted file mode 100644
index 39e39dd..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4ConnectionPoolDataSource.java
+++ /dev/null
@@ -1,346 +0,0 @@
-// @@@ 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.sql.SQLFeatureNotSupportedException;
-import java.util.Properties;
-import java.util.logging.FileHandler;
-import java.util.logging.Formatter;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.Referenceable;
-import javax.naming.StringRefAddr;
-import javax.sql.PooledConnection;
-
-/**
- *
- * <p>
- * JDBC Type 4 Driver <code>ConnectionPoolDataSource</code> class.
- * </p>
- * <p>
- * Description: A <code>ConnectionPoolDataSource</code> object is a factory
- * for <code>PooledConnection</code> objects. As the name indicates, this
- * object provides a <code>PooledConnection</code> for data sources to be used
- * by the application servers.
- * </p>
- *
- * <p>
- * The <code>HPT4ConnectionPoolDataSource</code> class should be used to
- * provide JDBC3.0 connection pooling features. The
- * <code>HPT4ConnectionPoolDataSource</code> is used by the application
- * servers like WSAS to provide connection pooling features to the J2EE
- * applications. <code>HPT4ConnectionPoolDataSource.getPooledConnection()</code>
- * returns the <code>javax.sql.PooledConnection object</code>.
- * </p>
- *
- *
- * Setting connection properties such as catalog, schema, timeouts, and so on
- * are done at the higher level objects such as DataSource or DriverManager.
- *
- * <p>
- * Licensed to the Apache Software Foundation (ASF)
- * </p>
- *
- * @see T4Properties
- * @see HPT4DataSource
- */
-
-public class HPT4ConnectionPoolDataSource extends T4DSProperties implements javax.sql.ConnectionPoolDataSource,
- java.io.Serializable, Referenceable
-
-{
-
- /**
- * Attempts to establish a physical database connection that can be used as
- * a pooled connection.
- *
- * @return A <code>PooledConnection</code> object that is a physical
- * connection to the NDCS server that this
- * <code>HPT4ConnectionPoolDataSource</code> object represents.
- * @throws SQLException
- * If any NDCS error occurs.
- */
- public PooledConnection getPooledConnection() throws SQLException {
- if (t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null);
- t4Logger_.logp(Level.FINE, "HPT4ConnectionPoolDataSource", "getPooledConnection", "", p);
- }
- if (getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null);
- lr.setParameters(p);
- lr.setSourceClassName("HPT4ConnectionPoolDataSource");
- lr.setSourceMethodName("getPooledConnection");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- getLogWriter().println(temp);
- }
- HPT4PooledConnection connect;
-
- Properties l_props = super.getProperties();
- T4Properties l_t4props = new T4Properties(l_props);
- connect = new HPT4PooledConnection(this, l_t4props);
-
- return connect;
- }
-
- /**
- * Attempts to establish a physical database connection that can be used as
- * a pooled connection.
- *
- * @param username
- * Safeguard user name.
- * @param password
- * Safeguard user password.
- * @return A <code>PooledConnection</code> object that is a physical
- * connection to the NDCS server that this
- * <code>HPT4ConnectionPoolDataSource</code> object represents.
- * @throws SQLException
- * If any NDCS error occurs.
- */
- public PooledConnection getPooledConnection(String username, String password) throws SQLException {
- if (t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null, username);
- t4Logger_.logp(Level.FINE, "HPT4ConnectionPoolDataSource", "getPooledConnection", "", p);
- }
- if (getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null, username);
- lr.setParameters(p);
- lr.setSourceClassName("HPT4ConnectionPoolDataSource");
- lr.setSourceMethodName("getPooledConnection");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- getLogWriter().println(temp);
- }
- HPT4PooledConnection connect;
-
- setUser(username);
- setPassword(password);
- return getPooledConnection();
-
- }
-
- /**
- * Returns all the properties associated with this
- * <code>ConnectionPoolDataSource</code>.
- *
- * @return Reference Object containing all the Type 4 property references.
- * @throws NamingException
- */
- public Reference getReference() throws NamingException {
- if (t4Logger_ != null && t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null);
- t4Logger_.logp(Level.FINE, "HPT4ConnectionPoolDataSource", "getReference", "", p);
- }
- try {
- if (getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null);
- lr.setParameters(p);
- lr.setSourceClassName("HPT4ConnectionPoolDataSource");
- lr.setSourceMethodName("getReference");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- getLogWriter().println(temp);
- }
- } catch (SQLException se) {
- // ignore
- }
-
- Reference ref = new Reference(this.getClass().getName(), "org.trafodion.jdbc.t4.HPT4ConnectionPoolDataSourceFactory",
- null);
- ref = addReferences(ref);
- ref.add(new StringRefAddr("propertyCycle", Integer.toString(propertyCycle_)));
- return ref;
-
- }
-
- /**
- * Sets the Property cycle property. This property is not supprted by the
- * Type 4 driver. This property is ignored by the Type 4 driver.
- *
- * @param propertyCycle
- */
- public void setPropertyCycle(int propertyCycle) {
- if (t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null);
- t4Logger_.logp(Level.FINE, "HPT4ConnectionPoolDataSource", "setPropertyCycle", "", p);
- }
- try {
- if (getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null, propertyCycle);
- lr.setParameters(p);
- lr.setSourceClassName("HPT4ConnectionPoolDataSource");
- lr.setSourceMethodName("setPropertyCycle");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- getLogWriter().println(temp);
- }
- } catch (SQLException se) {
- // ignore
- }
- propertyCycle_ = propertyCycle;
- }
-
- /**
- * Returns the Property cycle property. This property is not supprted by the
- * Type 4 driver. This property is ignored by the Type 4 driver.
- *
- * @return propertyCycle
- */
- public int getPropertyCycle() {
- if (t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null);
- t4Logger_.logp(Level.FINE, "HPT4ConnectionPoolDataSource", "getPropertyCycle", "", p);
- }
- try {
- if (getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null);
- lr.setParameters(p);
- lr.setSourceClassName("HPT4ConnectionPoolDataSource");
- lr.setSourceMethodName("getPropertyCycle");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- getLogWriter().println(temp);
- }
- } catch (SQLException se) {
- // ignore
- }
- return propertyCycle_;
- }
-
- // --------------------------------------------------------
- void setupLogFileHandler() {
- try {
- if (getT4LogFile() == null) {
- setT4LogFile(getT4GlobalLogFile());
- setT4LogFileHandler(getT4GlobalLogFileHandler());
- } else {
- if (getT4LogFileHandler() == null) {
- String temp = getT4LogFile();
- FileHandler fh1 = new FileHandler(temp);
- Formatter ff1 = new T4LogFormatter();
-
- fh1.setFormatter(ff1);
- setT4LogFileHandler(fh1);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- } // end setupLogFileHandler
-
- // --------------------------------------------------------
-
- /**
- * Creates a pooled connection object.
- *
- * @see #HPT4ConnectionPoolDataSource(Properties)
- * @see T4Properties
- */
- public HPT4ConnectionPoolDataSource() {
- super();
- if (getT4LogLevel() != Level.OFF)
- setupLogFileHandler();
- if (t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null);
- t4Logger_.logp(Level.FINE, "HPT4ConnectionPoolDataSource", "HPT4ConnectionPoolDataSource",
- "Note, super called before this.", p);
- }
- try {
- if (getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null);
- lr.setParameters(p);
- lr.setSourceClassName("HPT4ConnectionPoolDataSource");
- lr.setSourceMethodName("");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- getLogWriter().println(temp);
- }
- } catch (SQLException se) {
- // ignore
- }
- }
-
- /**
- * Creates a pooled connection object with the properties specified.
- *
- * @param props
- * properties for the Type 4 connection
- * @see #HPT4ConnectionPoolDataSource()
- * @link T4Properties
- */
- public HPT4ConnectionPoolDataSource(Properties props) {
- super(props);
- if (getT4LogLevel() != Level.OFF)
- setupLogFileHandler();
- if (t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null, props);
- t4Logger_.logp(Level.FINE, "HPT4ConnectionPoolDataSource", "HPT4ConnectionPoolDataSource",
- "Note, super called before this.", p);
- }
- try {
- if (getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null, props);
- lr.setParameters(p);
- lr.setSourceClassName("HPT4ConnectionPoolDataSource");
- lr.setSourceMethodName("");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- getLogWriter().println(temp);
- }
- } catch (SQLException se) {
- // ignore
- }
- }
-
- /**
- * @deprecated
- */
- public void setNameType(String nameType) {
- }
-
- /**
- * @deprecated
- */
- public String getNameType() {
- return null;
- }
-
- // Standard ConnectionPoolDataSource Properties
- int propertyCycle_;
-
- public Logger getParentLogger() throws SQLFeatureNotSupportedException {
- // TODO Auto-generated method stub
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4ConnectionPoolDataSourceFactory.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4ConnectionPoolDataSourceFactory.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4ConnectionPoolDataSourceFactory.java
deleted file mode 100644
index 3f87539..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4ConnectionPoolDataSourceFactory.java
+++ /dev/null
@@ -1,68 +0,0 @@
-// @@@ 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.Enumeration;
-import java.util.Hashtable;
-import java.util.Properties;
-
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.RefAddr;
-import javax.naming.Reference;
-
-public class HPT4ConnectionPoolDataSourceFactory implements javax.naming.spi.ObjectFactory {
- public HPT4ConnectionPoolDataSourceFactory() {
- }
-
- public Object getObjectInstance(Object refobj, Name name, Context nameCtx, Hashtable env) throws Exception {
- Reference ref = (Reference) refobj;
- HPT4ConnectionPoolDataSource ds;
- RefAddr refAddr;
- String tmp;
-
- if (ref.getClassName().equals("org.trafodion.jdbc.t4.HPT4ConnectionPoolDataSource")) {
- Properties props = new Properties();
- for (Enumeration enum2 = ref.getAll(); enum2.hasMoreElements();) {
- RefAddr tRefAddr = (RefAddr) enum2.nextElement();
- String type = tRefAddr.getType();
- String content = (String) tRefAddr.getContent();
- props.setProperty(type, content);
- }
- ds = new HPT4ConnectionPoolDataSource(props);
- /*
- * tmp = props.getProperty("initialPoolSize"); if (tmp != null) {
- * try { ds.setInitialPoolSize(Integer.parseInt(tmp)); } catch
- * (NumberFormatException e1) { } } tmp =
- * props.getProperty("maxIdleTime"); if (tmp != null) { try {
- * ds.setMaxIdleTime(Integer.parseInt(tmp)); } catch
- * (NumberFormatException e4) { } } tmp =
- * props.getProperty("propertyCycle"); if (tmp != null) { try {
- * ds.setPropertyCycle(Integer.parseInt(tmp)); } catch
- * (NumberFormatException e5) { } }
- */
- return ds;
- } else {
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4DataSource.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4DataSource.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4DataSource.java
deleted file mode 100644
index f0e0c8f..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4DataSource.java
+++ /dev/null
@@ -1,366 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.io.PrintWriter;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.util.Properties;
-import java.util.logging.FileHandler;
-import java.util.logging.Formatter;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.Referenceable;
-
-/**
- *
- * <p>
- * JDBC Type 4 Driver <code>DataSource</code> class.
- * </p>
- * <p>
- * Description: A <code>DataSource</code> object is a factory for Connection
- * objects. An object that implements the <code>DataSource</code> interface is
- * typically registered with a JNDI service provider. A JDBC driver that is
- * accessed through the <code>DataSource</code> API does not automatically
- * register itself with the <code>DriverManager</code> object.
- * </p>
- *
- * <p>
- * The <code>HPT4DataSource</code> class can provide connection pooling and
- * statement pooling features.
- * </p>
- *
- * <pre>
- * <b>Setting properties for the HPT4DataSource in the Type 4 driver</b>
- * HPT4DataSource ds = new HPT4DataSource();
- * ds.setUrl("jdbc:t4jdbc://<NDCS host>:<NDCS port>/:");
- * ds.setCatalog("your catalog");
- * ds.setSchema("your schema");
- * ds.setUser("safeguard user name");
- * ds.setPassword("safeguard password");
- *
- * // Following are optional properties
- * ds.setConnectionTimeout("timeout in seconds");
- * ds.setT4LogFile("your log file location");
- * ds.setT4LogLevel("SEVERE");
- * ds.setServerDataSource("NDCS datasource name");
- *
- * // Properties relevant for Type 4 connection pooling.
- * // Set ds.setMaxPoolSize(-1) to turn OFF connection pooling
- * ds.setMaxPoolSize("number of connections required");
- * ds.setMinPoolSize("number of connections required");
- *
- * // Properties relevant for Type 4 statement pooling.
- * // Set ds.setMaxStatement(0) to turn statement pooling OFF
- * // Statement pooling is enabled only when connection pooling is enabled.
- * ds.setMaxStatements("number of statements to be pooled");
- * </pre>
- *
- * <pre>
- * <b>Programmatically registering HPT4DataSource with JDNI</b>
- * java.util.Hashtable env = new java.util.Hashtable();
- * env.put(Context.INITIAL_CONTEXT_FACTORY, "Factory class name here");
- * javax.naming.Context ctx = new javax.naming.InitialContext(env);
- * ctx.rebind("DataSource name here", ds);
- * </pre>
- *
- * <pre>
- * <b>Application making Type4 connection using the DataSource from JDNI</b>
- * java.util.Hashtable env = new java.util.Hashtable();
- * env.put(Context.INITIAL_CONTEXT_FACTORY, "Factory class name here");
- * javax.naming.Context ctx = new javax.naming.InitialContext(env);
- * DataSource ds = (DataSource)ctx.lookup("DataSource name here");
- * java.sql.Connection con = ds.getConnection();
- * </pre>
- *
- * <p>
- * Copyright: (C) Apache Software Foundation (ASF)
- * </p>
- *
- * @see T4Properties
- */
-public class HPT4DataSource extends T4DSProperties implements javax.sql.DataSource, java.io.Serializable, Referenceable
-
-{
- /**
- * Attempts to establish an NDCS connection.
- *
- * @return a connection to the NDCS server.
- * @throws SQLException
- * if a database access error or NDCS error occurs.
- * @see #getConnection(String, String)
- */
- synchronized public Connection getConnection() throws SQLException {
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("HPT4DataSource", "getConnection");
- }
-
- Connection conn;
- TrafT4Connection t4Conn;
- HPT4ConnectionPoolDataSource pds;
-
- if (getSQLException() != null) {
- throw HPT4Messages.createSQLException(null, getLocale(), "invalid_property", getSQLException());
- }
-
- if (getMaxPoolSize() == -1) {
- t4Conn = new TrafT4Connection(this, getT4Properties());
- } else {
- if (poolManager != null) {
- t4Conn = (TrafT4Connection) poolManager.getConnection();
- } else {
-
- pds = new HPT4ConnectionPoolDataSource(getProperties());
- poolManager = new HPT4PooledConnectionManager(pds, getT4LogLevel());
- t4Conn = (TrafT4Connection) poolManager.getConnection();
- }
- }
-
- t4Conn.setLogInfo(getT4LogLevel(), getLogWriter());
- conn = t4Conn;
-
- if (logger.isLoggable(Level.FINER)) {
- logger.exiting("HPT4DataSource", "getConnection", conn);
- }
-
- return conn;
- }
-
- /**
- * Attempts to establish an NDCS connection.
- *
- * @return a connection to the NDCS server.
- * @param username
- * Safeguard user name
- * @param password
- * Safeguard user password
- * @throws SQLException
- * if a database access error or NDCS error occurs.
- * @see #getConnection()
- */
- synchronized public Connection getConnection(String username, String password) throws SQLException {
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("HPT4DataSource", "getConnection", new Object[] { this, username });
- }
-
- Connection conn;
-
- setUser(username);
- setPassword(password);
-
- conn = getConnection();
-
- if (logger.isLoggable(Level.FINER)) {
- logger.exiting("HPT4DataSource", "getConnection", conn);
- }
-
- return conn;
- }
-
- /**
- * @return Reference Object containing all the Type 4 property references.
- * @throws NamingException
- */
- public Reference getReference() throws NamingException {
-
- Reference ref = new Reference(this.getClass().getName(), "org.trafodion.jdbc.t4.HPT4DataSourceFactory", null);
- return addReferences(ref);
- }
-
- /**
- * Sets the print writer for the current Type 4 data source.
- *
- * @param out
- * java.io.PrintWriter for the current T4 connection.
- * @throws SQLException
- * when error occurs.
- * @see #getLogWriter()
- * @see javax.sql.ConnectionPoolDataSource
- */
- public void setLogWriter(PrintWriter out) throws SQLException {
- super.setLogWriter(out);
- if (t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null, out);
- t4Logger_.logp(Level.FINE, "HPT4DataSource", "setLogWriter",
- "Note, this constructor was called before the previous constructor", p);
- }
- if (getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null, out);
- lr.setParameters(p);
- lr.setSourceClassName("HPT4DataSource");
- lr.setSourceMethodName("setLogWriter");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- getLogWriter().println(temp);
- }
- if (poolManager != null) {
- poolManager.setLogWriter(getLogWriter());
- }
- }
-
- // Local methods
- void setPoolManager(Context nameCtx, String dataSourceName) throws Exception {
- if (t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null, nameCtx, dataSourceName);
- t4Logger_.logp(Level.FINER, "HPT4DataSource", "setPoolManager", "", p);
- }
- Object pds;
-
- try {
- pds = nameCtx.lookup(dataSourceName);
- if (pds instanceof HPT4ConnectionPoolDataSource) {
- poolManager = new HPT4PooledConnectionManager((HPT4ConnectionPoolDataSource) pds, getT4LogLevel());
- }
- } catch (javax.naming.NameNotFoundException nnfe) {
- }
- }
-
- // --------------------------------------------------------
- void setupLogFileHandler() {
- try {
- if (getT4LogFile() == null) {
- setT4LogFile(getT4GlobalLogFile());
- setT4LogFileHandler(getT4GlobalLogFileHandler());
- } else {
- if (getT4LogFileHandler() == null) {
- String temp = getT4LogFile();
- FileHandler fh1 = new FileHandler(temp);
-
- Formatter ff1 = new T4LogFormatter();
-
- fh1.setFormatter(ff1);
- setT4LogFileHandler(fh1);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- } // end setupLogFileHandler
-
- // --------------------------------------------------------
-
- /**
- * Contructor for the <code>HPT4DataSource</code> object.
- *
- * @see #HPT4DataSource(java.util.Properties)
- */
- public HPT4DataSource() {
- super();
- if (getT4LogLevel() != Level.OFF) {
- setupLogFileHandler();
- }
- if (t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null);
- t4Logger_.logp(Level.FINE, "HPT4DataSource", "<init>",
- "Note, this constructor was called before the previous constructor", p);
- }
- try {
- if (getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null);
- lr.setParameters(p);
- lr.setSourceClassName("HPT4DataSource");
- lr.setSourceMethodName("<init>");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- getLogWriter().println(temp);
- }
- } catch (SQLException se) {
- // ignore
- }
-
- }
-
- /**
- * Contructor for the <code>HPT4DataSource</code> object.
- *
- * @param info
- * Contains all the Type 4 properties in a <code>name,
- * value</code>
- * pair.
- * @see #HPT4DataSource()
- * @see java.util.Properties
- */
- public HPT4DataSource(Properties info) {
- super(info);
- if (getT4LogLevel() != Level.OFF) {
- setupLogFileHandler();
- }
- if (t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(null);
- t4Logger_.logp(Level.FINE, "HPT4DataSource", "<init>",
- "Note, this constructor was called before the previous constructor", p);
- }
- try {
- if (getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(null);
- lr.setParameters(p);
- lr.setSourceClassName("HPT4DataSource");
- lr.setSourceMethodName("<init>");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- getLogWriter().println(temp);
- }
- } catch (SQLException se) {
- // ignore
- }
- }
-
- /**
- * @deprecated
- */
- public void setNameType(String nameType) {
- }
-
- /**
- * @deprecated
- */
- public String getNameType() {
- return null;
- }
-
- // fields
- HPT4PooledConnectionManager poolManager;
-
- public Logger getParentLogger() throws SQLFeatureNotSupportedException {
- // TODO Auto-generated method stub
- return null;
- }
-
- 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;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4DataSourceFactory.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4DataSourceFactory.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4DataSourceFactory.java
deleted file mode 100644
index 1b7a8da..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4DataSourceFactory.java
+++ /dev/null
@@ -1,62 +0,0 @@
-// @@@ 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.Enumeration;
-import java.util.Hashtable;
-import java.util.Properties;
-
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.RefAddr;
-import javax.naming.Reference;
-
-public class HPT4DataSourceFactory implements javax.naming.spi.ObjectFactory {
- public HPT4DataSourceFactory() {
- }
-
- public Object getObjectInstance(Object refobj, Name name, Context nameCtx, Hashtable env) throws Exception {
- Reference ref = (Reference) refobj;
- HPT4DataSource ds;
- String dataSourceName = null;
-
- if (ref.getClassName().equals("org.trafodion.jdbc.t4.HPT4DataSource")) {
- Properties props = new Properties();
- for (Enumeration enum2 = ref.getAll(); enum2.hasMoreElements();) {
- RefAddr tRefAddr = (RefAddr) enum2.nextElement();
- String type = tRefAddr.getType();
- String content = (String) tRefAddr.getContent();
- props.setProperty(type, content);
- }
-
- ds = new HPT4DataSource(props);
- dataSourceName = ds.getDataSourceName();
-
- if (dataSourceName != null) {
- ds.setPoolManager(nameCtx, dataSourceName);
- }
- return ds;
- } else {
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4Desc.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4Desc.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4Desc.java
deleted file mode 100644
index 1eec5a3..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4Desc.java
+++ /dev/null
@@ -1,542 +0,0 @@
-// @@@ 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.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.Locale;
-
-class HPT4Desc {
-
- String getColumnClassName() throws SQLException {
- switch (dataType_) {
- case Types.SMALLINT:
- return "java.lang.Integer";
- case Types.INTEGER:
- return "java.lang.Integer";
- case Types.BIGINT:
- return "java.lang.Long";
- case Types.REAL:
- return "java.lang.Float";
- case Types.FLOAT:
- case Types.DOUBLE:
- return "java.lang.Double";
- case Types.NUMERIC:
- case Types.DECIMAL:
- return "java.math.BigDecimal";
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- return "java.lang.String";
- case Types.DATE:
- return "java.sql.Date";
- case Types.TIME:
- return "java.sql.Time";
- case Types.TIMESTAMP:
- return "java.sql.Timestamp";
- case Types.OTHER:
- return "java.sql.String";
- case Types.CLOB:
- return "java.sql.Clob";
- case Types.BLOB:
- return "java.sql.Blob";
- case Types.BIT:
- case Types.TINYINT:
- default:
- return null;
- }
- } // end getColumnClassName
-
- // ---------------------------------------------------------------
- String getColumnTypeName(Locale locale) throws SQLException {
- switch (dataType_) {
- case Types.SMALLINT:
- return "SMALLINT";
- case Types.INTEGER:
- return "INTEGER";
- case Types.BIGINT:
- return "BIGINT";
- case Types.REAL:
- return "REAL";
- case Types.FLOAT:
- return "FLOAT";
- case Types.DOUBLE:
- return "DOUBLE PRECISION";
- case Types.NUMERIC:
- return "NUMERIC";
- case Types.DECIMAL:
- return "DECIMAL";
- case Types.CHAR:
- return "CHAR";
- case Types.VARCHAR:
- return "VARCHAR";
- case Types.LONGVARCHAR:
- return "LONG VARCHAR";
- case Types.DATE:
- return "DATE";
- case Types.TIME:
- return "TIME";
- case Types.TIMESTAMP:
- return "TIMESTAMP";
- case Types.BLOB:
- return "BLOB";
- case Types.CLOB:
- return "CLOB";
- case Types.OTHER:
- if (sqlDataType_ == SQLTYPECODE_INTERVAL) {
- return "INTERVAL";
- } else {
- return "UNKNOWN";
- }
- case Types.BIT:
- case Types.TINYINT:
- default:
- return null;
- }
- } // end getColumnTypeName
-
- // ---------------------------------------------------------------
- void checkValidNumericConversion(Locale locale) throws SQLException {
- switch (dataType_) {
- case Types.TINYINT:
- case Types.SMALLINT:
- case Types.INTEGER:
- case Types.BIGINT:
- case Types.REAL:
- case Types.FLOAT:
- case Types.DOUBLE:
- case Types.NUMERIC:
- case Types.DECIMAL:
- case Types.BIT:
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.CLOB:
- case Types.BLOB:
- break;
- default:
- System.out.println("Data type is " + dataType_);
- throw HPT4Messages.createSQLException(null, locale, "restricted_data_type", null);
- }
- return;
- } // end checkValidNumericConversion
-
- // ---------------------------------------------------------------
- // Constructors
- HPT4Desc(int dataType, short datetimeCode, int maxLen, short precision, short scale, boolean nullInfo,
- String colName, boolean signType, int odbcDataType, short odbcPrecision, int sqlCharset, int odbcCharset,
- String catalogName, String schemaName, String tableName, int fsDataType, int intLeadPrec, int paramMode) {
- catalogName_ = catalogName;
- schemaName_ = schemaName;
- tableName_ = tableName;
- name_ = colName;
- if (nullInfo) {
- isNullable_ = ResultSetMetaData.columnNullable;
- } else {
- isNullable_ = ResultSetMetaData.columnNoNulls;
-
- }
-
- sqlDataType_ = dataType;
- dataType_ = odbcDataType;
- sqlDatetimeCode_ = datetimeCode;
- sqlCharset_ = sqlCharset;
- odbcCharset_ = odbcCharset;
- isSigned_ = signType;
- sqlOctetLength_ = maxLen;
- scale_ = scale;
- sqlPrecision_ = precision;
-
- //
- // Convert ODBC type to equivalent JDBC type when necessary.
- //
- // From SqlUcode.h
- //
- // #define SQL_WCHAR (-8)
- // #define SQL_WVARCHAR (-9)
- // #define SQL_WLONGVARCHAR (-10)
- //
- if (odbcDataType == -8) {
-
- // ODBC's SQL_WCHAR becomes a Types.CHAR
- dataType_ = Types.CHAR;
- } else if (odbcDataType == -9) {
-
- // ODBC's SQL_WVARCHAR becomes a Types.VARCHAR
- dataType_ = Types.VARCHAR;
- } else if (odbcDataType == -10) {
-
- // ODBC's SQL_WLONGVARCHAR becomes a Types.LONGVARCHAR
- dataType_ = Types.LONGVARCHAR;
-
- }
- if (sqlDataType_ == InterfaceResultSet.SQLTYPECODE_DATETIME) // 9
- {
- switch (dataType_) { // ODBC conversion to ODBC2.0
- case 9: // ODBC2 Date
-
- // check the datetime code and set appropriately
- switch (sqlDatetimeCode_) {
- case SQLDTCODE_YEAR:
- case SQLDTCODE_YEAR_TO_MONTH:
- case SQLDTCODE_MONTH:
- case SQLDTCODE_MONTH_TO_DAY:
- case SQLDTCODE_DAY:
- dataType_ = Types.OTHER;
- precision_ = odbcPrecision;
- displaySize_ = maxLen;
- sqlOctetLength_ = maxLen;
- break;
- default:
- dataType_ = Types.DATE;
- break;
- }
- break;
- case 10: // ODBC2 TIME
- switch (sqlDatetimeCode_) {
- case SQLDTCODE_HOUR:
- case SQLDTCODE_HOUR_TO_MINUTE:
- case SQLDTCODE_MINUTE:
- case SQLDTCODE_MINUTE_TO_SECOND:
- case SQLDTCODE_SECOND:
- dataType_ = Types.OTHER;
- precision_ = odbcPrecision;
- displaySize_ = maxLen;
- sqlOctetLength_ = maxLen;
- break;
- default:
- dataType_ = Types.TIME;
- break;
- }
- break;
- case 11: // ODBC2 TIMESTAMP
- switch (sqlDatetimeCode_) {
- case SQLDTCODE_YEAR_TO_HOUR:
- case SQLDTCODE_YEAR_TO_MINUTE:
- case SQLDTCODE_MONTH_TO_HOUR:
- case SQLDTCODE_MONTH_TO_MINUTE:
- case SQLDTCODE_MONTH_TO_SECOND:
- // case SQLDTCODE_MONTH_TO_FRACTION:
- case SQLDTCODE_DAY_TO_HOUR:
- case SQLDTCODE_DAY_TO_MINUTE:
- case SQLDTCODE_DAY_TO_SECOND:
- // case SQLDTCODE_DAY_TO_FRACTION:
- case SQLDTCODE_HOUR_TO_FRACTION: // note: Database
- // maps to TIME(6)
- // NCS maps to TIMESTAMP
- case SQLDTCODE_MINUTE_TO_FRACTION:
- case SQLDTCODE_SECOND_TO_FRACTION:
- dataType_ = Types.OTHER;
- precision_ = odbcPrecision;
- displaySize_ = maxLen;
- sqlOctetLength_ = maxLen;
- break;
- default:
- dataType_ = Types.TIMESTAMP;
- break;
- }
- break;
- default:
- dataType_ = Types.TIMESTAMP;
- break;
- }
- }
-
- switch (dataType_) {
- case Types.NUMERIC:
- case Types.DECIMAL:
- precision_ = odbcPrecision;
- displaySize_ = precision_ + 2; // 1 for dot and 1 for sign
- // if (scale != 0) // ODBC2.0
- // isCurrency_ = true;
- break;
- case Types.SMALLINT:
- precision_ = odbcPrecision;
- if (isSigned_) {
- displaySize_ = 6;
- } else {
- dataType_ = Types.INTEGER;
- displaySize_ = 5;
- }
- break;
- case Types.INTEGER:
- precision_ = odbcPrecision;
- if (isSigned_) {
- displaySize_ = 11;
- } else {
- dataType_ = Types.BIGINT;
- displaySize_ = 10;
- }
- break;
- case Types.TINYINT:
- precision_ = odbcPrecision;
- if (isSigned_) {
- displaySize_ = 4;
- } else {
- displaySize_ = 3;
- }
- break;
- case Types.BIGINT:
- precision_ = odbcPrecision;
- if (isSigned_) {
- displaySize_ = 20;
- } else {
- displaySize_ = 19;
- }
- break;
- case Types.REAL:
- precision_ = odbcPrecision;
- displaySize_ = 15;
- break;
- case Types.DOUBLE:
- case Types.FLOAT:
- precision_ = odbcPrecision;
- displaySize_ = 24;
- break;
- case Types.DATE:
- sqlOctetLength_ = maxLen + 3;
- displaySize_ = 10;
- precision_ = 10; // ODBC2.0
- break;
- case Types.TIME:
- sqlOctetLength_ = maxLen + 3;
- displaySize_ = (precision == 0)?8: precision + 9;
- precision_ = 8; // ODBC2.0
- break;
- case Types.TIMESTAMP:
- sqlOctetLength_ = maxLen + 3;
- precision_ = odbcPrecision;
- displaySize_ = precision_;
- if (sqlDatetimeCode_ > 3) // if it is more than 3, it is one of
- // SQL/MP Datetime columns
- {
- // like YEAR, YEAR TO MONTH, YEAR TO DAY ...see dfs2rec.h
- dataType_ = Types.OTHER;
- }
- break;
- case Types.CHAR:
-
- // sqlOctetLength_ = maxLen+1;
- sqlOctetLength_ = maxLen;
- displaySize_ = maxLen;
- precision_ = maxLen; // ODBC2.0
- break;
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.BLOB:
- case Types.CLOB:
- boolean shortLength = maxLen < Math.pow(2, 15);
- int dataOffset = ((shortLength) ? 2 : 4);
- if (sqlDataType_ == SQLTYPECODE_VARCHAR) {
- sqlOctetLength_ = maxLen + 1;
- } else {
- sqlOctetLength_ = maxLen + dataOffset + 1;
- }
- displaySize_ = maxLen;
- precision_ = maxLen; // ODBC2.0
- break;
- default:
- if (sqlDataType_ == SQLTYPECODE_INTERVAL) {
- dataType_ = Types.OTHER;
- precision_ = odbcPrecision;
- displaySize_ = maxLen; // Make sure maxLen returns the right
- // display size for interval
- // sqlOctetLength_ = maxLen+3;
- // Swastik - commented above line 02/10/2005 for Interval Data
- // Type support
- // 3 was added earlier because interval datatype was handled in
- // the same
- // way as varchar and varchar-long were handled. Since we are
- // separating it
- // we don't need to add the additional 3
- sqlOctetLength_ = maxLen;
- }
- break;
- }
- if (sqlDataType_ == SQLTYPECODE_CHAR || sqlDataType_ == SQLTYPECODE_VARCHAR
- || sqlDataType_ == SQLTYPECODE_BLOB || sqlDataType_ == SQLTYPECODE_CLOB
- || sqlDataType_ == SQLTYPECODE_VARCHAR_LONG || sqlDataType_ == SQLTYPECODE_VARCHAR_WITH_LENGTH) {
- isCaseSensitive_ = true;
- }
- isSearchable_ = true;
- fsDataType_ = fsDataType;
- intLeadPrec_ = intLeadPrec;
- paramMode_ = paramMode;
- } // end HPT4Desc
-
- // ---------------------------------------------------------------
- // Constructors
-
- HPT4Desc(
- int noNullValue // Descriptor2 only
- ,
- int nullValue // Descriptor2 only
- ,
- int version // Descriptor2 only
- , int dataType, short datetimeCode, int maxLen, short precision, short scale, boolean nullInfo,
- boolean signType // same as signe
- , int odbcDataType, int odbcPrecision, int sqlCharset, int odbcCharset, String colName // same
- // as
- // colHeadingNm
- , String tableName, String catalogName, String schemaName, String headingName // Descriptor2
- // only
- , int intLeadPrec, int paramMode, int fsDataType // fsDataType
- // seems to be
- // the same as
- // dataType (see
- // old
- // descriptor)
- , int rowLength) {
-
- //
- // Call the old constructor to set the items that are
- // in both the old descriptor and the new descriptor.
- //
- this(dataType, datetimeCode, maxLen, precision, scale, nullInfo, colName, signType, odbcDataType,
- (short) odbcPrecision, sqlCharset, odbcCharset, catalogName, schemaName, tableName, fsDataType,
- intLeadPrec, paramMode);
- //
- // Set the items specific to the new descriptor.
- //
- noNullValue_ = noNullValue;
- nullValue_ = nullValue;
- version_ = version;
- headingName_ = headingName;
- rowLength_ = rowLength;
-
- maxLen_ = maxLen;
-
- } // end HPT4Desc
-
- // ---------------------------------------------------------------
- /***************************************************************************
- * Returns encoding type for character data types from Database
- * COLS table.
- */
- String getCharacterSetName() throws SQLException {
- switch (dataType_) {
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.BLOB:
- case Types.CLOB:
- return (String) InterfaceUtilities.getCharsetName(sqlCharset_);
- default:
- return null;
- }
- }
-
- // ---------------------------------------------------------------
- // Constants
- public static final int SQLTYPECODE_CHAR = 1;
- public static final int SQLTYPECODE_VARCHAR = 12;
- public static final int SQLTYPECODE_VARCHAR_LONG = -1;
- public static final int SQLTYPECODE_INTERVAL = 10;
- public static final int SQLTYPECODE_VARCHAR_WITH_LENGTH = -601;
- public static final int SQLTYPECODE_BLOB = -602;
- public static final int SQLTYPECODE_CLOB = -603;
- public static final int SQLTYPECODE_SMALLINT = 5;
- public static final int SQLTYPECODE_INTEGER = 4;
-
- // datetime codes taken from NCS - File ....\....\...\Common\DrvrSrvr.h
- public static final int SQLDTCODE_YEAR = 4;
- public static final int SQLDTCODE_YEAR_TO_MONTH = 5;
- // public static final int SQLDTCODE_YEAR_TO_DAY 1 //Database
- // DATE
- public static final int SQLDTCODE_YEAR_TO_HOUR = 7; // ODBC TIMESTAMP(0)
- public static final int SQLDTCODE_YEAR_TO_MINUTE = 8;
- // public static final int SQLDTCODE_YEAR_TO_SECOND 3 //
- // DatabaseTIMESTAMP(0)
- // public static final int SQLDTCODE_YEAR_TO_FRACTION 3 //
- // Database TIMESTAMP(1 - 5)
- public static final int SQLDTCODE_MONTH = 10;
- public static final int SQLDTCODE_MONTH_TO_DAY = 11;
- public static final int SQLDTCODE_MONTH_TO_HOUR = 12;
- public static final int SQLDTCODE_MONTH_TO_MINUTE = 13;
- public static final int SQLDTCODE_MONTH_TO_SECOND = 14;
- public static final int SQLDTCODE_MONTH_TO_FRACTION = 14;
- public static final int SQLDTCODE_DAY = 15;
- public static final int SQLDTCODE_DAY_TO_HOUR = 16;
- public static final int SQLDTCODE_DAY_TO_MINUTE = 17;
- public static final int SQLDTCODE_DAY_TO_SECOND = 18;
- public static final int SQLDTCODE_DAY_TO_FRACTION = 18;
- public static final int SQLDTCODE_HOUR = 19;
- public static final int SQLDTCODE_HOUR_TO_MINUTE = 20;
- // define SQLDTCODE_HOUR_TO_SECOND 2 //Database TIME(0) --> NCS
- // Maps this to TIME
- public static final int SQLDTCODE_HOUR_TO_FRACTION = 2; // Database TIME(1 -
- // 6) // MXCI Maps
- // this to TIMESTAMP
- public static final int SQLDTCODE_MINUTE = 22;
- public static final int SQLDTCODE_MINUTE_TO_SECOND = 23;
- public static final int SQLDTCODE_MINUTE_TO_FRACTION = 23;
- public static final int SQLDTCODE_SECOND = 24;
- public static final int SQLDTCODE_SECOND_TO_FRACTION = 24;
- public static final int SQLDTCODE_FRACTION_TO_FRACTION = 29;
-
- // fields
- int sqlCharset_;
- int odbcCharset_;
- int sqlDataType_;
- int dataType_;
- short sqlPrecision_;
- short sqlDatetimeCode_;
- int sqlOctetLength_;
- int isNullable_;
- String name_;
- short scale_;
- int precision_;
- boolean isSigned_;
- boolean isCurrency_;
- boolean isCaseSensitive_;
- String catalogName_;
- String schemaName_;
- String tableName_;
- int fsDataType_;
- int intLeadPrec_;
- int paramMode_;
- int paramIndex_;
- int paramPos_;
-
- String columnClassName_;
- int displaySize_;
- // fields which are not pouplated now
- String columnLabel_;
- boolean isAutoIncrement_;
- boolean isSearchable_;
-
- boolean isValueSet_; // To denote if setXXX method is called for this
- // parameter
- // String paramValue_; // Contains the value of output parameter value
- Object paramValue_; // Contains the value of output parameter value
-
- int noNullValue_; // Descriptor2 only
- int nullValue_; // Descriptor2 only
- int version_; // Descriptor2 only
-
- String headingName_; // Descriptor2 only
-
- int rowLength_;
- int maxLen_;
-
-} // end class HPT4Desc
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4Exception.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4Exception.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4Exception.java
deleted file mode 100644
index 10c8d18..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4Exception.java
+++ /dev/null
@@ -1,38 +0,0 @@
-// @@@ 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;
-
-class HPT4Exception extends SQLException {
- protected String messageId;
-
- public HPT4Exception(String reason, String SQLState, int vendorCode, String msgId) {
- super(reason, SQLState, vendorCode);
- if (msgId == null) {
- messageId = "";
- } else {
- messageId = msgId;
- }
- }
-
-} // end class HPT4Exception
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4Handle.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4Handle.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4Handle.java
deleted file mode 100644
index 10a62b9..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4Handle.java
+++ /dev/null
@@ -1,84 +0,0 @@
-// @@@ 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.sql.SQLWarning;
-
-public abstract class HPT4Handle {
- SQLWarning sqlWarning_;
-
- public void clearWarnings() throws SQLException {
- sqlWarning_ = null;
- }
-
- public SQLWarning getWarnings() throws SQLException {
- return sqlWarning_;
- }
-
- void setSQLWarning(T4Properties t4props, String messageId, Object[] messageArguments) {
- SQLWarning sqlWarningLeaf = HPT4Messages.createSQLWarning(t4props, messageId, messageArguments);
- if (sqlWarning_ == null) {
- sqlWarning_ = sqlWarningLeaf;
- } else {
- sqlWarning_.setNextWarning(sqlWarningLeaf);
- }
- }
-
- // Method used by JNI layer to set the warning
- void setSqlWarning(SQLWarning sqlWarning) {
- if (sqlWarning_ == null) {
- sqlWarning_ = sqlWarning;
- } else {
- sqlWarning_.setNextWarning(sqlWarning);
- }
- }
-
- // Method added to check if the connection had any errors
- // This calls the abstract method closeErroredConnection()
- //returns true if a connection error occured
- boolean performConnectionErrorChecks(SQLException se) {
- if (se instanceof HPT4Exception) {
- HPT4Exception sqlmx_e = (HPT4Exception) se;
- if (sqlmx_e.messageId.equals(ERROR_SOCKET_WRITE_ERROR) || sqlmx_e.messageId.equals(ERROR_SOCKET_READ_ERROR)
- || sqlmx_e.messageId.equals(ERROR_SOCKET_IS_CLOSED_ERROR)
- || sqlmx_e.messageId.equals(ERROR_INVALID_CONNECTION) || sqlmx_e.messageId.equals(ERROR_IDS_08_S01)
- || sqlmx_e.messageId.equals(IDS_S1_T00)
- || sqlmx_e.messageId.equals(ERROR_SOCKET_OPEN)) {
- closeErroredConnection(sqlmx_e);
- return true;
- }
- }
-
- return false;
- }
-
- abstract void closeErroredConnection(HPT4Exception se);
-
- static final String ERROR_IDS_08_S01 = new String("ids_08_s01");
- static final String ERROR_INVALID_CONNECTION = new String("invalid_connection");
- static final String ERROR_SOCKET_WRITE_ERROR = new String("socket_write_error");
- static final String ERROR_SOCKET_READ_ERROR = new String("socket_read_error");
- static final String ERROR_SOCKET_IS_CLOSED_ERROR = new String("socket_is_closed_error");
- static final String IDS_S1_T00 = new String("ids_s1_t00");
- static final String ERROR_SOCKET_OPEN = new String("socket_open_error");
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4Messages.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4Messages.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4Messages.java
deleted file mode 100644
index cf58470..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4Messages.java
+++ /dev/null
@@ -1,324 +0,0 @@
-// @@@ 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.SQLWarning;
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.PropertyResourceBundle;
-import java.util.ResourceBundle;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-class HPT4Messages {
- static Logger getMessageLogger(T4Properties t4props) {
- return (t4props != null) ? t4props.t4Logger_ : T4Properties.t4GlobalLogger;
- }
-
- static SQLWarning createSQLWarning(T4Properties t4props, String messageId, Object[] messageArguments) {
- Logger log = getMessageLogger(t4props);
-
- if (log != null && log.isLoggable(Level.WARNING)) {
- Object p[] = T4LoggingUtilities.makeParams(t4props, messageId, messageArguments);
- log.logp(Level.WARNING, "HPT4Messages", "createSQLWarning", "", p);
- }
-
- Locale currentLocale = t4props == null ? null : t4props.getLocale();
- currentLocale = currentLocale == null ? Locale.getDefault() : currentLocale;
-
- int sqlcode = 1;
- SQLWarning ret = null;
-
- try {
- PropertyResourceBundle messageBundle = (PropertyResourceBundle) ResourceBundle.getBundle("T4Messages",
- currentLocale);
-
- 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) {
- // use 1 as default
- }
- }
-
- ret = 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(",");
- }
- }
- } // end if
-
- ret = new SQLWarning(message, "01000", 1);
- }
-
- return ret;
- }
-
- static void setSQLWarning(T4Properties t4props, HPT4Handle handle, SQLWarningOrError[] we1) {
- Logger log = getMessageLogger(t4props);
-
- int curErrorNo;
- SQLWarning sqlWarningLeaf;
-
- if (we1.length == 0) {
- handle.setSqlWarning(null);
- return;
- }
-
- for (curErrorNo = 0; curErrorNo < we1.length; curErrorNo++) {
- if (log != null && log.isLoggable(Level.WARNING)) {
- Object p[] = new Object[] { t4props, "Text: " + we1[curErrorNo].text,
- "SQLState: " + we1[curErrorNo].sqlState, "SQLCode: " + we1[curErrorNo].sqlCode };
- log.logp(Level.WARNING, "HPT4Messages", "setSQLWarning", "", p);
- }
-
- sqlWarningLeaf = new SQLWarning(we1[curErrorNo].text, we1[curErrorNo].sqlState, we1[curErrorNo].sqlCode);
- handle.setSqlWarning(sqlWarningLeaf);
- } // end for
- return;
- }
-
- static void setSQLWarning(T4Properties t4props, HPT4Handle handle, ERROR_DESC_LIST_def sqlWarning) {
- Logger log = getMessageLogger(t4props);
-
- int curErrorNo;
- ERROR_DESC_def error_desc_def[];
- SQLWarning sqlWarningLeaf;
-
- if (sqlWarning.length == 0) {
- handle.setSqlWarning(null);
- return;
- }
-
- error_desc_def = sqlWarning.buffer;
- for (curErrorNo = 0; curErrorNo < sqlWarning.length; curErrorNo++) {
- if (log != null && log.isLoggable(Level.WARNING)) {
- Object p[] = new Object[] { t4props, "Text: " + error_desc_def[curErrorNo].errorText,
- "SQLState: " + error_desc_def[curErrorNo].sqlstate,
- "SQLCode: " + error_desc_def[curErrorNo].sqlcode };
- log.logp(Level.WARNING, "HPT4Messages", "setSQLWarning", "", p);
- }
-
- sqlWarningLeaf = new SQLWarning(error_desc_def[curErrorNo].errorText, error_desc_def[curErrorNo].sqlstate,
- error_desc_def[curErrorNo].sqlcode);
- handle.setSqlWarning(sqlWarningLeaf);
- }
- return;
- } // end setSQLWarning
-
- // ------------------------------------------------------------------------------------------------
- static void throwSQLException(T4Properties t4props, ERROR_DESC_LIST_def SQLError) throws HPT4Exception {
- Logger log = getMessageLogger(t4props);
- Locale locale = (t4props != null) ? t4props.getLocale() : Locale.getDefault();
-
- HPT4Exception sqlException = null;
- HPT4Exception sqlExceptionHead = null;
- int curErrorNo;
-
- if (SQLError.length == 0) {
- throw createSQLException(t4props, locale, "No messages in the Error description", null);
- }
-
- for (curErrorNo = 0; curErrorNo < SQLError.length; curErrorNo++) {
- if (log != null && log.isLoggable(Level.SEVERE)) {
- Object p[] = new Object[] { t4props, "Text: " + SQLError.buffer[curErrorNo].errorText,
- "SQLState: " + SQLError.buffer[curErrorNo].sqlstate,
- "SQLCode: " + SQLError.buffer[curErrorNo].sqlcode };
- log.logp(Level.SEVERE, "HPT4Messages", "throwSQLException", "", p);
- }
-
- if (SQLError.buffer[curErrorNo].errorCodeType == TRANSPORT.ESTIMATEDCOSTRGERRWARN) {
- //
- // NCS said it was an SQL error, but it really wasn't it was a
- // NCS resource governing error
- //
- sqlException = HPT4Messages.createSQLException(t4props, locale, "resource_governing", null);
- } else {
- sqlException = new HPT4Exception(SQLError.buffer[curErrorNo].errorText,
- SQLError.buffer[curErrorNo].sqlstate, SQLError.buffer[curErrorNo].sqlcode, null);
- }
- if (curErrorNo == 0) {
- sqlExceptionHead = sqlException;
- } else {
- sqlExceptionHead.setNextException(sqlException);
- }
- }
-
- throw sqlExceptionHead;
- }
-
- // ------------------------------------------------------------------------------------------------
- static void throwSQLException(T4Properties t4props, SQLWarningOrError[] we1) throws HPT4Exception {
- Logger log = getMessageLogger(t4props);
- Locale locale = (t4props != null) ? t4props.getLocale() : Locale.getDefault();
-
- HPT4Exception sqlException = null;
- HPT4Exception sqlExceptionHead = null;
- int curErrorNo;
-
- if (we1.length == 0) {
- throw createSQLException(t4props, locale, "No messages in the Error description", null);
- }
-
- for (curErrorNo = 0; curErrorNo < we1.length; curErrorNo++) {
- if (log != null && log.isLoggable(Level.SEVERE)) {
- Object p[] = new Object[] { t4props, "Text: " + we1[curErrorNo].text,
- "SQLState: " + we1[curErrorNo].sqlState, "SQLCode: " + we1[curErrorNo].sqlCode };
- log.logp(Level.SEVERE, "HPT4Messages", "throwSQLException", "", p);
- }
-
- sqlException = new HPT4Exception(we1[curErrorNo].text, we1[curErrorNo].sqlState, we1[curErrorNo].sqlCode,
- null);
- if (curErrorNo == 0) {
- sqlExceptionHead = sqlException;
- } else {
- sqlExceptionHead.setNextException(sqlException);
- }
- } // end for
-
- throw sqlExceptionHead;
- } // end throwSQLException
-
- // ------------------------------------------------------------------------------------------------
- static HPT4Exception createSQLException(T4Properties t4props, Locale msgLocale, String messageId, Object mA1,
- Object mA2) {
-
- Object[] mAs = new Object[2];
-
- mAs[0] = mA1;
- mAs[1] = mA2;
-
- return createSQLException(t4props, msgLocale, messageId, mAs);
-
- } // end createSQLException
-
- // ------------------------------------------------------------------------------------------------
- static HPT4Exception createSQLException(T4Properties t4props, Locale msgLocale, String messageId,
- Object messageArgument) {
- Object[] mAs = new Object[1];
-
- mAs[0] = messageArgument;
-
- return createSQLException(t4props, msgLocale, messageId, mAs);
-
- } // end createSQLException
-
- // ------------------------------------------------------------------------------------------------
- static HPT4Exception createSQLException(T4Properties t4props, Locale msgLocale, String messageId,
- Object[] messageArguments) {
- Logger log = getMessageLogger(t4props);
-
- if (log != null && log.isLoggable(Level.SEVERE)) {
- Object p[] = T4LoggingUtilities.makeParams(t4props, messageId, messageArguments);
- log.logp(Level.SEVERE, "HPT4Messages", "createSQLException", "", p);
- }
-
- Locale currentLocale = t4props == null ? null : t4props.getLocale();
- currentLocale = currentLocale == null ? Locale.getDefault(): currentLocale;
-
- int sqlcode;
- try {
- PropertyResourceBundle messageBundle = (PropertyResourceBundle) ResourceBundle.getBundle("T4Messages",
- currentLocale);
-
- 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 HPT4Exception(message, sqlState, sqlcode, messageId);
- } 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++] + "");
- if (i >= messageArguments.length) {
- break;
- } else {
- message = message.concat(",");
- }
- }
- } // end if
-
- return new HPT4Exception(message, "HY000", -1, messageId);
- } // end catch
- } // end createSQLException
-
- // ------------------------------------------------------------------------------------------------
- static void throwUnsupportedFeatureException(T4Properties t4props, Locale locale, String s) throws HPT4Exception {
- Object[] messageArguments = new Object[1];
-
- messageArguments[0] = s;
- throw HPT4Messages.createSQLException(t4props, locale, "unsupported_feature", messageArguments);
- } // end throwUnsupportedFeatureException
-
- // ------------------------------------------------------------------------------------------------
- static void throwDeprecatedMethodException(T4Properties t4props, Locale locale, String s) throws HPT4Exception {
- Object[] messageArguments = new Object[1];
-
- messageArguments[0] = s;
- throw HPT4Messages.createSQLException(t4props, locale, "deprecated_method", messageArguments);
- } // end throwDeprecatedMethodException
-
-} // end class HPT4Messages
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4ParameterMetaData.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4ParameterMetaData.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4ParameterMetaData.java
deleted file mode 100644
index b8b3422..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4ParameterMetaData.java
+++ /dev/null
@@ -1,243 +0,0 @@
-// @@@ 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.logging.Level;
-
-public class HPT4ParameterMetaData implements java.sql.ParameterMetaData {
-
- public String getParameterClassName(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
- return inputDesc[param - 1].getColumnClassName();
- }
-
- public int getParameterCount() throws SQLException {
- return inputDesc.length;
- }
-
- public int getParameterMode(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
- return inputDesc[param - 1].paramMode_;
- }
-
- public int getParameterType(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
- return inputDesc[param - 1].dataType_;
- }
-
- public String getParameterTypeName(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].getColumnTypeName(props.getLocale());
- }
-
- public int getPrecision(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].precision_;
- }
-
- public int getScale(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].scale_;
- }
-
- public int isNullable(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].isNullable_;
- }
-
- public boolean isSigned(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
- return inputDesc[param - 1].isSigned_;
- }
-
- // ////////////////////////
- // begin custom accessors//
- // ////////////////////////
- public int getRowLength() throws SQLException {
- // this is the same for all params
- // only if we have no input params will we throw an error
- if (inputDesc.length == 0) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[0].rowLength_;
- }
-
- public int getDisplaySize(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].displaySize_;
- }
-
- public int getFSDataType(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].fsDataType_;
- }
-
- public int getMaxLength(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].maxLen_;
- }
-
- public int getNoNullOffset(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].noNullValue_;
- }
-
- public int getNullOffset(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].nullValue_;
- }
-
- public int getOdbcCharset(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].odbcCharset_;
- }
-
- public int getSqlCharset(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].sqlCharset_;
- }
-
- public int getSqlDataType(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].sqlDataType_;
- }
-
- public int getSqlDatetimeCode(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].sqlDatetimeCode_;
- }
-
- public int getSqlOctetLength(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].sqlOctetLength_;
- }
-
- public int getSqlPrecision(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].sqlPrecision_;
- }
-
- // /////////////////////////////////
- // these are legacy names...do not remove these yet even though they are
- // duplicate
- // i will depricate these before 2.3 release
- // ///////////////////////////////
-
- /**
- * @deprecated
- */
- public int getSqlTypeCode(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].dataType_;
- }
-
- /**
- * @deprecated
- */
- public int getSqlLength(int param) throws SQLException {
- if (param > inputDesc.length) {
- throw HPT4Messages.createSQLException(props, props.getLocale(), "invalid_desc_index", null);
- }
-
- return inputDesc[param - 1].maxLen_;
- }
-
- HPT4ParameterMetaData(TrafT4PreparedStatement stmt, HPT4Desc[] inputDesc) {
- this.props = stmt.connection_.props_;
- this.inputDesc = inputDesc;
-
- if (props.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(stmt.connection_.props_, stmt, inputDesc);
- stmt.connection_.props_.t4Logger_.logp(Level.FINE, "HPT4ParameterMetaData", "", "", p);
- }
- }
-
- T4Properties props;
- HPT4Desc[] inputDesc;
- 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;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4PooledConnection.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4PooledConnection.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4PooledConnection.java
deleted file mode 100644
index 719d59a..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/HPT4PooledConnection.java
+++ /dev/null
@@ -1,238 +0,0 @@
-// @@@ 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.Connection;
-import java.sql.SQLException;
-import java.util.LinkedList;
-import java.util.Locale;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-import javax.sql.ConnectionEvent;
-import javax.sql.ConnectionEventListener;
-import javax.sql.StatementEventListener;
-
-public class HPT4PooledConnection implements javax.sql.PooledConnection {
-
- public void addConnectionEventListener(ConnectionEventListener listener) {
- try {
- if (connection_ != null && connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, listener);
- connection_.props_.t4Logger_.logp(Level.FINE, "HPT4PooledConnecton", "addConnectionEventListener", "",
- p);
- }
- if (connection_ != null && connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, listener);
- lr.setParameters(p);
- lr.setSourceClassName("HPT4PooledConnection");
- lr.setSourceMethodName("addConnectionEventListener");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- } catch (SQLException se) {
- // ignore
- }
- if (isClosed_ || connection_ == null) {
- return;
- }
- listenerList_.add(listener);
- }
-
- public void close() throws SQLException {
- if (connection_ != null && connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "HPT4PooledConnecton", "close", "", p);
- }
- if (connection_ != null && connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("HPT4PooledConnection");
- lr.setSourceMethodName("close");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- //3196 - NDCS transaction for SPJ
- if (connection_.ic_.suspendRequest_) {
- connection_.suspendUDRTransaction();
- }
-
- if (isClosed_) {
- return;
- }
- connection_.close(true, true);
- }
-
- public Connection getConnection() throws SQLException {
- if (connection_ != null && connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "HPT4PooledConnecton", "getConnection", "", p);
- }
- if (connection_ != null && connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("HPT4PooledConnection");
- lr.setSourceMethodName("getConnection");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- if (isClosed_ || connection_ == null) {
- throw HPT4Messages.createSQLException(connection_.props_, locale_, "invalid_connection", null);
- }
- if (LogicalConnectionInUse_) {
- connection_.close(false, false);
- }
- LogicalConnectionInUse_ = true;
- connection_.reuse();
- return connection_;
- }
-
- public void removeConnectionEventListener(ConnectionEventListener listener) {
- try {
- if (connection_ != null && connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, listener);
- connection_.props_.t4Logger_.logp(Level.FINE, "HPT4PooledConnecton", "removeConnectionEventListener",
- "", p);
- }
- if (connection_ != null && connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, listener);
- lr.setParameters(p);
- lr.setSourceClassName("HPT4PooledConnection");
- lr.setSourceMethodName("removeConnectionEventListener");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- } catch (SQLException se) {
- // ignore
- }
- if (isClosed_ || connection_ == null) {
- return;
- }
- listenerList_.remove(listener);
- }
-
- // Called by TrafT4Connection when the connection is closed by the application
- void logicalClose(boolean sendEvents) {
- int i;
- int totalListener;
- ConnectionEventListener listener;
-
- LogicalConnectionInUse_ = false;
-
- try {
- //3196 - NDCS transaction for SPJ
- if (connection_.ic_.suspendRequest_) {
- connection_.suspendUDRTransaction();
- }
- }
- catch (SQLException ex) {}
-
- if (sendEvents) {
- totalListener = listenerList_.size();
- ConnectionEvent event = new ConnectionEvent(this);
- for (i = 0; i < totalListener; i++) {
- listener = (ConnectionEventListener) listenerList_.get(i);
- listener.connectionClosed(event);
- }
- }
- }
-
- void sendConnectionErrorEvent(SQLException ex) throws SQLException {
- 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();
- }
-
- // Constructor
- HPT4PooledConnection(HPT4ConnectionPoolDataSource pds, T4Properties t4props) throws SQLException {
- super();
-
- T4Properties t4LocalProps;
-
- pds_ = pds;
- if (t4props != null) {
- t4LocalProps = t4props;
- locale_ = t4props.getLocale();
- } else {
- t4LocalProps = new T4Properties();
- locale_ = Locale.getDefault();
- }
- listenerList_ = new LinkedList();
- connection_ = new TrafT4Connection(this, t4LocalProps);
- try {
- if (connection_ != null && connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, pds, t4props);
- connection_.props_.t4Logger_.logp(Level.FINE, "HPT4PooledConnecton", "", "", p);
- }
- if (connection_ != null && connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, pds, t4props);
- lr.setParameters(p);
- lr.setSourceClassName("HPT4PooledConnection");
- lr.setSourceMethodName("");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- } catch (SQLException se) {
- // ignore
- }
- }
-
- TrafT4Connection getTrafT4ConnectionReference() {
- return connection_;
- }
-
- private LinkedList listenerList_;
- private boolean isClosed_ = false;
- private HPT4ConnectionPoolDataSource pds_;
- private TrafT4Connection connection_;
- private Locale locale_;
- private boolean LogicalConnectionInUse_ = false;
- public void addStatementEventListener(StatementEventListener listener) {
- // TODO Auto-generated method stub
-
- }
-
- public void removeStatementEventListener(StatementEventListener listener) {
- // TODO Auto-generated method stub
-
- }
-}
[51/60] incubator-trafodion git commit: fixed dcs/rest/udr to have
the version infor for jdbcT4 jar file
Posted by db...@apache.org.
fixed dcs/rest/udr to have the version infor for jdbcT4 jar file
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/5955e92b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/5955e92b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/5955e92b
Branch: refs/heads/master
Commit: 5955e92b21961b2805149f9f02f11ce681a5026e
Parents: 9d450e9
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Fri Apr 22 22:47:01 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Fri Apr 22 22:47:01 2016 +0000
----------------------------------------------------------------------
core/rest/pom.xml | 2 +-
core/sql/regress/udr/EXPECTED002 | 2 +-
core/sql/regress/udr/TEST002 | 2 +-
dcs/pom.xml | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/5955e92b/core/rest/pom.xml
----------------------------------------------------------------------
diff --git a/core/rest/pom.xml b/core/rest/pom.xml
index ab36f7c..c364448 100644
--- a/core/rest/pom.xml
+++ b/core/rest/pom.xml
@@ -191,7 +191,7 @@
</dependencies>
<configuration>
<additionalClasspathElements>
- <additionalClasspathElement>${basedir}/target/test-classes/jdbcT4.jar</additionalClasspathElement>
+ <additionalClasspathElement>${basedir}/target/test-classes/jdbcT4-${TRAFODION_VER}.jar</additionalClasspathElement>
</additionalClasspathElements>
<includes>
<include>${integrationtest.include}</include>
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/5955e92b/core/sql/regress/udr/EXPECTED002
----------------------------------------------------------------------
diff --git a/core/sql/regress/udr/EXPECTED002 b/core/sql/regress/udr/EXPECTED002
index 0245a11..2e7677b 100644
--- a/core/sql/regress/udr/EXPECTED002
+++ b/core/sql/regress/udr/EXPECTED002
@@ -6749,7 +6749,7 @@ P SLICE_TIME VAL1_FCI VAL1_LCI VAL2_FCI
>>-- 'jdbc:t4jdbc://localhost:23400/:'
>>prepare s_traf from
+>select *
-+>from udf(jdbc('jdbcT4.jar',
++>from udf(jdbc('jdbcT4-${TRAFODION_VER}.jar',
+> 'org.trafodion.jdbc.t4.T4Driver',
+> $$QUOTE$$$$JDBC_T4_URL$$$$QUOTE$$,
+> 'any', -- no user id
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/5955e92b/core/sql/regress/udr/TEST002
----------------------------------------------------------------------
diff --git a/core/sql/regress/udr/TEST002 b/core/sql/regress/udr/TEST002
index 79d8250..fd60dda 100644
--- a/core/sql/regress/udr/TEST002
+++ b/core/sql/regress/udr/TEST002
@@ -239,7 +239,7 @@ sh cp $$MY_SQROOT$$/export/lib/jdbcT2.jar $$MY_SQROOT$$/udr/external_libs;
-- 'jdbc:t4jdbc://localhost:23400/:'
prepare s_traf from
select *
-from udf(jdbc('jdbcT4.jar',
+from udf(jdbc('jdbcT4-${TRAFODION_VER}.jar',
'org.trafodion.jdbc.t4.T4Driver',
$$QUOTE$$$$JDBC_T4_URL$$$$QUOTE$$,
'any', -- no user id
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/5955e92b/dcs/pom.xml
----------------------------------------------------------------------
diff --git a/dcs/pom.xml b/dcs/pom.xml
index e9b6d11..a575b3b 100644
--- a/dcs/pom.xml
+++ b/dcs/pom.xml
@@ -325,7 +325,7 @@
</dependencies>
<configuration>
<additionalClasspathElements>
- <additionalClasspathElement>${basedir}/target/test-classes/jdbcT4.jar</additionalClasspathElement>
+ <additionalClasspathElement>${basedir}/target/test-classes/jdbcT4-${TRAFODION_VER}.jar</additionalClasspathElement>
</additionalClasspathElements>
<includes>
<include>${integrationtest.include}</include>
[52/60] incubator-trafodion git commit: Minor T4 driver fix Fixed
duplicate copyright in dcs files
Posted by db...@apache.org.
Minor T4 driver fix
Fixed duplicate copyright in dcs files
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/8ed58bf6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/8ed58bf6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/8ed58bf6
Branch: refs/heads/master
Commit: 8ed58bf6389015275646f83298ca2bf067f817f9
Parents: 5955e92
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Tue Apr 26 16:18:13 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Tue Apr 26 16:18:13 2016 +0000
----------------------------------------------------------------------
core/conn/jdbcT4/Makefile | 2 +-
.../java/org/trafodion/jdbc/t4/BaseTest.java | 60 --------------------
.../org/trafodion/jdbc/t4/T4DriverTest.java | 6 +-
.../trafodion/dcs/zookeeper/DcsQuorumPeer.java | 22 +------
.../org/trafodion/dcs/zookeeper/ZKConfig.java | 21 +------
.../trafodion/dcs/zookeeper/ZKServerTool.java | 24 +-------
.../org/trafodion/dcs/zookeeper/ZkClient.java | 22 +------
.../org/trafodion/dcs/zookeeper/ZkUtil.java | 23 +-------
.../dcs/zookeeper/ZooKeeperMainServerArg.java | 23 +-------
9 files changed, 14 insertions(+), 189 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8ed58bf6/core/conn/jdbcT4/Makefile
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/Makefile b/core/conn/jdbcT4/Makefile
index 189a053..6006abb 100644
--- a/core/conn/jdbcT4/Makefile
+++ b/core/conn/jdbcT4/Makefile
@@ -27,7 +27,7 @@ all: build_all
build_all:
echo "$(MAVEN) package -DskipTests"
- set -o pipefail && $(MAVEN) package | tee build_jdbct4.log | grep --line-buffered -E -e '^\[[^WId]' -e '^\[INFO\] B[Uu][Ii][Ll][Dd]' -e 'to compile'
+ set -o pipefail && $(MAVEN) package -DskipTests | tee build_jdbct4.log | grep --line-buffered -E -e '^\[[^WId]' -e '^\[INFO\] B[Uu][Ii][Ll][Dd]' -e 'to compile'
cp target/jdbcT4-${TRAFODION_VER}.jar ${MY_SQROOT}/export/lib
mkdir -p ../clients
mv target/jdbcT4-${TRAFODION_VER}.zip ../clients
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8ed58bf6/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/BaseTest.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/BaseTest.java b/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/BaseTest.java
deleted file mode 100644
index 71a9486..0000000
--- a/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/BaseTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-* @@@ 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 org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-
-public class BaseTest {
-
- /**
- * @throws java.lang.Exception
- */
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
-
- /**
- * @throws java.lang.Exception
- */
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
- /**
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- }
-
- /**
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws Exception {
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8ed58bf6/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/T4DriverTest.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/T4DriverTest.java b/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/T4DriverTest.java
index 5619784..e44c97a 100644
--- a/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/T4DriverTest.java
+++ b/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/T4DriverTest.java
@@ -18,7 +18,9 @@
* specific language governing permissions and limitations
* under the License.
*
-* @@@ END COPYRIGHT @@@ */
+* @@@ END COPYRIGHT @@@
+*/
+
package org.trafodion.jdbc.t4;
import java.sql.SQLException;
@@ -27,7 +29,7 @@ import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
-public class T4DriverTest extends BaseTest {
+public class T4DriverTest {
private static T4Driver driver;
@BeforeClass
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8ed58bf6/dcs/src/main/java/org/trafodion/dcs/zookeeper/DcsQuorumPeer.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/zookeeper/DcsQuorumPeer.java b/dcs/src/main/java/org/trafodion/dcs/zookeeper/DcsQuorumPeer.java
index 62883f9..bb7dede 100644
--- a/dcs/src/main/java/org/trafodion/dcs/zookeeper/DcsQuorumPeer.java
+++ b/dcs/src/main/java/org/trafodion/dcs/zookeeper/DcsQuorumPeer.java
@@ -19,27 +19,7 @@ specific language governing permissions and limitations
under the License.
* @@@ END COPYRIGHT @@@
- */
-/**
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
+*/
package org.trafodion.dcs.zookeeper;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8ed58bf6/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZKConfig.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZKConfig.java b/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZKConfig.java
index 57095f4..1e5d2f2 100644
--- a/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZKConfig.java
+++ b/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZKConfig.java
@@ -19,26 +19,7 @@ specific language governing permissions and limitations
under the License.
* @@@ END COPYRIGHT @@@
- */
-/**
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+*/
package org.trafodion.dcs.zookeeper;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8ed58bf6/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZKServerTool.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZKServerTool.java b/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZKServerTool.java
index 728ce63..eabb47f 100644
--- a/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZKServerTool.java
+++ b/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZKServerTool.java
@@ -19,27 +19,7 @@ specific language governing permissions and limitations
under the License.
* @@@ END COPYRIGHT @@@
- */
-/**
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
+*/
package org.trafodion.dcs.zookeeper;
import java.util.Properties;
@@ -73,4 +53,4 @@ public class ZKServerTool {
}
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8ed58bf6/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZkClient.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZkClient.java b/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZkClient.java
index 6ad4be7..1d69d95 100644
--- a/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZkClient.java
+++ b/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZkClient.java
@@ -19,27 +19,7 @@ specific language governing permissions and limitations
under the License.
* @@@ END COPYRIGHT @@@
- */
-/**
- * Copyright 2011 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
+*/
package org.trafodion.dcs.zookeeper;
import java.io.*;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8ed58bf6/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZkUtil.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZkUtil.java b/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZkUtil.java
index a66ecfa..5598cd5 100644
--- a/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZkUtil.java
+++ b/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZkUtil.java
@@ -19,26 +19,7 @@ specific language governing permissions and limitations
under the License.
* @@@ END COPYRIGHT @@@
- */
-/**
- * Copyright 2011 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+*/
package org.trafodion.dcs.zookeeper;
@@ -107,4 +88,4 @@ public class ZkUtil {
System.exit(1);
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8ed58bf6/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZooKeeperMainServerArg.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZooKeeperMainServerArg.java b/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZooKeeperMainServerArg.java
index 5843717..159fe0d 100644
--- a/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZooKeeperMainServerArg.java
+++ b/dcs/src/main/java/org/trafodion/dcs/zookeeper/ZooKeeperMainServerArg.java
@@ -19,26 +19,7 @@ specific language governing permissions and limitations
under the License.
* @@@ END COPYRIGHT @@@
- */
-/**
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+*/
package org.trafodion.dcs.zookeeper;
@@ -87,4 +68,4 @@ public class ZooKeeperMainServerArg {
System.out.println((hostport == null || hostport.length() == 0)? "":
"-server " + hostport);
}
-}
\ No newline at end of file
+}
[25/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
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);
+ }
+}
[20/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Statement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Statement.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Statement.java
new file mode 100644
index 0000000..d0daff1
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Statement.java
@@ -0,0 +1,1690 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.lang.ref.WeakReference;
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+import java.sql.BatchUpdateException;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+/**
+ * <p>
+ * JDBC Type 4 TrafT4Statement class.
+ * </p>
+ * <p>
+ * Description: The <code>TrafT4Statement</code> class is an implementation of
+ * the <code>java.sql.Statement</code> interface.
+ * </p>
+ */
+public class TrafT4Statement extends HPT4Handle implements java.sql.Statement {
+ // java.sql.Statement interface Methods
+
+ public void addBatch(String sql) throws SQLException {
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("addBatch");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "addBatch", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("addBatch");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (batchCommands_ == null) {
+ batchCommands_ = new ArrayList();
+ }
+
+
+ batchCommands_.add(sql);
+ }
+
+ public void cancel() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "cancel", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("cancel");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ // Donot clear warning, since the warning may pertain to
+ // previous opertation and it is not yet seen by the application
+ //
+ // We must decide if this statement is currently being processed or
+ // if it has a result set associated with it, and if that
+ // result set is currently active (i.e. we are fetching rows).
+ if ((ist_.t4statement_ != null && ist_.t4statement_.m_processing == true)
+ || (resultSet_ != null && resultSet_[result_set_offset] != null
+ && resultSet_[result_set_offset].irs_ != null
+ && resultSet_[result_set_offset].irs_.t4resultSet_ != null && resultSet_[result_set_offset].irs_.t4resultSet_.m_processing == true))
+ ist_.cancel();
+ }
+
+ public void clearBatch() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "clearBatch", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("clearBatch");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ batchCommands_.clear();
+ }
+
+ /**
+ * Closes the statement object. Synchronized to prevent the same resource
+ * issued free command twice on the server.
+ *
+ * @throws SQLException
+ */
+ synchronized public void close() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "close", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("close");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (isClosed_) {
+ return;
+ }
+
+ try {
+ if (connection_._isClosed() == false) {
+ for (int i = 0; i < num_result_sets_; i++) {
+ if (resultSet_[i] != null) {
+ resultSet_[i].close(false);
+ }
+ }
+ ist_.close();
+ }
+ } finally {
+ isClosed_ = true;
+ connection_.removeElement(pRef_);
+ initResultSets();
+ }
+ }
+
+ void initResultSets() {
+ num_result_sets_ = 1;
+ result_set_offset = 0;
+ resultSet_[result_set_offset] = null;
+ }
+
+ // ------------------------------------------------------------------
+ /**
+ * This method will execute an operation.
+ *
+ * @return true
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+
+ public boolean execute() throws SQLException {
+ try {
+ ist_.executeDirect(queryTimeout_, this);
+ } catch (SQLException se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ return true;
+ } // end execute
+
+ // ------------------------------------------------------------------
+
+ public boolean execute(String sql) throws SQLException {
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("execute");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "execute", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("execute");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateExecDirectInvocation(sql);
+ try {
+ ist_.execute(TRANSPORT.SRVR_API_SQLEXECDIRECT, 0, 0, null, queryTimeout_, sql_, this);
+
+ checkSQLWarningAndClose();
+ } catch (SQLException se) {
+ try {
+ if (num_result_sets_ == 1 && resultSet_[result_set_offset] == null)
+ ;
+ {
+ internalClose();
+ }
+ } catch (SQLException closeException) {
+ se.setNextException(closeException);
+ }
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ if (resultSet_[result_set_offset] != null) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, autoGeneratedKeys);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "execute", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, autoGeneratedKeys);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("execute");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ boolean ret;
+
+ if (autoGeneratedKeys == TrafT4Statement.NO_GENERATED_KEYS) {
+ ret = execute(sql);
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "auto_generated_keys_not_supported", null);
+ }
+ return ret;
+ }
+
+ public boolean execute(String sql, int[] columnIndexes) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnIndexes);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "execute", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnIndexes);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("execute");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ boolean ret;
+
+ if (columnIndexes == null) {
+ ret = execute(sql);
+ } else if (columnIndexes.length == 0) {
+ ret = execute(sql);
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "auto_generated_keys_not_supported", null);
+ }
+ return ret;
+ }
+
+ public boolean execute(String sql, String[] columnNames) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnNames);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "execute", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnNames);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("execute");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ boolean ret;
+
+ if (columnNames == null) {
+ ret = execute(sql);
+ } else if (columnNames.length == 0) {
+ ret = execute(sql);
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "auto_generated_keys_not_supported", null);
+ }
+ return ret;
+ }
+
+ public int[] executeBatch() throws SQLException, BatchUpdateException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeBatch", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("executeBatch");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ try {
+ int i = 0;
+ SQLException se;
+
+ validateExecDirectInvocation();
+ if ((batchCommands_ == null) || (batchCommands_.isEmpty())) {
+ return new int[]
+
+ {};
+ }
+
+ batchRowCount_ = new int[batchCommands_.size()];
+ for (i = 0; i < batchCommands_.size(); i++) {
+ String sql = (String) batchCommands_.get(i);
+
+ if (sql == null) {
+ se = HPT4Messages.createSQLException(connection_.props_, this.ist_.ic_.getLocale(),
+ "batch_command_failed", "Invalid SQL String");
+ throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+ }
+
+ sqlStmtType_ = ist_.getSqlStmtType(sql);
+
+ if (sqlStmtType_ == TRANSPORT.TYPE_SELECT) {
+ se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "select_in_batch_not_supported", null);
+ throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+ } else if (sqlStmtType_ == TRANSPORT.TYPE_STATS) {
+ se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "infostats_invalid_error", null);
+ throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+ } else if (sqlStmtType_ == TRANSPORT.TYPE_CONFIG) {
+ se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "config_cmd_invalid_error", null);
+ throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+ }
+ ist_.setTransactionStatus(connection_, sql);
+ }
+
+ Object[] commands = batchCommands_.toArray();
+ int[] batchRowCount = new int[commands.length];
+ String sql;
+ int rowCount = 0;
+
+ try {
+ for (i = 0; i < commands.length; i++) {
+ sql = String.valueOf(commands[i]);
+
+ validateExecDirectInvocation(sql);
+
+ ist_.execute(TRANSPORT.SRVR_API_SQLEXECDIRECT, 0, 0, null, queryTimeout_, sql_, this);
+
+ checkSQLWarningAndClose();
+
+ batchRowCount[i] = batchRowCount_[0]; // the member will
+ // be set by
+ // execute...keep
+ // them in our local
+ // array
+ rowCount += ist_.getRowCount();
+ }
+ // CTS requirement.
+ if (commands.length < 1) {
+ batchRowCount = new int[] {};
+ }
+ } catch (SQLException e) {
+ ist_.setRowCount(rowCount);
+ batchRowCount_ = new int[i];
+ System.arraycopy(batchRowCount, 0, batchRowCount_, 0, i);
+
+ BatchUpdateException be;
+
+ se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "batch_command_failed", null);
+ be = new BatchUpdateException(se.getMessage(), se.getSQLState(), batchRowCount_);
+ be.setNextException(e);
+
+ try {
+ if (resultSet_[result_set_offset] == null) {
+ internalClose();
+ }
+ } catch (SQLException closeException) {
+ be.setNextException(closeException);
+ }
+ performConnectionErrorChecks(e);
+
+ throw be;
+ }
+
+ ist_.setRowCount(rowCount);
+ batchRowCount_ = new int[i];
+ System.arraycopy(batchRowCount, 0, batchRowCount_, 0, i);
+ return batchRowCount_;
+ } finally {
+ clearBatch();
+ }
+
+ }
+
+ public ResultSet executeQuery(String sql) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeQuery", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("executeQuery");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ validateExecDirectInvocation(sql);
+ if (sqlStmtType_ != TRANSPORT.TYPE_SELECT && sqlStmtType_ != TRANSPORT.TYPE_STATS) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "non_select_invalid",
+ null);
+ }
+ try {
+ ist_.execute(TRANSPORT.SRVR_API_SQLEXECDIRECT, 0, 0, null, queryTimeout_, sql_, this);
+
+ checkSQLWarningAndClose();
+ } catch (SQLException se) {
+ try {
+ if (resultSet_[result_set_offset] == null) {
+ internalClose();
+ }
+ } catch (SQLException closeException) {
+ se.setNextException(closeException);
+ }
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ return resultSet_[result_set_offset];
+ }
+
+ public int executeUpdate(String sql) throws SQLException {
+ long count = executeUpdate64(sql);
+
+ if (count > Integer.MAX_VALUE)
+ this.setSQLWarning(null, "numeric_out_of_range", null);
+
+ return (int) count;
+ }
+
+ public long executeUpdate64(String sql) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeUpdate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("executeUpdate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateExecDirectInvocation(sql);
+ // 7708
+ if (sqlStmtType_ == TRANSPORT.TYPE_SELECT && (ist_.stmtIsLock != true)) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "select_invalid", null);
+ }
+ try {
+ ist_.execute(TRANSPORT.SRVR_API_SQLEXECDIRECT, 0, 0, null, queryTimeout_, sql_, this);
+
+ checkSQLWarningAndClose();
+ } catch (SQLException se) {
+ try {
+ if (resultSet_[result_set_offset] == null) {
+ internalClose();
+ }
+ } catch (SQLException closeException) {
+ se.setNextException(closeException);
+ }
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ return ist_.getRowCount();
+ }
+
+ public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, autoGeneratedKeys);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeUpdate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, autoGeneratedKeys);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("executeUpdate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int ret;
+
+ if (autoGeneratedKeys == TrafT4Statement.NO_GENERATED_KEYS) {
+ ret = executeUpdate(sql);
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "auto_generated_keys_not_supported", null);
+ }
+ return ret;
+ }
+
+ public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnIndexes);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeUpdate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnIndexes);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("executeUpdate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int ret;
+
+ if (columnIndexes == null) {
+ ret = executeUpdate(sql);
+ } else if (columnIndexes.length == 0) {
+ ret = executeUpdate(sql);
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "auto_generated_keys_not_supported", null);
+ }
+ return ret;
+ }
+
+ public int executeUpdate(String sql, String[] columnNames) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnNames);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeUpdate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnNames);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("executeUpdate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int ret;
+
+ if (columnNames == null) {
+ ret = executeUpdate(sql);
+ } else if (columnNames.length == 0) {
+ ret = executeUpdate(sql);
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "auto_generated_keys_not_supported", null);
+ }
+ return ret;
+ }
+
+ public Connection getConnection() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getConnection", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getConnection");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return connection_;
+ }
+
+ public int getFetchDirection() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getFetchDirection", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getFetchDirection");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return fetchDirection_;
+ }
+
+ public int getFetchSize() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getFetchSize", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getFetchSize");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return fetchSize_;
+ }
+
+ public ResultSet getGeneratedKeys() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getGeneratedKeys", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getGeneratedKeys");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "auto_generated_keys_not_supported", null);
+ }
+
+ public int getMaxFieldSize() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getMaxFieldSize", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getMaxFieldSize");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return maxFieldSize_;
+ }
+
+ public int getMaxRows() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getMaxRows", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getMaxRows");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return maxRows_;
+ }
+
+ public boolean getMoreResults() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getMoreResults", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getMoreResults");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return getMoreResults(Statement.CLOSE_CURRENT_RESULT);
+ }
+
+ public boolean getMoreResults(int current) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, current);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getMoreResults", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, current);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getMoreResults");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ switch (current) {
+ case Statement.CLOSE_ALL_RESULTS:
+ for (int i = 0; i <= result_set_offset; i++) {
+ if (resultSet_[i] != null) {
+ resultSet_[i].close();
+ }
+ }
+ break;
+ case Statement.KEEP_CURRENT_RESULT:
+ break;
+ case Statement.CLOSE_CURRENT_RESULT: // this is the default action
+ default:
+ if (resultSet_[result_set_offset] != null) {
+ resultSet_[result_set_offset].close();
+ }
+ break;
+ }
+ ist_.setRowCount(-1);
+ if (result_set_offset < num_result_sets_ - 1) {
+ result_set_offset++;
+ return true;
+ }
+ return false;
+ }
+
+ public int getQueryTimeout() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getQueryTimeout", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getQueryTimeout");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return queryTimeout_;
+ }
+
+ public ResultSet getResultSet() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getResultSet", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getResultSet");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return resultSet_[result_set_offset];
+ }
+
+ public int getResultSetConcurrency() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getResultSetConcurrency", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getResultSetConcurrency");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return resultSetConcurrency_;
+ }
+
+ public int getResultSetHoldability() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getResultSetHoldability", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getResultSetHoldability");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return resultSetHoldability_;
+ }
+
+ public int getResultSetType() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getResultSetType", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getResultSetType");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return resultSetType_;
+ }
+
+ public int getUpdateCount() throws SQLException {
+ long count = getUpdateCount64();
+
+ if (count > Integer.MAX_VALUE)
+ this.setSQLWarning(null, "numeric_out_of_range", null);
+
+ return (int) count;
+ }
+
+ public long getUpdateCount64() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getUpdateCount", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getUpdateCount");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (ist_ == null) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_statement_handle", null);
+ }
+
+ // Spec wants -1 when the resultset is current and no more rows.
+ long count = ist_.getRowCount();
+ if ((count == 0) && resultSet_ != null && resultSet_[result_set_offset] != null) {
+ count = -1;
+ }
+
+ return count;
+ }
+
+ // ------------------------------------------------------------------
+ /**
+ * This method will get the operation ID for this statement. -1 is returned
+ * if the operation ID has not been set.
+ *
+ * @retrun The operation ID or -1 if the operation ID has not been set.
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+ public short getOperationID() throws SQLException {
+ return operationID_;
+ } // end getOperationID
+
+ // ------------------------------------------------------------------
+ /**
+ * This method will get the operation buffer for this statement. Null is
+ * returned if the operation buffer has not been set.
+ *
+ * @retrun The operation buffer or null if the operation ID has not been
+ * set.
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+ public byte[] getOperationBuffer() throws SQLException {
+ // System.out.println("in getOperation");
+ return operationBuffer_;
+ }
+
+ // ------------------------------------------------------------------
+ /**
+ * This method will get the operation reply buffer for this statement. Null
+ * is returned if the operation reply buffer has not been set.
+ *
+ * @retrun The operation reply buffer or null.
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+ public byte[] getOperationReplyBuffer() throws SQLException {
+ // System.out.println("in getOperationReplyBuffer");
+ return operationReply_;
+ }
+
+ // ------------------------------------------------------------------
+
+ public void setCursorName(String name) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, name);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setCursorName", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, name);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("setCursorName");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ // TODO: May need to check the Statement STATE
+ cursorName_ = name;
+ }
+
+ public void setEscapeProcessing(boolean enable) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, enable);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setEscapeProcessing", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, enable);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("setEscapeProcessing");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ escapeProcess_ = enable;
+
+ }
+
+ public void setFetchDirection(int direction) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, direction);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setFetchDirection", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, direction);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("setFetchDirection");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ switch (direction) {
+ case ResultSet.FETCH_FORWARD:
+ fetchDirection_ = direction;
+ break;
+ case ResultSet.FETCH_REVERSE:
+ case ResultSet.FETCH_UNKNOWN:
+ fetchDirection_ = ResultSet.FETCH_FORWARD;
+ break;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_fetch_direction", null);
+ }
+ }
+
+ public void setFetchSize(int rows) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rows);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setFetchSize", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rows);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("setFetchSize");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (rows < 0) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_fetch_size",
+ null);
+ } else if (rows == 0) {
+ fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
+ } else {
+ fetchSize_ = rows;
+ }
+ }
+
+ public void setMaxFieldSize(int max) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, max);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setMaxFieldSize", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, max);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("setMaxFieldSize");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (max < 0) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_maxFieldSize_value", null);
+ }
+ maxFieldSize_ = max;
+ }
+
+ public void setMaxRows(int max) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, max);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setMaxRows", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, max);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("setMaxRows");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (max < 0) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_maxRows_value",
+ null);
+ }
+ maxRows_ = max;
+ }
+
+ public void setQueryTimeout(int seconds) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, seconds);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setQueryTimeout", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, seconds);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("setQueryTimeout");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ //HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "setQueryTimeout()");
+
+ if (seconds < 0) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_queryTimeout_value", null);
+ }
+ queryTimeout_ = seconds;
+ }
+
+ // ------------------------------------------------------------------
+ /**
+ * This method will set the operation ID for this statement.
+ *
+ * @param opID
+ * the operation ID to associate with this statement.
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+ public void setOperationID(short opID) throws SQLException {
+ operationID_ = opID;
+ } // end setOperationID
+
+ // ------------------------------------------------------------------
+ /**
+ * This method will set the operation buffer for this statement.
+ *
+ * @param The
+ * operation buffer.
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+ public void setOperationBuffer(byte[] opBuffer) throws SQLException {
+ operationBuffer_ = opBuffer;
+ }
+
+
+ void validateExecDirectInvocation(String sql) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "validateExecDirectInvocation", "", p);
+ }
+
+ validateExecDirectInvocation();
+ sqlStmtType_ = ist_.getSqlStmtType(sql);
+ ist_.setTransactionStatus(connection_, sql);
+ sql_ = sql;
+
+ }
+
+ void validateExecDirectInvocation() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "validateExecDirectInvocation", "", p);
+ }
+ ist_.setRowCount(-1);
+ clearWarnings();
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_statement",
+ null);
+ }
+ try {
+ // connection_.getServerHandle().isConnectionOpen();
+ connection_.isConnectionOpen();
+
+ // close the previous resultset, if any
+ for (int i = 0; i < num_result_sets_; i++) {
+ if (resultSet_[i] != null) {
+ resultSet_[i].close();
+ }
+ }
+ } catch (SQLException se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ }
+
+ // This functions ensure that Database Resources are cleaned up,
+ // but leave the java Statement object
+ // intact.
+ void internalClose() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "internalClose", "", p);
+ }
+ if (connection_._isClosed() == false) {
+ ist_.close();
+ }
+ }
+
+ private void setResultSet(HPT4Desc[] outputDesc) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, outputDesc);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "setResultSet", "", p);
+ }
+ initResultSets();
+ if (outputDesc != null) {
+ resultSet_[result_set_offset] = new TrafT4ResultSet(this, outputDesc);
+ } else {
+ resultSet_[result_set_offset] = null;
+ }
+ }
+
+ public void setTransactionToJoin(byte[] txid) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, txid);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "setTransactionToJoin", "", p);
+ }
+
+ this.transactionToJoin = txid;
+ }
+
+ void setMultipleResultSets(int num_result_sets, HPT4Desc[][] output_descriptors, String[] stmt_labels,
+ String[] proxySyntax) throws SQLException {
+ if (num_result_sets < 1)
+ return;
+
+ resultSet_ = new TrafT4ResultSet[num_result_sets];
+ num_result_sets_ = num_result_sets;
+ for (int i = 0; i < num_result_sets; i++) {
+ HPT4Desc[] desc = output_descriptors[i];
+ if (desc == null) {
+ resultSet_[i] = null;
+ } else {
+ resultSet_[i] = new TrafT4ResultSet(this, desc, stmt_labels[i], true);
+ resultSet_[i].proxySyntax_ = proxySyntax[i];
+ }
+ }
+ }
+
+ // ----------------------------------------------------------------------------------
+ void setExecute2Outputs(byte[] values, short rowsAffected, boolean endOfData, String[] proxySyntax, HPT4Desc[] desc)
+ throws SQLException {
+ num_result_sets_ = 1;
+ result_set_offset = 0;
+
+ // if NO DATA FOUND is returned from the server, desc = null but
+ // we still want to save our descriptors from PREPARE
+ if (desc != null)
+ outputDesc_ = desc;
+
+ resultSet_ = new TrafT4ResultSet[num_result_sets_];
+
+ if (outputDesc_ != null) {
+ resultSet_[result_set_offset] = new TrafT4ResultSet(this, outputDesc_);
+ resultSet_[result_set_offset].proxySyntax_ = proxySyntax[result_set_offset];
+
+ if (rowsAffected == 0) {
+ if (endOfData == true) {
+ resultSet_[result_set_offset].setFetchOutputs(new Row[0], 0, true);
+ }
+ } else {
+ if(resultSet_[result_set_offset].keepRawBuffer_ == true)
+ resultSet_[result_set_offset].rawBuffer_ = values;
+
+ resultSet_[result_set_offset].irs_.setExecute2FetchOutputs(resultSet_[result_set_offset], 1, true,
+ values);
+ }
+ } else {
+ resultSet_[result_set_offset] = null;
+ }
+ }
+
+ // Constructors with access specifier as "default"
+ TrafT4Statement() {
+ if (T4Properties.t4GlobalLogger.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ T4Properties.t4GlobalLogger.logp(Level.FINE, "TrafT4Statement", "<init>", "", p);
+ }
+ resultSet_ = new TrafT4ResultSet[1];
+ initResultSets();
+ }
+
+ /*
+ * * For closing statements using label.
+ */
+ TrafT4Statement(TrafT4Connection connection, String stmtLabel) throws SQLException {
+ if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, stmtLabel);
+ connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>", "", p);
+ }
+ if (connection.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("Note, this constructor was called before the previous constructor");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection.props_.getLogWriter().println(temp);
+ }
+ int hashcode;
+
+ connection_ = connection;
+ operationID_ = -1;
+
+ resultSetType_ = ResultSet.TYPE_FORWARD_ONLY;
+ resultSetConcurrency_ = ResultSet.CONCUR_READ_ONLY;
+ resultSetHoldability_ = TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT;
+ queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
+
+ stmtLabel_ = stmtLabel;
+ fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
+ maxRows_ = 0;
+ fetchDirection_ = ResultSet.FETCH_FORWARD;
+ pRef_ = new WeakReference(this, connection_.refStmtQ_);
+ ist_ = new InterfaceStatement(this);
+ connection_.addElement(pRef_, stmtLabel_);
+
+ resultSet_ = new TrafT4ResultSet[1];
+ initResultSets();
+ }
+
+ TrafT4Statement(TrafT4Connection connection) throws SQLException {
+ this(connection, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT);
+ if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection);
+ connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>",
+ "Note, this constructor was called before the previous constructor", p);
+ }
+ if (connection.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("<init>");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection.props_.getLogWriter().println(temp);
+ }
+ resultSet_ = new TrafT4ResultSet[1];
+ roundingMode_ = connection_.props_.getRoundingMode();
+ initResultSets();
+ }
+
+ TrafT4Statement(TrafT4Connection connection, int resultSetType, int resultSetConcurrency) throws SQLException {
+ this(connection, resultSetType, resultSetConcurrency, TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT);
+ if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+ resultSetConcurrency);
+ connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>",
+ "Note, this constructor was called before the previous constructor", p);
+ }
+ if (connection.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+ resultSetConcurrency);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("<init>");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection.props_.getLogWriter().println(temp);
+ }
+ resultSet_ = new TrafT4ResultSet[1];
+ roundingMode_ = connection_.props_.getRoundingMode();
+ initResultSets();
+ }
+ TrafT4Statement(TrafT4Connection connection, int resultSetType, int resultSetConcurrency, int resultSetHoldability,
+ String stmtLabel) throws SQLException {
+ if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>", "", p);
+ }
+ if (connection.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("<init>");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection.props_.getLogWriter().println(temp);
+ }
+ int hashcode;
+
+ connection_ = connection;
+ operationID_ = -1;
+
+ if (resultSetType != ResultSet.TYPE_FORWARD_ONLY && resultSetType != ResultSet.TYPE_SCROLL_INSENSITIVE
+ && resultSetType != ResultSet.TYPE_SCROLL_SENSITIVE) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_resultset_type", null);
+ }
+
+ if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) {
+ resultSetType_ = ResultSet.TYPE_SCROLL_INSENSITIVE;
+ connection_.setSQLWarning(null, "scrollResultSetChanged", null);
+ //setSQLWarning(null, "scrollResultSetChanged", null);
+ } else {
+ resultSetType_ = resultSetType;
+ }
+ if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY && resultSetConcurrency != ResultSet.CONCUR_UPDATABLE) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_resultset_concurrency", null);
+ }
+
+ if ((resultSetHoldability != 0) && (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT)
+ && (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_holdability",
+ null);
+ }
+
+ resultSetConcurrency_ = resultSetConcurrency;
+ resultSetHoldability_ = resultSetHoldability;
+ queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
+
+ stmtLabel_ = stmtLabel;
+ fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
+ maxRows_ = 0;
+ fetchDirection_ = ResultSet.FETCH_FORWARD;
+
+ connection_.gcStmts();
+ pRef_ = new WeakReference(this, connection_.refStmtQ_);
+ ist_ = new InterfaceStatement(this);
+ connection_.addElement(pRef_, stmtLabel_);
+ roundingMode_ = connection_.props_.getRoundingMode();
+
+ resultSet_ = new TrafT4ResultSet[1];
+ }
+
+ TrafT4Statement(TrafT4Connection connection, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException {
+ if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>", "", p);
+ }
+ if (connection.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("<init>");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection.props_.getLogWriter().println(temp);
+ }
+ int hashcode;
+
+ connection_ = connection;
+ operationID_ = -1;
+
+ if (resultSetType != ResultSet.TYPE_FORWARD_ONLY && resultSetType != ResultSet.TYPE_SCROLL_INSENSITIVE
+ && resultSetType != ResultSet.TYPE_SCROLL_SENSITIVE) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_resultset_type", null);
+ }
+
+ if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) {
+ resultSetType_ = ResultSet.TYPE_SCROLL_INSENSITIVE;
+ connection_.setSQLWarning(null, "scrollResultSetChanged", null);
+ //setSQLWarning(null, "scrollResultSetChanged", null);
+ } else {
+ resultSetType_ = resultSetType;
+ }
+ if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY && resultSetConcurrency != ResultSet.CONCUR_UPDATABLE) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_resultset_concurrency", null);
+ }
+
+ if ((resultSetHoldability != 0) && (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT)
+ && (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_holdability",
+ null);
+ }
+
+ resultSetConcurrency_ = resultSetConcurrency;
+ resultSetHoldability_ = resultSetHoldability;
+ queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
+
+ stmtLabel_ = generateStmtLabel();
+ fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
+ maxRows_ = 0;
+ fetchDirection_ = ResultSet.FETCH_FORWARD;
+
+ connection_.gcStmts();
+ pRef_ = new WeakReference(this, connection_.refStmtQ_);
+ ist_ = new InterfaceStatement(this);
+ connection_.addElement(pRef_, stmtLabel_);
+
+ resultSet_ = new TrafT4ResultSet[1];
+ roundingMode_ = connection_.props_.getRoundingMode();
+ initResultSets();
+ }
+
+ //max length for a label is 32 characters.
+ String generateStmtLabel() {
+ String id = String.valueOf(this.connection_.ic_.getSequenceNumber());
+ if(id.length() > 24) {
+ id = id.substring(id.length()-24);
+ }
+
+ return "SQL_CUR_" + id;
+ }
+
+ // Database statement are not deallocated when there is a
+ // SQLWarning or SQLException or when a resultSet is produced
+ void checkSQLWarningAndClose() {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "checkSQLWarningAndClose", "", p);
+ }
+ if (sqlWarning_ != null) {
+ if (resultSet_[result_set_offset] == null) {
+ try {
+ internalClose();
+ } catch (SQLException closeException1) {
+ }
+ }
+ }
+ }
+
+ public void setRoundingMode(int roundingMode) {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, roundingMode);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setRoundingMode", "", p);
+ }
+ roundingMode_ = Utility.getRoundingMode(roundingMode);
+ }
+
+ public void setRoundingMode(String roundingMode) {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, roundingMode);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setRoundingMode", "", p);
+ }
+ roundingMode_ = Utility.getRoundingMode(roundingMode);
+ }
+
+ void closeErroredConnection(HPT4Exception sme) {
+ connection_.closeErroredConnection(sme);
+ }
+
+ /**
+ * Use this method to retrieve the statement-label name that was used when
+ * creating the statement through the Trafodion connectivity service. You can
+ * subsequently use the name retrieved as the cursor name when invoking
+ * INFOSTATS to gather resource statistics through either the
+ * <code>executeQuery(String sql)</code> or
+ * <code>execute(String sql)</code> methods.
+ */
+ public String getStatementLabel() {
+ return new String(stmtLabel_);
+ }
+
+ /**
+ * Returns the raw SQL associated with the statement
+ *
+ * @return the SQL text
+ */
+ public String getSQL() {
+ return this.sql_;
+ }
+
+ /**
+ * Returns the MXCS statement handle
+ *
+ * @return the MXCS statement handle
+ */
+ public int getStmtHandle() {
+ return this.ist_.stmtHandle_;
+ }
+
+ // static fields
+ public static final int NO_GENERATED_KEYS = 2;
+ // Fields
+ TrafT4Connection connection_;
+ int resultSetType_;
+ int resultSetConcurrency_;
+ String sql_;
+ int queryTimeout_;
+ int maxRows_;
+ int maxFieldSize_;
+ int fetchSize_;
+ int fetchDirection_;
+ boolean escapeProcess_;
+ String cursorName_ = "";
+ TrafT4ResultSet[] resultSet_; // Added for SPJ RS - SB 11/21/2005
+ int num_result_sets_; // Added for SPJ RS - SB 11/21/2005
+ int result_set_offset; // Added for SPJ RS - SB 11/21/2005
+ String stmtLabel_;
+ short sqlStmtType_;
+ boolean isClosed_;
+ ArrayList batchCommands_;
+ int[] batchRowCount_;
+ WeakReference pRef_;
+ int resultSetHoldability_;
+ InterfaceStatement ist_;
+
+ int inputParamsLength_;
+ int outputParamsLength_;
+ int inputDescLength_;
+ int outputDescLength_;
+
+ int inputParamCount_;
+ int outputParamCount_;
+
+ int roundingMode_ = BigDecimal.ROUND_HALF_EVEN;
+
+ HPT4Desc[] inputDesc_, outputDesc_;
+
+ short operationID_;
+ byte[] operationBuffer_;
+ byte[] operationReply_;
+
+ boolean usingRawRowset_;
+ ByteBuffer rowwiseRowsetBuffer_;
+
+ byte[] transactionToJoin;
+
+ int _lastCount = -1;
+
+ /**
+ * @return the inputParamsLength_
+ */
+ public int getInputParamsLength_() {
+ return inputParamsLength_;
+ }
+
+ /**
+ * @return the outputParamsLength_
+ */
+ public int getOutputParamsLength_() {
+ return outputParamsLength_;
+ }
+
+ public Object unwrap(Class iface) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isWrapperFor(Class iface) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isClosed() throws SQLException {
+ // TODO Auto-generated method stub
+ return isClosed_;
+ }
+
+ public void setPoolable(boolean poolable) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isPoolable() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void closeOnCompletion() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isCloseOnCompletion() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/USER_DESC_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/USER_DESC_def.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/USER_DESC_def.java
new file mode 100644
index 0000000..d67aa96
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/USER_DESC_def.java
@@ -0,0 +1,61 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class USER_DESC_def {
+ int userDescType;
+ byte[] userSid;
+ String domainName;
+ String userName;
+ byte[] password;
+
+ byte[] domainNameBytes;
+ byte[] userNameBytes;
+
+ int sizeOf(InterfaceConnection ic) throws CharacterCodingException, UnsupportedCharsetException {
+ int size = 0;
+
+ domainNameBytes = ic.encodeString(domainName, 1);
+ userNameBytes = ic.encodeString(userName, 1);
+
+ size += TRANSPORT.size_int; // descType
+
+ size += TRANSPORT.size_bytes(userSid);
+ size += TRANSPORT.size_bytes(domainNameBytes);
+ size += TRANSPORT.size_bytes(userNameBytes);
+ size += TRANSPORT.size_bytes(password);
+
+ return size;
+ }
+
+ void insertIntoByteArray(LogicalByteArray buf) {
+ buf.insertInt(userDescType);
+
+ buf.insertString(userSid);
+ buf.insertString(domainNameBytes);
+ buf.insertString(userNameBytes);
+ buf.insertString(password);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Utility.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Utility.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Utility.java
new file mode 100644
index 0000000..a3224d7
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Utility.java
@@ -0,0 +1,636 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.sql.DataTruncation;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ * This class contains a variety of methods for doing all sorts of things.
+ * @version 1.0
+ */
+
+class Utility {
+
+ private static final byte key[] = Utility.UnicodeToAscii("ci4mg04-3;" + "b,hl;y'd1q" + "x8ngp93nGp" + "oOp4HlD7vm"
+ + ">o(fHoPdkd" + "khp1`gl0hg" + "qERIFdlIFl" + "w48fgljksg" + "3oi5980rfd" + "4t8u9dfvkl");
+
+ // -------------------------------------------------------------
+ /**
+ * This method will translate a double byte Unicode string into a single
+ * byte ASCII array.
+ *
+ * @param original
+ * the original string
+ *
+ * @return a byte array containing the translated string
+ *
+ * @exception An
+ * UnsupportedEncodingException is thrown
+ */
+ static byte[] UnicodeToAscii(String original) {
+ try {
+ byte[] utf8Bytes = original.getBytes("UTF8");
+ return utf8Bytes;
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ return null;
+ } // end UnicodeToAscii
+
+ // -------------------------------------------------------------
+ /**
+ * This method will encrypt a byte buffer according to the encryption
+ * algorithm used by the ODBC server.
+ *
+ * @param original
+ * the original string
+ *
+ * @return a byte array containing the translated string
+ *
+ */
+ static boolean Encryption(byte inBuffer[], byte outBuffer[], int inLength) {
+ // Use simple encryption/decryption
+
+ if (outBuffer != inBuffer) {
+ System.arraycopy(outBuffer, 0, inBuffer, 0, inLength);
+ } // end if
+
+ for (int i = 0; i < inLength; ++i) {
+ int j = i % 100;
+ outBuffer[i] ^= key[j];
+ }
+
+ return true;
+ } // end Encryption
+
+ // -------------------------------------------------------------
+ /**
+ * This method will check a float value according to the MAX_FLOAT and
+ * MIN_FLOAT values in the Java language.
+ *
+ * @param the
+ * original double value to check
+ * @Locale the Locale to print the error message in
+ *
+ * @return none
+ *
+ */
+ static void checkFloatBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+ double indbl = inbd.doubleValue();
+ // double abdbl = inbd.abs().doubleValue(); Need to do MIN check as well
+ if (indbl > (double) Float.MAX_VALUE) {
+ throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", inbd.toString());
+ }
+ } // end checkFloatBoundary
+
+ // -------------------------------------------------------------
+ /**
+ * This method will check a double value according to the MAX_VALUE and
+ * MIN_VALUE values in the Double class.
+ *
+ * @param the
+ * original double value to check
+ * @Locale the Locale to print the error message in
+ *
+ * @return none
+ *
+ */
+ static void checkDoubleBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+ BigDecimal maxbd = new BigDecimal(Double.MAX_VALUE);
+ // need to check min as well
+ // BigDecimal minbd = new BigDecimal(Double.MIN_VALUE);
+ if ((inbd.compareTo(maxbd) > 0)) {
+ throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", inbd.toString());
+ }
+
+ } // end checkDoubleBoundary
+
+ // -------------------------------------------------------------
+ /**
+ * This method will check a Integer value according to the
+ * Interger.MAX_VALUE and Integer.MIN_VALUE values.
+ *
+ * @param the
+ * original long value to check
+ * @Locale the Locale to print the error message in
+ *
+ * @return none
+ *
+ */
+ static void checkIntegerBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+ long inlong = inbd.longValue();
+ if ((inlong > Integer.MAX_VALUE) || (inlong < Integer.MIN_VALUE)) {
+ throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
+ }
+ } // end checkIntegerBoundary
+
+ // -------------------------------------------------------------
+ /**
+ * This method will check a Long value according to the Long.MAX_VALUE*2 and
+ * 0 values.
+ *
+ * @param the
+ * original BigDecimal value to check
+ * @Locale the Locale to print the error message in
+ *
+ * @return none
+ *
+ */
+ static void checkSignedLongBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+ long inlong = inbd.longValue();
+ BigDecimal maxbd = new BigDecimal(Long.MAX_VALUE);
+ maxbd = maxbd.add(maxbd);
+ if ((inlong < 0) || (inbd.compareTo(maxbd) > 0)) {
+ throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
+ }
+ } // end checkIntegerBoundary
+
+ // -------------------------------------------------------------
+ /**
+ * This method will check a unsigned Short value according to the
+ * Short.MAX_VALUE*2 and 0 values.
+ *
+ * @param the
+ * original BigDecimal value to check
+ * @Locale the Locale to print the error message in
+ *
+ * @return none
+ *
+ */
+ static void checkSignedShortBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+ long inlong = inbd.longValue();
+ long maxushort = (Short.MAX_VALUE * 2) + 1;
+ if ((inlong < 0) || (inlong > maxushort)) {
+ throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
+ }
+ } // end checkIntegerBoundary
+
+ // -------------------------------------------------------------
+ /**
+ * This method will check a unsigned Int value according to the
+ * Integer.MAX_VALUE*2 and 0 values.
+ *
+ * @param the
+ * original BigDecimal value to check
+ * @Locale the Locale to print the error message in
+ *
+ * @return none
+ *
+ */
+ static void checkUnsignedIntegerBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+ long inlong = inbd.longValue();
+ long maxuint = ((long) Integer.MAX_VALUE * 2L) + 1L;
+ if ((inlong < 0) || (inlong > maxuint)) {
+ throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
+ }
+ } // end checkIntegerBoundary
+
+ // -------------------------------------------------------------
+ /**
+ * This method will check a Tinyint value according to the Byte.MAX_VALUE
+ * and Byte.MIN_VALUE values.
+ *
+ * @param the
+ * original long value to check
+ * @Locale the Locale to print the error message in
+ *
+ * @return none
+ *
+ */
+ static void checkTinyintBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+ long inlong = inbd.longValue();
+ if ((inlong > Byte.MAX_VALUE) || (inlong < Byte.MIN_VALUE)) {
+ throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
+ }
+ } // end checkTinyintBoundary
+
+ // -------------------------------------------------------------
+ /**
+ * This method will check a Short value according to the Short.MAX_VALUE and
+ * Short.MIN_VALUE values.
+ *
+ * @param the
+ * original long value to check
+ * @Locale the Locale to print the error message in
+ *
+ * @return none
+ *
+ */
+ static void checkShortBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+ long inlong = inbd.longValue();
+ if ((inlong > Short.MAX_VALUE) || (inlong < Short.MIN_VALUE)) {
+ throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", String.valueOf(inlong));
+ }
+ } // end checkShortBoundary
+
+ // -------------------------------------------------------------
+ /**
+ * This method will extract the BigDecimal value.
+ *
+ * @param the
+ * Locale to print the error message in
+ * @param the
+ * original object value to extract
+ *
+ * @return constructed BigDecimal value
+ *
+ */
+ static BigDecimal getBigDecimalValue(Locale locale, Object paramValue) throws SQLException {
+ BigDecimal tmpbd;
+
+ if (paramValue instanceof Long) {
+ tmpbd = BigDecimal.valueOf(((Long) paramValue).longValue());
+ } else if (paramValue instanceof Integer) {
+ tmpbd = BigDecimal.valueOf(((Integer) paramValue).longValue());
+ } else if (paramValue instanceof BigDecimal) {
+ tmpbd = (BigDecimal) paramValue;
+ } else if (paramValue instanceof String) {
+ String sVal = (String) paramValue;
+ if (sVal.equals("true") == true) {
+ sVal = "1";
+ } else if (sVal.equals("false") == true) {
+ sVal = "0";
+ }
+ tmpbd = new BigDecimal(sVal);
+ } else if (paramValue instanceof Float) {
+ tmpbd = new BigDecimal(paramValue.toString());
+ } else if (paramValue instanceof Double) {
+ tmpbd = new BigDecimal(((Double) paramValue).toString());
+ } else if (paramValue instanceof Boolean) {
+ tmpbd = BigDecimal.valueOf(((((Boolean) paramValue).booleanValue() == true) ? 1 : 0));
+ } else if (paramValue instanceof Byte) {
+ tmpbd = BigDecimal.valueOf(((Byte) paramValue).longValue());
+ } else if (paramValue instanceof Short) {
+ tmpbd = BigDecimal.valueOf(((Short) paramValue).longValue());
+ } else if (paramValue instanceof Integer) {
+ tmpbd = BigDecimal.valueOf(((Integer) paramValue).longValue());
+ // For LOB Support SB: 10/25/2004
+ /*
+ * else if (paramValue instanceof DataWrapper) tmpbd =
+ * BigDecimal.valueOf(((DataWrapper)paramValue).longValue);
+ */
+ } else {
+ throw HPT4Messages.createSQLException(null, locale, "object_type_not_supported", paramValue);
+ }
+ return tmpbd;
+ } // end getBigDecimalValue
+
+ // -------------------------------------------------------------
+ /**
+ * This method will check a Decimal value according to the precision in the
+ * Database table.
+ *
+ * @param the
+ * original BigDecimal value to check
+ * @param the
+ * Locale to print the error message in
+ *
+ * @return none
+ *
+ */
+ static void checkDecimalBoundary(Locale locale, BigDecimal inbd, int precision) throws SQLException {
+ if (precision > 0) {
+ BigDecimal maxbd = new BigDecimal(Math.pow(10, precision));
+ BigDecimal minbd = maxbd.negate();
+ if ((inbd.compareTo(maxbd) >= 0) || (inbd.compareTo(minbd) < 0)) {
+ throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", inbd.toString());
+ }
+ }
+ } // end checkBigDecimalBoundary
+ //---------------------------------------------------------------
+ /*code change starts
+ * MR Description: Warnings not being displayed when numeric overflow occurs
+ */
+
+ /**
+ * This method will check a scale value with the column in the
+ * Database table.
+ *
+ * @param the
+ * BigDecimal value to check
+ * @param the
+ * scale to check with the BigDecimal's scale
+ *
+ * @return none
+ *
+ */
+ static void checkScale(BigDecimal tmpbd, int scale) throws SQLException
+ {
+ if (tmpbd.scale() > scale)
+ if (!((tmpbd.scale() == 1) && (tmpbd.toString().endsWith("0"))))
+ {
+ try
+ {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = new String("A numeric overflow occurred during an arithmetic computation " +
+ "or data conversion.");
+ throw HPT4Messages.createSQLWarning(null, "8411", messageArguments);
+ }
+ catch (SQLWarning e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ //code change ends
+
+ // Fix_LeadingZero - AM 08/07/2006
+ private static int getExtraLen(String s) {
+ int extra = 0;
+
+ // count the trailing zero
+ int inx = s.indexOf(".");
+ if (inx != -1) {
+ int len = s.length();
+ for (int i = len - 1; i > inx; i--) {
+ char ch = s.charAt(i);
+ if (ch != '0') {
+ break;
+ }
+ extra++;
+ }
+ }
+ // count for leading zero
+ if (s.startsWith("0.") || s.startsWith("-0.")) {
+ extra++;
+ }
+
+ return extra;
+ }
+
+ // -------------------------------------------------------------
+ /**
+ * This method will check a Decimal value according to the precision in the
+ * Database table.
+ *
+ * @param the
+ * original BigDecimal value to check
+ * @param the
+ * Locale to print the error message in
+ *
+ * @return none
+ *
+ */
+ static void checkDecimalTruncation(int parameterIndex, Locale locale, BigDecimal inbd, int precision, int scale)
+ throws SQLException {
+ if (precision <= 0)
+ return;
+
+ int expectedLen = precision;
+
+ if (scale > 0)
+ expectedLen = precision + 1;
+
+ if (inbd.signum() == -1)
+ expectedLen++;
+ int actualLen = 0;
+
+ // Fix_LeadingZero - AM 08/07/2006
+ expectedLen += getExtraLen(inbd.toString());
+ /*
+ * if( (actualLen = inbd.toString().length()) > expectedLen ){
+ * //System.out.println("Length of " + inbd.toString() + " is greater
+ * than " + precision); throw new DataTruncation(parameterIndex, true,
+ * false, actualLen, expectedLen); }
+ */
+ actualLen = inbd.toString().length();
+ if (precision > 0) {
+ BigDecimal maxbd = new BigDecimal(Math.pow(10, precision - scale));
+ BigDecimal minbd = maxbd.negate();
+ if ((inbd.compareTo(maxbd) >= 0) || (inbd.compareTo(minbd) < 0)) {
+ // System.out.println("Max = " + maxbd.toString() + "\nMin = " +
+ // minbd + "\nInputted Val: " + inbd.toString());
+ // throw new DataTruncation(parameterIndex, true, false,
+ // actualLen, expectedLen);
+ throw new SQLException("*** ERROR[29188] Numeric value " + inbd.doubleValue() + " is out of range [" + minbd.doubleValue() + ", " + maxbd.doubleValue() + "]; Parameter index: " + (parameterIndex) +". ["+new SimpleDateFormat("yyyy-MM-dd HH:mm:s").format(new Date())+"]", "22003", -8411);
+ }
+ }
+ } // end checkDecimalTruncation
+
+ // -------------------------------------------------------------
+ /**
+ * This method will check a Long value according to the Long.MAX_VALUE and
+ * Long.MIN_VALUE values.
+ *
+ * @param the
+ * original long value to check
+ * @param the
+ * Locale to print the error message in
+ *
+ * @return none
+ *
+ */
+ static void checkLongBoundary(Locale locale, BigDecimal inbd) throws SQLException {
+ if ((inbd.compareTo(long_maxbd) > 0) || (inbd.compareTo(long_minbd) < 0)) {
+ throw HPT4Messages.createSQLException(null, locale, "numeric_out_of_range", inbd.toString());
+ }
+ } // end checkBigDecimalBoundary
+
+ // -------------------------------------------------------------
+ /**
+ * This method will check a Double and long value are the same.
+ *
+ * @param the
+ * original double value to check
+ * @param the
+ * original long value to check
+ * @param the
+ * Locale to print the error message in
+ *
+ * @return none
+ *
+ */
+ static void checkLongTruncation(int parameterindex, BigDecimal inbd) throws SQLException {
+ long inlong = inbd.longValue();
+ double indbl = inbd.doubleValue();
+
+ if ((double) inlong != indbl) {
+ int sizeLong = String.valueOf(inlong).length();
+ int sizeDbl = String.valueOf(indbl).length();
+ // throw new DataTruncation(parameterindex, true, false,
+ // sizeLong, sizeDbl);
+
+ DataTruncation dt = new DataTruncation(parameterindex, true, false, sizeLong, sizeDbl);
+ dt.setNextException(new SQLException("DataTruncation", "22003", -8411));
+ throw dt;
+ }
+ } // end checkLongTruncation
+
+ /**
+ * This method sets the round mode behaviour for the driver. Accepted values
+ * are: static int ROUND_CEILING Rounding mode to round towards positive
+ * infinity. static int ROUND_DOWN Rounding mode to round towards zero.
+ * static int ROUND_FLOOR Rounding mode to round towards negative infinity.
+ * static int ROUND_HALF_DOWN Rounding mode to round towards "nearest
+ * neighbor" unless both neighbors are equidistant, in which case round
+ * down. static int ROUND_HALF_EVEN Rounding mode to round towards the
+ * "nearest neighbor" unless both neighbors are equidistant, in which case,
+ * round towards the even neighbor. static int ROUND_HALF_UP Rounding mode
+ * to round towards "nearest neighbor" unless both neighbors are
+ * equidistant, in which case round up. static int ROUND_UNNECESSARY
+ * Rounding mode to assert that the requested operation has an exact result,
+ * hence no rounding is necessary. static int ROUND_UP Rounding mode to
+ * round away from zero. The default behaviour is to do ROUND_DOWN.
+ *
+ * @param ref
+ * roundMode
+ */
+ static int getRoundingMode(String roundMode) {
+ int op_roundMode = BigDecimal.ROUND_DOWN;
+ if (roundMode == null) {
+ op_roundMode = BigDecimal.ROUND_DOWN;
+ } else if (roundMode.equals("ROUND_CEILING")) {
+ op_roundMode = BigDecimal.ROUND_CEILING;
+ } else if (roundMode.equals("ROUND_DOWN")) {
+ op_roundMode = BigDecimal.ROUND_DOWN;
+ } else if (roundMode.equals("ROUND_FLOOR")) {
+ op_roundMode = BigDecimal.ROUND_FLOOR;
+ } else if (roundMode.equals("ROUND_HALF_UP")) {
+ op_roundMode = BigDecimal.ROUND_HALF_UP;
+ } else if (roundMode.equals("ROUND_UNNECESSARY")) {
+ op_roundMode = BigDecimal.ROUND_UNNECESSARY;
+ } else if (roundMode.equals("ROUND_HALF_EVEN")) {
+ op_roundMode = BigDecimal.ROUND_HALF_EVEN;
+ } else if (roundMode.equals("ROUND_HALF_DOWN")) {
+ op_roundMode = BigDecimal.ROUND_HALF_DOWN;
+ } else if (roundMode.equals("ROUND_UP")) {
+ op_roundMode = BigDecimal.ROUND_UP;
+ } else {
+ try {
+ op_roundMode = getRoundingMode(Integer.parseInt(roundMode));
+ } catch (Exception ex) {
+ op_roundMode = BigDecimal.ROUND_DOWN;
+ }
+
+ }
+ return op_roundMode;
+ }
+
+ /**
+ * This method sets the round mode behaviour for the driver. Accepted values
+ * are: static int ROUND_CEILING Rounding mode to round towards positive
+ * infinity. static int ROUND_DOWN Rounding mode to round towards zero.
+ * static int ROUND_FLOOR Rounding mode to round towards negative infinity.
+ * static int ROUND_HALF_DOWN Rounding mode to round towards "nearest
+ * neighbor" unless both neighbors are equidistant, in which case round
+ * down. static int ROUND_HALF_EVEN Rounding mode to round towards the
+ * "nearest neighbor" unless both neighbors are equidistant, in which case,
+ * round towards the even neighbor. static int ROUND_HALF_UP Rounding mode
+ * to round towards "nearest neighbor" unless both neighbors are
+ * equidistant, in which case round up. static int ROUND_UNNECESSARY
+ * Rounding mode to assert that the requested operation has an exact result,
+ * hence no rounding is necessary. static int ROUND_UP Rounding mode to
+ * round away from zero. The default behaviour is to do ROUND_DOWN.
+ *
+ * @param ref
+ * roundMode
+ */
+ static int getRoundingMode(int roundMode) {
+ if ((roundMode == BigDecimal.ROUND_CEILING) || (roundMode == BigDecimal.ROUND_DOWN)
+ || (roundMode == BigDecimal.ROUND_UP) || (roundMode == BigDecimal.ROUND_FLOOR)
+ || (roundMode == BigDecimal.ROUND_HALF_UP) || (roundMode == BigDecimal.ROUND_UNNECESSARY)
+ || (roundMode == BigDecimal.ROUND_HALF_EVEN) || (roundMode == BigDecimal.ROUND_HALF_DOWN)) {
+ return roundMode;
+ } else {
+ return BigDecimal.ROUND_DOWN;
+ }
+ }
+
+ static BigDecimal setScale(BigDecimal tmpbd, int scale, int roundingMode) throws SQLException {
+ try {
+ if (scale > -1) {
+ tmpbd = tmpbd.setScale(scale, roundingMode);
+ }
+ } catch (ArithmeticException aex) {
+ throw new SQLException(aex.getMessage());
+ }
+ return tmpbd;
+ }
+
+ static final BigDecimal long_maxbd = BigDecimal.valueOf(Long.MAX_VALUE);
+ static final BigDecimal long_minbd = BigDecimal.valueOf(Long.MIN_VALUE);
+
+ static private final char DEFAULT_TRIM_WHITESPACE = ' ';
+
+ static public String trimRight(final String string)
+ {
+ return trimRight(string, DEFAULT_TRIM_WHITESPACE);
+ }
+
+ static public String trimRight(final String string, final char trimChar)
+ {
+ final int lastChar = string.length() - 1;
+ int i;
+
+ for (i = lastChar; i >= 0 && string.charAt(i) == trimChar; i--) {
+ /* Decrement i until it is equal to the first char that does not
+ * match the trimChar given. */
+ }
+
+ if (i < lastChar) {
+ // the +1 is so we include the char at i
+ return string.substring(0, i+1);
+ } else {
+ return string;
+ }
+ }
+ static public String trimLeft(String string)
+ {
+ return trimLeft( string, DEFAULT_TRIM_WHITESPACE );
+ }
+
+ static public String trimLeft(final String string, final char trimChar)
+ {
+ final int stringLength = string.length();
+ int i;
+
+ for (i = 0; i < stringLength && string.charAt(i) == trimChar; i++) {
+ /* increment i until it is at the location of the first char that
+ * does not match the trimChar given. */
+ }
+
+ if (i == 0) {
+ return string;
+ } else {
+ return string.substring(i);
+ }
+ }
+ static public String trimRightZeros(String x) {
+ byte[] input = x.getBytes();
+ int i = input.length;
+
+ while (i-- > 0 && input[i] == 0) {}
+
+ byte[] output = new byte[i+1];
+ System.arraycopy(input, 0, output, 0, i+1);
+ return new String(output);
+ }
+
+} // end class Utility
[50/60] incubator-trafodion git commit: updated files
Posted by db...@apache.org.
updated files
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/9d450e99
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/9d450e99
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/9d450e99
Branch: refs/heads/master
Commit: 9d450e992f4d8610f1caff99181fd232849b368a
Parents: e17dce6
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Fri Apr 22 17:25:07 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Fri Apr 22 17:25:07 2016 +0000
----------------------------------------------------------------------
.../java/org/trafodion/jdbc/t4/RunAllTests.java | 31 ++++
core/conn/jdbc_type4/.gitignore | 3 -
core/conn/jdbc_type4/build.xml | 142 -------------------
core/conn/jdbc_type4/getBuildInfo | 24 ----
core/conn/jdbc_type4/test/RunAllTests.java | 31 ----
5 files changed, 31 insertions(+), 200 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9d450e99/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/RunAllTests.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/RunAllTests.java b/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/RunAllTests.java
new file mode 100644
index 0000000..0de5f33
--- /dev/null
+++ b/core/conn/jdbcT4/src/test/java/org/trafodion/jdbc/t4/RunAllTests.java
@@ -0,0 +1,31 @@
+/*
+* @@@ 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 @@@ */
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+import org.trafodion.jdbc.t4.T4DriverTest;
+
+@RunWith(Suite.class)
+@SuiteClasses({T4DriverTest.class})
+public class RunAllTests {
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9d450e99/core/conn/jdbc_type4/.gitignore
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/.gitignore b/core/conn/jdbc_type4/.gitignore
deleted file mode 100644
index 9a66973..0000000
--- a/core/conn/jdbc_type4/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-buildId
-temp/
-/target/
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9d450e99/core/conn/jdbc_type4/build.xml
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/build.xml b/core/conn/jdbc_type4/build.xml
deleted file mode 100755
index 9222a18..0000000
--- a/core/conn/jdbc_type4/build.xml
+++ /dev/null
@@ -1,142 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!-- @@@ 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 @@@ -->
-
-<project name="jdbct4" default="deploy">
- <tstamp>
- <format property="now.timestamp" pattern="yyyy_MM_dd" locale="en" />
- </tstamp>
-
- <!-- input -->
- <exec executable="git" outputproperty="bldId">
- <arg value="rev-parse" />
- <arg value="--short" />
- <arg value="HEAD" />
- </exec>
- <property name="vproc.str" value="Traf_JDBC_Type4_Build_${bldId}" />
- <property name="my_sqroot" value="../../sqf"/>
- <property id="basedir" name="basedir" value="."/>
- <property name="src.root" value="${basedir}" />
- <property name="target.dir" value="${basedir}/../../sqf/export/lib" />
- <property name="src.src" value="${src.root}/src" />
- <property name="src.test" value="${src.root}/test" />
- <property name="src.install" value="${src.root}/install" />
- <property name="src.samples" value="${src.root}/samples"/>
- <property name="src.lib" value="${src.root}/lib"/>
- <property name="src.lic" value="${src.root}/../../../licenses"/>
- <property name="src.notice" value="${src.root}/../../.."/>
- <property name="client.dir" value="${src.root}/../clients"/>
- <property name="temp.dir" value="${src.root}/temp"/>
- <property name="deploy.dir" value="${temp.dir}/deploy" />
- <property name="installclasses.dir" value="${temp.dir}/install-classes"/>
- <property name="tempinstall.dir" value="${temp.dir}/install"/>
- <property name="installer.zipfile" value="JDBCT4.zip" />
- <property name="temp.test" value="${temp.dir}/test" />
- <property name="vproc.java" value="org/trafodion/jdbc/t4/Vproc.java" />
- <property name="vproc.class" value="org.trafodion.jdbc.t4.Vproc" />
-
- <!-- output -->
- <property name="temp.src" value="${temp.dir}/src" />
- <property name="temp.classes" value="${temp.dir}/classes" />
- <property name="temp.lib" value="${temp.dir}/lib" />
-
- <!-- output files -->
- <property name="jdbcT4.jar" value="${temp.lib}/jdbcT4.jar" />
-
- <!-- CLEAN -->
- <target name="clean">
- <delete includeEmptyDirs="true" failonerror="false">
- <fileset dir="${temp.dir}"/>
- </delete>
- <delete file="${target.dir}/jdbcT4.jar"/>
- <delete file="${src.lib}/jdbcT4.jar"/>
- </target>
-
- <!-- INIT -->
- <target name="init">
- <mkdir dir="${temp.dir}" />
- <mkdir dir="${temp.classes}" />
- <mkdir dir="${temp.lib}" />
- <mkdir dir="${deploy.dir}"/>
- <mkdir dir="${client.dir}"/>
- </target>
-
- <!-- COMPILE -->
- <target name="compile" depends="init">
- <copy todir="${temp.src}">
- <fileset dir="${src.src}">
- <include name="**/*.java" />
- </fileset>
- </copy>
- <copy todir="${temp.classes}">
- <fileset dir="${src.src}">
- <include name="**/*.properties" />
- </fileset>
- <fileset dir="${src.notice}">
- <include name="NOTICE" />
- </fileset>
- </copy>
- <copy file="${src.lic}/Apache" tofile="${temp.classes}/LICENSE" />
-
- <replace file="${temp.src}/${vproc.java}" token="@@@@" value="${vproc.str}" />
- <javac destdir="${temp.classes}" srcdir="${temp.src}" debug="on" includes="**/*.java" classpath="${java.home}/lib/tools.jar;${temp.classes}" includeAntRuntime="false" />
- </target>
-
- <!-- LIB -->
- <target name="lib" depends="compile">
- <property file="${my_sqroot}/export/include/SCMBuildMan.mf"/>
- <jar destfile="${jdbcT4.jar}" basedir="${temp.classes}">
- <include name="LICENSE" />
- <include name="NOTICE" />
- <include name="**/*.class" />
- <include name="**/*.properties" />
-
- <manifest>
- <attribute name="Main-Class" value="${vproc.class}" />
- <attribute name="Vproc" value="${vproc.str}" />
- <attribute name="Implementation-Version-1" value="Version 1.0.0"/>
- <attribute name="Implementation-Version-2" value="${Implementation-Version-2}"/>
- <attribute name="Implementation-Version-3" value="${Implementation-Version-3}"/>
- <attribute name="Implementation-Version-4" value="${Implementation-Version-4}"/>
- <attribute name="Implementation-Version-5" value="${Implementation-Version-5}"/>
- <attribute name="Implementation-Version-6" value="${Implementation-Version-6}"/>
- </manifest>
- </jar>
- <copy file="${jdbcT4.jar}" todir="${target.dir}"/>
- <copy file="${jdbcT4.jar}" todir="${src.lib}"/>
- </target>
-
- <!-- DEPLOY -->
- <target name="deploy" depends="lib">
- <copy todir="${deploy.dir}/lib">
- <fileset dir="${temp.dir}/lib" />
- </copy>
-
- <copy todir="${deploy.dir}/samples">
- <fileset dir="${src.samples}">
- </fileset>
- </copy>
-
- <zip destfile="${client.dir}/${installer.zipfile}" basedir="${deploy.dir}"/>
- </target>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9d450e99/core/conn/jdbc_type4/getBuildInfo
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/getBuildInfo b/core/conn/jdbc_type4/getBuildInfo
deleted file mode 100755
index 410a160..0000000
--- a/core/conn/jdbc_type4/getBuildInfo
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-# @@@ 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 @@@
-
-buildId=`../../sqf/build-scripts/build.id`
-echo "bldId=$buildId" > buildId
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9d450e99/core/conn/jdbc_type4/test/RunAllTests.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/test/RunAllTests.java b/core/conn/jdbc_type4/test/RunAllTests.java
deleted file mode 100644
index 0de5f33..0000000
--- a/core/conn/jdbc_type4/test/RunAllTests.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-* @@@ 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 @@@ */
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-import org.trafodion.jdbc.t4.T4DriverTest;
-
-@RunWith(Suite.class)
-@SuiteClasses({T4DriverTest.class})
-public class RunAllTests {
-
-}
[26/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Properties.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Properties.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Properties.java
new file mode 100644
index 0000000..49100b4
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Properties.java
@@ -0,0 +1,2511 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.math.BigDecimal;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.util.Locale;
+import java.util.Properties;
+import java.util.logging.FileHandler;
+import java.util.logging.Formatter;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+
+/**
+ * <p>
+ * JDBC Type 4 driver connetion properties class.
+ * </p>
+ * <p>
+ * Description: The <code>T4Properties</code> class contains all the
+ * properties associated with Type 4 connection. <code>T4Properties</code> is
+ * inherited directy or indirectly by the <code>T4Driver, HPT4DataSource,
+ * HPT4ConnectionPooledDataSource</code>
+ * classes for configuring Type 4 connection properties.
+ * </p>
+ * <p>
+ * The properties passed to the Type 4 driver have this precedence order in
+ * event of the values set through more than one option:
+ * </p>
+ * <blockquote>
+ * <p>
+ * 1. java.util.properties parameter in the
+ * <code>DriverManager.getConnection</code> call or through
+ * <code>DataSource.setXXX()</code> call.
+ * </p>
+ * <p>
+ * 2. <code>java.util.properties</code> file properties set through
+ * <code>-Dt4jdbc.properties</code> option.
+ * </p>
+ * <p>
+ * 3. Command line properties using -D option. All the system properties passed
+ * through the command-line option have to be prefixed with
+ * <code>t4jdbc</code>, to distinguish JDBC Type 4 driver properties
+ * from other system properties. For example: property <code>user</code> when
+ * specified with -D has to be qualified as
+ * <code>-Dt4jdbc.user=super.super</code>.
+ * </p>
+ * </blockquote>
+ * <p>
+ * Licensed to the Apache Software Foundation (ASF)
+ * </p>
+ */
+public class T4Properties {
+ private String description_;
+ private String dataSourceName_;
+ private String serverDataSource_;
+ private String catalog_;
+ private String schema_;
+ private String user_;
+ private String url_;
+ private String pwd_;
+ private Locale locale_;
+ private int maxPoolSize_;
+ private int minPoolSize_;
+ private int initialPoolSize_;
+ private int maxStatements_;
+ private int loginTimeout_;
+ // private int closeConnectionTimeout_;
+ private int networkTimeout_;
+ private int connectionTimeout_;
+ private int maxIdleTime_;
+ private Level t4LogLevel;
+ private String T4LogFile_;
+ private Properties defaults_;
+ private Properties inprops_;
+ private PrintWriter logWriter_;
+ // For LOB Support - SB 9/28/04
+ static long reserveDataLocator_;
+ private int roundMode_;
+ private String language_;
+
+ private short fetchBufferSize_;
+
+ private String connectionID_;
+ private String dialogueID_;
+ private String serverID_;
+ private short ncsMajorVersion_;
+ private short ncsMinorVersion_;
+ private short sqlmxMajorVersion_;
+ private short sqlmxMinorVersion_;
+
+ // LOB Support
+ String clobTableName_;
+ String blobTableName_;
+
+ // private short transportBufferSize_;
+ private boolean useArrayBinding_;
+ private boolean batchRecovery_;
+ private final String propPrefix_ = "t4jdbc.";
+
+ // Default catalog
+ static final String DEFAULT_CATALOG = "TRAFODION";
+
+ // propertiy queryTimeout_ for future use.
+ private short queryTimeout_;
+ private T4Address t4addr_;
+
+ // Error handling while setting Type 4 properties.
+ String sqlExceptionMessage_;
+
+ // Logger for this connection.
+ Logger logger;
+ Logger t4Logger_;
+
+ // Log file handler for this connection.
+ FileHandler t4LogFileHandler_;
+
+ private boolean SPJEnv_ = false;
+ private boolean keepRawFetchBuffer_ = false;
+ private short cpuToUse_ = -1;
+ private String sessionName;
+ private String replacementString_;
+ private String ISO88591_;
+
+ private String _roleName;
+ private String _applicationName;
+ private boolean _sessionToken;
+ private boolean _fetchAhead;
+ private boolean _delayedErrorMode;
+ private boolean _compression;
+ private String _certificateDir;
+ private String _certificateFileActive;
+ private String _certificateFile;
+ private boolean _keepAlive = false;
+ private boolean _tokenAuth;
+
+ private static int DEFAULT_MAX_IDLE_TIMEOUT = 0; // Max idle timeout
+ // default = infinite
+
+ //TCP Nagle's algorithm
+ private boolean _tcpNoDelay = true;
+
+ // -----------------------------------------------------------
+ //
+ // The following static members and static block are ment to
+ // establish the one and only global t4 logger for this JVM.
+ //
+ static Level t4GlobalLogLevel = null;
+ static String t4GlobalLogFile = null;
+ static Logger t4GlobalLogger = null;
+ static FileHandler t4GlobalLogFileHandler = null;
+
+ void initializeLogging() {
+ if (t4GlobalLogger != null) {
+ return;
+ }
+
+ t4GlobalLogger = Logger.getLogger("org.trafodion.jdbc.t4.logger");
+
+ try {
+ boolean createGlobalLogFile = false;
+ String userSpecifiedLogFile = null;
+ Level userSpecifiedLogLevel = null;
+ Properties p = getPropertiesFileValues();
+
+ t4GlobalLogger.setUseParentHandlers(false);
+ //
+ // See if the user specified a log file and/or log level via the
+ // properties file or the system properties.
+ //
+ if (p != null) {
+ userSpecifiedLogFile = p.getProperty("T4LogFile");
+ String temp = p.getProperty("T4LogLevel");
+ if (temp != null) {
+ userSpecifiedLogLevel = Level.parse(temp);
+ }
+ }
+
+ if (userSpecifiedLogFile == null) {
+ userSpecifiedLogFile = System.getProperty("t4jdbc.T4LogFile");
+
+ }
+ if (userSpecifiedLogLevel == null) {
+ String temp = System.getProperty("t4jdbc.T4LogLevel");
+ if (temp != null) {
+ userSpecifiedLogLevel = Level.parse(temp);
+ } else {
+ userSpecifiedLogLevel = null;
+ }
+ }
+
+ //
+ // At this point, if the user specified a log file and/or log level,
+ // we have captured
+ // that information.
+ //
+
+ //
+ // Decide if we should create a global log file now or wait until
+ // someone
+ // asks for it. That is, until a connection turns on logging and
+ // doesn't
+ // specify its own log file.
+ //
+ if (userSpecifiedLogFile != null || (userSpecifiedLogLevel != null && userSpecifiedLogLevel != Level.OFF)) {
+ createGlobalLogFile = true;
+ }
+
+ //
+ // Set the global log file and global log level.
+ //
+ if (userSpecifiedLogFile == null) {
+ t4GlobalLogFile = T4LoggingUtilities.getUniqueLogFileName(T4LoggingUtilities.getUniqueID());
+ } else {
+ t4GlobalLogFile = userSpecifiedLogFile;
+ }
+ if (userSpecifiedLogLevel == null) {
+ t4GlobalLogLevel = Level.OFF;
+ } else {
+ t4GlobalLogLevel = userSpecifiedLogLevel;
+ }
+ t4GlobalLogger.setLevel(t4GlobalLogLevel);
+
+ //
+ // If we decided to make the log file now, make the file (i.e.
+ // FileHandler) and
+ // it the global logger.
+ //
+ if (createGlobalLogFile == true) {
+ t4GlobalLogFileHandler = new FileHandler(t4GlobalLogFile);
+
+ t4GlobalLogger.addHandler(t4GlobalLogFileHandler);
+
+ Formatter ff1 = new T4LogFormatter();
+
+ t4GlobalLogFileHandler.setFormatter(ff1);
+ }
+ } catch (Exception e) {
+ // SQLException se = HPT4Messages.createSQLException(null, null,
+ // "problem_with_logging", e.getMessage());
+ // sqlExceptionMessage_ = se.getMessage();
+
+ SQLException se = HPT4Messages.createSQLException(null, null, "problem_with_logging", e.getMessage());
+ sqlExceptionMessage_ = se.getMessage();
+ // RuntimeException rte = new RuntimeException(se.getMessage(), se);
+ // throw rte;
+ // e.printStackTrace();
+ // throw HPT4Messages.createSQLException(null, null,
+ // "problem_with_logging", e.getMessage());
+ }
+ } // end initializeLogging
+
+ // -----------------------------------------------------------------
+
+ public T4Properties() {
+ initializeLogging();
+ initialize(null);
+ }
+
+ public T4Properties(Properties props) {
+ initializeLogging();
+ initialize(props);
+ }
+
+ void initialize(Properties props) {
+ sqlExceptionMessage_ = null;
+ inprops_ = props;
+ setProperties();
+ }
+
+ // ---------------------------------------------------------------
+ private Object getHashTableEntry(String token) {
+ Object outObj = null;
+
+ // if the token is present in input-props get it
+ if (inprops_ != null) {
+ outObj = inprops_.get((Object) token);
+
+ }
+ return outObj;
+ } // end getHashTableEntry
+
+ // ---------------------------------------------------------------
+ private String getProperty(String token) {
+ String ret = null;
+
+ // check input props first
+ if (inprops_ != null) {
+ ret = inprops_.getProperty(token);
+ }
+ // props file next
+ if (ret == null && defaults_ != null) {
+ ret = defaults_.getProperty(token);
+ }
+ // system properties with the t4jdbc prefix
+ if (ret == null) {
+ ret = System.getProperty(propPrefix_ + token);
+ }
+
+ return ret;
+ }
+
+ private void setProperties() {
+ defaults_ = null;
+ String propsFile = getProperty("properties");
+ if (propsFile != null) {
+ propsFile = propsFile.trim();
+ if (propsFile.length() != 0) {
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(new File(propsFile));
+ defaults_ = new Properties();
+ defaults_.load(fis);
+ } catch (Exception ex) {
+ fis = null;
+ sqlExceptionMessage_ = "Error while loading " + propPrefix_ + "properties file: " + ex.getMessage();
+ } finally {
+ try {
+ if (fis != null) {
+ fis.close();
+ }
+ } catch (IOException ioe) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ setDescription(getProperty("description"));
+ setDataSourceName(getProperty("dataSourceName"));
+ setServerDataSource(getProperty("serverDataSource"));
+ setCatalog(getProperty("catalog"));
+ setSchema(getProperty("schema"));
+
+ // DriverManager passes property user. HPUX does not like
+ // property user. System properties must be prefixed with t4jdbc.
+ // For example user should be t4jdbc.user if set as system property.
+ setUser(getProperty("user"));
+ setPassword(getProperty("password"));
+
+ // url is special. Set it from properties only when it is not already
+ // set.
+ if (url_ == null) {
+ setUrl(getProperty("url"));
+
+ }
+ setMaxPoolSize(getProperty("maxPoolSize"));
+ setMinPoolSize(getProperty("minPoolSize"));
+ setInitialPoolSize(getProperty("initialPoolSize"));
+ setMaxStatements(getProperty("maxStatements"));
+ setLoginTimeout(getProperty("loginTimeout"));
+ // setCloseConnectionTimeout(getProperty("closeConnectionTimeout"));
+ setNetworkTimeout(getProperty("networkTimeout"));
+ setT4LogLevel(getProperty("T4LogLevel"));
+ setT4LogFile(getProperty("T4LogFile"));
+ setLogger(getHashTableEntry("logger"));
+ setT4LogFileHandler(getHashTableEntry("T4LogFileHandler"));
+ setUseArrayBinding(getProperty("useArrayBinding"));
+ setBatchRecovery(getProperty("batchRecovery"));
+ // setTransportBufferSize(getProperty("TransportBufferSize"));
+ setLanguage(getProperty("language"));
+
+ setMaxIdleTime(getProperty("maxIdleTime"));
+ setConnectionTimeout(getProperty("connectionTimeout"));
+ setFetchBufferSize(getProperty("fetchBufferSize"));
+
+ // For LOB Support - SB 9/28/04
+ try {
+ setClobTableName(getProperty("clobTableName"));
+ } catch (SQLException se) {
+ sqlExceptionMessage_ = "Error while reading the clobTableName property: " + se.getMessage();
+ }
+
+ try {
+ setBlobTableName(getProperty("blobTableName"));
+ } catch (SQLException se2) {
+ sqlExceptionMessage_ = "Error while reading the blobTableName property: " + se2.getMessage();
+ }
+
+ setReserveDataLocator(getProperty("reserveDataLocator"));
+ setQueryTimeout(getProperty("queryTimeout"));
+ setRoundingMode(getProperty("roundingMode"));
+ setSPJEnv(getProperty("SPJEnv"));
+ setKeepRawFetchBuffer(getProperty("keepRawFetchBuffer"));
+ setCpuToUse(getProperty("cpuToUse"));
+ setSessionName(getProperty("sessionName"));
+ setReplacementString(getProperty("replacementString"));
+ setISO88591(getProperty("ISO88591"));
+
+ setRoleName(getProperty("roleName"));
+ setApplicationName(getProperty("applicationName"));
+ setSessionToken(getProperty("sessionToken"));
+ setFetchAhead(getProperty("fetchAhead"));
+ setDelayedErrorMode(getProperty("delayedErrorMode"));
+ setCompression(getProperty("compression"));
+ setCertificateDir(getProperty("certificateDir"));
+ setCertificateFileActive(getProperty("certificateFileActive"));
+ setCertificateFile(getProperty("certificateFile"));
+ setKeepAlive(getProperty("keepAlive"));
+ setTokenAuth(getProperty("tokenAuth"));
+ setTcpNoDelay(getProperty("tcpNoDelay"));
+ }
+
+ T4Properties getT4Properties() {
+ return this;
+ }
+
+ /**
+ * Returns all the connection properties associated with the current Type 4
+ * connection object in the <code>java.util.Properties</code> object.
+ *
+ * @return The properties associated with the current Type 4 connection.
+ */
+ public Properties getProperties() {
+ Properties props = new Properties();
+ if (getCatalog() != null) {
+ props.setProperty("catalog", catalog_);
+ }
+ if (getSchema() != null) {
+ props.setProperty("schema", schema_);
+ }
+ if (url_ != null) {
+ props.setProperty("url", url_);
+ }
+
+ props.setProperty("user", user_);
+ props.setProperty("password", pwd_);
+ props.setProperty("maxPoolSize", String.valueOf(maxPoolSize_));
+ props.setProperty("minPoolSize", String.valueOf(minPoolSize_));
+ props.setProperty("initialPoolSize", String.valueOf(initialPoolSize_));
+ props.setProperty("maxStatements", String.valueOf(maxStatements_));
+ props.setProperty("T4LogLevel", t4LogLevel.toString());
+ props.setProperty("fetchBufferSize", String.valueOf(fetchBufferSize_));
+
+ if (logger != null) {
+ props.put("logger", logger);
+ }
+ if (t4LogFileHandler_ != null) {
+ props.put("T4LogFileHandler", t4LogFileHandler_);
+
+ }
+ props.setProperty("T4LogFile", T4LogFile_);
+ props.setProperty("loginTimeout", String.valueOf(loginTimeout_));
+ // props.setProperty("closeConnectionTimeout",
+ // String.valueOf(closeConnectionTimeout_));
+ props.setProperty("networkTimeout", String.valueOf(networkTimeout_));
+ props.setProperty("connectionTimeout", String.valueOf(connectionTimeout_));
+ props.setProperty("description", description_);
+ props.setProperty("dataSourceName", dataSourceName_);
+ props.setProperty("serverDataSource", serverDataSource_);
+ // props.setProperty("transportBufferSize",
+ // String.valueOf(transportBufferSize_));
+ props.setProperty("useArrayBinding", String.valueOf(useArrayBinding_));
+ props.setProperty("batchRecovery", String.valueOf(batchRecovery_));
+ props.setProperty("maxIdleTime", String.valueOf(maxIdleTime_));
+ props.setProperty("language", language_);
+
+ if (getBlobTableName() != null) {
+ props.setProperty("blobTableName", blobTableName_);
+ }
+ if (getClobTableName() != null) {
+ props.setProperty("clobTableName", clobTableName_);
+
+ }
+
+ // properties queryTimeout_ for future use.
+ props.setProperty("queryTimeout", String.valueOf(queryTimeout_));
+ props.setProperty("roundingMode", String.valueOf(roundMode_));
+ props.setProperty("SPJEnv", String.valueOf(SPJEnv_));
+ props.setProperty("keepRawFetchBuffer", String.valueOf(keepRawFetchBuffer_));
+ props.setProperty("cpuToUse", String.valueOf(cpuToUse_));
+ props.setProperty("sessionName", String.valueOf(sessionName));
+ props.setProperty("replacementString", String.valueOf(replacementString_));
+ props.setProperty("ISO88591", String.valueOf(ISO88591_));
+
+ if (_roleName != null)
+ props.setProperty("roleName", _roleName);
+ if (_applicationName != null)
+ props.setProperty("applicationName", _applicationName);
+
+ props.setProperty("sessionToken", String.valueOf(_sessionToken));
+ props.setProperty("fetchAhead", String.valueOf(_fetchAhead));
+ props.setProperty("delayedErrorMode", String.valueOf(_delayedErrorMode));
+ props.setProperty("compression", String.valueOf(_compression));
+ if(_certificateDir != null)
+ props.setProperty("certificateDir", _certificateDir);
+ if(_certificateFileActive != null)
+ props.setProperty("certFileActive", _certificateFileActive);
+ if(_certificateFile != null)
+ props.setProperty("certificateFile", _certificateFile);
+ props.setProperty("keepAlive", String.valueOf(_keepAlive));
+ props.setProperty("tokenAuth", String.valueOf(_tokenAuth));
+ props.setProperty("tcpNoDelay", String.valueOf(_tcpNoDelay));
+
+ return props;
+ }
+
+ /**
+ * Sets the description for the current Type 4 connection.
+ *
+ * @param description
+ * For the current Type 4 connection.
+ * @see #getDescription()
+ */
+ void setDescription(String description) {
+ if (description == null) {
+ description_ = "JDBC T4 DataSource.";
+ } else {
+ description_ = description;
+ }
+ }
+
+ /**
+ * Returns the description associated with the current Type 4 connection.
+ *
+ * @return The description associated with the current Type 4 connection.
+ * @see #setDescription(String)
+ */
+ String getDescription() {
+ return description_;
+ }
+
+ /**
+ * Sets the data source name for the current Type 4 connection.
+ *
+ * @param dataSourceName
+ * For the client side <code>DataSource</code> object.
+ * @see #getDataSourceName()
+ */
+ void setDataSourceName(String dataSourceName) {
+ if (dataSourceName == null) {
+ dataSourceName_ = "";
+ } else {
+ dataSourceName_ = dataSourceName;
+ }
+ }
+
+ /**
+ * Return the data source name given to the client side data source.
+ *
+ * @return data source name.
+ * @see #setDataSourceName(String)
+ */
+ String getDataSourceName() {
+ return dataSourceName_;
+ }
+
+ /**
+ * Sets the data source name to use on the NDCS server side.
+ *
+ * @param serverDataSource
+ * the data source name to use on the NDCS server side. The
+ * default value is a blank string.
+ * @see #getDataSourceName()
+ */
+ void setServerDataSource(String serverDataSource) {
+ if (serverDataSource == null) {
+ serverDataSource_ = "";
+ } else {
+ serverDataSource_ = serverDataSource;
+ }
+ }
+
+ /**
+ * Returns the NDCS server side data source name used for the current Type 4
+ * connection. The default server data source name is
+ * <code>TDM_Defaullt_DataSource</code>.
+ *
+ * @return NDCS server side data source Name.
+ * @see #setServerDataSource(String)
+ */
+ String getServerDataSource() {
+ return serverDataSource_;
+ }
+
+ /**
+ * Sets the default catalog that will be used to access SQL objects
+ * referenced in SQL statements if the SQL objects are not fully qualified.
+ *
+ * @param catalog
+ * Database catalog name. The default catalog name is set by
+ * the NDCS server side data source.
+ * @see #getCatalog()
+ */
+ void setCatalog(String catalog) {
+ catalog_ = catalog;
+ if (catalog_ == null) {
+ catalog_ = getProperty("catalog");
+
+ }
+ if (catalog_ != null) {
+ if (catalog_.length() == 0) {
+ catalog_ = DEFAULT_CATALOG;
+ } else if (!catalog_.startsWith("\"")) {
+ catalog_ = catalog_.trim().toUpperCase();
+ }
+ } else {
+ // catalog_ = null;
+ catalog_ = DEFAULT_CATALOG;
+ }
+ }
+
+ /**
+ * Gets the default catalog that will be used to access SQL objects
+ * referenced in SQL statements if the SQL objects are not fully qualified.
+ *
+ * @return T4 2.0 catalog name.
+ * @see #setCatalog(String)
+ */
+ String getCatalog() {
+ return catalog_;
+ }
+
+ /**
+ * Sets the default schema that will be used to access SQL objects
+ * referenced in SQL statements if the SQL objects are not fully qualified.
+ *
+ * @param schema
+ * Sets the database schema name. The default schema name is set
+ * by the NDCS server side data source.
+ * @see #getSchema()
+ */
+ void setSchema(String schema) {
+ schema_ = schema;
+ if (schema_ == null) {
+ schema_ = getProperty("schema");
+
+ }
+ if (schema_ != null) {
+ if (!schema_.startsWith("\"")) {
+ schema_ = schema_.trim().toUpperCase();
+ }
+ } else {
+ schema_ = null;
+ }
+ }
+
+ /**
+ * Gets the default schema that will be used to access SQL objects
+ * referenced in SQL statements if the SQL objects are not fully qualified.
+ *
+ * @return The schema associated with the current Type 4 connection.
+ * @see #setSchema(String)
+ */
+ String getSchema() {
+ return schema_;
+ }
+
+ /**
+ * Returns the <code>java.util.Locale</code> object associated with the
+ * current Type 4 connection.
+ *
+ * @return <code>java.util.Locale</code> object.
+ * @see #setLanguage(String language)
+ */
+ Locale getLocale() {
+ return locale_;
+ }
+
+ /**
+ * The maximum number of physical connections that the pool (free and inuse
+ * pool) should contain. When the maximum number of physical connections is
+ * reached, the Type 4 driver throws an <code>SQLException
+ * </code> with the
+ * message "Maximum pool size reached". Specifying a value of 0 (zero)
+ * indicates there is no maximum size for the pool. Specifying a value of -1
+ * indicates no connection pooling is performed. The default value is -1
+ * indicating that no pooling of physical connections is done.
+ *
+ * @param maxPoolSize
+ * the maximum number of physical connections the pool should
+ * contain in the pool (free and inuse).
+ * @see #setMaxPoolSize(int)
+ */
+ void setMaxPoolSize(String maxPoolSize) {
+ int maxPs = -1;
+ if (maxPoolSize != null) {
+ try {
+ maxPs = Integer.parseInt(maxPoolSize);
+ } catch (NumberFormatException ex) {
+ sqlExceptionMessage_ = "Incorrect maxPoolSize value set: " + maxPoolSize + ". " + ex.getMessage();
+ maxPs = -1;
+ }
+ }
+ setMaxPoolSize(maxPs);
+ }
+
+ /**
+ * The maximum number of physical connections that the pool (free and inuse
+ * pool) should contain. When the maximum number of physical connections is
+ * reached, the Type 4 driver throws an <code>SQLException
+ * </code> with the
+ * message "Maximum pool size reached". Specifying a value of 0 (zero)
+ * indicates there is no maximum size for the pool. Specifying a value of -1
+ * indicates no connection pooling is performed. The default value is -1
+ * indicating that no pooling of physical connections is done.
+ *
+ * @param maxPoolSize
+ * the maximum number of physical connections the pool should
+ * contain in the pool (free and inuse).
+ * @see #setMaxPoolSize(String)
+ */
+ void setMaxPoolSize(int maxPoolSize) {
+ if (maxPoolSize < -1) {
+ // The ES says that we set maxPoolSize to -1. It doesn't say we
+ // produce an error.
+ // sqlExceptionMessage_ = "Incorrect maxPoolSize value set: " +
+ // maxPoolSize;
+ maxPoolSize_ = -1;
+ } else if (maxPoolSize > 0) {
+ if (minPoolSize_ != 0 && minPoolSize_ > maxPoolSize) {
+ maxPoolSize_ = minPoolSize_;
+ } else {
+ maxPoolSize_ = maxPoolSize;
+ }
+ } else {
+ maxPoolSize_ = maxPoolSize;
+ }
+ }
+
+ /**
+ * Returns the maximum number of physical connections that the pool (free
+ * and inuse) should contain. A value of zero (0) indicates no maximum size.
+ * A value of -1 indicates that connection pooling is not being done.
+ *
+ * @return maxPoolSize the maximum number of physical connections that the
+ * pool should contain.
+ * @see #setMaxPoolSize(int)
+ */
+ int getMaxPoolSize() {
+ return maxPoolSize_;
+ }
+
+ /**
+ * Sets the number of physical connections the pool should keep available at
+ * all times.
+ *
+ * @param minPoolSize
+ * Limits the number of physical connection that can be in the
+ * free pool. When the number of physical connections in the free
+ * pool reaches the value of minPoolSize, subsequent connections
+ * that are closed are physically closed and are not added to the
+ * free pool. Specifying a value of 0 means that the value of
+ * minPoolSize is the same as the value of maxPoolSize. If the
+ * value of maxPoolSize is -1, the value of minPoolSize is
+ * ignored. The default value is 0. For this data source it is
+ * recommended that you use the default value.
+ * @return the number of physical connections the pool should keep available
+ * at all times.
+ * @see #getMinPoolSize()
+ * @see #setMinPoolSize(int minPoolSize)
+ */
+ void setMinPoolSize(String minPoolSize) {
+ int minPs = -1;
+ if (minPoolSize != null) {
+ try {
+ minPs = Integer.parseInt(minPoolSize);
+ } catch (NumberFormatException ex) {
+ sqlExceptionMessage_ = "Incorrect value for minPoolSize set: " + minPoolSize + ". " + ex.getMessage();
+ minPs = -1;
+ }
+ }
+ setMinPoolSize(minPs);
+ }
+
+ /**
+ * Sets the number of physical connections the pool should keep available at
+ * all times.
+ *
+ * @param minPoolSize
+ * Limits the number of physical connection that can be in the
+ * free pool. When the number of physical connections in the free
+ * pool reaches the value of minPoolSize, subsequent connections
+ * that are closed are physically closed and are not added to the
+ * free pool. Specifying a value of 0 means that the value of
+ * minPoolSize is the same as the value of maxPoolSize. If the
+ * value of maxPoolSize is -1, the value of minPoolSize is
+ * ignored. The default value is 0. For this data source it is
+ * recommended that you use the default value.
+ * @return the number of physical connections the pool should keep available
+ * at all times.
+ * @see #getMinPoolSize()
+ * @see #setMinPoolSize(String minPoolSize)
+ */
+ void setMinPoolSize(int minPoolSize) {
+ if (maxPoolSize_ == -1) {
+ // minPoolSize_ = minPoolSize;
+ minPoolSize_ = -1;
+ return;
+ }
+ if (minPoolSize < -1) {
+ // Swastik: Commented on 14th Feb 2005 to match behavior in
+ // setMaxPoolSize(int)
+ // sqlExceptionMessage_ = "Incorrect value for minPoolSize set: " +
+ // minPoolSize;
+ minPoolSize_ = -1;
+ } else if (minPoolSize == 0) {
+ minPoolSize_ = 0;
+ } else {
+ if (minPoolSize > 0) {
+ if (maxPoolSize_ != 0 && maxPoolSize_ < minPoolSize) {
+ minPoolSize_ = maxPoolSize_;
+ } else {
+ minPoolSize_ = minPoolSize;
+ }
+ } else {
+ minPoolSize_ = minPoolSize;
+ }
+ }
+ }
+
+ /**
+ * Returns the number of physical connections the pool should keep in the
+ * free pool. A value of 0 (zero) indicates that minPoolSize is equal to
+ * maxPoolsize. If maxPoolsize is equal to -1, the value of minPoolSize is
+ * ignored. The default value is 0.
+ *
+ * @return The number of physical connections the pool should maintain in
+ * the free pool.
+ * @see #setMinPoolSize(int)
+ * @see #setMaxPoolSize(int)
+ */
+ int getMinPoolSize() {
+ return minPoolSize_;
+ }
+
+ /**
+ * The initial number of physical connections that the pool should be
+ * created with. Specifying a valueof 0 (zero) or less indicates that the
+ * pool should not be created with any initial connections. The default
+ * value is -1 indicating that no initial pool of physical connections is
+ * created. The value can be less than minPoolSize but must be less than or
+ * equal to the value of maxPoolSize. Specifying a value greater than
+ * maxPoolSize will set the initialPoolSize to the value of maxPoolSize.
+ *
+ * @param initialPoolSize
+ * the initial number of physical connections the pool should be
+ * created with.
+ * @see #setInitialPoolSize(int)
+ */
+ void setInitialPoolSize(String initialPoolSize) {
+ int initPs = -1;
+ if (initialPoolSize != null) {
+ try {
+ initPs = Integer.parseInt(initialPoolSize);
+ } catch (NumberFormatException ex) {
+ sqlExceptionMessage_ = "Incorrect initialPoolSize value set: " + initialPoolSize + ". "
+ + ex.getMessage();
+ initPs = -1;
+ }
+ }
+ setInitialPoolSize(initPs);
+ }
+
+ /**
+ * The initial number of physical connections that the pool should be
+ * created with. Specifying a valueof 0 (zero) or less indicates that the
+ * pool should not be created with any initial connections. The default
+ * value is -1 indicating that no initial pool of physical connections is
+ * created. The value can be less than minPoolSize but must be less than or
+ * equal to the value of maxPoolSize. Specifying a value greater than
+ * maxPoolSize will set the initialPoolSize to the value of maxPoolSize.
+ *
+ * @param initialPoolSize
+ * the initial number of physical connections the pool should be
+ * created with.
+ * @see #setInitialPoolSize(String)
+ */
+ void setInitialPoolSize(int initialPoolSize) {
+ if (initialPoolSize <= 0) {
+ initialPoolSize_ = -1;
+ return;
+ }
+ // otherwise initialPoolSize > 0
+ if (initialPoolSize > maxPoolSize_) {
+ initialPoolSize_ = maxPoolSize_;
+ } else {
+ initialPoolSize_ = initialPoolSize;
+ }
+ }
+
+ /**
+ * Returns the number of physical connections that the pool should be
+ * created with. A value of -1 indicates that the pool is not created with
+ * any initial connections.
+ *
+ * @return initialPoolSize the number of physical connections that the pool
+ * should be created with.
+ * @see #setInitialPoolSize(int)
+ */
+ int getInitialPoolSize() {
+ return initialPoolSize_;
+ }
+
+ /**
+ * Total number of statements that can be pooled. A value of zero (0)
+ * indicates that caching of statements is disabled.
+ *
+ * @param maxStatements
+ * The number of statements that can be pooled.
+ * @see #setMaxStatements(int)
+ */
+ void setMaxStatements(String maxStatements) {
+ int maxstmt = 0;
+ if (maxStatements != null) {
+ try {
+ maxstmt = Integer.parseInt(maxStatements);
+ } catch (NumberFormatException ex) {
+ sqlExceptionMessage_ = "Incorrect value for maxStatements set: " + maxStatements + ex.getMessage();
+ maxstmt = 0;
+ }
+ }
+ setMaxStatements(maxstmt);
+ }
+
+ /**
+ * Total number of statements that can be pooled. A value of zero (0)
+ * indicates that caching of statements is disabled.
+ *
+ * @param maxStatements
+ * The number of statements that can be pooled.
+ * @see #setMaxStatements(int)
+ */
+ void setMaxStatements(int maxStatements) {
+ if (maxStatements < 0) {
+ sqlExceptionMessage_ = "Incorrect value for maxStatements set: " + maxStatements;
+ maxStatements_ = 0;
+ } else {
+ maxStatements_ = maxStatements;
+ }
+ }
+
+ /**
+ * Returns the total number of statements that can be pooled. A value of
+ * zero (0) indicates that pooling of statements is disabled.
+ *
+ * @return The total number of statements that can be pooled.
+ */
+ int getMaxStatements() {
+ return maxStatements_;
+ }
+
+ /**
+ * Returns the URL used in the current Type 4 connection. JDBC Type 4
+ * driver URL uses the following format:-
+ * <code>jdbc:t4jdbc://host:port/:</code>
+ *
+ * @deprecated Use <code>getUrl()</code> to obtain the URL string.
+ * @return the URL string.
+ * @see #getUrl()
+ */
+ String getURL() {
+ return getUrl();
+ }
+
+ /**
+ * Returns the URL used in the current Type 4 connection. JDBC Type 4
+ * driver URL uses the following format:-
+ * <code>jdbc:t4jdbc://host:port/:</code>
+ *
+ * @return the URL string.
+ * @see #setUrl(String)
+ */
+ public String getUrl() {
+ return url_;
+ }
+
+ /**
+ * Sets the URL for the Type 4 connection. JDBC Type 4 driver URL uses
+ * the following format:-
+ * <code>jdbc:t4jdbc://host:port/:prop-name=value</code> This method
+ * does not validate the url value.
+ *
+ * @param url
+ * the URL.
+ * @see #getUrl()
+ */
+ void setUrl(String url) {
+ if (url != null) {
+ url_ = url;
+ } else {
+ url_ = "";
+ }
+ }
+
+ /**
+ * Validates the input url string follows the correct jdbc:t4jdbc:<host>:<port>/:<prop-name=prop-val>;<prop-name=prop-val>
+ * format.
+ *
+ * @param url
+ * of the Type 4 driver.
+ * @return <code>true</code> when the <url> is in the Type 4 driver
+ * format.
+ */
+ boolean acceptsUrl(String url) {
+ try {
+ new T4Address(this, locale_, url);
+ } catch (SQLException sqlex) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Sets the URL for the Type 4 connection. JDBC Type 4 driver URL uses
+ * the following format:-
+ * <code>jdbc:t4jdbc://host:port/:prop-name=value</code>. This
+ * validates the url value and throws SQLException if the URL value is
+ * incorrect.
+ *
+ * @param url
+ * the URL.
+ * @see #getUrl()
+ */
+ Properties setURL(String url) throws SQLException {
+ String host = null;
+ String port = null;
+ Properties props = null;
+
+ t4addr_ = new T4Address(this, locale_, url);
+ props = t4addr_.getProps();
+ initialize(props);
+ setUrl(t4addr_.getUrl());
+ return props;
+ }
+
+ /**
+ * Retunrs the Type 4 <code>T4Address</code> class.
+ *
+ * @return the current <code>T4Address</code> class.
+ */
+ T4Address getAddress() {
+ return t4addr_;
+ }
+
+ /**
+ * Sets the Safeguard user name to be used while connecting to NDCS server
+ * for authentication.
+ *
+ * @param user
+ * Sets the user for the current Type 4 connection.
+ * @see #getUser()
+ */
+ void setUser(String user) {
+ if (user == null) {
+ user_ = "";
+ } else {
+ user_ = user;
+ }
+ }
+
+ /**
+ * Returns the Safeguard user name associated with this Type 4 connection.
+ *
+ * @return The user name.
+ * @see #setUser(String)
+ */
+ String getUser() {
+ return user_;
+ }
+
+ /**
+ * Sets the Safeguard password to be used for authentication when connecting
+ * to the NDCS server.
+ *
+ * @param pwd
+ * The Safeguard password for the current Type 4 connection.
+ */
+ void setPassword(String pwd) {
+ if (pwd == null) {
+ pwd_ = "";
+ } else {
+ pwd_ = pwd;
+ }
+ }
+
+ /**
+ * @deprecated <code>getPassword()</code> would not be supported in the
+ * future releases.
+ * @return the password associated with this Type 4 connection.
+ */
+ String getPassword() {
+ return pwd_;
+ }
+
+ /**
+ * Sets the login timeout in seconds for the Type 4 connection. The default
+ * login timeout value is set to 30 minutes.
+ *
+ * @param loginTimeout
+ * The login timeout value in seconds.
+ * @see #setLoginTimeout(int)
+ * @see #getLoginTimeout()
+ */
+ void setLoginTimeout(String loginTimeout) {
+ int loginTo = 1800;
+ if (loginTimeout != null) {
+ try {
+ loginTo = Short.parseShort(loginTimeout);
+ } catch (NumberFormatException ex) {
+ sqlExceptionMessage_ = "Incorrect value for loginTimeout set: " + loginTimeout + ex.getMessage();
+ loginTo = 1800;
+ }
+ }
+ setLoginTimeout(loginTo);
+ }
+
+ /**
+ * Sets the login timeout in seconds for the Type 4 connection. The default
+ * login timeout value is set to 30 minutes.
+ *
+ * @param loginTimeout
+ * The login timeout value in seconds.
+ * @see #setLoginTimeout(String)
+ * @see #getLoginTimeout()
+ */
+ void setLoginTimeout(int loginTimeout) {
+ if (loginTimeout < 0) {
+ sqlExceptionMessage_ = "Incorrect value for loginTimeout set: " + loginTimeout + ".";
+ loginTimeout_ = 1800;
+ } else {
+ loginTimeout_ = loginTimeout;
+ }
+ }
+
+ /**
+ * Returns the login timeout value set for the current Type 4 connection.
+ *
+ * @return the login timeout value in seconds.
+ * @see #setLoginTimeout(int)
+ * @see #setLoginTimeout(String)
+ */
+ int getLoginTimeout() {
+ return loginTimeout_;
+ }
+
+ // -----------------------------------------------------------------
+
+ /***************************************************************************
+ * Start comment out seciont ************* * Sets the close connection
+ * timeout in seconds for the Type 4 connection. The default close
+ * connection timeout value is set to 60 seconds.
+ *
+ * @param closeConnectionTimeout
+ * The close connection timeout value in seconds.
+ * @see #setCloseConnectionTimeout(int)
+ * @see #getCloseConnectionTimeout()
+ *
+ * public void setCloseConnectionTimeout(String closeConnectionTimeout) {
+ * int closeConnectionTo = 60; if (closeConnectionTimeout != null) { try {
+ * closeConnectionTo = Integer.parseInt(closeConnectionTimeout); } catch
+ * (NumberFormatException ex) { sqlExceptionMessage_ = "Incorrect value for
+ * closeConnectionTimeout set: " + closeConnectionTimeout + ex.getMessage();
+ * closeConnectionTo = 60; } } setCloseConnectionTimeout(closeConnectionTo); } *
+ * Sets the close connection timeout in seconds for the Type 4 connection.
+ * The default close connection timeout value is set to 60 seconds.
+ * @param closeConnectionTimeout
+ * The close connection timeout value in seconds.
+ * @see #setCloseConnectionTimeout(String)
+ * @see #getCloseConnectionTimeout()
+ *
+ * public void setCloseConnectionTimeout(int closeConnectionTimeout) { if
+ * (closeConnectionTimeout < 0) { sqlExceptionMessage_ = "Incorrect value
+ * for closeConnectionTimeout set: " + closeConnectionTimeout + ".";
+ * closeConnectionTimeout_ = 60; } else { closeConnectionTimeout_ =
+ * closeConnectionTimeout; } } * Returns the close connection timeout value
+ * set for the current Type 4 connection.
+ * @return the close connection timeout value in seconds.
+ * @see #setCloseConnectionTimeout(int)
+ * @see #setCloseConnectionTimeout(String)
+ *
+ * public int getCloseConnectionTimeout() { return closeConnectionTimeout_; }
+ **************************************************************************/
+
+ // -----------------------------------------------------------------
+ /**
+ * Sets the network timeout in seconds for the Type 4 connection. The
+ * default network timeout value is set to infinity seconds.
+ *
+ * @param networkTimeout
+ * The network timeout value in seconds.
+ * @see #setNetworkTimeout(int)
+ * @see #getNetworkTimeout()
+ */
+ void setNetworkTimeout(String networkTimeout) {
+ int networkTo = 0;
+ if (networkTimeout != null) {
+ try {
+ networkTo = Integer.parseInt(networkTimeout);
+ } catch (NumberFormatException ex) {
+ sqlExceptionMessage_ = "Incorrect value for networkTimeout set: " + networkTimeout + ex.getMessage();
+ networkTo = 0;
+ }
+ }
+ setNetworkTimeout(networkTo);
+ }
+
+ /**
+ * Sets the network timeout in seconds for the Type 4 connection. The
+ * default network timeout value is set to infinity seconds.
+ *
+ * @param networkTimeout
+ * The network timeout value in seconds.
+ * @see #setNetworkTimeout(String)
+ * @see #getNetworkTimeout()
+ */
+ void setNetworkTimeout(int networkTimeout) {
+ if (networkTimeout < 0) {
+ sqlExceptionMessage_ = "Incorrect value for networkTimeout set: " + networkTimeout + ".";
+ networkTimeout_ = 0;
+ } else {
+ networkTimeout_ = networkTimeout;
+ }
+ }
+
+ /**
+ * Returns the network timeout value set for the current Type 4 connection.
+ *
+ * @return the network timeout value in seconds.
+ * @see #setNetworkTimeout(int)
+ * @see #setNetworkTimeout(String)
+ */
+ int getNetworkTimeout() {
+ return networkTimeout_;
+ }
+
+ // -----------------------------------------------------------------
+
+ /*
+ * Sets the connection timeout value for the Type 4 connection. Set this
+ * value to 0 for infinite timeout. The default is set to -1. A negative
+ * value indicates the NDCS server to use the connection timeout value set
+ * by the administrator on the NDCS data source. @param connectionTimeout
+ * The connection timeout value in seconds.
+ *
+ * @see #setConnectionTimeout(int)
+ * @see #setServerDataSource(String)
+ */
+ void setConnectionTimeout(String connectionTimeout) {
+ int tmpTimeout = -1;
+ if (connectionTimeout != null) {
+ try {
+ tmpTimeout = Integer.parseInt(connectionTimeout);
+ } catch (NumberFormatException ex) {
+ sqlExceptionMessage_ = "Incorrect value for connectionTimeout set: " + connectionTimeout + ". "
+ + ex.getMessage();
+ tmpTimeout = -1;
+ }
+ }
+ setConnectionTimeout(tmpTimeout);
+ }
+
+ /*
+ * Sets the connection timeout value for the Type 4 connection. Set this
+ * value to 0 for infinite timeout. The default is set to -1. A negative
+ * value indicates the NDCS server to use the connection timeout value set
+ * by the administrator on the NDCS data source. @param connectionTimeout
+ * The connection timeout value in seconds.
+ *
+ * @see #setConnectionTimeout(String)
+ * @see #setServerDataSource(String)
+ */
+ void setConnectionTimeout(int connectionTimeout) {
+ if (connectionTimeout < 0) {
+ /*
+ * sqlExceptionMessage_ = "Incorrect value for connectionTimeout
+ * set: " + connectionTimeout + ". ";
+ */
+ connectionTimeout_ = -1;
+ } else {
+ connectionTimeout_ = connectionTimeout;
+ }
+ }
+
+ /**
+ * Sets the max idle time value for the Type 4 connection. The default is
+ * set to 0 (no timeout). Negative values are treated as 0.
+ *
+ * @param maxIdleTime
+ * The timeout value in seconds.
+ * @see #setMaxIdleTime(int)
+ */
+ void setMaxIdleTime(String maxIdleTime) {
+ int tmpTimeout = DEFAULT_MAX_IDLE_TIMEOUT;
+ if (maxIdleTime != null) {
+ try {
+ tmpTimeout = Integer.parseInt(maxIdleTime);
+ } catch (NumberFormatException ex) {
+ sqlExceptionMessage_ = "Incorrect value for maxIdleTime set: " + maxIdleTime + ". " + ex.getMessage();
+ tmpTimeout = DEFAULT_MAX_IDLE_TIMEOUT;
+ }
+ }
+ setMaxIdleTime(tmpTimeout);
+ }
+
+ /**
+ * Sets the max idle time value for the Type 4 connection. The default is
+ * set to 0 (no timeout). Negative values are treated as 0.
+ *
+ * @param maxIdleTime
+ * The timeout value in seconds.
+ * @see #setMaxIdleTime(String)
+ */
+ void setMaxIdleTime(int maxIdleTime) {
+ if (maxIdleTime < 0) {
+ maxIdleTime_ = DEFAULT_MAX_IDLE_TIMEOUT;
+ } else {
+ maxIdleTime_ = maxIdleTime;
+ }
+ }
+
+ /*
+ * Returns the connection timeout value associated with this Type 4
+ * connection. @return The connection timeout value in seconds.
+ *
+ * @see #setConnectionTimeout(int)
+ */
+
+ int getConnectionTimeout() {
+ return connectionTimeout_;
+ }
+
+ /**
+ * Returns the max idle time value associated with this Type 4 connection.
+ *
+ * @return The connection timeout value in seconds.
+ * @see #setMaxIdleTime(int)
+ */
+ int getMaxIdleTime() {
+ return maxIdleTime_;
+ }
+
+ /**
+ * Sets the logging level for the current Type 4 connection. Default value
+ * is OFF. Other valid values are SEVERE (highest value) WARNING INFO CONFIG
+ * FINE FINER FINEST (lowest value).
+ *
+ * @param level
+ * logging level.
+ * @see #getT4LogLevel()
+ * @see java.util.logging.Level
+ */
+ void setT4LogLevel(String level) {
+ t4LogLevel = Level.parse("OFF");
+ if (level != null) {
+ try {
+ t4LogLevel = Level.parse(level);
+ } catch (Exception ex) {
+
+ SQLException se = HPT4Messages.createSQLException(null, null, "problem_with_logging", ex.getMessage());
+ sqlExceptionMessage_ = se.getMessage();
+ // throw se;
+ // RuntimeException rte = new RuntimeException(se.getMessage(),
+ // se);
+ // throw rte;
+ // sqlExceptionMessage_ = "Incorrect value for T4LogLevel set: "
+ // +
+ // level + ". " + ex.getMessage();
+ // t4LogLevel = Level.parse("INFO");
+ }
+ }
+ }
+
+ /**
+ * Returns the Type 4 log level associated with the current Type 4
+ * connection. The value returned must one of the following strings. SEVERE
+ * (highest value) WARNING INFO CONFIG FINE FINER FINEST (lowest value).
+ *
+ * @return <code>java.util.logging.Level</code> associated with the
+ * current Type 4 connection.
+ * @see #setT4LogLevel(String)
+ * @see java.util.logging.Level
+ */
+ Level getT4LogLevel() {
+ return t4LogLevel;
+ }
+
+ /**
+ * Sets the location of the file to which the logging is to be done.
+ * Changing this location after making a connection has no effect; because
+ * the Type 4 reads this property before the connection is made. The default
+ * name is a generated file name defined by the following pattern:
+ * %h/t4jdbc%u.log where: "/" represents the local pathname separator "%h"
+ * represents the value of the "user.home" system property. If %h is not
+ * defined, then the behavior is undefined "%u" represents a unique number
+ * to resolve conflicts
+ *
+ * @param t4LogFile
+ * The Type 4 log file location. If the parameter is null, then
+ * the T4LogFile is set to the global log file.
+ * @see #getT4LogFile()
+ * @see java.util.logging.Logger
+ */
+ void setT4LogFile(String t4LogFile) {
+ if (t4LogFile != null) {
+ T4LogFile_ = t4LogFile;
+ } else {
+ T4LogFile_ = t4GlobalLogFile;
+ }
+ }
+
+ /**
+ * Returns the Type 4 log file location associated with the current Type 4
+ * connection.
+ *
+ * @return The Type 4 log file location.
+ * @see #setT4LogFile(String)
+ */
+ String getT4LogFile() {
+ return T4LogFile_;
+ }
+
+ String getT4GlobalLogFile() {
+ return t4GlobalLogFile;
+ }
+
+ void setT4GlobalLogFile(String lgf) {
+ t4GlobalLogFile = lgf;
+ }
+
+ // --------------------------------------------
+ FileHandler getT4GlobalLogFileHandler() {
+ return t4GlobalLogFileHandler;
+ } // end getT4GlobalLogFileHandler
+
+ // --------------------------------------------
+ void setT4GlobalLogFileHandler(Object fh) {
+ t4GlobalLogFileHandler = (FileHandler) fh;
+ }
+
+ // --------------------------------------------
+
+ Logger getLogger() {
+ return logger;
+ }
+
+ void setLogger(Object log) {
+ if (log != null) {
+ logger = (Logger) log;
+ t4Logger_ = logger;
+ } else {
+ logger = t4GlobalLogger;
+ t4Logger_ = logger;
+ }
+ }
+
+ // --------------------------------------------
+ /**
+ * This method will return the log file handlder It also has the side effect
+ * of creating a log file handler if one doesn't exist.
+ */
+ FileHandler getT4LogFileHandler() {
+ try {
+ if (t4LogFileHandler_ == null) {
+ if (T4LogFile_.equals(t4GlobalLogFile)) {
+ t4LogFileHandler_ = t4GlobalLogFileHandler;
+ } else {
+ t4LogFileHandler_ = new FileHandler(T4LogFile_);
+ t4LogFileHandler_.setFormatter(new T4LogFormatter());
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return t4LogFileHandler_;
+ } // end getT4LogFileHandler
+
+ // --------------------------------------------
+ void setT4LogFileHandler(Object fh) {
+ t4LogFileHandler_ = (FileHandler) fh;
+ }
+
+ // ----------------------------------------------------------
+
+ /**
+ * Returns the <code>PrintWriter</code> object associated with the current
+ * Type 4 connection.
+ *
+ * @return <code>java.io.PrintWriter</code> object associated with current
+ * connection.
+ * @throws SQLException
+ * when error occurs.
+ * @see #setLogWriter(PrintWriter)
+ * @see javax.sql.ConnectionPoolDataSource
+ */
+ public PrintWriter getLogWriter() throws SQLException {
+ return logWriter_;
+ }
+
+ /**
+ * Sets the <code>PrintWriter</code> object for the current Type 4
+ * connection.
+ *
+ * @param printWriter
+ * For the current Type 4 logging.
+ * @throws SQLException
+ * when error occurs.
+ * @see #getLogWriter()
+ * @see javax.sql.ConnectionPoolDataSource
+ */
+ public void setLogWriter(PrintWriter printWriter) throws SQLException {
+ logWriter_ = printWriter;
+ }
+
+ // properties queryTimeout_ for future use.
+ // setter/getter methods for queryTimeout. These methods are not public YET.
+ /**
+ * @param queryTimeout
+ * Sets the query timeout value in seconds. For future use only
+ * this property is not supported in the current release.
+ */
+ void setQueryTimeout(String queryTimeout) {
+ short tmpQTimeOut = 0;
+ if (queryTimeout != null) {
+ try {
+ tmpQTimeOut = Short.parseShort(queryTimeout);
+ } catch (NumberFormatException ex) {
+ sqlExceptionMessage_ = "Incorrect value for queryTimeout set: " + queryTimeout + ex.getMessage();
+ tmpQTimeOut = 0;
+ }
+ }
+ setQueryTimeout(tmpQTimeOut);
+ }
+
+ /**
+ * @param queryTimeout
+ * Sets the query timeout value in seconds. For future use only
+ * this property is not supported in the current release.
+ */
+ void setQueryTimeout(short queryTimeout) {
+ queryTimeout_ = queryTimeout;
+ }
+
+ /**
+ * @return queryTimeOut value in seconds. For future use only this property
+ * is not supported in the current release.
+ */
+ short getQueryTimeout() {
+ return queryTimeout_;
+ }
+
+ /**
+ * Sets the value (in KB) for the size of the fetch buffer. This is used
+ * when rows are fetched are performed from a ResultSet object after a
+ * successful executeQuery() operation on a statement. The default size is
+ * 4. Zero and negative values are treated as default values.
+ *
+ * @param fetchBufferSize
+ * @see #getFetchBufferSize()
+ * @see #setFetchBufferSize(String)
+ */
+ void setFetchBufferSize(short fetchBufferSize) {
+ fetchBufferSize_ = 512;
+ if (fetchBufferSize > 512) {
+ fetchBufferSize_ = fetchBufferSize;
+ }
+ }
+
+ /**
+ * Sets the value (in KB) for the size of the fetch buffer. This is used
+ * when rows are fetched are performed from a ResultSet object after a
+ * successful executeQuery() operation on a statement. The default size is
+ * 4. Zero and negative values are treated as default values.
+ *
+ * @param fetchBufferSize
+ * @see #getFetchBufferSize()
+ * @see #setFetchBufferSize(short)
+ */
+ void setFetchBufferSize(String fetchBufferSize) {
+ short setFetchSizeVal = 4;
+ if (fetchBufferSize != null) {
+ try {
+ setFetchSizeVal = Short.parseShort(fetchBufferSize);
+ } catch (NumberFormatException ex) {
+ sqlExceptionMessage_ = "Incorrect fetchBufferSize value set: " + setFetchSizeVal + ". "
+ + ex.getMessage();
+ setFetchSizeVal = 1;
+ }
+ }
+ setFetchBufferSize(setFetchSizeVal);
+ }
+
+ /**
+ * Returns the size of the fetch buffer.
+ *
+ * @see #setFetchBufferSize(short)
+ * @see #setFetchBufferSize(String)
+ */
+ short getFetchBufferSize() {
+ return fetchBufferSize_;
+ }
+
+ /**
+ * Configure to use array binding feature for the Type 4 connection. Default
+ * value is true.
+ *
+ * @param useArrayBinding
+ */
+ void setUseArrayBinding(String useArrayBinding) {
+ boolean boolUseArrayBinding = false;
+ if (useArrayBinding != null) {
+ if (useArrayBinding.equalsIgnoreCase("true")) {
+ boolUseArrayBinding = true;
+ }
+ }
+ setUseArrayBinding(boolUseArrayBinding);
+ }
+
+ /**
+ * Configure to use array binding feature for the Type 4 connection. Default
+ * value is true.
+ *
+ * @param useArrayBinding
+ */
+ void setUseArrayBinding(boolean useArrayBinding) {
+ useArrayBinding_ = useArrayBinding;
+ }
+
+ /**
+ * Return whether the connection uses Database array binding feature.
+ *
+ * @return useArrayBinding boolean flag indicates Database RowSet (array
+ * binding) feature is used or not.
+ */
+ boolean getUseArrayBinding() {
+ return useArrayBinding_;
+ }
+
+ /**
+ * Configure the Type 4 connection to continue batch processing of next
+ * commands even after errors. Default value is true.
+ *
+ * @param batchRecovery
+ */
+ void setBatchRecovery(String batchRecovery) {
+ boolean boolBatchRecovery = true;
+ if (batchRecovery != null) {
+ if (batchRecovery.equalsIgnoreCase("false")) {
+ boolBatchRecovery = false;
+ }
+ }
+ setBatchRecovery(boolBatchRecovery);
+ }
+
+ /**
+ * Configure the Type 4 connection to continue batch processing of next
+ * commands even after errors. Default value is true.
+ *
+ * @param batchRecovery
+ */
+ void setBatchRecovery(boolean batchRecovery) {
+ batchRecovery_ = batchRecovery;
+ }
+
+ /**
+ * Return whether the Type 4 connection is configured to continue batch
+ * processing of next commands even after errors.
+ *
+ * @return batchRecovery
+ */
+ boolean getBatchRecovery() {
+ return batchRecovery_;
+ }
+
+ /**
+ * Sets the buffer size in bytes used by the transport layer between Type 4
+ * client classes and NDCS server on the NSK system.
+ *
+ * @param transportBufferSize
+ * set the transport buffer size in bytes for the current Type 4
+ * connection. Default value is 32000.
+ */
+ /*
+ * public void setTransportBufferSize(String transportBufferSize) { short
+ * tmpbuf = 32000; if (transportBufferSize != null) { try { tmpbuf = (new
+ * Short(transportBufferSize)).shortValue(); } catch (Exception ex) {
+ * sqlExceptionMessage_ = "Incorrect value for transportBufferSize set: " +
+ * transportBufferSize + ex.getMessage(); tmpbuf = 32000; } }
+ * setTransportBufferSize(tmpbuf); }
+ */
+
+ /**
+ * Sets the buffer size in bytes used by the transport layer between Type 4
+ * client classes and NDCS server on the NSK system. Transport buffer
+ * minimum acceptable size is 2000 bytes. If the value set is below 2000
+ * default buffer size of 3200 is set instead.
+ *
+ * @param transportBufferSize
+ * set the transport buffer size in bytes for the current
+ * connection. Default value for the driver is 32000 bytes.
+ */
+ /*
+ * public void setTransportBufferSize(short transportBufferSize) { if
+ * (transportBufferSize < 2000) { transportBufferSize_ = 32000; } else {
+ * transportBufferSize_ = transportBufferSize; } }
+ */
+
+ /**
+ * Returns the buffer size in bytes used by the transport layer between Type
+ * 4 client classes and NDCS server on the NSK system.
+ *
+ * @return The transport buffer size used by the current Type 4 connection.
+ */
+ /*
+ * public short getTransportBufferSize() { return transportBufferSize_; }
+ */
+
+ /**
+ * Sets the table name to store and retrieve the CLOB data for all CLOB
+ * columns accessed in the connection using the data source.
+ *
+ * @param clobTableName
+ * The clob table name which is of the format
+ * <code><var>catalog_name.schema_name.clob_table_name</code></var>
+ *
+ * @since 1.1
+ */
+ void setClobTableName(String clobTableName) throws SQLException {
+ int fromIndex = -1;
+ int count = 0;
+
+ if (clobTableName != null) {
+ while (((fromIndex = clobTableName.indexOf('.', fromIndex + 1)) != -1) && count < 2) {
+ count++;
+ }
+ if (count < 2) {
+ SQLException se = HPT4Messages.createSQLException(null, null, "no_clobTableName", null);
+ sqlExceptionMessage_ = se.getMessage();
+ }
+ clobTableName_ = clobTableName;
+ } else { // If the name is null, let it be null
+ clobTableName_ = null;
+ // throw HPT4Messages.createSQLException(null,
+ // null,"no_clobTableName",null);
+ }
+ }
+
+ /**
+ * Retrieves the table name used to store CBLOB data for all CLOB columns
+ * accessed in the connection using the data source.
+ *
+ * @return the clob table name which is of the format
+ * <code><var>catalog_name.schema_name.clob_table_name</code></var>
+ *
+ * @since 1.1
+ */
+ String getClobTableName() {
+ return clobTableName_;
+ }
+
+ /**
+ * @return any sql exception associated while setting the properties on this
+ * Type 4 connection. This mthod is accessed by InterfaceConnection
+ * to check if there is any SQL error setting the Type 4 properties.
+ */
+ String getSQLException() {
+ // System.out.println("sqlExceptionMessage_ = " + sqlExceptionMessage_);
+ return sqlExceptionMessage_;
+ }
+
+ /**
+ * Sets the table name to store and retrieve the BLOB data for all BLOB
+ * columns accessed in the connection using the data source.
+ *
+ * @param blobTableName
+ * the blob table name which is of the format
+ * <code><var>catalog_name.schema_name.blob_table_name</code></var>
+ *
+ * @since 1.1
+ */
+ void setBlobTableName(String blobTableName) throws SQLException {
+ int fromIndex = -1;
+ int count = 0;
+
+ if (blobTableName != null) {
+ while (((fromIndex = blobTableName.indexOf('.', fromIndex + 1)) != -1) && count < 2) {
+ count++;
+ }
+ if (count < 2) {
+ SQLException se = HPT4Messages.createSQLException(null, null, "no_blobTableName", null);
+ sqlExceptionMessage_ = se.getMessage();
+ }
+ blobTableName_ = blobTableName;
+ }
+ // If the name is null, then let it be null
+ else {
+ blobTableName_ = null;
+ // throw HPT4Messages.createSQLException(null, null,
+ // "no_blobTableName", null);
+ }
+ }
+
+ /**
+ * Retrieves the table name used to store BLOB data for all BLOB columns
+ * accessed in the connection using the data source.
+ *
+ * @return the blob table name which is of the format
+ * <code><var>catalog_name.schema_name.blob_table_name</code></var>
+ *
+ * @since 1.1
+ */
+ String getBlobTableName() {
+ return blobTableName_;
+ }
+
+ /**
+ * Configure to set the number of data locators to be reserved by the Type 4
+ * connection. Default value is 100.
+ *
+ * @param reserveDataLocator
+ * Set the value of the reserve data locator length for the
+ * binding) feature.
+ *
+ * @since 1.1
+ */
+ void setReserveDataLocator(String reserveDataLocator) {
+ long reserveDataLocatorLen = 100;
+ if (reserveDataLocator != null) {
+ try {
+ reserveDataLocatorLen = Long.parseLong(reserveDataLocator);
+ } catch (NumberFormatException ex) {
+ sqlExceptionMessage_ = "Incorrect value for setReserveDataLocator set: " + reserveDataLocator
+ + ex.getMessage();
+ reserveDataLocatorLen = 100;
+ }
+ }
+ setReserveDataLocator(reserveDataLocatorLen);
+ }
+
+ /**
+ * Configure to set the number of data locators to be reserved by the Type 4
+ * connection. Default value is 100.
+ *
+ * @param reserveDataLocatorLen
+ * Set the value of the reserve data locator length for the Type
+ * 4 connection.
+ *
+ * @since 1.1
+ */
+ void setReserveDataLocator(long reserveDataLocatorLen) {
+ if (reserveDataLocatorLen < 0) {
+ sqlExceptionMessage_ = "Incorrect value for reserveDataLocator set: " + reserveDataLocatorLen + ".";
+ reserveDataLocator_ = 100;
+ } else {
+ reserveDataLocator_ = reserveDataLocatorLen;
+ }
+ }
+
+ /**
+ * Return the value of the reserve data locator length.
+ *
+ * @return reserveDataLocatorLength int indicates the value of the reserved
+ * data locator length.
+ *
+ * @since 1.1
+ */
+ long getReserveDataLocator() {
+ return reserveDataLocator_;
+ }
+
+ /**
+ * Returns the rounding mode set for the driver as an Integer value with one
+ * of the following values. static int ROUND_CEILING Rounding mode to round
+ * towards positive infinity. static int ROUND_DOWN Rounding mode to round
+ * towards zero. static int ROUND_FLOOR Rounding mode to round towards
+ * negative infinity. static int ROUND_HALF_DOWN Rounding mode to round
+ * towards "nearest neighbor" unless both neighbors are equidistant, in
+ * which case round down. static int ROUND_HALF_EVEN Rounding mode to round
+ * towards the "nearest neighbor" unless both neighbors are equidistant, in
+ * which case, round towards the even neighbor. static int ROUND_HALF_UP
+ * Rounding mode to round towards "nearest neighbor" unless both neighbors
+ * are equidistant, in which case round up. static int ROUND_UNNECESSARY
+ * Rounding mode to assert that the requested operation has an exact result,
+ * hence no rounding is necessary. static int ROUND_UP Rounding mode to
+ * round away from zero.
+ */
+ int getRoundingMode() {
+ return roundMode_;
+ }
+
+ /**
+ * This method sets the round mode behaviour for the driver.
+ *
+ * @param roundMode
+ * Integer value with one of the following values: static int
+ * ROUND_CEILING Rounding mode to round towards positive
+ * infinity. static int ROUND_DOWN Rounding mode to round towards
+ * zero. static int ROUND_FLOOR Rounding mode to round towards
+ * negative infinity. static int ROUND_HALF_DOWN Rounding mode to
+ * round towards "nearest neighbor" unless both neighbors are
+ * equidistant, in which case round down. static int
+ * ROUND_HALF_EVEN Rounding mode to round towards the "nearest
+ * neighbor" unless both neighbors are equidistant, in which
+ * case, round towards the even neighbor. static int
+ * ROUND_HALF_UP Rounding mode to round towards "nearest
+ * neighbor" unless both neighbors are equidistant, in which case
+ * round up. static int ROUND_UNNECESSARY Rounding mode to assert
+ * that the requested operation has an exact result, hence no
+ * rounding is necessary. static int ROUND_UP Rounding mode to
+ * round away from zero. The default behaviour is to do
+ * ROUND_HALF_EVEN.
+ */
+ void setRoundingMode(String roundMode) {
+ roundMode_ = Utility.getRoundingMode(roundMode);
+ }
+
+ /**
+ * This method sets the round mode behaviour for the driver.
+ *
+ * @param roundMode
+ * Integer value with one of the following values: static int
+ * ROUND_CEILING Rounding mode to round towards positive
+ * infinity. static int ROUND_DOWN Rounding mode to round towards
+ * zero. static int ROUND_FLOOR Rounding mode to round towards
+ * negative infinity. static int ROUND_HALF_DOWN Rounding mode to
+ * round towards "nearest neighbor" unless both neighbors are
+ * equidistant, in which case round down. static int
+ * ROUND_HALF_EVEN Rounding mode to round towards the "nearest
+ * neighbor" unless both neighbors are equidistant, in which
+ * case, round towards the even neighbor. static int
+ * ROUND_HALF_UP Rounding mode to round towards "nearest
+ * neighbor" unless both neighbors are equidistant, in which case
+ * round up. static int ROUND_UNNECESSARY Rounding mode to assert
+ * that the requested operation has an exact result, hence no
+ * rounding is necessary. static int ROUND_UP Rounding mode to
+ * round away from zero. The default behaviour is to do
+ * ROUND_HALF_EVEN.
+ */
+ void setRoundingMode(int roundMode) {
+ roundMode_ = Utility.getRoundingMode(roundMode);
+ }
+
+ // ----------------------------------------------------------
+ void setConnectionID(String connID) {
+ connectionID_ = connID;
+ }
+
+ String getConnectionID() {
+ return connectionID_;
+ }
+
+ // ----------------------------------------------------------
+ void setDialogueID(String diaID) {
+ dialogueID_ = diaID;
+ }
+
+ String getDialogueID() {
+ return dialogueID_;
+ }
+
+ // ----------------------------------------------------------
+ void setNcsMajorVersion(short majorVer) {
+ ncsMajorVersion_ = majorVer;
+ }
+
+ void setNcsMajorVersion(String majorVer) {
+ short mv = 0;
+
+ if (majorVer != null) {
+ try {
+ mv = Short.parseShort(majorVer);
+ } catch (NumberFormatException ex) {
+ sqlExceptionMessage_ = "Incorrect value for NDCS major version set: " + majorVer + ex.getMessage();
+ mv = 0;
+ }
+ }
+ setNcsMajorVersion(mv);
+ ncsMajorVersion_ = mv;
+ }
+
+ short getNcsMajorVersion() {
+ return ncsMajorVersion_;
+ }
+
+ // ----------------------------------------------------------
+ void setNcsMinorVersion(short minorVer) {
+ ncsMinorVersion_ = minorVer;
+ }
+
+ void setNcsMinorVersion(String minorVer) {
+ short mv = 0;
+
+ if (minorVer != null) {
+ try {
+ mv = Short.parseShort(minorVer);
+ } catch (NumberFormatException ex) {
+ sqlExceptionMessage_ = "Incorrect value for NDCS minor version set: " + minorVer + ex.getMessage();
+ mv = 0;
+ }
+ }
+ setNcsMinorVersion(mv);
+ ncsMinorVersion_ = mv;
+ }
+
+ short getNcsMinorVersion() {
+ return ncsMinorVersion_;
+ }
+
+ void setSqlmxMajorVersion(short majorVer) {
+ sqlmxMajorVersion_ = majorVer;
+ }
+
+ void setSqlmxMajorVersion(String majorVer) {
+ short mv = 0;
+
+ if (majorVer != null) {
+ try {
+ mv = Short.parseShort(majorVer);
+ } catch (NumberFormatException ex) {
+ sqlExceptionMessage_ = "Incorrect value for Database major version set: " + majorVer
+ + ex.getMessage();
+ mv = 0;
+ }
+ }
+ setSqlmxMajorVersion(mv);
+ }
+
+ public void setSPJEnv(String SPJEnv) {
+ if (SPJEnv == null) {
+ SPJEnv_ = false;
+ } else {
+ SPJEnv_ = (SPJEnv.equalsIgnoreCase("true"));
+ }
+ }
+
+ public void setSPJEnv(boolean SPJEnv) {
+ SPJEnv_ = SPJEnv;
+ }
+
+ public boolean getSPJEnv() {
+ return SPJEnv_;
+ }
+
+ public void setKeepRawFetchBuffer(String keep) {
+ if (keep == null) {
+ keepRawFetchBuffer_ = false;
+ } else {
+ keepRawFetchBuffer_ = (keep.equalsIgnoreCase("true"));
+ }
+ }
+
+ public void setKeepRawFetchBuffer(boolean keep) {
+ keepRawFetchBuffer_ = keep;
+ }
+
+ public boolean getKeepRawFetchBuffer() {
+ return keepRawFetchBuffer_;
+ }
+
+ short getSqlmxMajorVersion() {
+ return sqlmxMajorVersion_;
+ }
+
+ public void setCpuToUse(String cpu) {
+ if (cpu == null) {
+ cpuToUse_ = -1;
+ } else {
+ cpuToUse_ = Short.parseShort(cpu);
+ }
+ }
+
+ public void setCpuToUse(short cpu) {
+ cpuToUse_ = cpu;
+ }
+
+ public short getCpuToUse() {
+ return cpuToUse_;
+ }
+
+ public void setSessionName(String name) {
+ if (name == null)
+ sessionName = "";
+ else {
+ sessionName = name;
+ }
+ }
+
+ public String getSessionName() {
+ return sessionName;
+ }
+
+ public void setReplacementString(String str) {
+ if (str == null) {
+ replacementString_ = "?";
+ } else {
+ replacementString_ = str;
+ }
+ }
+
+ public String getReplacementString() {
+ return replacementString_;
+ }
+
+ void setISO88591(String lang) {
+ if (lang == null) {
+ ISO88591_ = InterfaceUtilities.getCharsetName(InterfaceUtilities.SQLCHARSETCODE_ISO88591);
+ } else {
+ ISO88591_ = lang;
+ }
+ }
+
+ String getISO88591() {
+ return ISO88591_;
+ }
+
+ public String getRoleName() {
+ return _roleName;
+ }
+
+ public void setRoleName(String roleName) {
+ if (roleName != null && roleName.length() > 0) {
+ if (roleName.length() > 128)
+ sqlExceptionMessage_ = "Invalid RoleName. Max length: 128";
+ }
+
+ this._roleName = roleName;
+ }
+
+ public String getApplicationName() {
+ return _applicationName;
+ }
+
+ public void setApplicationName(String applicationName) {
+ if (applicationName == null || applicationName.length() == 0)
+ this._applicationName = "FASTJDBC";
+ else
+ this._applicationName = applicationName;
+ }
+
+ public void setCertificateFileActive(String file) {
+ _certificateFileActive = file;
+ }
+
+ public String getCertificateFileActive() {
+ return _certificateFileActive;
+ }
+
+ public void setCertificateFile(String file) {
+ _certificateFile = file;
+ }
+
+ public String getCertificateFile() {
+ return _certificateFile;
+ }
+
+ public void setCertificateDir(String dir) {
+ _certificateDir = dir;
+ }
+
+ public String getCertificateDir() {
+ return _certificateDir;
+ }
+
+ public void setDelayedErrorMode(String mode) {
+ _delayedErrorMode = Boolean.valueOf(mode).booleanValue();
+ }
+
+ public void setDelayedErrorMode(boolean mode) {
+ _delayedErrorMode = mode;
+ }
+
+ public boolean getDelayedErrorMode() {
+ return _delayedErrorMode;
+ }
+
+ public void setCompression(String compression) {
+ _compression = Boolean.valueOf(compression).booleanValue();
+ }
+
+ public void setCompression(boolean compression) {
+ _compression = compression;
+ }
+
+ public boolean getCompression() {
+ return _compression;
+ }
+
+ public void setKeepAlive(String val) {
+ if(val == null)
+ {
+ _keepAlive = true;
+ }
+ else
+ {
+ _keepAlive = Boolean.valueOf(val).booleanValue();
+ }
+ }
+
+ public void setKeepAlive(boolean val) {
+ _keepAlive = val;
+ }
+
+ public boolean getKeepAlive() {
+ return _keepAlive;
+ }
+
+ public void setTcpNoDelay(String val) {
+ if(val == null) {
+ _tcpNoDelay = true;
+ }
+ else {
+ _tcpNoDelay = Boolean.valueOf(val).booleanValue();
+ }
+ }
+
+ public void setTcp_NoDelay(boolean val) {
+ _tcpNoDelay = val;
+ }
+
+ public boolean getTcpNoDelay() {
+ return _tcpNoDelay;
+ }
+
+ public void setTokenAuth(String val) {
+ if(val == null)
+ {
+ _tokenAuth = true;
+ }
+ else
+ {
+ _tokenAuth = Boolean.valueOf(val).booleanValue();
+ }
+ }
+
+ public void setTokenAuth(boolean val) {
+ _tokenAuth = val;
+ }
+
+ public boolean getTokenAuth() {
+ return _tokenAuth;
+ }
+
+ boolean getSessionToken() {
+ return this._sessionToken;
+ }
+
+ void setSessionToken(boolean sessionToken) {
+ this._sessionToken = sessionToken;
+ }
+
+ void setSessionToken(String sessionToken) {
+ setSessionToken(Boolean.valueOf(sessionToken).booleanValue());
+ }
+
+ boolean getFetchAhead() {
+ return this._fetchAhead;
+ }
+
+ void setFetchAhead(boolean fetchAhead) {
+ this._fetchAhead = fetchAhead;
+ }
+
+ void setFetchAhead(String fetchAhead) {
+ setFetchAhead(Boolean.valueOf(fetchAhead).booleanValue());
+ }
+
+ // ----------------------------------------------------------
+ void setSqlmxMinorVersion(short minorVer) {
+ sqlmxMinorVersion_ = minorVer;
+ }
+
+ void setSqlmxMinorVersion(String minorVer) {
+ short mv = 0;
+
+ if (minorVer != null) {
+ try {
+ mv = Short.parseShort(minorVer);
+ } catch (NumberFormatException ex) {
+ sqlExceptionMessage_ = "Incorrect value for Database minor version set: " + minorVer
+ + ex.getMessage();
+ mv = 0;
+ }
+ }
+ setSqlmxMinorVersion(mv);
+ }
+
+ short getSqlmxMinorVersion() {
+ return sqlmxMinorVersion_;
+ }
+
+ // ----------------------------------------------------------
+ BigDecimal getNcsVersion() {
+ String minor = new Short(getNcsMinorVersion()).toString();
+ String major = new Short(getNcsMajorVersion()).toString();
+ BigDecimal bigD = new BigDecimal(major + "." + minor);
+ return bigD;
+ }
+
+ // ----------------------------------------------------------
+ void setServerID(String serID) {
+ serverID_ = serID;
+ }
+
+ String getServerID() {
+ return serverID_;
+ }
+
+ /**
+ * Sets the language to use for the error messages.
+ *
+ * @param language
+ * Sets the language for the current Type 4 connection. The
+ * default language used by the Type 4 driver is American
+ * English.
+ * @see #getLanguage()
+ */
+ void setLanguage(String language) {
+ if (language == null) {
+ locale_ = Locale.getDefault();
+ } else {
+ locale_ = new Locale(language, "", "");
+ }
+ language_ = locale_.getLanguage();
+ }
+
+ /**
+ * Returns the language in which to the Type 4 error messages will be
+ * returned to the application.
+ *
+ * @return The language associated with the current Type 4 connection.
+ * @see #setLanguage(String language)
+ */
+ String getLanguage() {
+ return language_;
+ }
+
+ // ----------------------------------------------------------
+
+ /**
+ * @return Reference object containing all the Type 4 connection properties.
+ * The reference object can be used to register with naming
+ * services.
+ */
+ Reference addReferences(Reference ref) {
+ ref.add(new StringRefAddr("dataSourceName", getDataSourceName()));
+ ref.add(new StringRefAddr("serverDataSource", getServerDataSource()));
+ ref.add(new StringRefAddr("description", getDescription()));
+ String val = getCatalog();
+ if (val != null) {
+ ref.add(new StringRefAddr("catalog", val));
+ }
+ val = getSchema();
+ if (val != null) {
+ ref.add(new StringRefAddr("schema", val));
+
+ }
+ ref.add(new StringRefAddr("language", getLanguage()));
+ ref.add(new StringRefAddr("maxPoolSize", Integer.toString(getMaxPoolSize())));
+ ref.add(new StringRefAddr("minPoolSize", Integer.toString(getMinPoolSize())));
+ ref.add(new StringRefAddr("initialPoolSize", Integer.toString(getInitialPoolSize())));
+ ref.add(new StringRefAddr("maxStatements", Integer.toString(getMaxStatements())));
+
+ ref.add(new StringRefAddr("connectionTimeout", Integer.toString(getConnectionTimeout())));
+ ref.add(new StringRefAddr("maxIdleTime", Integer.toString(getMaxIdleTime())));
+ ref.add(new StringRefAddr("loginTimeout", Integer.toString(getLoginTimeout())));
+ // ref.add(new StringRefAddr("closeConnectionTimeout",
+ // Integer.toString(getCloseConnectionTimeout())));
+ ref.add(new StringRefAddr("networkTimeout", Integer.toString(getNetworkTimeout())));
+ ref.add(new StringRefAddr("T4LogLevel", getT4LogLevel().toString()));
+ ref.add(new StringRefAddr("T4LogFile", getT4LogFile()));
+
+ ref.add(new StringRefAddr("url", getUrl()));
+ ref.add(new StringRefAddr("user", getUser()));
+ ref.add(new StringRefAddr("password", getPassword()));
+ /*
+ * ref.add(new StringRefAddr("transportBufferSize",
+ * Short.toString(getTransportBufferSize())));
+ */
+ /*
+ * ref.add(new StringRefAddr("useArrayBinding",
+ * Boolean.toString(getUseArrayBinding())));
+ */
+
+ // LOB Support - SB 9/28/04
+ val = getClobTableName();
+ if (val != null) {
+ ref.add(new StringRefAddr("clobTableName", val));
+ }
+ val = getBlobTableName();
+ if (val != null) {
+ ref.add(new StringRefAddr("blobTableName", val));
+
+ }
+ ref.add(new StringRefAddr("reserveDataLocator", Long.toString(reserveDataLocator_)));
+ ref.add(new StringRefAddr("roundingMode", Integer.toString(getRoundingMode())));
+
+ // propertiy queryTimeout_ for future use.
+ ref.add(new StringRefAddr("queryTimeout", Integer.toString(getQueryTimeout())));
+ ref.add(new StringRefAddr("fetchBufferSize", Short.toString(this.getFetchBufferSize())));
+ ref.add(new StringRefAddr("batchRecovery", Boolean.toString(this.getBatchRecovery())));
+ return ref;
+ }
+
+ /**
+ * Instantiated by either <code>
+ * Class.forName("org.trafodion.jdbc.t4.T4Driver")</code>
+ * or by passing <code>-Djdbc.drivers=org.trafodion.jdbc.t4.T4Driver</code>
+ * property in the command line of the JDBC program.
+ */
+ DriverPropertyInfo[] getPropertyInfo(String url, Properties defaults) throws SQLException {
+
+ String level[] = { "OFF", "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", "FINEST" };
+ String roundingMode[] = { "ROUND_CEILING", "ROUND_DOWN", "ROUND_UP", "ROUND_FLOOR", "ROUND_HALF_UP",
+ "ROUND_UNNECESSARY", "ROUND_HALF_EVEN", "ROUND_HALF_DOWN", "ROUND_DOWN" };
+
+ Properties props = new Properties(defaults);
+ props.setProperty("url", url);
+
+ // catalog setting
+ DriverPropertyInfo[] propertyInfo = {
+ setPropertyInfo("catalog", props, true, "Database catalog name", null),
+ setPropertyInfo("schema", props, true, "Database schema name", null),
+ setPropertyInfo("url", props, false, "jdbc:t4jdbc://<host>:<port>/:", null),
+ setPropertyInfo("user", props, true, "NSK safeguard user name", null),
+ setPropertyInfo("password", props, true, "NSK safeguard user password", null),
+ setPropertyInfo("maxPoolSize", props, false, "Maximum connection pool size", null),
+ setPropertyInfo("minPoolSize", props, false, "Minimum connection pool size", null),
+ setPropertyInfo("initialPoolSize", props, false, "Initial connection pool size", null),
+ setPropertyInfo("maxStatements", props, false, "Maximum statement pool size", null),
+ setPropertyInfo("T4LogLevel", props, false, "Logging Level", level),
+ setPropertyInfo("T4LogFile", props, false, "Logging file location", null),
+ setPropertyInfo("loginTimeout", props, false, "Login time out in secs", null),
+ setPropertyInfo("networkTimeout", props, false, "Network time out in secs", null),
+ setPropertyInfo("connectionTimeout", props, false, "Connection time out in secs", null),
+ setPropertyInfo("maxIdleTime", props, false, "Max idle time for a free pool connection in secs", null),
+ setPropertyInfo("language", props, false, "Locale language to use", null),
+ setPropertyInfo("serverDataSource", props, false, "NDCS data source name", null),
+ setPropertyInfo("roundingMode", props, false, "Data rounding mode", roundingMode),
+ setPropertyInfo("blobTableName", props, false, "Table name to store and retrieve BLOB column data",
+ null),
+ setPropertyInfo("clobTableName", props, false, "Table name to store and retrieve CLOB column data",
+ null),
+ setPropertyInfo("reserveDataLocator", props, false,
+ "Number of data locators (for LOB) to be reserved by the connection", null),
+ setPropertyInfo("fetchBufferSize", props, false,
+ "Value (in KB) for the size of the fetch buffer to be used when rows are fetched", null),
+ setPropertyInfo("batchRecovery", props, false,
+ "Continue batch processing of next commands even after errors", null) };
+
+ return propertyInfo;
+
+ }
+
+ private DriverPropertyInfo setPropertyInfo(String name, Properties props, boolean required, String description,
+ String[] choices) {
+ String value = props.getProperty(name);
+ DriverPropertyInfo propertyInfo = new DriverPropertyInfo(name, value);
+ propertyInfo.required = required;
+ propertyInfo.description = description;
+ propertyInfo.choices = choices;
+ return propertyInfo;
+ }
+
+ // ---------------------------------------------------------------
+ static private Properties getPropertiesFileValues() {
+ Properties values = null;
+ String propsFile = System.getProperty("t4jdbc.properties");
+
+ if (propsFile != null) {
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(new File(propsFile));
+ values = new Properties();
+ values.load(fis);
+ } catch (Exception ex) {
+ fis = null;
+ // sqlExceptionMessage_ = "Error while loading " +
+ // prefix_ + "properties file: " + ex.getMessage();
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException ioe) {
+ // ignore
+ }
+ }
+ }
+ } // end if
+
+ return values;
+ } // end getPropertiesFileValues
+
+ // -------------------------------------------------------------------------
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4ResultSet.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4ResultSet.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4ResultSet.java
new file mode 100644
index 0000000..45410c7
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4ResultSet.java
@@ -0,0 +1,164 @@
+// @@@ 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 T4ResultSet extends T4Connection {
+ private String m_stmtLabel;
+ static final short SQL_CLOSE = 0;
+
+ boolean m_processing = false;
+
+ T4ResultSet(InterfaceResultSet ir) throws SQLException {
+ super(ir.ic_);
+ m_stmtLabel = ir.stmtLabel_;
+
+ if (m_stmtLabel == null) {
+ throwInternalException();
+
+ }
+ }
+
+ /**
+ * This method will send a fetch rowset command to the server.
+ *
+ * @param maxRowCnt
+ * the maximum rowset count to return
+ * @param maxRowLen
+ * the maximum row length to return
+ * @param sqlAsyncEnable
+ * a flag to enable/disable asynchronies execution
+ * @param queryTimeout
+ * the number of seconds before the query times out
+ *
+ * @retrun a FetchPerfReply class representing the reply from the ODBC
+ * server is returned
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+
+ FetchReply Fetch(int sqlAsyncEnable, int queryTimeout, int stmtHandle, int stmtCharset, int maxRowCnt,
+ String cursorName, int cursorCharset, String stmtOptions) throws SQLException {
+
+ try {
+ getInputOutput().setTimeout(m_ic.t4props_.getNetworkTimeout());
+
+ LogicalByteArray wbuffer = FetchMessage.marshal(m_dialogueId, sqlAsyncEnable, queryTimeout, stmtHandle,
+ m_stmtLabel, stmtCharset, maxRowCnt, 0 // infinite row size
+ , cursorName, cursorCharset, stmtOptions, this.m_ic);
+
+ LogicalByteArray rbuffer = getReadBuffer(TRANSPORT.SRVR_API_SQLFETCH, wbuffer);
+
+ //
+ // Process output parameters
+ //
+ FetchReply frr = new FetchReply(rbuffer, m_ic);
+
+ return frr;
+ } // end try
+ catch (SQLException se) {
+ throw se;
+ } catch (CharacterCodingException e) {
+ SQLException se = HPT4Messages.createSQLException(m_ic.t4props_, m_locale,
+ "translation_of_parameter_failed", "FetchMessage", 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, "fetch_perf_message_error", e
+ .getMessage());
+
+ se.initCause(e);
+ throw se;
+ } // end catch
+
+ } // end FetchPerf
+
+ /**
+ * This method will send an close command, which does not return any
+ * rowsets, to the ODBC server.
+ *
+ * @retrun A CloseReply class representing the reply from the ODBC server is
+ * returned
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+
+ CloseReply Close() throws SQLException {
+
+ try {
+ getInputOutput().setTimeout(m_ic.t4props_.getNetworkTimeout());
+
+ LogicalByteArray wbuffer = CloseMessage.marshal(m_dialogueId, m_stmtLabel, SQL_CLOSE, this.m_ic);
+
+ LogicalByteArray rbuffer = getReadBuffer(TRANSPORT.SRVR_API_SQLFREESTMT, wbuffer);
+
+ CloseReply cr = new CloseReply(rbuffer, m_ncsAddress.getIPorName(), m_ic);
+
+ return cr;
+ } // end try
+ 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;
+ } // end catch
+
+ } // end Close
+
+ // --------------------------------------------------------------------------------
+ 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;
+ }
+}
[14/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InterfaceConnection.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InterfaceConnection.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InterfaceConnection.java
deleted file mode 100644
index 4c1877f..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InterfaceConnection.java
+++ /dev/null
@@ -1,1420 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.lang.ref.Reference;
-import java.lang.ref.ReferenceQueue;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.CharBuffer;
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CharsetEncoder;
-import java.nio.charset.CodingErrorAction;
-import java.nio.charset.UnsupportedCharsetException;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.util.Hashtable;
-import java.util.Locale;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-
-
-class InterfaceConnection {
- static final int MODE_SQL = 0;
- static final int MODE_WMS = 1;
- static final int MODE_CMD = 2;
-
- static final short SQL_COMMIT = 0;
- static final short SQL_ROLLBACK = 1;
- private int txnIsolationLevel = Connection.TRANSACTION_READ_COMMITTED;
- private boolean autoCommit = true;
- private boolean isReadOnly = false;
- private boolean isClosed_;
- private long txid;
- private Locale locale;
- private USER_DESC_def userDesc;
- private CONNECTION_CONTEXT_def inContext;
- OUT_CONNECTION_CONTEXT_def outContext;
- private boolean useArrayBinding_;
- private short transportBufferSize_;
- Handler t4FileHandler;
- private NCSAddress ncsAddr_;
- private T4Connection t4connection_;
- private String m_ncsSrvr_ref;
- private int dialogueId_;
- private String m_sessionName;
-
- // character set information
- private int isoMapping_ = 15;
- private int termCharset_ = 15;
- private boolean enforceISO = false;
- private boolean byteSwap = false;
- private String _serverDataSource;
-
- private int _mode = MODE_SQL;
-
- T4Properties t4props_;
- SQLWarning sqlwarning_;
-
- Hashtable encoders = new Hashtable(11);
- Hashtable decoders = new Hashtable(11);
-
- // static fields from odbc_common.h and sql.h
- static final int SQL_TXN_READ_UNCOMMITTED = 1;
- static final int SQL_TXN_READ_COMMITTED = 2;
- static final int SQL_TXN_REPEATABLE_READ = 4;
- static final int SQL_TXN_SERIALIZABLE = 8;
- static final short SQL_ATTR_CURRENT_CATALOG = 109;
- static final short SQL_ATTR_ACCESS_MODE = 101;
- static final short SQL_ATTR_AUTOCOMMIT = 102;
- static final short SQL_TXN_ISOLATION = 108;
-
- // spj proxy syntax support
- static final short SPJ_ENABLE_PROXY = 1040;
-
- static final int PASSWORD_SECURITY = 0x4000000; //(2^26)
- static final int ROWWISE_ROWSET = 0x8000000; // (2^27);
- static final int CHARSET = 0x10000000; // (2^28)
- static final int STREAMING_DELAYEDERROR_MODE = 0x20000000; // 2^29
- // Zbig added new attribute on 4/18/2005
- static final short JDBC_ATTR_CONN_IDLE_TIMEOUT = 3000;
- static final short RESET_IDLE_TIMER = 1070;
-
- // for handling WeakReferences
- static ReferenceQueue refQ_ = new ReferenceQueue();
- static Hashtable refTosrvrCtxHandle_ = new Hashtable();
-
- //3196 - NDCS transaction for SPJ
- static final short SQL_ATTR_JOIN_UDR_TRANSACTION = 1041;
- static final short SQL_ATTR_SUSPEND_UDR_TRANSACTION = 1042;
- long transId_ = 0;
- boolean suspendRequest_ = false;
-
- private String _roleName = "";
- private boolean _ignoreCancel;
-
- private long _seqNum = 0;
- private SecPwd _security;
- long currentTime;
-
- private TrafT4Connection _t4Conn;
- private String _remoteProcess;
- private String _connStringHost = "";
-
- InterfaceConnection(TrafT4Connection conn, T4Properties t4props) throws SQLException {
- _t4Conn = conn;
- t4props_ = t4props;
- _remoteProcess = "";
-
- // close any weak connections that need to be closed.
- gcConnections();
-
- if (t4props.getSQLException() != null) {
- throw HPT4Messages.createSQLException(t4props_, t4props.getLocale(), "invalid_property", t4props
- .getSQLException());
- }
-
- m_sessionName = t4props_.getSessionName();
-
- if (m_sessionName != null && m_sessionName.length() > 0) {
- if (m_sessionName.length() > 24)
- m_sessionName = m_sessionName.substring(0, 24);
-
- if (!m_sessionName.matches("\\w+"))
- throw new SQLException("Invalid sessionName. Session names can only contain alphnumeric characters.");
- }
-
- locale = t4props.getLocale();
- txid = 0;
- isClosed_ = false;
- useArrayBinding_ = t4props.getUseArrayBinding();
- // transportBufferSize_ = t4props.getTransportBufferSize();
- transportBufferSize_ = 32000;
-
- userDesc = getUserDescription(t4props.getUser());
-
- // Connection context details
- inContext = getInContext(t4props);
- m_ncsSrvr_ref = t4props.getUrl();
- _ignoreCancel = false;
-
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(t4props_, t4props);
- String temp = "url is = " + t4props.getUrl();
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "", temp, p);
- p = T4LoggingUtilities.makeParams(t4props_, t4props);
- temp = "user is = " + userDesc.userName;
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "", temp, p);
- }
- sqlwarning_ = null;
- connect();
- }
-
- public void setConnStrHost(String host) {
- this._connStringHost = host;
- }
-
- public int getMode() {
- return this._mode;
- }
-
- public void setMode(int mode) {
- this._mode = mode;
- }
-
- public long getSequenceNumber() {
- if(++_seqNum < 0) {
- _seqNum = 1;
- }
-
- return _seqNum;
- }
-
- public String getRemoteProcess() throws SQLException {
- return _remoteProcess;
- }
-
- public boolean isClosed() {
- return this.isClosed_;
- }
-
- String getRoleName() {
- return this._roleName;
- }
-
- CONNECTION_CONTEXT_def getInContext() {
- return inContext;
- }
-
- private CONNECTION_CONTEXT_def getInContext(T4Properties t4props) {
- inContext = new CONNECTION_CONTEXT_def();
- inContext.catalog = t4props.getCatalog();
- inContext.schema = t4props.getSchema();
- inContext.datasource = t4props.getServerDataSource();
- inContext.userRole = t4props.getRoleName();
- inContext.cpuToUse = t4props.getCpuToUse();
- inContext.cpuToUseEnd = -1; // for future use by DBTransporter
-
- inContext.accessMode = (short) (isReadOnly ? 1 : 0);
- inContext.autoCommit = (short) (autoCommit ? 1 : 0);
-
- inContext.queryTimeoutSec = t4props.getQueryTimeout();
- inContext.idleTimeoutSec = (short) t4props.getConnectionTimeout();
- inContext.loginTimeoutSec = (short) t4props.getLoginTimeout();
- inContext.txnIsolationLevel = (short) SQL_TXN_READ_COMMITTED;
- inContext.rowSetSize = t4props.getFetchBufferSize();
- inContext.diagnosticFlag = 0;
- inContext.processId = (int) System.currentTimeMillis() & 0xFFF;
-
- try {
- inContext.computerName = InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException uex) {
- inContext.computerName = "Unknown Client Host";
- }
- inContext.windowText = t4props.getApplicationName();
-
- inContext.ctxDataLang = 15;
- inContext.ctxErrorLang = 15;
-
- inContext.ctxACP = 1252;
- inContext.ctxCtrlInferNXHAR = -1;
- inContext.clientVersionList.list = getVersion(inContext.processId);
- return inContext;
- }
-
- private VERSION_def[] getVersion(int pid) {
- short majorVersion = 3;
- short minorVersion = 0;
- int buildId = 0;
-
- VERSION_def version[] = new VERSION_def[2];
-
- // Entry [0] is the Driver Version information
- version[0] = new VERSION_def();
- version[0].componentId = 20;
- version[0].majorVersion = majorVersion;
- version[0].minorVersion = minorVersion;
- version[0].buildId = buildId | ROWWISE_ROWSET | CHARSET | PASSWORD_SECURITY;
-
- if (this.t4props_.getDelayedErrorMode())
- {
- version[0].buildId |= STREAMING_DELAYEDERROR_MODE;
- }
-
- // Entry [1] is the Application Version information
- version[1] = new VERSION_def();
- version[1].componentId = 8;
- version[1].majorVersion = 3;
- version[1].minorVersion = 0;
- version[1].buildId = 0;
-
- return version;
- }
-
- USER_DESC_def getUserDescription() {
- return userDesc;
- }
-
- private void setISOMapping(int isoMapping) {
-// if (InterfaceUtilities.getCharsetName(isoMapping) == InterfaceUtilities.SQLCHARSET_UNKNOWN)
-// isoMapping = InterfaceUtilities.getCharsetValue("ISO8859_1");
-
- isoMapping_ = InterfaceUtilities.getCharsetValue("UTF-8");;
- }
-
- String getServerDataSource() {
- return this._serverDataSource;
- }
-
- boolean getEnforceISO() {
- return enforceISO;
- }
-
- int getISOMapping() {
- return isoMapping_;
- }
-
- public String getSessionName() {
- return m_sessionName;
- }
-
- private void setTerminalCharset(int termCharset) {
-// if (InterfaceUtilities.getCharsetName(termCharset) == InterfaceUtilities.SQLCHARSET_UNKNOWN)
-// termCharset = InterfaceUtilities.getCharsetValue("ISO8859_1");
-
- termCharset_ = InterfaceUtilities.getCharsetValue("UTF-8");;
- }
-
- int getTerminalCharset() {
- return termCharset_;
- }
-
- private USER_DESC_def getUserDescription(String user) throws SQLException {
- userDesc = new USER_DESC_def();
- userDesc.userDescType = (this.t4props_.getSessionToken()) ? TRANSPORT.PASSWORD_ENCRYPTED_USER_TYPE
- : TRANSPORT.UNAUTHENTICATED_USER_TYPE;
- userDesc.userName = (user.length() > 128) ? user.substring(0, 128) : user;
- userDesc.domainName = "";
-
- userDesc.userSid = null;
- userDesc.password = null; //we no longer want to send the password to the MXOAS
-
- return userDesc;
- }
-
- void writeToOutFile(byte[] input, String file)
- {
- java.io.DataOutputStream os = null;
- try {
- os = new java.io.DataOutputStream
- (new java.io.FileOutputStream(file));
- os.write(input, 0, input.length);
- }catch (java.io.IOException io) {
- System.out.println("IO exception");
- }finally {
- if (os != null)
- try {
- os.close();
- }catch (java.io.IOException io) {
- System.out.println("IO exception");
- }
- }
- }
-
- private void oldEncryptPassword() throws SQLException {
- String pwd = this.t4props_.getPassword();
-
- if (pwd.length() > 386)
- pwd = pwd.substring(0, 386);
-
- byte [] authentication;
- try {
- authentication = pwd.getBytes("US-ASCII");
- } catch (UnsupportedEncodingException uex) {
- throw HPT4Messages.createSQLException(t4props_, locale, uex.getMessage(), null);
- }
-
- if (authentication.length > 0) {
- Utility.Encryption(authentication, authentication, authentication.length);
- }
-
- userDesc.password = authentication;
- }
-
- T4Connection getT4Connection() {
- return t4connection_;
- }
-
- int getDialogueId() {
- return dialogueId_;
- }
-
- int getQueryTimeout() {
- return inContext.queryTimeoutSec;
- }
-
- int getLoginTimeout() {
- return inContext.loginTimeoutSec;
- }
-
- int getConnectionTimeout() {
- return inContext.idleTimeoutSec;
- }
-
- String getCatalog() {
- if (outContext != null) {
- return outContext.catalog;
- } else {
- return inContext.catalog;
- }
- }
-
- boolean getDateConversion() {
- return ((outContext.versionList.list[0].buildId & 512) > 0);
- }
-
- int getServerMajorVersion() {
- return outContext.versionList.list[1].majorVersion;
- }
-
- int getServerMinorVersion() {
- return outContext.versionList.list[1].minorVersion;
- }
-
- String getUid() {
- return userDesc.userName;
- }
-
- String getSchema() {
- if (outContext != null) {
- return outContext.schema;
- } else {
- return inContext.schema;
- }
- }
-
- void setLocale(Locale locale) {
- this.locale = locale;
- }
-
- Locale getLocale() {
- return locale;
- }
-
- boolean getByteSwap() {
- return this.byteSwap;
- }
-
- NCSAddress getNCSAddress() {
- return ncsAddr_;
- }
-
- void commit() throws SQLException {
- endTransaction(SQL_COMMIT);
- }
-
- void rollback() throws SQLException {
- endTransaction(SQL_ROLLBACK);
- }
-
- void cancel() throws SQLException {
- if(!this._ignoreCancel) {
- String srvrObjRef = "" + ncsAddr_.getPort();
- // String srvrObjRef = t4props_.getServerID();
- int srvrType = 2; // AS server
- CancelReply cr_ = null;
-
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(t4props_);
- String temp = "cancel request received for " + srvrObjRef;
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "connect", temp, p);
- }
-
- //
- // Send the cancel to the ODBC association server.
- //
- String errorText = null;
- int tryNum = 0;
- String errorMsg = null;
- String errorMsg_detail = null;
- long currentTime = (new java.util.Date()).getTime();
- long endTime;
-
- if (inContext.loginTimeoutSec > 0) {
- endTime = currentTime + inContext.loginTimeoutSec * 1000;
- } else {
-
- // less than or equal to 0 implies infinit time out
- endTime = Long.MAX_VALUE;
-
- //
- // Keep trying to contact the Association Server until we run out of
- // time, or make a connection or we exceed the retry count.
- //
- }
- cr_ = T4_Dcs_Cancel.cancel(t4props_, this, dialogueId_, srvrType, srvrObjRef, 0);
-
- switch (cr_.m_p1_exception.exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(t4props_);
- String temp = "Cancel successful";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "connect", temp, p);
- }
- break;
- default:
-
- //
- // Some unknown error
- //
- if (cr_.m_p1_exception.clientErrorText != null) {
- errorText = "Client Error text = " + cr_.m_p1_exception.clientErrorText;
- }
- errorText = errorText + " :Exception = " + cr_.m_p1_exception.exception_nr;
- errorText = errorText + " :" + "Exception detail = " + cr_.m_p1_exception.exception_detail;
- errorText = errorText + " :" + "Error code = " + cr_.m_p1_exception.errorCode;
-
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(t4props_);
- String temp = errorText;
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "cancel", temp, p);
- }
- throw HPT4Messages.createSQLException(t4props_, locale, "as_cancel_message_error", errorText);
- } // end switch
-
- currentTime = (new java.util.Date()).getTime();
- }
- }
-
- private void initDiag(boolean setTimestamp, boolean downloadCert) throws SQLException {
- short retryCount = 3;
- InitializeDialogueReply idr = null;
- long endTime = (inContext.loginTimeoutSec > 0) ? currentTime + inContext.loginTimeoutSec * 1000 : Long.MAX_VALUE;
- int tryNum = 0;
- boolean done = false;
-
- boolean socketException = false;
- SQLException seSave = null;
-
- do {
- if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
- String temp = "Attempting initDiag. Try " + (tryNum + 1) + " of " + retryCount;
- t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", temp, t4props_);
- }
-
- socketException = false;
- try {
- t4connection_ = new T4Connection(this);
- idr = t4connection_.InitializeDialogue(setTimestamp, downloadCert);
- } catch (SQLException se) {
- //
- // We will retry socket exceptions, but will fail on all other
- // exceptions.
- //
- int sc = se.getErrorCode();
- int s1 = HPT4Messages.createSQLException(t4props_, locale, "socket_open_error", null).getErrorCode();
- int s2 = HPT4Messages.createSQLException(t4props_, locale, "socket_write_error", null).getErrorCode();
- int s3 = HPT4Messages.createSQLException(t4props_, locale, "socket_read_error", null).getErrorCode();
-
- if (sc == s1 || sc == s2 || sc == s3) {
- if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
- String temp = "A socket exception occurred: " + se.getMessage();
- t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", temp, t4props_);
- }
-
- socketException = true;
- seSave = se;
- } else {
- if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
- String temp = "A non-socket fatal exception occurred: " + se.getMessage();
- t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", temp, t4props_);
- }
-
- try {
- t4connection_.getInputOutput().CloseIO(new LogicalByteArray(1, 0, false));
- } catch (Exception e) {
- // ignore error
- }
-
- throw se;
- }
- }
-
- if (socketException == false) {
- if (idr.exception_nr == TRANSPORT.CEE_SUCCESS) {
- done = true;
- if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
- String temp = "initDiag Successful.";
- t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", temp, t4props_);
- }
- } else if (idr.exception_nr == odbc_SQLSvc_InitializeDialogue_exc_.odbc_SQLSvc_InitializeDialogue_SQLError_exn_ ||
- idr.exception_nr == odbc_SQLSvc_InitializeDialogue_exc_.odbc_SQLSvc_InitializeDialogue_InvalidUser_exn_) {
- if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
- String temp = "A SQL Warning or Error occurred during initDiag: " + idr.SQLError;
- t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", temp, t4props_);
- }
-
- int ex_nr = idr.exception_nr;
- int ex_nr_d = idr.exception_detail;
-
- if (ex_nr_d == odbc_SQLSvc_InitializeDialogue_exc_.SQL_PASSWORD_EXPIRING ||
- ex_nr_d == odbc_SQLSvc_InitializeDialogue_exc_.SQL_PASSWORD_GRACEPERIOD) {
- HPT4Messages.setSQLWarning(this.t4props_, this._t4Conn, idr.SQLError);
- done = true;
- } else {
- HPT4Messages.throwSQLException(t4props_, idr.SQLError);
- }
- }
- }
-
- currentTime = System.currentTimeMillis();
- tryNum = tryNum + 1;
- } while (done == false && endTime > currentTime && tryNum < retryCount);
-
- if (done == false) {
- SQLException se1;
- SQLException se2;
-
- if (socketException == true) {
- throw seSave;
- }
-
- if (currentTime >= endTime) {
- se1 = HPT4Messages.createSQLException(t4props_, locale, "ids_s1_t00", null);
- } else if (tryNum >= retryCount) {
- se1 = HPT4Messages.createSQLException(t4props_, locale, "as_connect_message_error",
- "exceeded retry count");
- } else {
- se1 = HPT4Messages.createSQLException(t4props_, locale, "as_connect_message_error", null);
- }
- throw se1;
- }
-
- //
- // Set the outcontext value returned by the ODBC MX server in the
- // serverContext
- //
- outContext = idr.outContext;
- enforceISO = outContext._enforceISO;
- this._roleName = outContext._roleName;
- this._ignoreCancel = outContext._ignoreCancel;
-
- t4props_.setDialogueID(Integer.toString(dialogueId_));
- t4props_.setServerID(m_ncsSrvr_ref);
-
- t4props_.setNcsMajorVersion(idr.outContext.versionList.list[0].majorVersion);
- t4props_.setNcsMinorVersion(idr.outContext.versionList.list[0].minorVersion);
- t4props_.setSqlmxMajorVersion(idr.outContext.versionList.list[1].majorVersion);
- t4props_.setSqlmxMinorVersion(idr.outContext.versionList.list[1].minorVersion);
-
- if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
- String temp = "Connection process successful";
- t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", temp, t4props_);
- }
- }
-
- private void encryptPassword() throws SecurityException, SQLException {
- byte [] pwBytes;
- byte [] roleBytes;
-
- String roleName = t4props_.getRoleName();
-
- try {
- pwBytes = t4props_.getPassword().getBytes("US-ASCII");
- roleBytes = (roleName != null && roleName.length() > 0)?roleName.getBytes("US-ASCII"):null;
- }
- catch (UnsupportedEncodingException uex) {
- //ERROR MESSAGE
- throw new SQLException("failed to find encoding");
- }
-
- userDesc.password = new byte[_security.getPwdEBufferLen()];
-
- _security.encryptPwd(pwBytes, roleBytes, userDesc.password);
- }
-
- private byte [] createProcInfo(int pid, int nid, byte [] timestamp) throws SQLException {
- byte [] procInfo;
-
- procInfo = new byte[16];
-
- ByteBuffer bb = ByteBuffer.allocate(16);
- bb.order(ByteOrder.LITTLE_ENDIAN);
- bb.putInt(pid);
- bb.putInt(nid);
- bb.put(timestamp);
- bb.rewind();
- bb.get(procInfo, 0, 16);
-
- return procInfo;
- }
-
- private void secureLogin(ConnectReply cr) throws SQLException {
- try {
- byte [] procInfo = createProcInfo(cr.processId, cr.serverNode, cr.timestamp);
- boolean tokenAuth = this.t4props_.getSPJEnv() && this.t4props_.getTokenAuth();
-
- _security = SecPwd.getInstance(
- this._t4Conn,
- this.t4props_.getCertificateDir(),
- this.t4props_.getCertificateFile(),
- cr.clusterName,
- tokenAuth,
- procInfo
- );
- }
- catch(SecurityException se) {
- CleanupServer(); //MXOSRVR is expecting InitDiag, clean it up since we failed
- throw se;
- }
-
- try {
- _security.openCertificate();
- this.encryptPassword();
- }catch(SecurityException se) {
- if(se.getErrorCode() != 29713) {
- throw se; //we have a fatal error
- }
-
- DownloadCertificate(); //otherwise, download and continue
- }
-
- try {
- inContext.connectOptions = new String(_security.getCertExpDate());
- initDiag(true,false);
- }catch(SQLException e) {
- if(outContext != null && outContext.certificate != null) { //we got a certificate back, switch to it, continue
- _security.switchCertificate(outContext.certificate);
- }
- else {
- throw e;
- }
-
- inContext.connectOptions = new String(_security.getCertExpDate());
- this.encryptPassword(); //re-encrypt
- this.initDiag(true,false); //re-initdiag
- }
- }
-
- private void CleanupServer() throws SQLException {
- this.userDesc.userName = null;
- this.userDesc.password = null;
-
- try {
- initDiag(false,false); //send dummy init diag to clean up server
- }catch(SQLException e) {
-
- }
-
- }
-
- private void DownloadCertificate() throws SQLException {
- //attempt download
- this.userDesc.userName = null;
- this.userDesc.password = null;
- inContext.connectOptions = null;
-
- try {
- initDiag(true,true);
- }catch(SQLException e) {
- if(outContext == null || outContext.certificate == null) {
- SQLException he = HPT4Messages.createSQLException(t4props_, this.locale, "certificate_download_error", e.getMessage());
- he.setNextException(e);
- throw he;
- }
- }
-
- this.userDesc.userName = this.t4props_.getUser();
-
- try {
- _security.switchCertificate(outContext.certificate);
- this.encryptPassword();
- }catch(SecurityException se1) {
- throw se1;
- }
- }
-
- private void connect() throws SQLException {
- short retryCount = 3;
- int srvrType = 2; // AS server
- ConnectReply cr = null;
-
- if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
- String msg = "Association Server URL: " + m_ncsSrvr_ref;
- t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", msg, t4props_);
- }
-
- //
- // Connect to the association server.
- //
- String errorText = null;
- boolean done = false;
- int tryNum = 0;
- String errorMsg = null;
- String errorMsg_detail = null;
- currentTime = System.currentTimeMillis();
- long endTime = (inContext.loginTimeoutSec > 0) ? currentTime + inContext.loginTimeoutSec * 1000
- : Long.MAX_VALUE;
-
- do {
- if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
- String temp = "Attempting getObjRef. Try " + (tryNum + 1) + " of " + retryCount;
- t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", temp, t4props_);
- }
-
- cr = T4_Dcs_Connect.getConnection(t4props_, this, inContext, userDesc, srvrType,
- retryCount);
-
- switch (cr.m_p1_exception.exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
- done = true;
- if (t4props_.t4Logger_.isLoggable(Level.INFO)) {
- String msg = "getObjRef Successful. Server URL: " + cr.m_p2_srvrObjRef;
- t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", msg, t4props_);
- }
- if (!cr.m_p4_dataSource.equals(t4props_.getServerDataSource())) {
- Object[] messageArguments = new Object[1];
- messageArguments[0] = cr.m_p4_dataSource;
- sqlwarning_ = HPT4Messages.createSQLWarning(t4props_, "connected_to_Default_DS", messageArguments);
- }
- break;
- case odbc_Dcs_GetObjRefHdl_exc_.odbc_Dcs_GetObjRefHdl_ASTryAgain_exn_:
- done = false;
- tryNum = tryNum + 1;
- errorMsg = "as_connect_message_error";
- errorMsg_detail = "try again request";
- if(tryNum < retryCount) {
- try {
- Thread.sleep(5000);
- }catch(Exception e) {}
- }
- break;
- case odbc_Dcs_GetObjRefHdl_exc_.odbc_Dcs_GetObjRefHdl_ASNotAvailable_exn_:
- done = false;
- tryNum = tryNum + 1;
- errorMsg = "as_connect_message_error";
- errorMsg_detail = "association server not available";
- break;
- case odbc_Dcs_GetObjRefHdl_exc_.odbc_Dcs_GetObjRefHdl_DSNotAvailable_exn_:
- done = false;
- tryNum = tryNum + 1;
- errorMsg = "as_connect_message_error";
- errorMsg_detail = "data source not available";
- break;
- case odbc_Dcs_GetObjRefHdl_exc_.odbc_Dcs_GetObjRefHdl_PortNotAvailable_exn_:
- done = false;
- tryNum = tryNum + 1;
- errorMsg = "as_connect_message_error";
- errorMsg_detail = "port not available";
- break;
- case odbc_Dcs_GetObjRefHdl_exc_.odbc_Dcs_GetObjRefHdl_ASNoSrvrHdl_exn_:
- done = false;
- tryNum = tryNum + 1;
- errorMsg = "as_connect_message_error";
- errorMsg_detail = "server handle not available";
- break;
- default:
-
- //
- // Some unknown error
- //
- if (cr.m_p1_exception.clientErrorText != null) {
- errorText = "Client Error text = " + cr.m_p1_exception.clientErrorText;
-
- }
- errorText = errorText + " :Exception = " + cr.m_p1_exception.exception_nr;
- errorText = errorText + " :" + "Exception detail = " + cr.m_p1_exception.exception_detail;
- errorText = errorText + " :" + "Error code = " + cr.m_p1_exception.errorCode;
-
- if (cr.m_p1_exception.ErrorText != null) {
- errorText = errorText + " :" + "Error text = " + cr.m_p1_exception.ErrorText;
-
- }
- throw HPT4Messages.createSQLException(t4props_, locale, "as_connect_message_error", errorText);
- }
-
- if (done == false && t4props_.t4Logger_.isLoggable(Level.INFO)) {
- String msg = "getObjRef Failed. Message from Association Server: " + errorMsg_detail;
- t4props_.t4Logger_.logp(Level.INFO, "InterfaceConnection", "connect", msg, t4props_);
- }
-
- currentTime = System.currentTimeMillis();
- } while (done == false && endTime > currentTime && tryNum < retryCount);
-
- if (done == false) {
- SQLException se1;
- SQLException se2;
-
- if (currentTime >= endTime) {
- se1 = HPT4Messages.createSQLException(t4props_, locale, "ids_s1_t00", null);
- se2 = HPT4Messages.createSQLException(t4props_, locale, errorMsg, errorMsg_detail);
- se1.setNextException(se2);
- } else {
- se1 = HPT4Messages.createSQLException(t4props_, locale, errorMsg, errorMsg_detail);
- }
-
- throw se1;
- }
-
- dialogueId_ = cr.m_p3_dialogueId;
- m_ncsSrvr_ref = cr.m_p2_srvrObjRef;
- _remoteProcess = "\\" + cr.remoteHost + "." + cr.remoteProcess;
-
- ncsAddr_ = cr.getNCSAddress();
- this.byteSwap = cr.byteSwap;
- this._serverDataSource = cr.m_p4_dataSource;
-
- setISOMapping(cr.isoMapping);
-
- if (cr.isoMapping == InterfaceUtilities.getCharsetValue("ISO8859_1")) {
- setTerminalCharset(InterfaceUtilities.getCharsetValue("ISO8859_1"));
- this.inContext.ctxDataLang = 0;
- this.inContext.ctxErrorLang = 0;
- } else {
- setTerminalCharset(InterfaceUtilities.getCharsetValue("UTF-8"));
- }
-
- if(cr.securityEnabled) {
- this.secureLogin(cr);
- }
- else {
- this.oldEncryptPassword();
- this.initDiag(false,false);
- }
- }
-
- // @deprecated
- void isConnectionClosed() throws SQLException {
- if (isClosed_ == false) {
- throw HPT4Messages.createSQLException(t4props_, locale, "invalid_connection", null);
- }
- }
-
- // @deprecated
- void isConnectionOpen() throws SQLException {
- if (isClosed_) {
- throw HPT4Messages.createSQLException(t4props_, locale, "invalid_connection", null);
- }
- }
-
- // @deprecated
- boolean getIsClosed() {
- return isClosed_;
- }
-
- void setIsClosed(boolean isClosed) {
- this.isClosed_ = isClosed;
- }
-
- String getUrl() {
- return m_ncsSrvr_ref;
- }
-
- void setCatalog(TrafT4Connection conn, String catalog) throws SQLException {
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(conn.props_, catalog);
- String temp = "Setting connection catalog = " + catalog;
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setCatalog", temp, p);
- }
- if (catalog != null && catalog.length() == 0) {
- catalog = T4Properties.DEFAULT_CATALOG;
- }
- setConnectionAttr(conn, SQL_ATTR_CURRENT_CATALOG, 0, catalog);
- outContext.catalog = catalog;
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(conn.props_, catalog);
- String temp = "Setting connection catalog = " + catalog + " is done.";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setCatalog", temp, p);
- }
- };
-
- // enforces the connection timeout set by the user
- // to be called by the connection pooling mechanism whenever a connection is
- // given to the user from the pool
- void enforceT4ConnectionTimeout(TrafT4Connection conn) throws SQLException {
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(conn.props_, (short) t4props_.getConnectionTimeout());
- String temp = "Enforcing connection timeout = " + (short) t4props_.getConnectionTimeout();
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "enforceT4ConnectionTimeout", temp, p);
- }
- inContext.idleTimeoutSec = (short) t4props_.getConnectionTimeout();
- setConnectionAttr(conn, JDBC_ATTR_CONN_IDLE_TIMEOUT, inContext.idleTimeoutSec, String
- .valueOf(inContext.idleTimeoutSec));
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(conn.props_, (short) t4props_.getConnectionTimeout());
- String temp = "Enforcing connection timeout = " + (short) t4props_.getConnectionTimeout() + " is done.";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "enforceT4ConnectionTimeout", temp, p);
- }
- };
-
- // disregards the T4's connectionTimeout value (set during initialize
- // dialog) and
- // enforces the connection timeout set by the NCS datasource settings
- // to be called by the connection pooling mechanism whenever a connection is
- // put into the pool (after a user has called connection.close())
- void disregardT4ConnectionTimeout(TrafT4Connection conn) throws SQLException {
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(conn.props_, "-1");
- String temp = "Setting connection timeout = -1";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "disregardT4ConnectionTimeout", temp, p);
- }
- setConnectionAttr(conn, JDBC_ATTR_CONN_IDLE_TIMEOUT, -1, "-1");
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(conn.props_, "-1");
- String temp = "Setting connection timeout = -1 is done.";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "disregardT4ConnectionTimeout", temp, p);
- }
- };
-
- void setConnectionAttr(TrafT4Connection conn, short attr, int valueNum, String valueString) throws SQLException {
- SetConnectionOptionReply scr_;
- isConnectionOpen();
-
- try {
- scr_ = t4connection_.SetConnectionOption(attr, valueNum, valueString);
- //3196 - NDCS transaction for SPJ
- if (attr == SQL_ATTR_JOIN_UDR_TRANSACTION) {
- transId_ = Long.valueOf(valueString);
- suspendRequest_ = true;
- }
- else if (attr == SQL_ATTR_SUSPEND_UDR_TRANSACTION) {
- transId_ = Long.valueOf(valueString);
- suspendRequest_ = false;
- }
- } catch (SQLException tex) {
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(conn.props_, attr, valueNum, valueString);
- String temp = "NDCS or SQLException occurred.";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setConnectionAttr", temp, p);
- }
- throw tex;
- }
-
- switch (scr_.m_p1.exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
-
- // do the warning processing
- if (scr_.m_p2.length != 0) {
- HPT4Messages.setSQLWarning(conn.props_, conn, scr_.m_p2);
- }
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(conn.props_, attr, valueNum, valueString);
- String temp = "Setting connection attribute is done.";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setConnectionAttr", temp, p);
- }
- break;
- case odbc_SQLSvc_SetConnectionOption_exc_.odbc_SQLSvc_SetConnectionOption_SQLError_exn_:
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(conn.props_, attr, valueNum, valueString);
- String temp = "odbc_SQLSvc_SetConnectionOption_SQLError_exn_ occurred.";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setConnectionAttr", temp, p);
- }
- HPT4Messages.throwSQLException(t4props_, scr_.m_p1.errorList);
- default:
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(conn.props_, attr, valueNum, valueString);
- String temp = "UnknownException occurred.";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setConnectionAttr", temp, p);
- }
- throw HPT4Messages.createSQLException(conn.props_, locale, "ids_unknown_reply_error", null);
- }
- };
-
- void setTransactionIsolation(TrafT4Connection conn, int level) throws SQLException {
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(conn.props_, level);
- String temp = "Setting transaction isolation = " + level;
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setTransactionIsolation", temp, p);
- }
- isConnectionOpen();
-
- if (level != Connection.TRANSACTION_NONE && level != Connection.TRANSACTION_READ_COMMITTED
- && level != Connection.TRANSACTION_READ_UNCOMMITTED && level != Connection.TRANSACTION_REPEATABLE_READ
- && level != Connection.TRANSACTION_SERIALIZABLE) {
- throw HPT4Messages.createSQLException(conn.props_, locale, "invalid_transaction_isolation", null);
- }
-
- txnIsolationLevel = level;
-
- switch (txnIsolationLevel) {
- case Connection.TRANSACTION_NONE:
- inContext.txnIsolationLevel = (short) SQL_TXN_READ_COMMITTED;
- break;
- case Connection.TRANSACTION_READ_COMMITTED:
- inContext.txnIsolationLevel = (short) SQL_TXN_READ_COMMITTED;
- break;
- case Connection.TRANSACTION_READ_UNCOMMITTED:
- inContext.txnIsolationLevel = (short) SQL_TXN_READ_UNCOMMITTED;
- break;
- case Connection.TRANSACTION_REPEATABLE_READ:
- inContext.txnIsolationLevel = (short) SQL_TXN_REPEATABLE_READ;
- break;
- case Connection.TRANSACTION_SERIALIZABLE:
- inContext.txnIsolationLevel = (short) SQL_TXN_SERIALIZABLE;
- break;
- default:
- inContext.txnIsolationLevel = (short) SQL_TXN_READ_COMMITTED;
- break;
- }
-
- setConnectionAttr(conn, SQL_TXN_ISOLATION, inContext.txnIsolationLevel, String
- .valueOf(inContext.txnIsolationLevel));
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(conn.props_, level);
- String temp = "Setting transaction isolation = " + level + " is done.";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setTransactionIsolation", temp, p);
- }
- };
-
- int getTransactionIsolation() throws SQLException {
- return txnIsolationLevel;
- }
-
- long getTxid() {
- return txid;
- }
-
- void setTxid(long txid) {
- this.txid = txid;
- }
-
- boolean getAutoCommit() {
- return autoCommit;
- }
-
- void setAutoCommit(TrafT4Connection conn, boolean autoCommit) throws SQLException {
- isConnectionOpen();
- boolean commit = this.autoCommit;
-
- this.autoCommit = autoCommit;
-
- if (autoCommit == false) {
- inContext.autoCommit = 0;
- } else {
- inContext.autoCommit = 1;
-
- }
- try {
- setConnectionAttr(conn, SQL_ATTR_AUTOCOMMIT, inContext.autoCommit, String.valueOf(inContext.autoCommit));
- } catch (SQLException sqle) {
- this.autoCommit = commit;
- throw sqle;
- }
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(conn.props_, autoCommit);
- String temp = "Setting autoCommit = " + autoCommit + " is done.";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "setAutoCommit", temp, p);
- }
- }
-
- void enableNARSupport(TrafT4Connection conn, boolean NARSupport) throws SQLException {
- int val = NARSupport ? 1 : 0;
- setConnectionAttr(conn, TRANSPORT.SQL_ATTR_ROWSET_RECOVERY, val, String.valueOf(val));
- }
-
- void enableProxySyntax(TrafT4Connection conn) throws SQLException {
- setConnectionAttr(conn, InterfaceConnection.SPJ_ENABLE_PROXY, 1, "1");
- }
-
- boolean isReadOnly() {
- return isReadOnly;
- }
-
- void setReadOnly(boolean readOnly) throws SQLException {
- isConnectionOpen();
- this.isReadOnly = readOnly;
- }
- void setReadOnly(TrafT4Connection conn, boolean readOnly) throws SQLException {
- isConnectionOpen();
- this.isReadOnly = readOnly;
- if (readOnly == false) {
- inContext.accessMode = 0;
- } else {
- inContext.accessMode = 1;
-
- }
- setConnectionAttr(conn, SQL_ATTR_ACCESS_MODE, inContext.accessMode, String.valueOf(inContext.accessMode));
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(conn.props_, readOnly);
- String temp = "Setting readOnly = " + readOnly + " is done.";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "readOnly", temp, p);
- }
-
- }
-
- void close() throws SQLException {
- TerminateDialogueReply tdr_ = null;
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(t4props_);
- String temp = "Terminate Dialogue.";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "close", temp, p);
- }
-
- //3196 - NDCS transaction for SPJ
- if (suspendRequest_) {
- _t4Conn.suspendUDRTransaction();
- }
-
- SecPwd.removeInstance(this._t4Conn);
-
- try {
- tdr_ = t4connection_.TerminateDialogue();
- } catch (SQLException tex) {
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(t4props_);
- String temp = "SQLException during TerminateDialogue.";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "close", temp, p);
- }
- throw tex;
- }
-
- switch (tdr_.m_p1.exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
- break;
- case odbc_SQLSvc_TerminateDialogue_exc_.odbc_SQLSvc_TerminateDialogue_SQLError_exn_:
- //ignore errors
- }
-
- // needs work here. This should be proxy destroy. close the logfiles
- try {
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(t4props_);
- String temp = "Terminate Dialogue successful.";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "close", temp, p);
- }
- } catch (java.lang.SecurityException sex) {
- }
- };
-
- void endTransaction(short commitOption) throws SQLException {
- EndTransactionReply etr_ = null;
- if (autoCommit && !_t4Conn.isBeginTransaction()) {
- throw HPT4Messages.createSQLException(t4props_, locale, "invalid_commit_mode", null);
- }
-
- isConnectionOpen();
- // XA_RESUMETRANSACTION();
-
- try {
- etr_ = t4connection_.EndTransaction(commitOption);
- _t4Conn.setBeginTransaction(false);
- } catch (SQLException tex) {
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(t4props_, commitOption);
- String temp = "SQLException during EndTransaction." + tex.toString();
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "endTransaction", temp, p);
- }
- throw tex;
- }
-
- switch (etr_.m_p1.exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
- break;
- case odbc_SQLSvc_EndTransaction_exc_.odbc_SQLSvc_EndTransaction_ParamError_exn_:
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(t4props_, commitOption);
- String temp = "odbc_SQLSvc_EndTransaction_ParamError_exn_ :";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "endTransaction", temp, p);
- }
- throw HPT4Messages.createSQLException(t4props_, locale, "ParamError:" + etr_.m_p1.ParamError, null);
- case odbc_SQLSvc_EndTransaction_exc_.odbc_SQLSvc_EndTransaction_InvalidConnection_exn_:
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(t4props_, commitOption);
- String temp = "odbc_SQLSvc_EndTransaction_InvalidConnection_exn_:";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "endTransaction", temp, p);
- }
- throw new SQLException("odbc_SQLSvc_EndTransaction_InvalidConnection_exn", "HY100002", 10001);
- case odbc_SQLSvc_EndTransaction_exc_.odbc_SQLSvc_EndTransaction_SQLError_exn_:
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(t4props_, commitOption);
- String temp = "odbc_SQLSvc_EndTransaction_SQLError_exn_:" + etr_.m_p1.SQLError;
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "endTransaction", temp, p);
- }
- HPT4Messages.throwSQLException(t4props_, etr_.m_p1.SQLError);
- case odbc_SQLSvc_EndTransaction_exc_.odbc_SQLSvc_EndTransaction_SQLInvalidHandle_exn_:
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(t4props_, commitOption);
- String temp = "odbc_SQLSvc_EndTransaction_SQLInvalidHandle_exn_:";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "endTransaction", temp, p);
- }
- throw new SQLException("odbc_SQLSvc_EndTransaction_SQLInvalidHandle_exn", "HY100004", 10001);
- case odbc_SQLSvc_EndTransaction_exc_.odbc_SQLSvc_EndTransaction_TransactionError_exn_:
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(t4props_, commitOption);
- String temp = "odbc_SQLSvc_EndTransaction_TransactionError_exn_:";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "endTransaction", temp, p);
- }
- throw new SQLException("odbc_SQLSvc_EndTransaction_TransactionError_exn", "HY100005", 10001);
- default:
- if (t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(t4props_, commitOption);
- String temp = "UnknownError:";
- t4props_.t4Logger_.logp(Level.FINEST, "InterfaceConnection", "endTransaction", temp, p);
- }
- throw new SQLException("Unknown Error during EndTransaction", "HY100001", 10001);
- }
-
- };
-
- long beginTransaction() throws SQLException {
- isConnectionOpen();
-
- return txid;
- };
-
- void reuse() {
- txnIsolationLevel = Connection.TRANSACTION_READ_COMMITTED;
- autoCommit = true;
- isReadOnly = false;
- isClosed_ = false;
- txid = 0;
- t4connection_.reuse();
- };
-
- boolean useArrayBinding() {
- return useArrayBinding_;
- }
-
- short getTransportBufferSize() {
- return transportBufferSize_;
- }
-
- // methods for handling weak connections
- void removeElement(TrafT4Connection conn) {
- refTosrvrCtxHandle_.remove(conn.pRef_);
- conn.pRef_.clear();
- }
-
- void gcConnections() {
- Reference pRef;
- InterfaceConnection ic;
- while ((pRef = refQ_.poll()) != null) {
- ic = (InterfaceConnection) refTosrvrCtxHandle_.get(pRef);
- // All PreparedStatement objects are added to Hashtable
- // Only Statement objects that produces ResultSet are added to
- // Hashtable
- // Hence stmtLabel could be null
- if (ic != null) {
- try {
- ic.close();
- } catch (SQLException e) {
- } finally {
- refTosrvrCtxHandle_.remove(pRef);
- }
- }
- }
- }
-
- public byte[] encodeString(String str, int charset) throws CharacterCodingException, UnsupportedCharsetException {
- Integer key = new Integer(charset);
- CharsetEncoder ce;
- byte[] ret = null;
-
- if (str != null) {
- if (this.isoMapping_ == InterfaceUtilities.SQLCHARSETCODE_ISO88591 && !this.enforceISO) {
- ret = str.getBytes(); //convert the old way
- } else {
- if ((ce = (CharsetEncoder) encoders.get(key)) == null) { //only create a new encoder if its the first time
- String charsetName = InterfaceUtilities.getCharsetName(charset);
-
- //encoder needs to be based on our current swap flag for UTF-16 data
- //this should be redesigned when we fixup character set issues for SQ
- if(key == InterfaceUtilities.SQLCHARSETCODE_UNICODE && this.byteSwap == true) {
- charsetName = "UTF-16LE";
- }
-
- Charset c = Charset.forName(charsetName);
- ce = c.newEncoder();
- ce.onUnmappableCharacter(CodingErrorAction.REPORT);
- encoders.put(key, ce);
- }
-
- synchronized(ce) { //since one connection shares encoders
- ce.reset();
- ByteBuffer buf = ce.encode(CharBuffer.wrap(str));
- ret = new byte[buf.remaining()];
- buf.get(ret, 0, ret.length);
- }
- }
- }
-
- return ret;
- }
-
- public String decodeBytes(byte[] data, int charset) throws CharacterCodingException, UnsupportedCharsetException {
- Integer key = new Integer(charset);
- CharsetDecoder cd;
- String str = null;
-
- // we use this function for USC2 columns as well and we do NOT want to
- // apply full pass-thru mode for them
- if (this.isoMapping_ == InterfaceUtilities.SQLCHARSETCODE_ISO88591 && !this.enforceISO
- && charset != InterfaceUtilities.SQLCHARSETCODE_UNICODE) {
- str = new String(data);
- } else {
- // the following is a fix for JDK 1.4.2 and MS932. For some reason
- // it does not handle single byte entries properly
- boolean fix = false;
- if (charset == 10 && data.length == 1) {
- data = new byte[] { 0, data[0] };
- fix = true;
- }
-
- if ((cd = (CharsetDecoder) decoders.get(key)) == null) { //only create a decoder if its the first time
- String charsetName = InterfaceUtilities.getCharsetName(charset);
-
- //encoder needs to be based on our current swap flag for UTF-16 data
- //this should be redesigned when we fixup character set issues for SQ
- if(key == InterfaceUtilities.SQLCHARSETCODE_UNICODE && this.byteSwap == true) {
- charsetName = "UTF-16LE";
- }
-
- Charset c = Charset.forName(charsetName);
- cd = c.newDecoder();
- cd.replaceWith(this.t4props_.getReplacementString());
- cd.onUnmappableCharacter(CodingErrorAction.REPLACE);
- decoders.put(key, cd);
- }
-
- synchronized(cd) { //one decoder for the entire connection
- cd.reset();
- str = cd.decode(ByteBuffer.wrap(data)).toString();
- }
-
- if (fix)
- str = str.substring(1);
- }
-
- return str;
- }
-
- public String getApplicationName() {
- return this.t4props_.getApplicationName();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InterfaceResultSet.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InterfaceResultSet.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InterfaceResultSet.java
deleted file mode 100644
index 0d7c0b4..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/InterfaceResultSet.java
+++ /dev/null
@@ -1,927 +0,0 @@
-// @@@ 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;
-import java.math.BigInteger;
-import java.sql.Date;
-import java.sql.SQLException;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.text.DecimalFormat;
-import java.text.FieldPosition;
-import java.util.Properties;
-import java.util.logging.Level;
-
-class InterfaceResultSet {
- InterfaceConnection ic_;
- String stmtLabel_;
-
- /* CHAR/CHARACTER */
- static final int SQLTYPECODE_CHAR = 1;
-
- /* NUMERIC */
- static final int SQLTYPECODE_NUMERIC = 2;
- static final int SQLTYPECODE_NUMERIC_UNSIGNED = -201;
-
- /* DECIMAL */
- static final int SQLTYPECODE_DECIMAL = 3;
-
- static final int SQLTYPECODE_DECIMAL_UNSIGNED = -301;
- static final int SQLTYPECODE_DECIMAL_LARGE = -302;
- static final int SQLTYPECODE_DECIMAL_LARGE_UNSIGNED = -303;
-
- /* INTEGER/INT */
- static final int SQLTYPECODE_INTEGER = 4;
-
- static final int SQLTYPECODE_INTEGER_UNSIGNED = -401;
- static final int SQLTYPECODE_LARGEINT = -402;
-
- /* SMALLINT */
- static final int SQLTYPECODE_SMALLINT = 5;
-
- static final int SQLTYPECODE_SMALLINT_UNSIGNED = -502;
-
- static final int SQLTYPECODE_BPINT_UNSIGNED = -503;
-
- /*
- * DOUBLE depending on precision
- */
- static final int SQLTYPECODE_FLOAT = 6;
-
- /*
- */
- static final int SQLTYPECODE_REAL = 7;
-
- /*
- */
- static final int SQLTYPECODE_DOUBLE = 8;
-
- /* DATE,TIME,TIMESTAMP */
- static final int SQLTYPECODE_DATETIME = 9;
-
- /* TIMESTAMP */
- static final int SQLTYPECODE_INTERVAL = 10;
-
- /* no ANSI value 11 */
-
- /* VARCHAR/CHARACTER VARYING */
- static final int SQLTYPECODE_VARCHAR = 12;
-
- /* SQL/MP stype VARCHAR with length prefix:
- * */
- static final int SQLTYPECODE_VARCHAR_WITH_LENGTH = -601;
- static final int SQLTYPECODE_BLOB = -602;
- static final int SQLTYPECODE_CLOB = -603;
-
- /* LONG VARCHAR/ODBC CHARACTER VARYING */
- static final int SQLTYPECODE_VARCHAR_LONG = -1; /* ## NEGATIVE??? */
-
- /* no ANSI value 13 */
-
- /* BIT */
- static final int SQLTYPECODE_BIT = 14; /* not supported */
-
- /* BIT VARYING */
- static final int SQLTYPECODE_BITVAR = 15; /* not supported */
-
- /* NCHAR -- CHAR(n) CHARACTER SET s -- where s uses two bytes per char */
- static final int SQLTYPECODE_CHAR_DBLBYTE = 16;
-
- /* NCHAR VARYING -- VARCHAR(n) CHARACTER SET s -- s uses 2 bytes per char */
- static final int SQLTYPECODE_VARCHAR_DBLBYTE = 17;
-
- /* Date/Time/TimeStamp related constants */
- static final int SQLDTCODE_DATE = 1;
- static final int SQLDTCODE_TIME = 2;
- static final int SQLDTCODE_TIMESTAMP = 3;
- static final int SQLDTCODE_MPDATETIME = 4;
- static final int dateLength = 10;
- static final int timeLength = 8;
- static final int timestampLength = 26;
-
- T4ResultSet t4resultSet_;
-
- static Properties javaLangToJavaNio = null;
-
- TrafT4ResultSet rs_;
-
- InterfaceResultSet(TrafT4ResultSet rs) throws SQLException {
- this.ic_ = ((TrafT4Connection) rs.connection_).getServerHandle();
- stmtLabel_ = rs.stmtLabel_;
- t4resultSet_ = new T4ResultSet(this);
- rs_ = rs;
- };
-
- // -------------------------------------------------------------------
- // from nskieee.cpp -- find the length for the data based on datatype
- //
- static int dataLengthFetchPerf(int SQLDataType, int SQLDateTimeCode, int SQLOctetLength, int maxRowLen,
- int bufferLen, int ODBCDataType, int ODBCPrecision) {
- int allocLength = 0;
- switch (SQLDataType) {
- case SQLTYPECODE_INTERVAL:
- allocLength = SQLOctetLength;
- break;
- case SQLTYPECODE_VARCHAR_WITH_LENGTH:
- case SQLTYPECODE_VARCHAR_LONG:
- case SQLTYPECODE_VARCHAR_DBLBYTE:
- case SQLTYPECODE_BITVAR:
- case SQLTYPECODE_BLOB:
- case SQLTYPECODE_CLOB:
- allocLength = bufferLen + 2;
- break;
- case SQLTYPECODE_CHAR:
-
- // allocLength = SQLOctetLength - 1; // no null at the end
- allocLength = SQLOctetLength;
- if (maxRowLen > 0) {
- allocLength = (allocLength > maxRowLen) ? (maxRowLen + 1) : (allocLength);
- }
- break;
- case SQLTYPECODE_BIT:
- case SQLTYPECODE_CHAR_DBLBYTE:
- case SQLTYPECODE_VARCHAR:
- allocLength = SQLOctetLength - 1; // no null at the end
- if (maxRowLen > 0) {
- allocLength = (allocLength > maxRowLen) ? (maxRowLen + 1) : (allocLength);
- }
- break;
- case SQLTYPECODE_DATETIME:
- switch (SQLDateTimeCode) {
- case SQLDTCODE_DATE:
- allocLength = dateLength;
- break;
- case SQLDTCODE_TIME:
- if (ODBCDataType == java.sql.Types.OTHER) // For
- // HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION
- {
- allocLength = SQLOctetLength;
- } else {
- allocLength = timeLength;
- }
- break;
- case SQLDTCODE_TIMESTAMP:
-
- /*
- * allocLength = timestampLength; if (SQLOctetLength <
- * timestampLength) { allocLength = 19; // timestamp without
- * fraction }
- */
- allocLength = ODBCPrecision;
- break;
- default:
- allocLength = SQLOctetLength;
- break;
- }
-
- break;
- default:
- allocLength = SQLOctetLength; // exclude nullable
- break;
- }
- return allocLength;
- }
-
- // -------------------------------------------------------------------
- // get the column value data in String format
- Object getFetchString(TrafT4Connection conn, int scale, int SQLDataType, int SQLDatetimeCode, int FSDataType,
- byte[] ibuffer, int byteIndex, int byteLen, int SQLcharset, int ODBCDataType) throws SQLException {
- Object retObj;
- String tmpStr;
- byte[] tbuffer;
- BigDecimal tmpbd;
-
- switch (SQLDataType) {
-
- case SQLTYPECODE_CHAR:
- tbuffer = new byte[byteLen];
- System.arraycopy(ibuffer, byteIndex, tbuffer, 0, byteLen);
- retObj = tbuffer;
- break;
- case SQLTYPECODE_VARCHAR:
- tbuffer = new byte[byteLen];
- System.arraycopy(ibuffer, byteIndex, tbuffer, 0, byteLen);
- retObj = tbuffer;
- break;
- case SQLTYPECODE_INTERVAL:
- tbuffer = new byte[byteLen];
- System.arraycopy(ibuffer, byteIndex, tbuffer, 0, byteLen);
- retObj = tbuffer;
- break;
- case SQLTYPECODE_VARCHAR_WITH_LENGTH:
- case SQLTYPECODE_VARCHAR_LONG:
- case SQLTYPECODE_BLOB:
- case SQLTYPECODE_CLOB:
- tbuffer = new byte[byteLen - 2];
- System.arraycopy(ibuffer, byteIndex + 2, tbuffer, 0, byteLen - 2);
-
- // retObj = new String(tbuffer); Swastik for LOB Support 10/29/2004
- retObj = tbuffer;
- break;
- case SQLTYPECODE_DATETIME:
- tmpStr = new String(Bytes.read_chars(ibuffer, byteIndex, byteLen));
- switch (SQLDatetimeCode) {
- case SQLDTCODE_DATE:
- retObj = Date.valueOf(tmpStr);
- break;
- case SQLDTCODE_TIMESTAMP:
- retObj = Timestamp.valueOf(tmpStr);
- break;
- case SQLDTCODE_TIME:
-
- // Need to add code here to check if it's
- // HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION
- if (ODBCDataType != java.sql.Types.OTHER) {
- retObj = Time.valueOf(tmpStr);
- break;
- } else {
- // Do default processing as it is
- // HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION
- }
- default:
- retObj = tmpStr;
- break;
- }
- break;
- case SQLTYPECODE_SMALLINT:
- short sValue = Bytes.extractShort(ibuffer, byteIndex, this.ic_.getByteSwap());
- retObj = new Short(sValue);
- if (scale > 0) {
- retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
- }
- break;
- case SQLTYPECODE_SMALLINT_UNSIGNED:
- retObj = new Integer(Bytes.extractUShort(ibuffer, byteIndex, this.ic_.getByteSwap()));
- if (scale > 0) {
- retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
- }
- break;
- case SQLTYPECODE_INTEGER:
- retObj = new Integer(Bytes.extractInt(ibuffer, byteIndex, this.ic_.getByteSwap()));
- if (scale > 0) {
- retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
- }
- break;
- case SQLTYPECODE_INTEGER_UNSIGNED:
- retObj = new Long(Bytes.extractUInt(ibuffer, byteIndex, this.ic_.getByteSwap()));
- if (scale > 0) {
- retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
- }
- break;
- case SQLTYPECODE_LARGEINT:
- tbuffer = new byte[byteLen];
- System.arraycopy(ibuffer, byteIndex, tbuffer, 0, byteLen);
- retObj = new BigInteger(tbuffer);
- if (scale > 0) {
- retObj = new BigDecimal((BigInteger) retObj, scale);
- }
- break;
- case SQLTYPECODE_NUMERIC:
- case SQLTYPECODE_NUMERIC_UNSIGNED:
- switch (FSDataType) {
- case 130:
- case 131:
- tmpStr = String.valueOf(Bytes.extractShort(ibuffer, byteIndex, this.ic_.getByteSwap()));
- break;
- case 132:
- case 133:
- tmpStr = String.valueOf(Bytes.extractInt(ibuffer, byteIndex, this.ic_.getByteSwap()));
- break;
- case 134:
- tmpStr = String.valueOf(Bytes.extractLong(ibuffer, byteIndex, this.ic_.getByteSwap()));
- break;
- default:
- throw HPT4Messages.createSQLException(conn.props_, conn.getLocale(), "restricted_data_type", null);
- }
- retObj = new BigDecimal((new BigInteger(tmpStr)), scale);
- break;
- case SQLTYPECODE_DECIMAL:
- case SQLTYPECODE_DECIMAL_UNSIGNED:
- case SQLTYPECODE_DECIMAL_LARGE:
- case SQLTYPECODE_DECIMAL_LARGE_UNSIGNED:
- String retStr;
-
- // check if the sign is minus (-80)
- byte sign = (byte) (ibuffer[byteIndex] & (byte) (-80));
-
- // first byte = inbyte - (-80)
- if (sign == (byte) (-80)) {
- byte firstByte = (byte) (ibuffer[byteIndex] - (byte) (-80));
- retStr = "-" + firstByte + String.valueOf(Bytes.read_chars(ibuffer, byteIndex + 1, byteLen - 1));
- } else {
- retStr = String.valueOf(Bytes.read_chars(ibuffer, byteIndex, byteLen));
- }
- retObj = new BigDecimal(new BigInteger(retStr), scale);
- break;
- case SQLTYPECODE_REAL:
- retObj = new Float(Float.intBitsToFloat(Bytes.extractInt(ibuffer, byteIndex, this.ic_.getByteSwap())));
- break;
- case SQLTYPECODE_DOUBLE:
- case SQLTYPECODE_FLOAT:
- retObj = new Double(Double.longBitsToDouble(Bytes.extractLong(ibuffer, byteIndex, this.ic_.getByteSwap())));
- break;
- case SQLTYPECODE_BIT:
- case SQLTYPECODE_BITVAR:
- case SQLTYPECODE_BPINT_UNSIGNED:
- default:
- throw HPT4Messages.createSQLException(conn.props_, conn.getLocale(), "restricted_data_type", null);
- }
- return retObj;
- } // end getFetchString
-
- private static String padZero(long i, int len) {
- String s = String.valueOf(i);
-
- while (s.length() < len)
- s = '0' + s;
-
- return s;
- }
-
- // -------------------------------------------------------------------
- // get the column value data from Execute2 in String format
- static Object getExecute2FetchString(TrafT4Connection conn, HPT4Desc desc, byte[] values, int noNullValue,
- int ODBCDataType, boolean useOldDateFormat, boolean swap) throws SQLException {
- Object retObj;
- String tmpStr;
- byte[] tbuffer;
- BigDecimal tmpbd;
- int length;
- int year, month, day, hour, minute, second;
- long nanoSeconds;
-
- switch (desc.sqlDataType_) {
- case SQLTYPECODE_CHAR:
- length = desc.sqlOctetLength_;
- tbuffer = new byte[length];
- System.arraycopy(values, noNullValue, tbuffer, 0, length);
- retObj = tbuffer;
- break;
- case SQLTYPECODE_VARCHAR:
- case SQLTYPECODE_VARCHAR_WITH_LENGTH:
- case SQLTYPECODE_VARCHAR_LONG:
- case SQLTYPECODE_BLOB:
- case SQLTYPECODE_CLOB:
- boolean shortLength = desc.precision_ < Math.pow(2, 15);
- int dataOffset = noNullValue + ((shortLength) ? 2 : 4);
-
- length = (shortLength) ? Bytes.extractShort(values, noNullValue, swap) : Bytes.extractInt(values, noNullValue, swap);
-
- tbuffer = new byte[length];
- int len = values.length - (dataOffset);
- System.arraycopy(values, (dataOffset), tbuffer, 0, (length > len) ? len : length);
- retObj = tbuffer;
- break;
- case SQLTYPECODE_INTERVAL:
- length = desc.sqlOctetLength_;
- tbuffer = new byte[length];
- System.arraycopy(values, noNullValue, tbuffer, 0, length);
- retObj = tbuffer;
- break;
- case SQLTYPECODE_DATETIME:
- switch (desc.sqlDatetimeCode_) {
- case SQLDTCODE_DATE:
- if (!useOldDateFormat) // new date format, only for bulk move
- {
- // "yyyy-mm-dd"
- year = Bytes.extractUShort(values, noNullValue, swap);
- month = values[noNullValue + 2];
- day = values[noNullValue + 3];
- String t = padZero(year,4) + "-" + padZero(month,2) + "-" + padZero(day,2);
- retObj = Date.valueOf(t);
- } else {// do the old way
- length = dateLength;
- retObj = Date.valueOf(new String(Bytes.read_chars(values, noNullValue, length)));
- }
- break;
- case SQLDTCODE_TIMESTAMP:
- if (!useOldDateFormat) // new date format, if not SQLCatalogs
- {
- // yyyy-mm-dd hh:mm:ss.fffffffff
- year = Bytes.extractUShort(values, noNullValue, swap);
- month = values[noNullValue + 2];
- day = values[noNullValue + 3];
- hour = values[noNullValue + 4];
- minute = values[noNullValue + 5];
- second = values[noNullValue + 6];
-
- if (desc.sqlPrecision_ > 0) {
- nanoSeconds = Bytes.extractUInt(values, noNullValue + 7, swap);
-
- if (nanoSeconds > 999999) // returned in microseconds
- nanoSeconds = 0;
-
- // apply leading 0's for string conversion
- tmpStr = "" + nanoSeconds;
- length = tmpStr.length();
- for (int i = 0; i < desc.sqlPrecision_ - length; i++) {
- tmpStr = "0" + tmpStr;
- }
- } else {
- tmpStr = "0";
- }
-
- retObj = Timestamp.valueOf(padZero((int) year, 4) + "-" + padZero(month, 2) + "-" + padZero(day, 2)
- + " " + padZero(hour, 2) + ":" + padZero(minute, 2) + ":" + padZero(second, 2) + "."
- + tmpStr);
- } else { // do the old way
- length = desc.precision_;
- retObj = Timestamp.valueOf(new String(Bytes.read_chars(values, noNullValue, length)));
- }
- break;
-
- case SQLDTCODE_TIME:
- if (ODBCDataType == java.sql.Types.OTHER) // For
- // HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION
- {
- length = desc.sqlOctetLength_;
- retObj = new String(Bytes.read_chars(values, noNullValue, length));
- } else {
- length = timeLength;
- if (!useOldDateFormat) // new date format, only for bulk
- // move
- {
- // "hh:mm:ss"
- hour = values[noNullValue];
- minute = values[noNullValue + 1];
- second = values[noNullValue + 2];
-
- if (desc.sqlPrecision_ > 0) {
- nanoSeconds = Bytes.extractUInt(values, noNullValue + 3, swap);
-
- if (nanoSeconds > 999999) // returned in microseconds
- nanoSeconds = 0;
-
- String formatStr = "";
- for(int i=0;i<desc.sqlPrecision_;i++)
- formatStr += "0";
-
- StringBuffer sb = new StringBuffer();
- DecimalFormat format = new DecimalFormat("00");
- format.format(hour, sb, new FieldPosition(0));
- sb.append(':');
- format.format(minute, sb, new FieldPosition(0));
- sb.append(':');
- format.format(second, sb, new FieldPosition(0));
- sb.append('.');
- format = new DecimalFormat(formatStr);
- format.format(nanoSeconds, sb, new FieldPosition(0));
-
- retObj = sb.toString();
- } else {
- retObj = Time.valueOf(String.valueOf(hour) + ":" + String.valueOf(minute) + ":"
- + String.valueOf(second));
- }
- } else
- // do the old way
- retObj = Time.valueOf(new String(Bytes.read_chars(values, noNullValue, length)));
- }
- break;
- default:
- length = desc.sqlOctetLength_;
- retObj = new String(Bytes.read_chars(values, noNullValue, length));
- break;
- }
- break;
- case SQLTYPECODE_SMALLINT:
- short sValue = Bytes.extractShort(values, noNullValue, swap);
- retObj = new Short(sValue);
- if (desc.scale_ > 0) {
- retObj = new BigDecimal(new BigInteger(retObj.toString()), desc.scale_);
- }
- break;
- case SQLTYPECODE_SMALLINT_UNSIGNED:
- int signedSValue = Bytes.extractUShort(values, noNullValue, swap);
- if (desc.scale_ > 0) {
- tmpbd = new BigDecimal(new BigInteger(String.valueOf(signedSValue)), (int) desc.scale_);
- } else {
- tmpbd = new BigDecimal(String.valueOf(signedSValue));
- }
- retObj = tmpbd;
- break;
- case SQLTYPECODE_INTEGER:
- retObj = new Integer(Bytes.extractInt(values, noNullValue,swap));
- if (desc.scale_ > 0) {
- retObj = new BigDecimal(new BigInteger(retObj.toString()), desc.scale_);
- }
- break;
- case SQLTYPECODE_INTEGER_UNSIGNED:
- retObj = new Long(Bytes.extractUInt(values, noNullValue, swap));
- if (desc.scale_ > 0) {
- retObj = new BigDecimal(new BigInteger(retObj.toString()), desc.scale_);
- }
- break;
- case SQLTYPECODE_LARGEINT:
- retObj = new Long(Bytes.extractLong(values, noNullValue, swap));
- if (desc.scale_ > 0) {
- retObj = new BigDecimal(new BigInteger(retObj.toString()), desc.scale_);
- }
- break;
- case SQLTYPECODE_NUMERIC:
- case SQLTYPECODE_NUMERIC_UNSIGNED:
- tbuffer = new byte[desc.sqlOctetLength_];
- System.arraycopy(values, noNullValue, tbuffer, 0, desc.sqlOctetLength_);
- retObj = InterfaceUtilities.convertSQLBigNumToBigDecimal(tbuffer, desc.scale_, swap);
- break;
- case SQLTYPECODE_DECIMAL:
- case SQLTYPECODE_DECIMAL_UNSIGNED:
- case SQLTYPECODE_DECIMAL_LARGE:
- case SQLTYPECODE_DECIMAL_LARGE_UNSIGNED:
- String retStr;
-
- // check if the sign is minus (-80)
- byte sign = (byte) (values[noNullValue] & (byte) (-80));
-
- // first byte = inbyte - (-80)
- if (sign == (byte) (-80)) {
- byte firstByte = (byte) (values[noNullValue] - (byte) (-80));
- retStr = "-" + firstByte
- + String.valueOf(Bytes.read_chars(values, noNullValue + 1, desc.sqlOctetLength_ - 1));
- } else {
- retStr = String.valueOf(Bytes.read_chars(values, noNullValue, desc.sqlOctetLength_));
- }
- retObj = new BigDecimal(new BigInteger(retStr), desc.scale_);
- break;
- case SQLTYPECODE_REAL:
- retObj = new Float(Float.intBitsToFloat(Bytes.extractInt(values, noNullValue, swap)));
- break;
- case SQLTYPECODE_DOUBLE:
- case SQLTYPECODE_FLOAT:
- retObj = new Double(Double.longBitsToDouble(Bytes.extractLong(values, noNullValue, swap)));
- break;
- case SQLTYPECODE_BIT:
- case SQLTYPECODE_BITVAR:
- case SQLTYPECODE_BPINT_UNSIGNED:
- default:
- throw HPT4Messages.createSQLException(conn.props_, conn.getLocale(), "restricted_data_type", null);
- }
- return retObj;
- } // end getExecute2FetchString
-
- // -------------------------------------------------------------------
- void setFetchOutputs(TrafT4ResultSet rs, int rowsAffected, boolean endOfData, byte[] outputDataValue)
- throws SQLException
-
- {
- Row[] rowArray;
- Object[] objectArray;
- Object columnValue;
-
- int columnCount;
- int rowIndex;
- int columnIndex;
- int byteIndex = 0;
- short SQLDataInd = 0;
- int byteLen = 0;
- int maxRowLen = rs.connection_.ic_.getTransportBufferSize(); // maxRowLen
-
- rowArray = new Row[rowsAffected];
-
- // get the number of colums
- columnCount = rs.getNoOfColumns();
-
- for (rowIndex = 0; rowIndex < rowsAffected; rowIndex++) {
- if (rs.connection_.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, rs, outputDataValue, rowsAffected,
- endOfData, 0);
- String temp = "Reading row = " + rowIndex;
- rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "setFetchOutputs", temp, p);
- }
- objectArray = new Object[columnCount];
-
- for (columnIndex = 0; columnIndex < columnCount; columnIndex++) {
- if (rs.connection_.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, rs, outputDataValue,
- rowsAffected, endOfData, 0);
- String temp = "Reading column = " + columnIndex;
- rs.connection_.props_.t4Logger_
- .logp(Level.FINEST, "InterfaceResultSet", "setFetchOutputs", temp, p);
- }
- SQLDataInd = new Byte(outputDataValue[byteIndex++]).shortValue();
- if (rs.connection_.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, rs, outputDataValue,
- rowsAffected, endOfData, 0);
- String temp = "Row = " + rowIndex + "," + "Column = " + columnIndex + " SQLDataInd is = "
- + SQLDataInd;
- rs.connection_.props_.t4Logger_
- .logp(Level.FINEST, "InterfaceResultSet", "setFetchOutputs", temp, p);
- }
- if (SQLDataInd == 0) {
- short varDataLen;
- if (outputDataValue.length > (byteIndex + 2)) {
- varDataLen = Bytes.extractShort(outputDataValue, byteIndex, this.ic_.getByteSwap());
- } else {
- varDataLen = 0;
-
- }
- byteLen = dataLengthFetchPerf(rs.outputDesc_[columnIndex].sqlDataType_,
- rs.outputDesc_[columnIndex].sqlDatetimeCode_, rs.outputDesc_[columnIndex].sqlOctetLength_,
- maxRowLen, // maxLength
- varDataLen, rs.outputDesc_[columnIndex].dataType_, rs.outputDesc_[columnIndex].precision_);
-
- columnValue = getFetchString(rs.connection_, rs.outputDesc_[columnIndex].scale_,
- rs.outputDesc_[columnIndex].sqlDataType_, rs.outputDesc_[columnIndex].sqlDatetimeCode_,
- rs.outputDesc_[columnIndex].fsDataType_, outputDataValue, byteIndex, byteLen,
- rs.outputDesc_[columnIndex].sqlCharset_, rs.outputDesc_[columnIndex].dataType_);
-
- byteIndex = byteIndex + byteLen;
-
- switch (rs.outputDesc_[columnIndex].sqlDataType_) {
- case SQLTYPECODE_VARCHAR_WITH_LENGTH:
- case SQLTYPECODE_VARCHAR_LONG:
- case SQLTYPECODE_VARCHAR_DBLBYTE:
- case SQLTYPECODE_BITVAR:
- case SQLTYPECODE_CHAR:
- case SQLTYPECODE_CHAR_DBLBYTE:
- case SQLTYPECODE_VARCHAR:
- case SQLTYPECODE_BLOB:
- case SQLTYPECODE_CLOB:
- byteIndex++;
- break;
- }
-
- if (columnValue == null) {
- throw HPT4Messages
- .createSQLException(rs.connection_.props_, ic_.getLocale(), "null_data", null);
- }
- } else {
- columnValue = null;
-
- }
- objectArray[columnIndex] = columnValue;
- }
- rowArray[rowIndex] = new Row(columnCount, objectArray);
- }
- rs.setFetchOutputs(rowArray, rowsAffected, endOfData);
- }
-
- // ----------------------------------------------------------------------------
- void setExecute2FetchOutputs(TrafT4ResultSet rs, int rowsAffected, boolean endOfData, byte[] values)
- throws SQLException {
- if (rs.useOldDateFormat()) {
- setFetchOutputs(rs, rowsAffected, endOfData, values);
- return;
- }
- Object[] objectArray;
- Object columnValue;
- Row[] rowArray = new Row[rowsAffected];
-
- int columnCount = rs.getNoOfColumns();
- int rowIndex;
- int columnIndex;
- int byteIndex = 0;
- int SQLDataInd = 0;
- int byteLen = 0;
- int maxRowLen = rs.connection_.ic_.getTransportBufferSize(); // maxRowLen
-
- objectArray = new Object[columnCount];
-
- int dataLength = 0;
-
- if (rs.outputDesc_ != null && rs.outputDesc_.length > 0) {
- dataLength = rs.outputDesc_[0].rowLength_;
- }
-
- int rowOffset = 0;
- for (rowIndex = 0; rowIndex < rowsAffected; rowIndex++) {
- rowOffset = rowIndex * dataLength;
-
- for (columnIndex = 0; columnIndex < columnCount; columnIndex++) {
- int noNullValueOffset = rs.outputDesc_[columnIndex].noNullValue_;
- int nullValueOffset = rs.outputDesc_[columnIndex].nullValue_;
-
- if (nullValueOffset != -1)
- nullValueOffset += rowOffset;
- if (noNullValueOffset != -1)
- noNullValueOffset += rowOffset;
-
- if (rs.connection_.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, rs, endOfData, values);
- String temp = "Processing column = " + columnIndex + ": noNullValueOffset = " + noNullValueOffset
- + ": nullValueOffset = " + nullValueOffset;
- rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "setExecute2FetchOutputs",
- temp, p);
- }
-
- if (nullValueOffset != -1 && Bytes.extractShort(values, nullValueOffset, this.ic_.getByteSwap()) == -1) {
- columnValue = null;
- } else {
- columnValue = getExecute2FetchString(rs.connection_, rs.outputDesc_[columnIndex], values,
- noNullValueOffset, rs.outputDesc_[columnIndex].dataType_, rs.useOldDateFormat(), this.ic_.getByteSwap());
- if (columnValue == null) {
- throw HPT4Messages
- .createSQLException(rs.connection_.props_, ic_.getLocale(), "null_data", null);
- }
- } // end if else
-
- objectArray[columnIndex] = columnValue;
- } // end for
-
- rowArray[rowIndex] = new Row(columnCount, objectArray);
- }
- rs.setFetchOutputs(rowArray, rowsAffected, endOfData);
-
- } // end setExectue2FetchOutputs
-
- // ----------------------------------------------------------------------------
- // Interface methods
- boolean fetch(String stmtLabel, int maxRowCnt, int queryTimeout, int holdability, TrafT4ResultSet rs)
- throws SQLException {
- int sqlAsyncEnable = 0;
- int stmtHandle = 0;
- int stmtCharset = 1;
- String cursorName = "";
- int cursorCharset = 1;
- String stmtOptions = "";
-
- boolean endOfData = false;
- boolean dataFound = false;
- String sqlStmt = ""; // qs_interface
-
- if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, stmtLabel, maxRowCnt, queryTimeout,
- holdability);
- String temp = "Entering Fetch";
- rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "fetch", temp, p);
- }
-
- if (rs_.stmt_ != null && rs_.stmt_.sql_ != null) {
- sqlStmt = rs_.stmt_.sql_.toUpperCase();
- }
-
- FetchReply fr;
-
- try {
- fr = t4resultSet_.Fetch(sqlAsyncEnable, queryTimeout, stmtHandle, stmtCharset, maxRowCnt, cursorName,
- cursorCharset, stmtOptions);
-
- } catch (SQLException tex) {
- if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, stmtLabel, maxRowCnt, queryTimeout,
- holdability);
- String temp = "SQLException while fetching.";
- rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "fetch", temp, p);
- }
- throw tex;
- }
-
- switch (fr.returnCode) {
- case TRANSPORT.CEE_SUCCESS:
- case TRANSPORT.SQL_SUCCESS_WITH_INFO:
-
- // do warning processing
- if (fr.errorList.length != 0) {
- HPT4Messages.setSQLWarning(rs.connection_.props_, rs, fr.errorList);
- }
- //endOfData = (fr.rowsAffected < maxRowCnt) ? true : false;
-
- if (fr.rowsAffected > 0) {
- if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, stmtLabel, maxRowCnt,
- queryTimeout, holdability);
- String temp = "Data Found. Setting fetch outputs";
- rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "fetch", temp, p);
- }
- if (rs.keepRawBuffer_ == true) {
- rs.rawBuffer_ = fr.outValues;
- }
-
- setExecute2FetchOutputs(rs, fr.rowsAffected, endOfData, fr.outValues);
-
- dataFound = true;
- }
- break;
- case 100: // fix this
- case odbc_SQLSvc_Fetch_exc_.odbc_SQLSvc_Fetch_SQLNoDataFound_exn_:
- dataFound = false;
- endOfData = true;
- break;
-
- default:
- HPT4Messages.throwSQLException(rs.connection_.props_, fr.errorList);
-
- }
-
- if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, stmtLabel, maxRowCnt, queryTimeout,
- holdability);
- String temp = "Exiting Fetch.";
- rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "fetch", temp, p);
- }
-
- // see if the rows fetched is valid
- return dataFound;
- };
-
- void close() throws SQLException {
- ic_.isConnectionOpen();
- if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(rs_.connection_.props_);
- String temp = "Closing resultset.";
- rs_.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "close", temp, p);
- }
-
- int rval = 0;
- CloseReply cry_ = null;
-
- //
- // If the query is non-unique, then close the result set (cursor).
- // If the query was a unique select, then the result set was implicitly
- // closed by NCS.
- //
- if (rs_ != null && rs_.stmt_ != null && rs_.stmt_.ist_ != null
- && rs_.stmt_.ist_.sqlQueryType_ != TRANSPORT.SQL_SELECT_UNIQUE) {
- cry_ = t4resultSet_.Close();
-
- switch (cry_.m_p1.exception_nr) {
- case TRANSPORT.CEE_SUCCESS:
-
- // ignore the SQLWarning for the static close
- break;
- case odbc_SQLSvc_Close_exc_.odbc_SQLSvc_Close_SQLError_exn_:
- if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(rs_.connection_.props_);
- String temp = "odbc_SQLSvc_Close_SQLError_exn_";
- rs_.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "close", temp, p);
- }
-
- HPT4Messages.throwSQLException(rs_.connection_.props_, cry_.m_p1.SQLError);
- default:
- if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(rs_.connection_.props_);
- String temp = "UnknownException occurred during close.";
- rs_.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "close", temp, p);
- }
- throw HPT4Messages.createSQLException(rs_.connection_.props_, ic_.getLocale(),
- "ids_unknown_reply_error", null);
- } // end switch
- } // end if
-
- if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(rs_.connection_.props_);
- String temp = "Closed resultset.";
- rs_.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "close", temp, p);
- }
- };
-
- // ----------------------------------------------------------------------------
- static Object[] getExecute2Outputs(TrafT4Connection conn, HPT4Desc[] desc, byte[] values, boolean swap) throws SQLException
-
- {
- Object[] objectArray;
- Object columnValue;
- int columnIndex;
- int columnCount = (desc == null) ? 0 : desc.length;
-
- objectArray = new Object[columnCount];
-
- for (columnIndex = 0; columnIndex < columnCount; columnIndex++) {
- int noNullValueOffset = desc[columnIndex].noNullValue_;
- int nullValueOffset = desc[columnIndex].nullValue_;
-
- if (conn.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
- Object p[] = T4LoggingUtilities.makeParams(conn.props_, conn, desc, values);
- String temp = "Processing column = " + columnIndex + ": noNullValueOffset = " + noNullValueOffset
- + ": nullValueOffset = " + nullValueOffset;
- conn.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "getExecute2Outputs", temp, p);
- }
-
- if ((nullValueOffset != -1 && Bytes.extractShort(values, nullValueOffset, swap) == -1)
- || (desc[columnIndex].paramMode_ == HPT4ParameterMetaData.parameterModeIn)) {
- columnValue = null;
- } else {
- columnValue = getExecute2FetchString(conn, desc[columnIndex], values, noNullValueOffset,
- desc[columnIndex].dataType_, false, swap);
- if (columnValue == null) {
- throw HPT4Messages.createSQLException(conn.props_, conn.getLocale(), "null_data", null);
- }
- } // end if else
-
- objectArray[columnIndex] = columnValue;
- } // end for
-
- return objectArray;
-
- } // end getExectue2Outputs
-
-}
[59/60] incubator-trafodion git commit: Merge branch 'master' of
github.com:apache/incubator-trafodion into wrkbrnch
Posted by db...@apache.org.
Merge branch 'master' of github.com:apache/incubator-trafodion into wrkbrnch
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/4cf0aac2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/4cf0aac2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/4cf0aac2
Branch: refs/heads/master
Commit: 4cf0aac2f2182aa0a60a4620de628fcc3b234c75
Parents: 755c383 64a68cf
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Fri Apr 29 23:15:53 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Fri Apr 29 23:15:53 2016 +0000
----------------------------------------------------------------------
.../jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecPwd.java | 9 ---------
1 file changed, 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4cf0aac2/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecPwd.java
----------------------------------------------------------------------
diff --cc core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecPwd.java
index 60da5da,0000000..6783c66
mode 100644,000000..100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecPwd.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecPwd.java
@@@ -1,274 -1,0 +1,265 @@@
+/**********************************************************************
+// @@@ 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 @@@
+ //
+ **********************************************************************/
+
+/**
+ * class SecPwd - builds the password key, encrypts password,
+ * creates HMAC message based on password, rolename
+ * process info and time stamp. It also gets expiration
+ * date of a certificate.
+ *
+ */
+
+package org.trafodion.jdbc.t4;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.sql.Connection;
+
+
+public class SecPwd {
+ /**
+ *
+ *
+ * @return SecPwd
+ */
+ public static SecPwd getInstance(Connection con, String directory, String fileName,
+ String serverName, boolean spjMode, byte[] procInfo) throws SecurityException
+ {
+ if (con == null)
+ throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"connection"});
+ SecPwd secpwd = new SecPwd(directory, fileName, serverName, spjMode, procInfo);
+
+ SymCrypto.insert(con, secpwd);
+
+
+ return secpwd;
+ }
+
+ public static void removeInstance(Connection con)
+ {
+ SymCrypto.remove(con);
+ }
+
+ /**
+ * Ctor for the SecPwd. There are two possible certificates: active
+ * certificate and certificate that is going to be active.
+ *
+ * If autodownload is true, certificate will always come from the
+ * server. In this case, only active certificate is used.
+ *
+ * If autodownload is false, active certificate is used to encrypt the
+ * password. When there is a new certificate, it will be stored in
+ * "certificate". As soon as this new certificate is activated on the
+ * server, the current active certificate will become stale, and the new
+ * certificate will be copied over and becomes the active certificate.
+ *
+ * If spjMode is true, the OS name is NONSTOP_KERNEL and the host name
+ * is the same as the server name then just setSpj mode to true
+ * and does nothing.
+ *
+ * @param directory
+ * specifies the directory to locate the certificate. The default
+ * value is %HOME% if set else %HOMEDRIVE%%HOMEPATH%.
+ * @param fileName
+ * specifies the certificate that is in waiting. The default
+ * value is the first 5 characters of server name.
+ * @param activeFileName
+ * specifies the current certificate in use. The default value is
+ * the first 5 character of server name + Active
+ * @param spjMode
+ * true - and if os.name == NSK and the host name
+ * matches the local host - token case. Certificate is not
+ * handled in this case.
+ * false - handles certificate
+ * @param serverName
+ * server name for this certificate.
+ * @throws SecurityException
+ */
+ private SecPwd(String directory, String fileName,
+ String serverName, boolean spjMode, byte[] procInfo) throws SecurityException {
- String hostName = null;
-
- try {
- hostName = java.net.InetAddress.getLocalHost().getHostName();
- } catch (java.net.UnknownHostException ex) {
- throw new SecurityException(
- SecClientMsgKeys.GET_LOCAL_HOST_NAME_FAILED, null);
- }
-
+ // check USERID env variable for MXCI testing of SPJs. If set use normal password
+ // encryption
+ if ((spjMode == true) &&
+ // ((hostName.substring(0, 5)).compareToIgnoreCase(serverName.substring(0, 5)) == 0) &&
+ (System.getenv("USERID") == null))// token
+ {
+ m_spjMode = spjMode;
+ }
+ else // password
+ {
+ if (procInfo == null)
+ throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"procInfo"});
+ // Stores procInfo with the time stamp for data message encryption used
+ m_procInfo = new byte [SecdefsCommon.PROCINFO_SIZE + SecdefsCommon.TIMESTAMP_SIZE];
+ System.arraycopy(procInfo, 0, m_procInfo, 0, (SecdefsCommon.PROCINFO_SIZE + SecdefsCommon.TIMESTAMP_SIZE));
+ directory = (directory != null) ? directory : System.getenv("HOME");
+ if (directory == null)
+ {
+ String hmdrive = System.getenv("HOMEDRIVE");
+ String hmpath = System.getenv("HOMEPATH");
+ if (hmdrive != null && hmpath != null)
+ {
+ directory = hmdrive + File.separator + hmpath;
+ }
+ else
+ {
+ directory = System.getProperty("user.home");
+ if (directory == null)
+ throw new SecurityException (SecClientMsgKeys.HOME_ENVIRONMENT_VAR_IS_NULL, null);
+ }
+ }
+ fileName = (fileName != null) ? fileName : serverName + ".cer";
+
+ File dir = new File(directory);
+ if (dir.isDirectory() == false)
+ throw new SecurityException(SecClientMsgKeys.DIR_NOTFOUND, new Object[]{dir.getPath()});
+
+ certFile = new File(directory, fileName);
+ }
+ }
+
+ /**
+ * Processes the active certificate when spjMode is false
+ * else does nothing. The certificate is processed by calling
+ * the Security ctor to creates the password key and initializes it
+ * with password id. Gets public key and the length of the public
+ * key from the certificate file. Generates nonce and session key.
+ * @throws SecurityException
+ */
+ public void openCertificate() throws SecurityException {
+ if (m_spjMode == false) // do nothing for the token case
+ m_sec = new Security(certFile);
+ }
+
+ /** This method builds the password key which consists 4 bytes of password id,
+ * 128 bytes of role name which would be 128 spaces when role name is null,
+ * 32 bytes of the digest message calculated using the session key on the data made up of
+ * the procInfo and the encrypted data and 256 bytes (if the 2048 public key is used) or
+ * 128 bytes (if the1024 public key is used) encrypted data calculated using the public key
+ * on the plain text made up of the session key, the nonce and the password.
+ * The password key is generated only when the spjMode is false. When
+ * the spjMode is true, 26 bytes of the token is returned instead.
+ * Builds password key
+ * @param pwd
+ * password to be encrypted
+ * @param rolename
+ * role name to build password key
+ * @param procInfo
+ * process information (PIN, CPU, segment name and time stamp)
+ * @return pwdkey
+ * returns the password key if spjMode is false
+ * returns the token when spjMode is true
+ * @throws SecurityException
+ */
+
+ public void encryptPwd(byte[] pwd, byte[] rolename, byte[] pwdkey) throws SecurityException {
+ // rolename is optional so can be NULL
+ if (pwd == null)
+ throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"password"});
+ if (pwdkey == null)
+ throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"password key"});
+ if (m_spjMode == true) // token
+ {
+ if (pwd.length != SecdefsCommon.TOKENSIZE)
+ throw new SecurityException(SecClientMsgKeys.BAD_TOKEN_LEN, null);
+ if ((pwd[0] != SecdefsCommon.USERTOKEN_ID_1)
+ || (pwd[1] != SecdefsCommon.USERTOKEN_ID_2))
+ throw new SecurityException(
+ SecClientMsgKeys.INCORRECT_TOKEN_FORMAT, null);
+ ByteBuffer.wrap(pwd).get(pwdkey, 0, SecdefsCommon.TOKENSIZE);
+ }
+ else
+ {
+ m_sec.encryptPwd(pwd, rolename, m_procInfo, pwdkey);
+ }
+ }
+
+ /** Gets length of buffer for password encryption (public)
+ * or the length of the token if it is the SPJ mode
+ * @returns
+ * If the spjMode is false
+ * the length of the password key is returnd if success
+ * 0 if failed
+ * If spjMode is true
+ * the length of the token is returned
+ * @throws SecurityException
+ */
+ public int getPwdEBufferLen() throws SecurityException {
+ if (m_spjMode == true)
+ return SecdefsCommon.TOKENSIZE;
+ else
+ return m_sec.getPwdEBufferLen();
+ }
+
+ /** Gets the expiration date of the certificate
+ * @return an array of bytes
+ * presents the certificate's
+ * expiration day in the format YYMMDDHHMMSS
+ * or a zero length byte array if the it is in the SPJ mode
+ */
+ public byte[] getCertExpDate() {
+ if (m_spjMode == false)
+ return m_sec.getCertExpDate();
+ else
+ return new byte[0];
+ }
+
+ /**
+ * When autodownload is on, client will download the certificate from server
+ * when there is no certificate or certificate is stale.
+ *
+ * @param buf
+ * content of the certificate pushed from server.
+ */
+ public void switchCertificate(byte[] buf) throws SecurityException {
+ FileChannel outChannel = null;
+ try {
+ outChannel = new FileOutputStream(certFile).getChannel();
+ outChannel.write(ByteBuffer.wrap(buf));
+ } catch (Exception e) {
+ throw new SecurityException(SecClientMsgKeys.ERR_WRITE_CERT_FILE, new Object[]{certFile});
+ } finally {
+ try {
+ if (outChannel != null)
+ outChannel.close();
+ } catch (Exception e) {
+ }
+ }
+ m_sec = new Security(certFile);
+ }
+
+ public byte[] getProcInfo()
+ {
+ return m_procInfo;
+ }
+
+ private Security m_sec;
+ private File certFile;
+ private boolean m_spjMode;
+ private byte[] m_procInfo; //stores only 4 bytes pid + 4 bytes nid
+
+
+};
[60/60] incubator-trafodion git commit: Merge [TRAFODION-1933] PR 458
Migrate JDBCT4 build from Ant to Maven
Posted by db...@apache.org.
Merge [TRAFODION-1933] PR 458 Migrate JDBCT4 build from Ant to Maven
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/56f3dbe6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/56f3dbe6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/56f3dbe6
Branch: refs/heads/master
Commit: 56f3dbe656a81ec8df19d9778488c10036ca6224
Parents: 58a4000 4cf0aac
Author: Dave Birdsall <db...@apache.org>
Authored: Mon May 2 16:10:46 2016 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Mon May 2 16:10:46 2016 +0000
----------------------------------------------------------------------
core/Makefile | 13 +-
core/conn/jdbcT4/.gitignore | 5 +
core/conn/jdbcT4/Makefile | 46 +
core/conn/jdbcT4/pom.xml | 169 +
core/conn/jdbcT4/src/assembly/all.xml | 56 +
.../jdbcT4/src/main/java/T4Messages.properties | 686 ++
.../java/org/trafodion/jdbc/t4/Address.java | 117 +
.../main/java/org/trafodion/jdbc/t4/Bytes.java | 269 +
.../jdbc/t4/CONNECTION_CONTEXT_def.java | 149 +
.../jdbc/t4/CachedPreparedStatement.java | 67 +
.../org/trafodion/jdbc/t4/CancelMessage.java | 49 +
.../java/org/trafodion/jdbc/t4/CancelReply.java | 38 +
.../java/org/trafodion/jdbc/t4/Certificate.java | 112 +
.../main/java/org/trafodion/jdbc/t4/Cipher.java | 201 +
.../org/trafodion/jdbc/t4/CloseMessage.java | 48 +
.../java/org/trafodion/jdbc/t4/CloseReply.java | 48 +
.../java/org/trafodion/jdbc/t4/Compression.java | 149 +
.../org/trafodion/jdbc/t4/ConnectMessage.java | 62 +
.../org/trafodion/jdbc/t4/ConnectReply.java | 148 +
.../java/org/trafodion/jdbc/t4/Descriptor2.java | 85 +
.../trafodion/jdbc/t4/ERROR_DESC_LIST_def.java | 42 +
.../org/trafodion/jdbc/t4/ERROR_DESC_def.java | 65 +
.../jdbc/t4/EndTransactionMessage.java | 49 +
.../trafodion/jdbc/t4/EndTransactionReply.java | 49 +
.../org/trafodion/jdbc/t4/ExecuteMessage.java | 107 +
.../org/trafodion/jdbc/t4/ExecuteReply.java | 127 +
.../org/trafodion/jdbc/t4/FetchMessage.java | 63 +
.../java/org/trafodion/jdbc/t4/FetchReply.java | 63 +
.../org/trafodion/jdbc/t4/GenericMessage.java | 45 +
.../org/trafodion/jdbc/t4/GenericReply.java | 43 +
.../jdbc/t4/GetSQLCatalogsMessage.java | 88 +
.../trafodion/jdbc/t4/GetSQLCatalogsReply.java | 54 +
.../jdbc/t4/HPT4ConnectionPoolDataSource.java | 346 +
.../t4/HPT4ConnectionPoolDataSourceFactory.java | 68 +
.../org/trafodion/jdbc/t4/HPT4DataSource.java | 366 ++
.../jdbc/t4/HPT4DataSourceFactory.java | 62 +
.../java/org/trafodion/jdbc/t4/HPT4Desc.java | 542 ++
.../org/trafodion/jdbc/t4/HPT4Exception.java | 38 +
.../java/org/trafodion/jdbc/t4/HPT4Handle.java | 84 +
.../org/trafodion/jdbc/t4/HPT4Messages.java | 324 +
.../jdbc/t4/HPT4ParameterMetaData.java | 243 +
.../trafodion/jdbc/t4/HPT4PooledConnection.java | 238 +
.../jdbc/t4/HPT4PooledConnectionManager.java | 385 ++
.../jdbc/t4/HPT4ResultSetMetaData.java | 309 +
.../main/java/org/trafodion/jdbc/t4/Header.java | 157 +
.../jdbc/t4/InitializeDialogueMessage.java | 66 +
.../jdbc/t4/InitializeDialogueReply.java | 90 +
.../java/org/trafodion/jdbc/t4/InputOutput.java | 682 ++
.../trafodion/jdbc/t4/InterfaceConnection.java | 1420 +++++
.../trafodion/jdbc/t4/InterfaceResultSet.java | 927 +++
.../trafodion/jdbc/t4/InterfaceStatement.java | 1392 +++++
.../trafodion/jdbc/t4/InterfaceUtilities.java | 235 +
.../main/java/org/trafodion/jdbc/t4/Key.java | 161 +
.../org/trafodion/jdbc/t4/LogicalByteArray.java | 345 +
.../org/trafodion/jdbc/t4/MessageDigest.java | 84 +
.../java/org/trafodion/jdbc/t4/NCSAddress.java | 220 +
.../jdbc/t4/OUT_CONNECTION_CONTEXT_def.java | 97 +
.../java/org/trafodion/jdbc/t4/ObjectArray.java | 86 +
.../org/trafodion/jdbc/t4/PrepareMessage.java | 82 +
.../org/trafodion/jdbc/t4/PrepareReply.java | 103 +
.../jdbc/t4/PreparedStatementManager.java | 242 +
.../trafodion/jdbc/t4/SQLItemDescList_def.java | 46 +
.../trafodion/jdbc/t4/SQLItemDescOld_def.java | 54 +
.../org/trafodion/jdbc/t4/SQLItemDesc_def.java | 70 +
.../org/trafodion/jdbc/t4/SQLValueList_def.java | 64 +
.../org/trafodion/jdbc/t4/SQLValue_def.java | 55 +
.../trafodion/jdbc/t4/SQLWarningOrError.java | 47 +
.../trafodion/jdbc/t4/SQL_DataValue_def.java | 54 +
.../org/trafodion/jdbc/t4/SecClientMsgKeys.java | 58 +
.../main/java/org/trafodion/jdbc/t4/SecPwd.java | 265 +
.../trafodion/jdbc/t4/SecResourceBundle.java | 57 +
.../org/trafodion/jdbc/t4/SecdefsCommon.java | 84 +
.../java/org/trafodion/jdbc/t4/Security.java | 319 +
.../trafodion/jdbc/t4/SecurityException.java | 47 +
.../jdbc/t4/SetConnectionOptionMessage.java | 50 +
.../jdbc/t4/SetConnectionOptionReply.java | 45 +
.../java/org/trafodion/jdbc/t4/SymCrypto.java | 87 +
.../java/org/trafodion/jdbc/t4/T4Address.java | 315 +
.../org/trafodion/jdbc/t4/T4Connection.java | 505 ++
.../org/trafodion/jdbc/t4/T4DSProperties.java | 967 +++
.../trafodion/jdbc/t4/T4DatabaseMetaData.java | 5901 ++++++++++++++++++
.../java/org/trafodion/jdbc/t4/T4Driver.java | 367 ++
.../org/trafodion/jdbc/t4/T4LogFormatter.java | 236 +
.../trafodion/jdbc/t4/T4LoggingUtilities.java | 816 +++
.../org/trafodion/jdbc/t4/T4Properties.java | 2511 ++++++++
.../java/org/trafodion/jdbc/t4/T4ResultSet.java | 164 +
.../java/org/trafodion/jdbc/t4/T4Statement.java | 204 +
.../org/trafodion/jdbc/t4/T4TimerThread.java | 116 +
.../org/trafodion/jdbc/t4/T4_Dcs_Cancel.java | 115 +
.../org/trafodion/jdbc/t4/T4_Dcs_Connect.java | 123 +
.../java/org/trafodion/jdbc/t4/TRANSPORT.java | 263 +
.../jdbc/t4/TerminateDialogueMessage.java | 38 +
.../jdbc/t4/TerminateDialogueReply.java | 39 +
.../jdbc/t4/TrafT4CallableStatement.java | 2462 ++++++++
.../org/trafodion/jdbc/t4/TrafT4Connection.java | 1987 ++++++
.../jdbc/t4/TrafT4PreparedStatement.java | 2558 ++++++++
.../org/trafodion/jdbc/t4/TrafT4ResultSet.java | 5106 +++++++++++++++
.../org/trafodion/jdbc/t4/TrafT4Statement.java | 1690 +++++
.../org/trafodion/jdbc/t4/USER_DESC_def.java | 61 +
.../java/org/trafodion/jdbc/t4/Utility.java | 636 ++
.../org/trafodion/jdbc/t4/VERSION_LIST_def.java | 65 +
.../java/org/trafodion/jdbc/t4/VERSION_def.java | 61 +
.../java/org/trafodion/jdbc/t4/Vproc.java-tmpl | 36 +
.../jdbc/t4/odbc_Dcs_GetObjRefHdl_exc_.java | 95 +
.../jdbc/t4/odbc_Dcs_StopSrvr_exc_.java | 86 +
.../jdbc/t4/odbc_SQLSvc_Close_exc_.java | 69 +
.../t4/odbc_SQLSvc_EndTransaction_exc_.java | 87 +
.../jdbc/t4/odbc_SQLSvc_Execute_exc_.java | 89 +
.../jdbc/t4/odbc_SQLSvc_Fetch_exc_.java | 87 +
.../t4/odbc_SQLSvc_GetSQLCatalogs_exc_.java | 100 +
.../t4/odbc_SQLSvc_InitializeDialogue_exc_.java | 76 +
.../jdbc/t4/odbc_SQLSvc_Prepare_exc_.java | 68 +
.../odbc_SQLSvc_SetConnectionOption_exc_.java | 70 +
.../t4/odbc_SQLSvc_TerminateDialogue_exc_.java | 66 +
.../jdbcT4/src/main/java/secClient.properties | 53 +
.../CallableStatementSample.java | 83 +
.../CallableStatementSample/IntegerSPJ.java | 28 +
.../main/samples/CallableStatementSample/README | 42 +
.../main/samples/DBMetaSample/DBMetaSample.java | 132 +
.../jdbcT4/src/main/samples/DBMetaSample/README | 904 +++
.../PreparedStatementSample.java | 151 +
.../main/samples/PreparedStatementSample/README | 232 +
core/conn/jdbcT4/src/main/samples/README | 47 +
.../src/main/samples/ResultSetSample/README | 91 +
.../ResultSetSample/ResultSetSample.java | 104 +
.../src/main/samples/StatementSample/README | 92 +
.../StatementSample/StatementSample.java | 104 +
.../src/main/samples/common/sampleUtils.java | 268 +
.../jdbcT4/src/main/samples/t4jdbc.properties | 26 +
.../java/org/trafodion/jdbc/t4/AppTest.java | 61 +
.../java/org/trafodion/jdbc/t4/RunAllTests.java | 31 +
.../org/trafodion/jdbc/t4/T4DriverTest.java | 49 +
core/conn/jdbc_type4/.gitignore | 3 -
core/conn/jdbc_type4/build.xml | 142 -
core/conn/jdbc_type4/getBuildInfo | 24 -
.../CallableStatementSample.java | 83 -
.../CallableStatementSample/IntegerSPJ.java | 28 -
.../samples/CallableStatementSample/README | 42 -
.../samples/DBMetaSample/DBMetaSample.java | 132 -
.../conn/jdbc_type4/samples/DBMetaSample/README | 904 ---
.../PreparedStatementSample.java | 151 -
.../samples/PreparedStatementSample/README | 232 -
core/conn/jdbc_type4/samples/README | 47 -
.../jdbc_type4/samples/ResultSetSample/README | 91 -
.../ResultSetSample/ResultSetSample.java | 104 -
.../jdbc_type4/samples/StatementSample/README | 92 -
.../StatementSample/StatementSample.java | 104 -
core/conn/jdbc_type4/samples/build.xml | 44 -
.../jdbc_type4/samples/common/sampleUtils.java | 268 -
core/conn/jdbc_type4/samples/t4jdbc.properties | 26 -
core/conn/jdbc_type4/src/T4Messages.properties | 686 --
.../src/org/trafodion/jdbc/t4/Address.java | 117 -
.../src/org/trafodion/jdbc/t4/Bytes.java | 269 -
.../jdbc/t4/CONNECTION_CONTEXT_def.java | 149 -
.../jdbc/t4/CachedPreparedStatement.java | 67 -
.../org/trafodion/jdbc/t4/CancelMessage.java | 49 -
.../src/org/trafodion/jdbc/t4/CancelReply.java | 38 -
.../src/org/trafodion/jdbc/t4/Certificate.java | 112 -
.../src/org/trafodion/jdbc/t4/Cipher.java | 201 -
.../src/org/trafodion/jdbc/t4/CloseMessage.java | 48 -
.../src/org/trafodion/jdbc/t4/CloseReply.java | 48 -
.../src/org/trafodion/jdbc/t4/Compression.java | 149 -
.../org/trafodion/jdbc/t4/ConnectMessage.java | 62 -
.../src/org/trafodion/jdbc/t4/ConnectReply.java | 148 -
.../src/org/trafodion/jdbc/t4/Descriptor2.java | 85 -
.../trafodion/jdbc/t4/ERROR_DESC_LIST_def.java | 42 -
.../org/trafodion/jdbc/t4/ERROR_DESC_def.java | 65 -
.../jdbc/t4/EndTransactionMessage.java | 49 -
.../trafodion/jdbc/t4/EndTransactionReply.java | 49 -
.../org/trafodion/jdbc/t4/ExecuteMessage.java | 107 -
.../src/org/trafodion/jdbc/t4/ExecuteReply.java | 127 -
.../src/org/trafodion/jdbc/t4/FetchMessage.java | 63 -
.../src/org/trafodion/jdbc/t4/FetchReply.java | 63 -
.../org/trafodion/jdbc/t4/GenericMessage.java | 45 -
.../src/org/trafodion/jdbc/t4/GenericReply.java | 43 -
.../jdbc/t4/GetSQLCatalogsMessage.java | 88 -
.../trafodion/jdbc/t4/GetSQLCatalogsReply.java | 54 -
.../jdbc/t4/HPT4ConnectionPoolDataSource.java | 346 -
.../t4/HPT4ConnectionPoolDataSourceFactory.java | 68 -
.../org/trafodion/jdbc/t4/HPT4DataSource.java | 366 --
.../jdbc/t4/HPT4DataSourceFactory.java | 62 -
.../src/org/trafodion/jdbc/t4/HPT4Desc.java | 542 --
.../org/trafodion/jdbc/t4/HPT4Exception.java | 38 -
.../src/org/trafodion/jdbc/t4/HPT4Handle.java | 84 -
.../src/org/trafodion/jdbc/t4/HPT4Messages.java | 324 -
.../jdbc/t4/HPT4ParameterMetaData.java | 243 -
.../trafodion/jdbc/t4/HPT4PooledConnection.java | 238 -
.../jdbc/t4/HPT4PooledConnectionManager.java | 385 --
.../jdbc/t4/HPT4ResultSetMetaData.java | 309 -
.../src/org/trafodion/jdbc/t4/Header.java | 157 -
.../jdbc/t4/InitializeDialogueMessage.java | 66 -
.../jdbc/t4/InitializeDialogueReply.java | 90 -
.../src/org/trafodion/jdbc/t4/InputOutput.java | 682 --
.../trafodion/jdbc/t4/InterfaceConnection.java | 1420 -----
.../trafodion/jdbc/t4/InterfaceResultSet.java | 927 ---
.../trafodion/jdbc/t4/InterfaceStatement.java | 1392 -----
.../trafodion/jdbc/t4/InterfaceUtilities.java | 235 -
.../src/org/trafodion/jdbc/t4/Key.java | 161 -
.../org/trafodion/jdbc/t4/LogicalByteArray.java | 345 -
.../org/trafodion/jdbc/t4/MessageDigest.java | 84 -
.../src/org/trafodion/jdbc/t4/NCSAddress.java | 220 -
.../jdbc/t4/OUT_CONNECTION_CONTEXT_def.java | 97 -
.../src/org/trafodion/jdbc/t4/ObjectArray.java | 86 -
.../org/trafodion/jdbc/t4/PrepareMessage.java | 82 -
.../src/org/trafodion/jdbc/t4/PrepareReply.java | 103 -
.../jdbc/t4/PreparedStatementManager.java | 242 -
.../trafodion/jdbc/t4/SQLItemDescList_def.java | 46 -
.../trafodion/jdbc/t4/SQLItemDescOld_def.java | 54 -
.../org/trafodion/jdbc/t4/SQLItemDesc_def.java | 70 -
.../org/trafodion/jdbc/t4/SQLValueList_def.java | 64 -
.../src/org/trafodion/jdbc/t4/SQLValue_def.java | 55 -
.../trafodion/jdbc/t4/SQLWarningOrError.java | 47 -
.../trafodion/jdbc/t4/SQL_DataValue_def.java | 54 -
.../org/trafodion/jdbc/t4/SecClientMsgKeys.java | 58 -
.../src/org/trafodion/jdbc/t4/SecPwd.java | 265 -
.../trafodion/jdbc/t4/SecResourceBundle.java | 57 -
.../org/trafodion/jdbc/t4/SecdefsCommon.java | 84 -
.../src/org/trafodion/jdbc/t4/Security.java | 319 -
.../trafodion/jdbc/t4/SecurityException.java | 47 -
.../jdbc/t4/SetConnectionOptionMessage.java | 50 -
.../jdbc/t4/SetConnectionOptionReply.java | 45 -
.../src/org/trafodion/jdbc/t4/SymCrypto.java | 87 -
.../src/org/trafodion/jdbc/t4/T4Address.java | 315 -
.../src/org/trafodion/jdbc/t4/T4Connection.java | 505 --
.../org/trafodion/jdbc/t4/T4DSProperties.java | 967 ---
.../trafodion/jdbc/t4/T4DatabaseMetaData.java | 5901 ------------------
.../src/org/trafodion/jdbc/t4/T4Driver.java | 367 --
.../org/trafodion/jdbc/t4/T4LogFormatter.java | 236 -
.../trafodion/jdbc/t4/T4LoggingUtilities.java | 816 ---
.../src/org/trafodion/jdbc/t4/T4Properties.java | 2511 --------
.../src/org/trafodion/jdbc/t4/T4ResultSet.java | 164 -
.../src/org/trafodion/jdbc/t4/T4Statement.java | 204 -
.../org/trafodion/jdbc/t4/T4TimerThread.java | 116 -
.../org/trafodion/jdbc/t4/T4_Dcs_Cancel.java | 115 -
.../org/trafodion/jdbc/t4/T4_Dcs_Connect.java | 123 -
.../src/org/trafodion/jdbc/t4/TRANSPORT.java | 263 -
.../jdbc/t4/TerminateDialogueMessage.java | 38 -
.../jdbc/t4/TerminateDialogueReply.java | 39 -
.../jdbc/t4/TrafT4CallableStatement.java | 2462 --------
.../org/trafodion/jdbc/t4/TrafT4Connection.java | 1987 ------
.../jdbc/t4/TrafT4PreparedStatement.java | 2558 --------
.../org/trafodion/jdbc/t4/TrafT4ResultSet.java | 5106 ---------------
.../org/trafodion/jdbc/t4/TrafT4Statement.java | 1690 -----
.../org/trafodion/jdbc/t4/USER_DESC_def.java | 61 -
.../src/org/trafodion/jdbc/t4/Utility.java | 636 --
.../org/trafodion/jdbc/t4/VERSION_LIST_def.java | 65 -
.../src/org/trafodion/jdbc/t4/VERSION_def.java | 61 -
.../src/org/trafodion/jdbc/t4/Vproc.java | 36 -
.../jdbc/t4/odbc_Dcs_GetObjRefHdl_exc_.java | 95 -
.../jdbc/t4/odbc_Dcs_StopSrvr_exc_.java | 86 -
.../jdbc/t4/odbc_SQLSvc_Close_exc_.java | 69 -
.../t4/odbc_SQLSvc_EndTransaction_exc_.java | 87 -
.../jdbc/t4/odbc_SQLSvc_Execute_exc_.java | 89 -
.../jdbc/t4/odbc_SQLSvc_Fetch_exc_.java | 87 -
.../t4/odbc_SQLSvc_GetSQLCatalogs_exc_.java | 100 -
.../t4/odbc_SQLSvc_InitializeDialogue_exc_.java | 76 -
.../jdbc/t4/odbc_SQLSvc_Prepare_exc_.java | 68 -
.../odbc_SQLSvc_SetConnectionOption_exc_.java | 70 -
.../t4/odbc_SQLSvc_TerminateDialogue_exc_.java | 66 -
core/conn/jdbc_type4/src/secClient.properties | 53 -
core/conn/jdbc_type4/test/RunAllTests.java | 31 -
.../test/org/trafodion/jdbc/t4/BaseTest.java | 60 -
.../org/trafodion/jdbc/t4/T4DriverTest.java | 47 -
core/conn/trafci/build.xml | 4 +-
core/conn/trafci/install/Installer.java | 2 +-
core/conn/trafci/utils/trafci_install.sh | 2 +-
core/rest/pom.xml | 6 +-
core/sqf/sqenvcom.sh | 3 +-
core/sqf/sql/scripts/install_traf_components | 8 +-
core/sql/lib_mgmt/Makefile | 4 +-
core/sql/regress/udr/EXPECTED002 | 2 +-
core/sql/regress/udr/TEST002 | 2 +-
dcs/pom.xml | 8 +-
.../trafodion/dcs/zookeeper/DcsQuorumPeer.java | 22 +-
.../org/trafodion/dcs/zookeeper/ZKConfig.java | 21 +-
.../trafodion/dcs/zookeeper/ZKServerTool.java | 24 +-
.../org/trafodion/dcs/zookeeper/ZkClient.java | 22 +-
.../org/trafodion/dcs/zookeeper/ZkUtil.java | 23 +-
.../dcs/zookeeper/ZooKeeperMainServerArg.java | 23 +-
dcs/src/test/jdbc_test/jdbc_test.py | 4 +-
tests/phx/phoenix_test.py | 5 +-
281 files changed, 44868 insertions(+), 44920 deletions(-)
----------------------------------------------------------------------
[05/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4Connection.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4Connection.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4Connection.java
deleted file mode 100644
index f1d34f9..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4Connection.java
+++ /dev/null
@@ -1,1987 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.lang.ref.Reference;
-import java.lang.ref.ReferenceQueue;
-import java.lang.ref.WeakReference;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.CallableStatement;
-import java.sql.Clob;
-import java.sql.DatabaseMetaData;
-import java.sql.NClob;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLClientInfoException;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-import java.sql.Savepoint;
-import java.sql.Statement;
-import java.sql.Struct;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.Executor;
-import java.util.logging.FileHandler;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-import javax.sql.PooledConnection;
-
-/**
- * <p>
- * JDBC Type 4 TrafT4Connection class.
- * </p>
- * <p>
- * Description: The <code>TrafT4Connection</code> class is an implementation of
- * the <code>java.sql.Connection</code> interface.
- * </p>
- *
- */
-public class TrafT4Connection extends PreparedStatementManager implements java.sql.Connection {
-
- /**
- * Validates the connection by clearing warnings and verifying that the
- * Connection is still open.
- *
- * @throws SQLException
- * If the Connection is not valid
- */
- private void validateConnection() throws SQLException {
- clearWarnings();
-
- if (this.ic_ == null || this.ic_.isClosed()) {
- throw HPT4Messages.createSQLException(this.props_, this.getLocale(), "invalid_connection", null);
- }
- }
-
- public String getRemoteProcess() throws SQLException {
- return this.ic_.getRemoteProcess();
- }
-
- synchronized public void close() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "close", "", p);
- }
-
- if (this.ic_ == null || this.ic_.isClosed())
- return;
-
- // only hard-close if no pooled connection exists
- close((pc_ == null), true);
- }
-
- public void commit() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "commit", "", p);
- }
-
- validateConnection();
-
- try {
- ic_.commit();
- } catch (SQLException se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- }
-
- public void resetServerIdleTimer() throws SQLException {
- clearWarnings();
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
-
- this.setConnectionAttr(InterfaceConnection.RESET_IDLE_TIMER, 0, "0");
- }
-
- public String getApplicationName() throws SQLException {
- validateConnection();
-
- return this.ic_.getApplicationName();
- }
-
- public String getServerDataSource() throws SQLException {
- validateConnection();
-
- return this.ic_.getServerDataSource();
- }
-
- public boolean getEnforceISO() throws SQLException {
- validateConnection();
-
- return this.ic_.getEnforceISO();
- }
-
- public int getISOMapping() throws SQLException {
- validateConnection();
-
- return this.ic_.getISOMapping();
- }
-
- public String getRoleName() throws SQLException {
- validateConnection();
-
- return this.ic_.getRoleName();
- }
-
- public int getTerminalCharset() throws SQLException {
- validateConnection();
-
- return this.ic_.getTerminalCharset();
- }
-
- public T4Properties getT4Properties() throws SQLException {
- validateConnection();
-
- return this.ic_.t4props_;
- }
-
- public String getSessionName() throws SQLException {
- validateConnection();
-
- return this.ic_.getSessionName();
- }
-
- public Statement createStatement() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "createStatement", "", p);
- }
-
- validateConnection();
-
- try {
- return new TrafT4Statement(this);
- } catch (SQLException se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- }
-
- public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, resultSetType, resultSetConcurrency);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "createStatement", "", p);
- }
-
- validateConnection();
-
- try {
- return new TrafT4Statement(this, resultSetType, resultSetConcurrency);
- } catch (SQLException se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- }
-
- public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
- throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, resultSetType, resultSetConcurrency,
- resultSetHoldability);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "createStatement", "", p);
- }
-
- validateConnection();
-
- try {
- return new TrafT4Statement(this, resultSetType, resultSetConcurrency, resultSetHoldability);
- } catch (SQLException se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- }
-
- Locale getLocale() {
- if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "getLocale", "", p);
- }
- if (ic_ != null) {
- return ic_.getLocale();
- } else {
- return null;
- }
- }
-
- public boolean getAutoCommit() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getAutoCommit", "getAutoCommit", p);
- }
-
- validateConnection();
-
- return ic_.getAutoCommit();
- }
-
- public String getCatalog() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getCatalog", "", p);
- }
-
- validateConnection();
-
- return ic_.getCatalog();
- }
-
- public String getSchema() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getSchema", "", p);
- }
-
- Statement s = null;
- ResultSet rs = null;
- String sch = null;
-
- try {
- s = this.createStatement();
- rs = s.executeQuery("SHOWCONTROL DEFAULT SCHEMA, match full, no header");
- rs.next();
- sch = rs.getString(1);
- if(sch.charAt(0) != '\"' && sch.indexOf('.') != -1) {
- sch = sch.substring(sch.indexOf('.') + 1);
- }
- }catch(SQLException e) {
- sch = ic_.getSchema();
- }finally {
- if(rs != null)
- rs.close();
- if(s != null)
- s.close();
- }
-
- return sch;
- }
-
- public int getHoldability() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getHoldability", "", p);
- }
-
- validateConnection();
-
- return holdability_;
- }
-
- public DatabaseMetaData getMetaData() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getMetaData", "getMetaData", p);
- }
-
- validateConnection();
-
- return new T4DatabaseMetaData(this);
- }
-
- public int getTransactionIsolation() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getTransactionIsolation", "", p);
- }
-
- validateConnection();
-
- return ic_.getTransactionIsolation();
- }
-
- public Map getTypeMap() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getTypeMap", "", p);
- }
-
- validateConnection();
-
- return userMap_;
- }
-
- void isConnectionOpen() throws SQLException {
- validateConnection();
- }
-
- public boolean isClosed() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "isClosed", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("isClosed");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
-
- boolean rv = true;
-
- if (ic_ == null) {
- rv = true;
- // return true;
- } else {
- clearWarnings();
- rv = ic_.getIsClosed();
- }
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "isClosed", "At exit return = " + rv, p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("isClosed");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
-
- return rv;
- // return ic_.get_isClosed();
- }
-
- // New method that checks if the connection is closed
- // However, this is to be used only be internal classes
- // It does not clear any warnings associated with the current connection
- // Done for CASE 10_060123_4011 ; Swastik Bihani
- boolean _isClosed() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "_isClosed", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("_isClosed");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
-
- boolean rv = true;
-
- if (ic_ == null) {
- rv = true;
- } else {
- rv = ic_.getIsClosed();
- }
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "_isClosed", "At exit return = " + rv, p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("_isClosed");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
-
- return rv;
- }
-
- /**
- * @deprecated
- */
- public String getServiceName() throws SQLException {
- return "";
- }
-
- /**
- * @deprecated
- */
- public void setServiceName(String serviceName) throws SQLException {
-
- }
-
- public boolean isReadOnly() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "isReadOnly", "", p);
- }
-
- validateConnection();
-
- return ic_.isReadOnly();
- }
-
- public String nativeSQL(String sql) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, sql);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "nativeSQL", "", p);
- }
-
- validateConnection();
-
- return sql;
- }
-
- public CallableStatement prepareCall(String sql) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, sql);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "prepareCall", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, sql);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("prepareCall");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
-
- TrafT4CallableStatement stmt;
-
- clearWarnings();
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
-
- try {
- if (isStatementCachingEnabled()) {
- stmt = (TrafT4CallableStatement) getPreparedStatement(this, sql, ResultSet.TYPE_FORWARD_ONLY,
- ResultSet.CONCUR_READ_ONLY, holdability_);
-
- if (stmt != null) {
- return stmt;
- }
- }
-
- stmt = new TrafT4CallableStatement(this, sql);
- stmt.prepareCall(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
-
- if (isStatementCachingEnabled()) {
- addPreparedStatement(this, sql, stmt, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
- holdability_);
- }
- } catch (HPT4Exception se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- return stmt;
- }
-
- public CallableStatement prepareCall(String sql, String stmtLabel) throws SQLException {
- final String QUOTE = "\"";
-
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, sql);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "prepareCall", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, sql);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("prepareCall");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
-
- if (stmtLabel == null || stmtLabel.length() == 0) {
- throw HPT4Messages.createSQLException(props_, null, "null_data", null);
- }
-
- if (stmtLabel.startsWith(QUOTE) && stmtLabel.endsWith(QUOTE)) {
- int len = stmtLabel.length();
- if (len == 2) {
- throw HPT4Messages.createSQLException(props_, null, "null_data", null);
- } else {
- stmtLabel = stmtLabel.substring(1, len - 1);
- }
- } else {
- stmtLabel = stmtLabel.toUpperCase();
- }
-
- TrafT4CallableStatement stmt;
-
- clearWarnings();
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
-
- try {
- if (isStatementCachingEnabled()) {
- stmt = (TrafT4CallableStatement) getPreparedStatement(this, sql, ResultSet.TYPE_FORWARD_ONLY,
- ResultSet.CONCUR_READ_ONLY, holdability_);
-
- if (stmt != null) {
- return stmt;
- }
- }
-
- stmt = new TrafT4CallableStatement(this, sql, stmtLabel);
- stmt.prepareCall(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
-
- if (isStatementCachingEnabled()) {
- addPreparedStatement(this, sql, stmt, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
- holdability_);
- }
- } catch (HPT4Exception se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- return stmt;
- }
-
- public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, sql, resultSetType, resultSetConcurrency);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "prepaseCall", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, sql, resultSetType, resultSetConcurrency);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("prepaseCall");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- TrafT4CallableStatement stmt;
-
- clearWarnings();
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
-
- try {
- if (isStatementCachingEnabled()) {
- stmt = (TrafT4CallableStatement) getPreparedStatement(this, sql, resultSetType, resultSetConcurrency,
- holdability_);
- if (stmt != null) {
- return stmt;
- }
- }
-
- stmt = new TrafT4CallableStatement(this, sql, resultSetType, resultSetConcurrency);
- stmt.prepareCall(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
-
- if (isStatementCachingEnabled()) {
- addPreparedStatement(this, sql, stmt, resultSetType, resultSetConcurrency, holdability_);
- }
- } catch (HPT4Exception se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- return stmt;
- }
-
- public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,
- int resultSetHoldability) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, sql, resultSetType, resultSetConcurrency,
- resultSetHoldability);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "prepareCall", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, sql, resultSetType, resultSetHoldability);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("prepareCall");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- TrafT4CallableStatement stmt;
-
- clearWarnings();
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
- try {
- if (isStatementCachingEnabled()) {
- stmt = (TrafT4CallableStatement) getPreparedStatement(this, sql, resultSetType, resultSetConcurrency,
- resultSetHoldability);
- if (stmt != null) {
- return stmt;
- }
- }
-
- stmt = new TrafT4CallableStatement(this, sql, resultSetType, resultSetConcurrency, resultSetHoldability);
-
- stmt.prepareCall(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
-
- if (isStatementCachingEnabled()) {
- addPreparedStatement(this, sql, stmt, resultSetType, resultSetConcurrency, resultSetHoldability);
- }
- } catch (HPT4Exception se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- return stmt;
- }
-
- /**
- * Creates a <code>PreparedStatement</code> object for sending
- * parameterized SQL statements to the database.
- *
- * @param sql
- * SQL statement that might contain one or more '?' IN parameter
- * placeholders
- * @param stmtLabel
- * SQL statement label that can be passed to the method instead
- * of generated by the database system.
- * @returns a new default PreparedStatement object containing the
- * pre-compiled SQL statement
- * @throws SQLException
- * if a database access error occurs
- */
- public PreparedStatement prepareStatement(String sql, String stmtLabel) throws SQLException {
- final String QUOTE = "\"";
-
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, sql);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "prepareStatement", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, sql);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("prepareStatement");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
-
- if (stmtLabel == null || stmtLabel.length() == 0) {
- throw HPT4Messages.createSQLException(props_, null, "null_data", null);
- }
-
- if (stmtLabel.startsWith(QUOTE) && stmtLabel.endsWith(QUOTE)) {
- int len = stmtLabel.length();
- if (len == 2) {
- throw HPT4Messages.createSQLException(props_, null, "null_data", null);
- } else {
- stmtLabel = stmtLabel.substring(1, len - 1);
- }
- } else {
- stmtLabel = stmtLabel.toUpperCase();
- }
-
- TrafT4PreparedStatement stmt;
-
- clearWarnings();
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
- try {
- if (isStatementCachingEnabled()) {
- stmt = (TrafT4PreparedStatement) getPreparedStatement(this, sql, ResultSet.TYPE_FORWARD_ONLY,
- ResultSet.CONCUR_READ_ONLY, holdability_);
- if (stmt != null) {
- return stmt;
- }
- }
-
- stmt = new TrafT4PreparedStatement(this, sql, stmtLabel);
-
- stmt.prepare(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
-
- if (isStatementCachingEnabled()) {
- addPreparedStatement(this, sql, stmt, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
- holdability_);
- }
- } catch (HPT4Exception se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- return stmt;
- }
-
- public PreparedStatement prepareStatement(String sql) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, sql);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "prepareStatement", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, sql);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("prepareStatement");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
-
- TrafT4PreparedStatement stmt;
-
- clearWarnings();
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
- try {
- if (isStatementCachingEnabled()) {
- stmt = (TrafT4PreparedStatement) getPreparedStatement(this, sql, ResultSet.TYPE_FORWARD_ONLY,
- ResultSet.CONCUR_READ_ONLY, holdability_);
- if (stmt != null) {
- return stmt;
- }
- }
-
- stmt = new TrafT4PreparedStatement(this, sql);
-
- stmt.prepare(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
-
- if (isStatementCachingEnabled()) {
- addPreparedStatement(this, sql, stmt, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
- holdability_);
- }
- } catch (HPT4Exception se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- return stmt;
- }
-
- // SB 12/02/2004 - only for LOB statements - these will be not added to the
- // statement cache
- PreparedStatement prepareLobStatement(String sql) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, sql);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "prepareLobStatement", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, sql);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("prepareLobStatement");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
-
- TrafT4PreparedStatement stmt;
-
- clearWarnings();
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
-
- try {
- stmt = new TrafT4PreparedStatement(this, sql);
- stmt.prepare(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
- } catch (HPT4Exception se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- return stmt;
-
- }
-
- public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, sql, autoGeneratedKeys);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "prepareStatement", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, sql, autoGeneratedKeys);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("prepareStatement");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
-
- if (autoGeneratedKeys == TrafT4Statement.NO_GENERATED_KEYS) {
- return prepareStatement(sql);
- } else {
- throw HPT4Messages.createSQLException(props_, getLocale(), "auto_generated_keys_not_supported", null);
- }
- }
-
- public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, sql, columnIndexes);
- props_.t4Logger_.logp(Level.FINE, "SQLConnection", "prepareStatement", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, sql, columnIndexes);
- lr.setParameters(p);
- lr.setSourceClassName("SQLConnection");
- lr.setSourceMethodName("prepareStatement");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
-
- if (columnIndexes != null && columnIndexes.length > 0) {
- throw HPT4Messages.createSQLException(props_, getLocale(), "auto_generated_keys_not_supported", null);
- } else {
- return prepareStatement(sql);
- }
- }
-
- public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
- throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, sql, resultSetType, resultSetConcurrency);
- props_.t4Logger_.logp(Level.FINE, "SQLConnection", "prepareStatement", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, sql, resultSetType, resultSetConcurrency);
- lr.setParameters(p);
- lr.setSourceClassName("SQLConnection");
- lr.setSourceMethodName("prepareStatement");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- TrafT4PreparedStatement stmt;
-
- clearWarnings();
-
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
-
- try {
- if (isStatementCachingEnabled()) {
- stmt = (TrafT4PreparedStatement) getPreparedStatement(this, sql, resultSetType, resultSetConcurrency,
- holdability_);
- if (stmt != null) {
- return stmt;
- }
- }
-
- stmt = new TrafT4PreparedStatement(this, sql, resultSetType, resultSetConcurrency);
- stmt.prepare(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
-
- if (isStatementCachingEnabled()) {
- addPreparedStatement(this, sql, stmt, resultSetType, resultSetConcurrency, holdability_);
- }
- } catch (HPT4Exception se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- return stmt;
- }
-
- public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
- int resultSetHoldability) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, sql, resultSetType, resultSetConcurrency,
- resultSetHoldability);
- props_.t4Logger_.logp(Level.FINE, "SQLConnection", "prepareStatement", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, sql, resultSetType, resultSetHoldability);
- lr.setParameters(p);
- lr.setSourceClassName("SQLConnection");
- lr.setSourceMethodName("prepareStatement");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- TrafT4PreparedStatement stmt;
-
- clearWarnings();
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
-
- try {
- if (isStatementCachingEnabled()) {
- stmt = (TrafT4PreparedStatement) getPreparedStatement(this, sql, resultSetType, resultSetConcurrency,
- resultSetHoldability);
- if (stmt != null) {
- return stmt;
- }
- }
-
- stmt = new TrafT4PreparedStatement(this, sql, resultSetType, resultSetConcurrency, resultSetHoldability);
- stmt.prepare(stmt.sql_, stmt.queryTimeout_, stmt.resultSetHoldability_);
-
- if (isStatementCachingEnabled()) {
- addPreparedStatement(this, sql, stmt, resultSetType, resultSetConcurrency, resultSetHoldability);
- }
- } catch (HPT4Exception se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- return stmt;
- }
-
- public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, sql, columnNames);
- props_.t4Logger_.logp(Level.FINE, "SQLConnection", "prepareStatement", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, sql, columnNames);
- lr.setParameters(p);
- lr.setSourceClassName("SQLConnection");
- lr.setSourceMethodName("prepareStatement");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- if (columnNames != null && columnNames.length > 0) {
- throw HPT4Messages.createSQLException(props_, getLocale(), "auto_generated_keys_not_supported", null);
- } else {
- return prepareStatement(sql);
- }
- }
-
- public void releaseSavepoint(Savepoint savepoint) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, savepoint);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "releaseSavepoint", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, savepoint);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("releaseSavepoint");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- clearWarnings();
- HPT4Messages.throwUnsupportedFeatureException(props_, getLocale(), "releaseSavepoint()");
- }
-
- public void rollback() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "rollback", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("rollback");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- clearWarnings();
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
-
- // if (ic_.getTxid() == 0) - XA
- // return;
-
- // commit the Transaction
- try {
- ic_.rollback();
- } catch (HPT4Exception se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- // ic_.setTxid(0); - XA
- }
-
- public void rollback(Savepoint savepoint) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, savepoint);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "rollback", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, savepoint);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("rollback");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- clearWarnings();
- HPT4Messages.throwUnsupportedFeatureException(props_, getLocale(), "rollback(Savepoint)");
- }
-
- public void setAutoCommit(boolean autoCommit) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, autoCommit);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "setAutoCommit", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, autoCommit);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("setAutoCommit");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
-
- clearWarnings();
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
- try {
- ic_.setAutoCommit(this, autoCommit);
- } catch (HPT4Exception se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- }
-
- public void setCatalog(String catalog) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, catalog);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "setCalalog", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, catalog);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("setCalalog");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- clearWarnings();
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
- if (catalog != null) {
- try {
- ic_.setCatalog(this, catalog);
- } catch (HPT4Exception se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- }
- }
-
- public void setHoldability(int holdability) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, holdability);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "setHoldability", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, holdability);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("setHoldability");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- clearWarnings();
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
-
- if (holdability != TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT)
-
- {
- throw HPT4Messages.createSQLException(props_, getLocale(), "invalid_holdability", null);
- }
- holdability_ = holdability;
- }
-
- public void setReadOnly(boolean readOnly) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, readOnly);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "setReadOnly", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, readOnly);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("setReadOnly");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- clearWarnings();
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
- try {
- // ic_.setReadOnly(readOnly);
- ic_.setReadOnly(this, readOnly);
- } catch (HPT4Exception se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- }
-
- public void setConnectionAttr(short attr, int valueNum, String valueString) throws SQLException {
- ic_.setConnectionAttr(this, attr, valueNum, valueString);
- }
-
- //3196 - NDCS transaction for SPJ
- public void joinUDRTransaction(long transId) throws SQLException {
- String sTransid = String.valueOf(transId);
- ic_.setConnectionAttr(this, InterfaceConnection.SQL_ATTR_JOIN_UDR_TRANSACTION, 0, sTransid);
- }
-
- //3196 - NDCS transaction for SPJ
- public void suspendUDRTransaction() throws SQLException {
- String sTransid = String.valueOf(ic_.transId_);
- ic_.setConnectionAttr(this, InterfaceConnection.SQL_ATTR_SUSPEND_UDR_TRANSACTION, 0, sTransid);
- }
-
- public Savepoint setSavepoint(String name) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, name);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "setSavepoint", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, name);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("setSavepoint");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- clearWarnings();
- HPT4Messages.throwUnsupportedFeatureException(props_, getLocale(), "setSavepoint");
- return null;
- }
-
- public Savepoint setSavepoint() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "setSavepoint", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("setSavepoint");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- clearWarnings();
- HPT4Messages.throwUnsupportedFeatureException(props_, getLocale(), "setSavepoint");
- return null;
- }
-
- public void setTransactionIsolation(int level) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, level);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "setTransactionIsolation", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, level);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("setTransactionIsolation");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- clearWarnings();
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
- try {
- ic_.setTransactionIsolation(this, level);
- } catch (HPT4Exception se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- }
-
- // JDK 1.2
- public void setTypeMap(java.util.Map map) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, map);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "setTypeMap", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, map);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("setTypeMap");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- clearWarnings();
- userMap_ = map;
- }
-
- public void begintransaction() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "begintransaction", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("begintransaction");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
- try {
- ic_.beginTransaction();
-
- if (ic_.beginTransaction() == 0) {
- return;
- } else {
- setAutoCommit(false);
- }
- } catch (HPT4Exception se) {
- performConnectionErrorChecks(se);
- throw se;
- }
- }
-
- public long getCurrentTransaction() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getTxid", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("getTxid");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
- return ic_.getTxid();
- }
-
- public void setTxid(long txid) throws SQLException {
- setTransactionToJoin(Bytes.createLongBytes(txid, this.ic_.getByteSwap()));
- }
-
- public void setTransactionToJoin(byte[] txid) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, txid);
- props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "setTxid", "", p);
- }
- if (_isClosed() == true) {
- throw HPT4Messages.createSQLException(props_, null, "invalid_connection", null);
- }
-
- transactionToJoin = txid;
- }
-
- void gcStmts() {
- if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "gcStmt", "", p);
- }
- Reference pRef;
- String stmtLabel;
-
- while ((pRef = refStmtQ_.poll()) != null) {
- stmtLabel = (String) refToStmt_.get(pRef);
- // All PreparedStatement objects are added to Hashtable
- // Only Statement objects that produces ResultSet are added to
- // Hashtable
- // Hence stmtLabel could be null
- if (stmtLabel != null) {
- try {
- TrafT4Statement stmt = new TrafT4Statement(this, stmtLabel);
- stmt.close();
- stmt = null;
- } catch (SQLException e) {
- performConnectionErrorChecks(e);
- } finally {
- refToStmt_.remove(pRef);
- }
- }
- }
- }
-
- void removeElement(Reference pRef) {
- if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, pRef);
- props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "removeElement", "", p);
- }
-
- refToStmt_.remove(pRef);
- pRef.clear();
- }
-
- void addElement(Reference pRef, String stmtLabel) {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, stmtLabel);
- props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "addElement", "", p);
- }
- refToStmt_.put(pRef, stmtLabel);
- }
-
- private void physicalCloseStatements() {
- if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "physicalCloseStatement", "", p);
- }
- // close all the statements
- ArrayList stmts = new ArrayList(refToStmt_.values());
- int size = stmts.size();
- for (int i = 0; i < size; i++) {
- try {
- String stmtLabel = (String) stmts.get(i);
- TrafT4Statement stmt = new TrafT4Statement(this, stmtLabel);
- stmt.close();
- stmt = null;
- } catch (SQLException se) {
- // Ignore any exception and proceed to the next statement
- }
- }
- refToStmt_.clear();
-
-
- }
-
- private void rollbackAndIgnoreError() {
- if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "rollbackAndIgnoreError", "", p);
- }
- // Rollback the Transaction when autoCommit mode is OFF
- try {
- if (getAutoCommit() == false || isBeginTransaction) {
- rollback();
- }
- } catch (SQLException sqex) {
- if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "rollbackAndIgnoreError", "warning: "+sqex.getMessage(), p);
- }
- }
- }
-
-
- synchronized void close(boolean hardClose, boolean sendEvents) throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, hardClose, sendEvents);
- props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "close", "", p);
- }
- clearWarnings();
- try {
- if (!hardClose) {
- if (this.ic_ != null && this.ic_.getIsClosed()) {
- return;
- }
- if (isStatementCachingEnabled()) {
- closePreparedStatementsAll();
- } else {
- physicalCloseStatements();
- }
- rollbackAndIgnoreError();
-
- /*
- * //inform the NCS server to disregard the T4 ConnectionTimeout
- * value try{ if (ic_ != null) {
- * ic_.disregardT4ConnectionTimeout(this); } }catch(SQLException
- * e){ //ignore - new property from old MXCS ABD version (now
- * known as NCS) //ignored for backward compatibility }
- */
-
- // Need to logicallcally close the statement
- pc_.logicalClose(sendEvents);
- if (ic_ != null) {
- ic_.setIsClosed(true);
- }
- } else {
- if (getServerHandle() == null) {
- return;
- }
-
- // close all the statements
- physicalCloseStatements();
-
- // Need to logicallcally close the statement
- // Rollback the Transaction when autoCommit mode is OFF
- rollbackAndIgnoreError();
-
- if (isStatementCachingEnabled()) {
- clearPreparedStatementsAll();
- }
-
- // Close the connection
- try {
- ic_.close();
- } finally {
- if (ic_ != null) {
- ic_.removeElement(this);
- }
- ic_ = null;
- }
- }
- } catch (SQLException e) {
- performConnectionErrorChecks(e);
- throw e;
- } finally {
- // close the timer thread
- if (ic_ != null && ic_.getT4Connection() != null) {
- ic_.getT4Connection().closeTimers();
- }
- }
- }
-
- protected void finalize() {
- if (ic_ != null && ic_.getT4Connection() != null) {
- ic_.getT4Connection().closeTimers();
- }
- }
-
- void reuse() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "resue", "", p);
- }
- ic_.reuse();
- /*
- * try { ic_.enforceT4ConnectionTimeout(this); } catch (HPT4Exception
- * se) { //performConnectionErrorChecks(se); //throw se; //ignore - new
- * property from old MXCS ABD version (now known as NCS) //ignored for
- * backward compatibility }
- */
- }
-
-
- // Extension method for WLS, this method gives the pooledConnection object
- // associated with the given connection object.
- public PooledConnection getPooledConnection() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getPooledConnection", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("getPooledConnection");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- if (pc_ != null) {
- return pc_;
- } else {
- throw HPT4Messages.createSQLException(props_, getLocale(), "null_pooled_connection", null);
- }
- }
-
- TrafT4Connection(HPT4DataSource ds, T4Properties t4props) throws SQLException {
- super(t4props);
-
- t4props.setConnectionID(Integer.toString(this.hashCode()));
- setupLogging(t4props);
-
- if (t4props.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, ds, t4props);
- t4props.t4Logger_.logp(Level.FINE, "TrafT4Connection", "<init>", "", p);
- }
- if (t4props.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, ds, t4props);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("<init>");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- t4props.getLogWriter().println(temp);
- }
- ds_ = ds;
-
-
- makeConnection(t4props);
- holdability_ = TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT;
- }
-
- TrafT4Connection(HPT4PooledConnection poolConn, T4Properties t4props) throws SQLException {
- super(t4props);
-
- t4props.setConnectionID(Integer.toString(this.hashCode()));
- setupLogging(t4props);
-
- if (t4props.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, poolConn, t4props);
- t4props.t4Logger_.logp(Level.FINE, "TrafT4Connection", "<init>", "", p);
- }
- if (t4props.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_, poolConn, t4props);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("<init>");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- t4props.getLogWriter().println(temp);
- }
-
- pc_ = poolConn;
-
-
- makeConnection(t4props);
- holdability_ = TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT;
- }
-
- private void makeConnection(T4Properties t4props) throws SQLException {
- if (t4props.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_, t4props);
- t4props.t4Logger_.logp(Level.FINER, "TrafT4Connection", "makeConnection", "", p);
- }
-
- ArrayList<String> addresses = createAddressList(t4props);
- SQLException eList = null;
- boolean success = false;
-
- for(int i=0;i<addresses.size();i++) {
- clearWarnings();
- t4props.setUrl(addresses.get(i));
-
- try {
- ic_ = new InterfaceConnection(this, t4props);
- success = true;
- break;
- } catch (SQLException se) {
- boolean connectionError = performConnectionErrorChecks(se);
- if(addresses.size() == 1 || !connectionError) {
- throw se;
- }
- if(eList == null) {
- eList = se;
- }
- else {
- eList.setNextException(se);
- }
- }
- }
-
- if(!success) {
- throw eList;
- }
-
- if (ic_.sqlwarning_ != null) {
- setSqlWarning(ic_.sqlwarning_);
- }
-
- refStmtQ_ = new ReferenceQueue();
- refToStmt_ = new Hashtable();
- pRef_ = new WeakReference(this, ic_.refQ_);
- ic_.refTosrvrCtxHandle_.put(pRef_, ic_);
- props_ = t4props;
-
- ic_.enableNARSupport(this, props_.getBatchRecovery());
-
- if (props_.getSPJEnv()) {
- ic_.enableProxySyntax(this);
- }
- }
-
- private ArrayList<String> createAddressList(T4Properties t4props) {
- ArrayList<String> addresses = new ArrayList<String>(); //10 addresses by default
- addresses.add(t4props.getUrl());
- String os = System.getProperty("os.name");
- String enable = System.getProperty("t4jdbc.redirectaddr");
-
- if(enable != null && enable.equals("true") && os != null && os.equals("NONSTOP_KERNEL")) { // TODO get real name
- String providedUrl = t4props.getUrl();
- String providedHost = providedUrl.substring(16).toLowerCase();
- String hostPrefix = null;
- try {
- hostPrefix = java.net.InetAddress.getLocalHost().getHostName().substring(0, 5).toLowerCase();
- }catch(Exception e) {
- }
-
- if(hostPrefix != null && providedHost.startsWith(hostPrefix)) {
- File f = new File("/E/" + hostPrefix + "01/usr/t4jdbc/jdbcaddr.txt");
- if(f.exists()) {
- addresses.clear();
-
- String urlSuffix = providedUrl.substring(providedUrl.indexOf("/:"));
-
- try {
- BufferedReader in = new BufferedReader(new FileReader(f));
- String host;
- while ((host = in.readLine()) != null) {
- if(host.indexOf(':') == -1) {
- host += ":18650";
- }
- addresses.add(String.format("jdbc:t4jdbc://" + host + urlSuffix));
- }
- in.close();
- } catch (IOException e) {
- }
- }
- }
- }
-
- return addresses;
- }
-
-
-
- // --------------------------------------------------------
- private void setupLogging(T4Properties t4props) {
-
- String ID = T4LoggingUtilities.getUniqueID();
- String name = T4LoggingUtilities.getUniqueLoggerName(ID);
-
- if (t4props.getT4LogLevel() == Level.OFF) {
- if (dummyLogger_ == null) {
- dummyLogger_ = Logger.getLogger(name);
- }
- t4props.t4Logger_ = dummyLogger_;
- } else {
- t4props.t4Logger_ = Logger.getLogger(name);
- }
-
- // t4props.t4Logger_ = Logger.getLogger(name);
- t4props.t4Logger_.setUseParentHandlers(false);
- t4props.t4Logger_.setLevel(t4props.getT4LogLevel());
-
- if (t4props.getT4LogLevel() != Level.OFF) {
- FileHandler fh1 = t4props.getT4LogFileHandler();
- t4props.t4Logger_.addHandler(fh1);
- }
- } // end setupLogging
-
- // --------------------------------------------------------
-
- // Interface Methods
- InterfaceConnection getServerHandle() {
- if (props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINER, "TrafT4Connection", "getServerHandle", "", p);
- }
- return ic_;
- }
-
- // Interface Methods
- public int getDialogueId() throws SQLException {
- if (props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(props_);
- props_.t4Logger_.logp(Level.FINE, "TrafT4Connection", "getDialogueId", "", p);
- }
- if (props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4Connection");
- lr.setSourceMethodName("getDialogueId");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- props_.getLogWriter().println(temp);
- }
- return getServerHandle().getDialogueId();
- }
-
- /**
- * Returns true if the data format needs to be converted. Used by the
- * <CODE>TrafT4ResultSet</CODE> class.
- *
- * @return true if conversion is needed; otherwise, false.
- */
- public boolean getDateConversion() throws SQLException {
- validateConnection();
-
- return ic_.getDateConversion();
- }
-
- int getServerMajorVersion() throws SQLException {
- validateConnection();
-
- return ic_.getServerMajorVersion();
- }
-
- int getServerMinorVersion() throws SQLException {
- validateConnection();
-
- return ic_.getServerMinorVersion();
- }
-
-
- void closeErroredConnection(HPT4Exception se) {
- try {
- if (!erroredConnection) { // don't issue close repeatedly
- erroredConnection = true;
- if (pc_ != null) {
- pc_.sendConnectionErrorEvent(se);
- } else {
- // hardclose
- close(true, true);
- }
- }
- } catch (Exception e) {
- // ignore
- }
- }
-
-
- boolean erroredConnection = false;
-
- PreparedStatement[] LobPreparedStatements = new PreparedStatement[14];
-
- // boolean reserveEmptyDataLocator_ = false;
- // public static final int EMPTY_DATA_LOCATOR_UPDATE = 0;
-
- String clobTableName_;
- String blobTableName_;
- // String preparedClobTableName_;
- // String preparedBlobTableName_;
-
- static final int CLOB_INS_LOB_DATA_STMT = 0;
- static final int CLOB_GET_LOB_DATA_STMT = 1;
- static final int CLOB_GET_LOB_LEN_STMT = 2;
- static final int CLOB_DEL_LOB_DATA_STMT = 3;
- static final int CLOB_TRUN_LOB_DATA_STMT = 4;
- static final int CLOB_UPD_LOB_DATA_STMT = 5;
- static final int CLOB_GET_STRT_DATA_LOC_STMT = 6;
- static final int BLOB_INS_LOB_DATA_STMT = 7;
- static final int BLOB_GET_LOB_DATA_STMT = 8;
- static final int BLOB_GET_LOB_LEN_STMT = 9;
- static final int BLOB_DEL_LOB_DATA_STMT = 10;
- static final int BLOB_TRUN_LOB_DATA_STMT = 11;
- static final int BLOB_UPD_LOB_DATA_STMT = 12;
- static final int BLOB_GET_STRT_DATA_LOC_STMT = 13;
-
- static Logger dummyLogger_ = null;
-
- boolean[] bLobStatementPrepared = new boolean[14]; // initialized to false,
- // one each for the
- // BLOB/CLOB statements
- // listed above
-
- // Fields
- InterfaceConnection ic_;
-
- // Connection
- Map userMap_;
- ReferenceQueue refStmtQ_;
- Hashtable refToStmt_;
- Hashtable refToRS_;
- int holdability_;
- HPT4DataSource ds_;
- HPT4PooledConnection pc_;
- T4Driver driver_;
- WeakReference pRef_;
- T4Properties props_;
-
- byte[] transactionToJoin;
-
- private boolean isBeginTransaction = false;
-
- protected boolean isBeginTransaction() {
- return isBeginTransaction;
- }
-
- protected void setBeginTransaction(boolean isBeginTransaction) {
- this.isBeginTransaction = isBeginTransaction;
- }
-
-
- 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 Clob createClob() throws SQLException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Blob createBlob() throws SQLException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public NClob createNClob() throws SQLException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public SQLXML createSQLXML() throws SQLException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean isValid(int timeout) throws SQLException {
- // TODO Auto-generated method stub
- return false;
- }
-
- public void setClientInfo(String name, String value)
- throws SQLClientInfoException {
- // TODO Auto-generated method stub
-
- }
-
- public void setClientInfo(Properties properties)
- throws SQLClientInfoException {
- // TODO Auto-generated method stub
-
- }
-
- public String getClientInfo(String name) throws SQLException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Properties getClientInfo() throws SQLException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Array createArrayOf(String typeName, Object[] elements)
- throws SQLException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Struct createStruct(String typeName, Object[] attributes)
- throws SQLException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setSchema(String schema) throws SQLException {
- // TODO Auto-generated method stub
-
- }
-
- public void abort(Executor executor) throws SQLException {
- // TODO Auto-generated method stub
-
- }
-
- public void setNetworkTimeout(Executor executor, int milliseconds)
- throws SQLException {
- // TODO Auto-generated method stub
-
- }
-
- public int getNetworkTimeout() throws SQLException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- /*
- * JDK 1.6 functions public Clob createClob() throws SQLException { return
- * null; }
- *
- *
- * public Blob createBlob() throws SQLException { return null; }
- *
- *
- * public NClob createNClob() throws SQLException { return null; }
- *
- *
- * public SQLXML createSQLXML() throws SQLException { return null; }
- *
- *
- * public boolean isValid(int _int) throws SQLException { return false; }
- *
- *
- * public void setClientInfo(String string, String string1) throws
- * SQLClientInfoException { }
- *
- *
- * public void setClientInfo(Properties properties) throws
- * SQLClientInfoException { }
- *
- *
- * public String getClientInfo(String string) throws SQLException { return
- * ""; }
- *
- *
- * public Properties getClientInfo() throws SQLException { return null; }
- *
- *
- * public Array createArrayOf(String string, Object[] objectArray) throws
- * SQLException { return null; }
- *
- *
- * public Struct createStruct(String string, Object[] objectArray) throws
- * SQLException { return null; }
- *
- *
- * public Object unwrap(Class _class) throws SQLException { return null; }
- *
- *
- * public boolean isWrapperFor(Class _class) throws SQLException { return
- * false; }
- */
-}
[18/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/samples/PreparedStatementSample/PreparedStatementSample.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/samples/PreparedStatementSample/PreparedStatementSample.java b/core/conn/jdbc_type4/samples/PreparedStatementSample/PreparedStatementSample.java
deleted file mode 100755
index b086103..0000000
--- a/core/conn/jdbc_type4/samples/PreparedStatementSample/PreparedStatementSample.java
+++ /dev/null
@@ -1,151 +0,0 @@
-// @@@ 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 @@@
-import common.*;
-
-import java.sql.*;
-import java.math.BigDecimal;
-
-public class PreparedStatementSample
-{
- public static void main(String args[])
- {
-
- Connection connection;
- Statement stmt;
- PreparedStatement pStmt;
- ResultSet rs;
- DatabaseMetaData dbMeta;
- int rowNo;
- String table = "PreparedStatementSample";
-
- try
- {
- connection = sampleUtils.getPropertiesConnection();
- sampleUtils.dropTable(connection, table);
- sampleUtils.initialData(connection, table);
- sampleUtils.initialCurrentData(connection, table);
-
-
- for (int i = 0; i < 7; i++)
- {
- switch (i)
- {
- case 0:
- System.out.println("");
- System.out.println("Simple Select ");
- stmt = connection.createStatement();
- rs = stmt.executeQuery("select * from " + table);
- break;
- case 1:
- System.out.println("");
- System.out.println("Parameterized Select - CHAR");
- pStmt = connection.prepareStatement("select c1, c2 from " + table + " where c1 = ?");
- pStmt.setString(1, "Selva");
- rs = pStmt.executeQuery();
- break;
- case 2:
- System.out.println("");
- System.out.println("Parameterized Select - INT");
- pStmt = connection.prepareStatement("select c1, c2, c3 from " + table + " where c2 = ? or c2 = ?");
- pStmt.setInt(1, 100);
- pStmt.setInt(2, -100);
- rs = pStmt.executeQuery();
- break;
- case 3:
- System.out.println("");
- System.out.println("Parameterized Select - TIMESTAMP");
- pStmt = connection.prepareStatement("select c1, c2, c3, c10 from " + table + " where c10 = ?");
- pStmt.setTimestamp(1, Timestamp.valueOf("2000-05-06 10:11:12.0"));
- rs = pStmt.executeQuery();
- break;
- case 4:
- System.out.println("");
- System.out.println("Parameterized Select - DECIMAL");
- pStmt = connection.prepareStatement("select c1, c2, c3, c7 from " + table + " where c7 = ? or c7 = ?");
- pStmt.setBigDecimal(1, new BigDecimal("100.12"));
- pStmt.setBigDecimal(2, new BigDecimal("-100.12"));
- rs = pStmt.executeQuery();
- break;
- case 5:
- System.out.println("");
- System.out.println("Parameterized Select - NUMERIC");
- pStmt = connection.prepareStatement("select c1, c2, c3, c6 from " + table + " where c6 = ? or c6 = ?");
- pStmt.setBigDecimal(1, new BigDecimal("100.12"));
- pStmt.setBigDecimal(2, new BigDecimal("-100.12"));
- rs = pStmt.executeQuery();
- break;
- case 6:
- System.out.println("");
- System.out.println("Parameterized Select - DATE");
- pStmt = connection.prepareStatement(
- "select c11, c12 from " + table + " where c8 = ?");
- pStmt.setDate(1, Date.valueOf("2000-05-06"));
- rs = pStmt.executeQuery();
- break;
- default:
- rs = null;
- continue;
- }
-
- ResultSetMetaData rsMD = rs.getMetaData();
- System.out.println("");
- System.out.println("Printing ResultSetMetaData ...");
- System.out.println("No. of Columns " + rsMD.getColumnCount());
- for (int j = 1; j <= rsMD.getColumnCount(); j++)
- {
- System.out.println("Column " + j + " Data Type: " + rsMD.getColumnTypeName(j) + " Name: " + rsMD.getColumnName(j));
- }
- System.out.println("");
- System.out.println("Fetching rows...");
- rowNo = 0;
- while (rs.next())
- {
- rowNo++;
- System.out.println("");
- System.out.println("Printing Row " + rowNo + " using getString(), getObject()");
- for (int j=1; j <= rsMD.getColumnCount(); j++)
- {
- System.out.println("Column " + j + " - " + rs.getString(j) + "," + rs.getObject(j));
- }
-
- }
- System.out.println("");
- System.out.println("End of Data");
- rs.close();
- }
-
- sampleUtils.dropTable(connection, table);
- connection.close();
- }
- catch (SQLException e)
- {
- SQLException nextException;
-
- nextException = e;
- do
- {
- System.out.println(nextException.getMessage());
- System.out.println("SQLState " + nextException.getSQLState());
- System.out.println("Error Code " + nextException.getErrorCode());
- } while ((nextException = nextException.getNextException()) != null);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/samples/PreparedStatementSample/README
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/samples/PreparedStatementSample/README b/core/conn/jdbc_type4/samples/PreparedStatementSample/README
deleted file mode 100755
index 55c7252..0000000
--- a/core/conn/jdbc_type4/samples/PreparedStatementSample/README
+++ /dev/null
@@ -1,232 +0,0 @@
-
-Compiling the Java files
-========================
-On Windows Platform:
-%JAVA_HOME%\bin\javac -classpath ..\..\lib\jdbcT4.jar *.java ..\common\*.java
-
-On Linux:
-$JAVA_HOME/bin/javac -classpath ../../lib/jdbcT4.jar *.java ../common/*.java
-
-Note: Make sure there are no compilation errors displayed on
- the screen.
-
-
-Executing PreparedStatementSample
-=========================
-On Windows Platform:
-%JAVA_HOME%\bin\java -classpath ..\..\lib\jdbcT4.jar;..;. -Dt4jdbc.properties=..\t4jdbc.properties PreparedStatementSample
-
-On Linux:
-$JAVA_HOME/bin/java -classpath ../../lib/jdbcT4.jar:..:. -Dt4jdbc.properties=../t4jdbc.properties PreparedStatementSample
-
-
-Output of the execution would look like:
-========================================
-<DATE, TITME> common.sampleUtils getPropertiesConnection
-INFO: DriverManager.getConnection(url, props) passed
-
-Inserting TimeStamp
-
-Simple Select
-
-Printing ResultSetMetaData ...
-No. of Columns 12
-Column 1 Data Type: CHAR Name: C1
-Column 2 Data Type: SMALLINT Name: C2
-Column 3 Data Type: INTEGER Name: C3
-Column 4 Data Type: BIGINT Name: C4
-Column 5 Data Type: VARCHAR Name: C5
-Column 6 Data Type: NUMERIC Name: C6
-Column 7 Data Type: DECIMAL Name: C7
-Column 8 Data Type: DATE Name: C8
-Column 9 Data Type: TIME Name: C9
-Column 10 Data Type: TIMESTAMP Name: C10
-Column 11 Data Type: REAL Name: C11
-Column 12 Data Type: DOUBLE PRECISION Name: C12
-
-Fetching rows...
-
-Printing Row 1 using getString(), getObject()
-Column 1 - Row1 ,Row1
-Column 2 - 100,100
-Column 3 - 12345678,12345678
-Column 4 - 123456789012,123456789012
-Column 5 - Selva,Selva
-Column 6 - 100.12,100.12
-Column 7 - 100.12,100.12
-Column 8 - 2000-05-06,2000-05-06
-Column 9 - 10:11:12,10:11:12
-Column 10 - 2000-05-06 10:11:12.0,2000-05-06 10:11:12.0
-Column 11 - 100.12,100.12
-Column 12 - 100.12,100.12
-
-Printing Row 2 using getString(), getObject()
-Column 1 - Row2 ,Row2
-Column 2 - -100,-100
-Column 3 - -12345678,-12345678
-Column 4 - -123456789012,-123456789012
-Column 5 - Selva,Selva
-Column 6 - -100.12,-100.12
-Column 7 - -100.12,-100.12
-Column 8 - 2000-05-16,2000-05-16
-Column 9 - 10:11:12,10:11:12
-Column 10 - 2000-05-06 10:11:12.0,2000-05-06 10:11:12.0
-Column 11 - -100.12,-100.12
-Column 12 - -100.12,-100.12
-
-Printing Row 3 using getString(), getObject()
-Column 1 - TimeStamp ,TimeStamp
-Column 2 - -100,-100
-Column 3 - -12345678,-12345678
-Column 4 - -123456789012,-123456789012
-Column 5 - Selva,Selva
-Column 6 - -100.12,-100.12
-Column 7 - -100.12,-100.12
-Column 8 - 2004-04-14,2004-04-14
-Column 9 - 17:46:02,17:46:02
-Column 10 - 2004-04-14 17:46:02.74,2004-04-14 17:46:02.74
-Column 11 - -100.12,-100.12
-Column 12 - -100.12,-100.12
-
-End of Data
-
-Parameterized Select - CHAR
-
-Printing ResultSetMetaData ...
-No. of Columns 2
-Column 1 Data Type: CHAR Name: C1
-Column 2 Data Type: SMALLINT Name: C2
-
-Fetching rows...
-
-End of Data
-
-Parameterized Select - INT
-
-Printing ResultSetMetaData ...
-No. of Columns 3
-Column 1 Data Type: CHAR Name: C1
-Column 2 Data Type: SMALLINT Name: C2
-Column 3 Data Type: INTEGER Name: C3
-
-Fetching rows...
-
-Printing Row 1 using getString(), getObject()
-Column 1 - Row1 ,Row1
-Column 2 - 100,100
-Column 3 - 12345678,12345678
-
-Printing Row 2 using getString(), getObject()
-Column 1 - Row2 ,Row2
-Column 2 - -100,-100
-Column 3 - -12345678,-12345678
-
-Printing Row 3 using getString(), getObject()
-Column 1 - TimeStamp ,TimeStamp
-Column 2 - -100,-100
-Column 3 - -12345678,-12345678
-
-End of Data
-
-Parameterized Select - TIMESTAMP
-
-Printing ResultSetMetaData ...
-No. of Columns 4
-Column 1 Data Type: CHAR Name: C1
-Column 2 Data Type: SMALLINT Name: C2
-Column 3 Data Type: INTEGER Name: C3
-Column 4 Data Type: TIMESTAMP Name: C10
-
-Fetching rows...
-
-Printing Row 1 using getString(), getObject()
-Column 1 - Row1 ,Row1
-Column 2 - 100,100
-Column 3 - 12345678,12345678
-Column 4 - 2000-05-06 10:11:12.0,2000-05-06 10:11:12.0
-
-Printing Row 2 using getString(), getObject()
-Column 1 - Row2 ,Row2
-Column 2 - -100,-100
-Column 3 - -12345678,-12345678
-Column 4 - 2000-05-06 10:11:12.0,2000-05-06 10:11:12.0
-
-End of Data
-
-Parameterized Select - DECIMAL
-
-Printing ResultSetMetaData ...
-No. of Columns 4
-Column 1 Data Type: CHAR Name: C1
-Column 2 Data Type: SMALLINT Name: C2
-Column 3 Data Type: INTEGER Name: C3
-Column 4 Data Type: DECIMAL Name: C7
-
-Fetching rows...
-
-Printing Row 1 using getString(), getObject()
-Column 1 - Row1 ,Row1
-Column 2 - 100,100
-Column 3 - 12345678,12345678
-Column 4 - 100.12,100.12
-
-Printing Row 2 using getString(), getObject()
-Column 1 - Row2 ,Row2
-Column 2 - -100,-100
-Column 3 - -12345678,-12345678
-Column 4 - -100.12,-100.12
-
-Printing Row 3 using getString(), getObject()
-Column 1 - TimeStamp ,TimeStamp
-Column 2 - -100,-100
-Column 3 - -12345678,-12345678
-Column 4 - -100.12,-100.12
-
-End of Data
-
-Parameterized Select - NUMERIC
-
-Printing ResultSetMetaData ...
-No. of Columns 4
-Column 1 Data Type: CHAR Name: C1
-Column 2 Data Type: SMALLINT Name: C2
-Column 3 Data Type: INTEGER Name: C3
-Column 4 Data Type: NUMERIC Name: C6
-
-Fetching rows...
-
-Printing Row 1 using getString(), getObject()
-Column 1 - Row1 ,Row1
-Column 2 - 100,100
-Column 3 - 12345678,12345678
-Column 4 - 100.12,100.12
-
-Printing Row 2 using getString(), getObject()
-Column 1 - Row2 ,Row2
-Column 2 - -100,-100
-Column 3 - -12345678,-12345678
-Column 4 - -100.12,-100.12
-
-Printing Row 3 using getString(), getObject()
-Column 1 - TimeStamp ,TimeStamp
-Column 2 - -100,-100
-Column 3 - -12345678,-12345678
-Column 4 - -100.12,-100.12
-
-End of Data
-
-Parameterized Select - DATE
-
-Printing ResultSetMetaData ...
-No. of Columns 2
-Column 1 Data Type: REAL Name: C11
-Column 2 Data Type: DOUBLE PRECISION Name: C12
-
-Fetching rows...
-
-Printing Row 1 using getString(), getObject()
-Column 1 - 100.12,100.12
-Column 2 - 100.12,100.12
-
-End of Data
-===============================================
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/samples/README
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/samples/README b/core/conn/jdbc_type4/samples/README
deleted file mode 100755
index 916c8d2..0000000
--- a/core/conn/jdbc_type4/samples/README
+++ /dev/null
@@ -1,47 +0,0 @@
-This is samples README file.
-
-To setup the enviornment
-========================
- On UNIX platform:
- 1. export JAVA_HOME=<java home on your system>
-
- On WINDOWS platform command windows:
- 1. set JAVA_HOME=<java home on your system>
-
-
-To Configure samples
-====================
- Edit t4jdbc.properties file. Set the following values to your environment.
-
- catalog : SQL catalog - must exist on the database
- Please refer to the SQL documentation on how to create the catalog.
- schema : SQL schema - must exist on the database
- Please refer to the SQL documentation on how to create the schema.
-
- Example of creating catalog/schema:
- >>create catalog mycat;
- >>create schema mycat.myschema;
-
- user : Database user name
- password : Database text password
- url : jdbc:t4jdbc://<Database ip or name>:<port number where DCS is running>/:
-
- Example of a t4jdbc.properties file:
-
- catalog = CAT
- schema = SCH
- url = jdbc:t4jdbc://www.mymachine.net:61234/:
- user = software.john
- password = abcd
-
-
-
-To run the samples
-==================
- Follow the README file instructions in the following directories.
- 1. StatementSample
- 2. PreparedStatementSample
- 3. ResultSetSample
- 4. DBMetaSample
-
- NOTE: All samples create, populate and drop sample tables.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/samples/ResultSetSample/README
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/samples/ResultSetSample/README b/core/conn/jdbc_type4/samples/ResultSetSample/README
deleted file mode 100755
index 5a1d99e..0000000
--- a/core/conn/jdbc_type4/samples/ResultSetSample/README
+++ /dev/null
@@ -1,91 +0,0 @@
-Compiling the Java files
-========================
-On Windows Platform:
-%JAVA_HOME%\bin\javac -classpath ..\..\lib\jdbcT4.jar *.java ..\common\*.java
-
-On Linux:
-$JAVA_HOME/bin/javac -classpath ../../lib/jdbcT4.jar *.java ../common/*.java
-
-Note: Make sure there are no compilation errors displayed on
- the screen.
-
-
-Executing ResultSetSample
-=========================
-On Windows Platform:
-%JAVA_HOME%\bin\java -classpath ..\..\lib\jdbcT4.jar;..;. -Dt4jdbc.properties=..\t4jdbc.properties ResultSetSample
-
-On Linux:
-$JAVA_HOME/bin/java -classpath ../../lib/jdbcT4.jar:..:. -Dt4jdbc.properties=../t4jdbc.properties ResultSetSample
-
-
-Output of the execution would look like:
-========================================
-<DATE, TIME> common.sampleUtils getPropertiesConnection
-INFO: DriverManager.getConnection(url, props) passed
-
-Inserting TimeStamp
-
-Simple Select
-
-Printing ResultSetMetaData ...
-No. of Columns 12
-Column 1 Data Type: CHAR Name: C1
-Column 2 Data Type: SMALLINT Name: C2
-Column 3 Data Type: INTEGER Name: C3
-Column 4 Data Type: BIGINT Name: C4
-Column 5 Data Type: VARCHAR Name: C5
-Column 6 Data Type: NUMERIC Name: C6
-Column 7 Data Type: DECIMAL Name: C7
-Column 8 Data Type: DATE Name: C8
-Column 9 Data Type: TIME Name: C9
-Column 10 Data Type: TIMESTAMP Name: C10
-Column 11 Data Type: REAL Name: C11
-Column 12 Data Type: DOUBLE PRECISION Name: C12
-
-Fetching rows...
-
-Printing Row 1 using getString(), getObject()
-Column 1 - Row1 ,Row1
-Column 2 - 100,100
-Column 3 - 12345678,12345678
-Column 4 - 123456789012,123456789012
-Column 5 - Selva,Selva
-Column 6 - 100.12,100.12
-Column 7 - 100.12,100.12
-Column 8 - 2000-05-06,2000-05-06
-Column 9 - 10:11:12,10:11:12
-Column 10 - 2000-05-06 10:11:12.0,2000-05-06 10:11:12.0
-Column 11 - 100.12,100.12
-Column 12 - 100.12,100.12
-
-Printing Row 2 using getString(), getObject()
-Column 1 - Row2 ,Row2
-Column 2 - -100,-100
-Column 3 - -12345678,-12345678
-Column 4 - -123456789012,-123456789012
-Column 5 - Selva,Selva
-Column 6 - -100.12,-100.12
-Column 7 - -100.12,-100.12
-Column 8 - 2000-05-16,2000-05-16
-Column 9 - 10:11:12,10:11:12
-Column 10 - 2000-05-06 10:11:12.0,2000-05-06 10:11:12.0
-Column 11 - -100.12,-100.12
-Column 12 - -100.12,-100.12
-
-Printing Row 3 using getString(), getObject()
-Column 1 - TimeStamp ,TimeStamp
-Column 2 - -100,-100
-Column 3 - -12345678,-12345678
-Column 4 - -123456789012,-123456789012
-Column 5 - Selva,Selva
-Column 6 - -100.12,-100.12
-Column 7 - -100.12,-100.12
-Column 8 - 2004-04-14,2004-04-14
-Column 9 - 16:19:47,16:19:47
-Column 10 - 2004-04-14 16:19:47.003,2004-04-14 16:19:47.003
-Column 11 - -100.12,-100.12
-Column 12 - -100.12,-100.12
-
-End of Data
-========================================
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/samples/ResultSetSample/ResultSetSample.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/samples/ResultSetSample/ResultSetSample.java b/core/conn/jdbc_type4/samples/ResultSetSample/ResultSetSample.java
deleted file mode 100755
index 47b0b4c..0000000
--- a/core/conn/jdbc_type4/samples/ResultSetSample/ResultSetSample.java
+++ /dev/null
@@ -1,104 +0,0 @@
-// @@@ 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 @@@
-import common.*;
-
-import java.sql.*;
-import java.math.BigDecimal;
-
-public class ResultSetSample
-{
- public static void main(String args[])
- {
-
- Connection connection;
- Statement stmt;
- PreparedStatement pStmt;
- ResultSet rs;
- DatabaseMetaData dbMeta;
- int rowNo;
- String table = "ResultSetSample";
-
- try
- {
- connection = sampleUtils.getPropertiesConnection();
- sampleUtils.dropTable(connection, table);
- sampleUtils.initialData(connection, table);
- sampleUtils.initialCurrentData(connection, table);
-
- for (int i = 0; i < 10; i++)
- {
- switch (i)
- {
- case 0:
- System.out.println("");
- System.out.println("Simple Select ");
- stmt = connection.createStatement();
- rs = stmt.executeQuery("select * from " + table);
- break;
- default:
- rs = null;
- continue;
- }
-
- ResultSetMetaData rsMD = rs.getMetaData();
- System.out.println("");
- System.out.println("Printing ResultSetMetaData ...");
- System.out.println("No. of Columns " + rsMD.getColumnCount());
- for (int j = 1; j <= rsMD.getColumnCount(); j++)
- {
- System.out.println("Column " + j + " Data Type: " + rsMD.getColumnTypeName(j) + " Name: " + rsMD.getColumnName(j));
- }
- System.out.println("");
- System.out.println("Fetching rows...");
- rowNo = 0;
- while (rs.next())
- {
- rowNo++;
- System.out.println("");
- System.out.println("Printing Row " + rowNo + " using getString(), getObject()");
- for (int j=1; j <= rsMD.getColumnCount(); j++)
- {
- System.out.println("Column " + j + " - " + rs.getString(j) + "," + rs.getObject(j));
- }
-
- }
- System.out.println("");
- System.out.println("End of Data");
- rs.close();
- }
-
- sampleUtils.dropTable(connection, table);
- connection.close();
- }
- catch (SQLException e)
- {
- SQLException nextException;
-
- nextException = e;
- do
- {
- System.out.println(nextException.getMessage());
- System.out.println("SQLState " + nextException.getSQLState());
- System.out.println("Error Code " + nextException.getErrorCode());
- } while ((nextException = nextException.getNextException()) != null);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/samples/StatementSample/README
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/samples/StatementSample/README b/core/conn/jdbc_type4/samples/StatementSample/README
deleted file mode 100755
index 159f349..0000000
--- a/core/conn/jdbc_type4/samples/StatementSample/README
+++ /dev/null
@@ -1,92 +0,0 @@
-Compiling the Java files
-========================
-On Windows Platform:
-%JAVA_HOME%\bin\javac -classpath ..\..\lib\jdbcT4.jar *.java ..\common\*.java
-
-On Linux:
-$JAVA_HOME/bin/javac -classpath ../../lib/jdbcT4.jar *.java ../common/*.java
-
-Note: Make sure there are no compilation errors displayed on
- the screen.
-
-
-Executing StatementSample
-=========================
-On Windows Platform:
-%JAVA_HOME%\bin\java -classpath ..\..\lib\jdbcT4.jar;..;. -Dt4jdbc.properties=..\t4jdbc.properties StatementSample
-
-On Linux:
-$JAVA_HOME/bin/java -classpath ../../lib/jdbcT4.jar:..:. -Dt4jdbc.properties=../t4jdbc.properties StatementSample
-
-
-Output of the execution would look like:
-========================================
-
-<DATE, TIME> common.sampleUtils getPropertiesConnection
-INFO: DriverManager.getConnection(url, props) passed
-
-Inserting TimeStamp
-
-Simple Select
-
-Printing ResultSetMetaData ...
-No. of Columns 12
-Column 1 Data Type: CHAR Name: C1
-Column 2 Data Type: SMALLINT Name: C2
-Column 3 Data Type: INTEGER Name: C3
-Column 4 Data Type: BIGINT Name: C4
-Column 5 Data Type: VARCHAR Name: C5
-Column 6 Data Type: NUMERIC Name: C6
-Column 7 Data Type: DECIMAL Name: C7
-Column 8 Data Type: DATE Name: C8
-Column 9 Data Type: TIME Name: C9
-Column 10 Data Type: TIMESTAMP Name: C10
-Column 11 Data Type: REAL Name: C11
-Column 12 Data Type: DOUBLE PRECISION Name: C12
-
-Fetching rows...
-
-Printing Row 1 using getString(), getObject()
-Column 1 - Row1 ,Row1
-Column 2 - 100,100
-Column 3 - 12345678,12345678
-Column 4 - 123456789012,123456789012
-Column 5 - Selva,Selva
-Column 6 - 100.12,100.12
-Column 7 - 100.12,100.12
-Column 8 - 2000-05-06,2000-05-06
-Column 9 - 10:11:12,10:11:12
-Column 10 - 2000-05-06 10:11:12.0,2000-05-06 10:11:12.0
-Column 11 - 100.12,100.12
-Column 12 - 100.12,100.12
-
-Printing Row 2 using getString(), getObject()
-Column 1 - Row2 ,Row2
-Column 2 - -100,-100
-Column 3 - -12345678,-12345678
-Column 4 - -123456789012,-123456789012
-Column 5 - Selva,Selva
-Column 6 - -100.12,-100.12
-Column 7 - -100.12,-100.12
-Column 8 - 2000-05-16,2000-05-16
-Column 9 - 10:11:12,10:11:12
-Column 10 - 2000-05-06 10:11:12.0,2000-05-06 10:11:12.0
-Column 11 - -100.12,-100.12
-Column 12 - -100.12,-100.12
-
-Printing Row 3 using getString(), getObject()
-Column 1 - TimeStamp ,TimeStamp
-Column 2 - -100,-100
-Column 3 - -12345678,-12345678
-Column 4 - -123456789012,-123456789012
-Column 5 - Selva,Selva
-Column 6 - -100.12,-100.12
-Column 7 - -100.12,-100.12
-Column 8 - 2004-04-14,2004-04-14
-Column 9 - 15:43:36,15:43:36
-Column 10 - 2004-04-14 15:43:36.167,2004-04-14 15:43:36.167
-Column 11 - -100.12,-100.12
-Column 12 - -100.12,-100.12
-
-End of Data
--------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/samples/StatementSample/StatementSample.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/samples/StatementSample/StatementSample.java b/core/conn/jdbc_type4/samples/StatementSample/StatementSample.java
deleted file mode 100755
index 765d9d4..0000000
--- a/core/conn/jdbc_type4/samples/StatementSample/StatementSample.java
+++ /dev/null
@@ -1,104 +0,0 @@
-// @@@ 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 @@@
-import common.*;
-
-import java.sql.*;
-import java.math.BigDecimal;
-
-public class StatementSample
-{
- public static void main(String args[])
- {
-
- Connection connection;
- Statement stmt;
- PreparedStatement pStmt;
- ResultSet rs;
- DatabaseMetaData dbMeta;
- int rowNo;
- String table = "StatementSample";
-
- try
- {
- connection = sampleUtils.getPropertiesConnection();
- sampleUtils.dropTable(connection, table);
- sampleUtils.initialData(connection, table);
- sampleUtils.initialCurrentData(connection, table);
-
- for (int i = 0; i < 1; i++)
- {
- switch (i)
- {
- case 0:
- System.out.println("");
- System.out.println("Simple Select ");
- stmt = connection.createStatement();
- rs = stmt.executeQuery("select * from " + table);
- break;
- default:
- rs = null;
- continue;
- }
-
- ResultSetMetaData rsMD = rs.getMetaData();
- System.out.println("");
- System.out.println("Printing ResultSetMetaData ...");
- System.out.println("No. of Columns " + rsMD.getColumnCount());
- for (int j = 1; j <= rsMD.getColumnCount(); j++)
- {
- System.out.println("Column " + j + " Data Type: " + rsMD.getColumnTypeName(j) + " Name: " + rsMD.getColumnName(j));
- }
- System.out.println("");
- System.out.println("Fetching rows...");
- rowNo = 0;
- while (rs.next())
- {
- rowNo++;
- System.out.println("");
- System.out.println("Printing Row " + rowNo + " using getString(), getObject()");
- for (int j=1; j <= rsMD.getColumnCount(); j++)
- {
- System.out.println("Column " + j + " - " + rs.getString(j) + "," + rs.getObject(j));
- }
-
- }
- System.out.println("");
- System.out.println("End of Data");
- rs.close();
- }
-
- sampleUtils.dropTable(connection, table);
- connection.close();
- }
- catch (SQLException e)
- {
- SQLException nextException;
-
- nextException = e;
- do
- {
- System.out.println(nextException.getMessage());
- System.out.println("SQLState " + nextException.getSQLState());
- System.out.println("Error Code " + nextException.getErrorCode());
- } while ((nextException = nextException.getNextException()) != null);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/samples/build.xml
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/samples/build.xml b/core/conn/jdbc_type4/samples/build.xml
deleted file mode 100644
index 663e2fc..0000000
--- a/core/conn/jdbc_type4/samples/build.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!-- @@@ 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 @@@ -->
-
-<project name="jdbct4" default="deploy">
- <tstamp>
- <format property="now.timestamp" pattern="yyyy_MM_dd" locale="en" />
- </tstamp>
-
- <target name="init">
- <mkdir dir="target"/>
- <mkdir dir="target/classes"/>
- </target>
-
-
- <target name="deploy" depends="clean,init">
- <javac srcdir="CallableStatementSample" destdir="target/classes" includes="**/IntegerSPJ.java"></javac>
- <jar basedir="target/classes" includes="IntegerSPJ.class" destfile="target/qaspj.jar"></jar>
- </target>
-
- <target name="clean">
- <delete dir="target" deleteonexit="true">
- </delete>
- </target>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/samples/common/sampleUtils.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/samples/common/sampleUtils.java b/core/conn/jdbc_type4/samples/common/sampleUtils.java
deleted file mode 100755
index f234d28..0000000
--- a/core/conn/jdbc_type4/samples/common/sampleUtils.java
+++ /dev/null
@@ -1,268 +0,0 @@
-// @@@ 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 common;
-
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.sql.PreparedStatement;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.util.*;
-import java.io.*;
-import java.util.logging.*;
-import java.net.*;
-
-
-public class sampleUtils
-{
- static String url;
- static String usr;
- static String pwd;
- public static Properties props;
-
- //------------------------------------------------------------------------
- static
- {
- try
- {
- String propFile = System.getProperty("t4jdbc.properties");
- if (propFile != null)
- {
- FileInputStream fs = new FileInputStream(new File(propFile));
- props = new Properties();
- props.load(fs);
-
- url = props.getProperty("url");
- usr = props.getProperty("user");
- pwd = props.getProperty("password");
- } else {
- System.out.println("Error: t4jdbc.properties is not set. Exiting.");
- System.exit(0);
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- System.out.println(e.getMessage());
- }
-
- try
- {
- Class.forName("org.trafodion.jdbc.t4.T4Driver");
- Logger.global.setLevel(Level.FINEST);
- } catch (Exception e) {
- e.printStackTrace();
- System.out.println(e.getMessage());
- System.exit(0);
- }
- }
-
- //------------------------------------------------------------------------
- static void checkprops() throws SQLException
- {
- if (props == null)
- throw new SQLException ("Error: t4jdbc.properties is null. Exiting.");
- }
-
- //------------------------------------------------------------------------
- public static Connection getUserConnection() throws SQLException
- {
- Connection connection = null;
- checkprops();
-
- Logger.global.log(Level.FINE,"DriverManager.getConnection(url, usr, pwd)");
- connection = DriverManager.getConnection(url, usr, pwd);
- Logger.global.log(Level.INFO, "DriverManager.getConnection(url, usr, pwd) passed");
- Logger.global.log(Level.FINE, "==============\n\n");
-
- return connection;
- }
-
-
- //------------------------------------------------------------------------
- public static Connection getPropertiesConnection() throws SQLException
- {
-
- Connection connection = null;
- checkprops();
-
- Logger.global.log(Level.FINE, "DriverManager.getConnection(url, props)");
- Logger.global.log(Level.FINEST, "Properties = " + props);
- connection = DriverManager.getConnection(url, props);
- Logger.global.log(Level.INFO, "DriverManager.getConnection(url, props) passed");
- Logger.global.log(Level.FINE, "==============\n\n");
-
- return connection;
- }
-
- //------------------------------------------------------------------------
- public static Connection getUrlConnection() throws SQLException
- {
- Connection connection = null;
- checkprops();
-
- Logger.global.log(Level.FINE, "DriverManager.getConnection(url)");
- connection = DriverManager.getConnection(url);
- Logger.global.log(Level.INFO, "DriverManager.getConnection(url) passed");
- Logger.global.log(Level.FINE, "==============\n\n");
-
- return connection;
- }
-
- //------------------------------------------------------------------------
- public static Connection getUrlConnection(String newUrl) throws SQLException
- {
- Connection connection = null;
- checkprops();
-
- Logger.global.log(Level.FINE, "DriverManager.getConnection(newUrl) newUrl = " + newUrl);
- connection = DriverManager.getConnection(newUrl);
- Logger.global.log(Level.INFO, "DriverManager.getConnection(newUrl) passed mewUrl = " + newUrl);
- Logger.global.log(Level.FINE, "==============\n\n");
-
- return connection;
- }
-
- //------------------------------------------------------------------------
- public static void main(String args[])
- {
-
- Connection connection, connection1, connection2;
-
- try
- {
- connection = getUserConnection();
- connection1 = getPropertiesConnection();
- connection2 = getUrlConnection();
-
- Logger.global.log(Level.INFO, "testing valid setCatalog");
- connection.setCatalog("Velu");
- Logger.global.log(Level.INFO, "testing valid setCatalog done");
-
- Logger.global.log(Level.INFO, "testing invalid setTransactionIsolation");
- connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
- Logger.global.log(Level.INFO, "testing invalid TransactionIsolation done");
-
- Logger.global.log(Level.FINE, "testing connection.close for (url)");
- connection.close();
- Logger.global.log(Level.INFO, "testing connection.close for (url) passed");
- Logger.global.log(Level.FINE, "==============\n\n");
-
- Logger.global.log(Level.FINE, "testing connection.close for (url, usr, pwd)");
- connection1.close();
- Logger.global.log(Level.INFO, "testing connection.close for (url) passed");
- Logger.global.log(Level.FINE, "==============\n\n");
-
- Logger.global.log(Level.FINE, "testing connection.close for (url, info)");
- connection2.close();
- Logger.global.log(Level.INFO, "testing connection.close for (url) passed");
- Logger.global.log(Level.FINE, "==============\n\n");
-
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- public static void dropTable(Connection conn, String table)
- {
- Statement stmt = null;
-
- try
- {
- stmt = conn.createStatement();
- stmt.executeUpdate("drop table " + table);
- }
- catch (SQLException e)
- {
- Logger.global.log(Level.FINE, "Drop table failed for = " + table);
- Logger.global.log(Level.FINE, "==============\n\n");
- } finally {
- try {
- stmt.close();
- } catch (Exception ex) {}
- }
- }
-
- public static void initialData(Connection conn, String table) throws SQLException
- {
- Statement stmt = null;
-
- try
- {
- stmt = conn.createStatement();
- stmt.executeUpdate("create table " + table + " (c1 char(20), c2 smallint, c3 integer, c4 largeint, c5 varchar(120), c6 numeric(10,2), c7 decimal(10,2),c8 date, c9 time, c10 timestamp, c11 real, c12 double precision) NO PARTITION");
-
- stmt.executeUpdate("insert into " + table + " values('Row1', 100, 12345678, 123456789012, 'Selva', 100.12, 100.12, {d '2000-05-06'}, {t '10:11:12'}, {ts '2000-05-06 10:11:12.0'}, 100.12, 100.12)");
-
- stmt.executeUpdate("insert into " + table + " values('Row2', -100, -12345678, -123456789012, 'Selva', -100.12, -100.12, {d '2000-05-16'}, {t '10:11:12'}, {ts '2000-05-06 10:11:12'}, -100.12, -100.12)");
- stmt.close();
-
- }
- catch (SQLException e)
- {
- Logger.global.log(Level.FINE, "InitialData failed = " + e);
- Logger.global.log(Level.FINE, "==============\n\n");
- try {
- stmt.close();
- } catch (Exception ex) {}
- throw e;
- }
- }
-
- public static void initialCurrentData(Connection conn, String table) throws SQLException
- {
- PreparedStatement pStmt = null;
-
- try
- {
- System.out.println("");
- System.out.println("Inserting TimeStamp ");
- pStmt = conn.prepareStatement(
- "insert into " + table + " values('TimeStamp', -100, -12345678, -123456789012, 'Selva', -100.12, -100.12, ?, ?, ?, -100.12, -100.12)"
- );
-
- pStmt.setDate(1, new Date(new java.util.Date().getTime()));
- pStmt.setTime(2, new Time(new java.util.Date().getTime()));
- Timestamp t1 = new Timestamp( (new java.util.Date()).getTime());
- pStmt.setTimestamp(3, t1);
- if (pStmt.executeUpdate() != 1)
- {
- System.out.println("executeUpdate of TimeStamp failed");
- }
- pStmt.close();
-
- }
- catch (SQLException e)
- {
- Logger.global.log(Level.FINE, "InitialCurrentData failed =" + e);
- Logger.global.log(Level.FINE, "==============\n\n");
- try {
- pStmt.close();
- } catch (Exception ex) {}
- throw e;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/samples/t4jdbc.properties
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/samples/t4jdbc.properties b/core/conn/jdbc_type4/samples/t4jdbc.properties
deleted file mode 100755
index d4c1f98..0000000
--- a/core/conn/jdbc_type4/samples/t4jdbc.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-# @@@ 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 @@@
-
-catalog = TRAFODION
-schema = SCH
-url = jdbc:t4jdbc://server:port/:
-user = usr
-password = pwd
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/T4Messages.properties
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/T4Messages.properties b/core/conn/jdbc_type4/src/T4Messages.properties
deleted file mode 100644
index 24d6fb1..0000000
--- a/core/conn/jdbc_type4/src/T4Messages.properties
+++ /dev/null
@@ -1,686 +0,0 @@
-# @@@ 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 @@@
-##############################################################
-
-#
-# Messages for T2 Driver
-#
-
-unsupported_feature_msg=Unsupported feature - {0}
-unsupported_feature_sqlstate=HYC00
-unsupported_feature_sqlcode=29001
-
-invalid_connection_msg=Connection does not exist
-invalid_connection_sqlstate=08003
-invalid_connection_sqlcode=29002
-
-invalid_statement_msg=Statement does not exist
-invalid_statement_sqlstate=HY000
-invalid_statement_sqlcode=29003
-
-invalid_transaction_isolation_msg=Invalid transaction isolation value
-invalid_transaction_isolation_sqlstate=HY024
-invalid_transaction_isolation_sqlcode=29004
-
-invalid_resultset_type_msg=Invalid ResultSet Type
-invalid_resultset_type_sqlstate=HY024
-invalid_resultset_type_sqlcode=29005
-
-invalid_resultset_concurrency_msg=Invalid Result Set Concurrency
-invalid_resultset_concurrency_sqlstate=HY000
-invalid_resultset_concurrency_sqlcode=29006
-
-invalid_desc_index_msg=Invalid descriptor index
-invalid_desc_index_sqlstate=07009
-invalid_desc_index_sqlcode=29007
-
-invalid_cursor_state_msg=Invalid cursor State
-invalid_cursor_state_sqlstate=24000
-invalid_cursor_state_sqlcode=29008
-
-invalid_cursor_position_msg=Invalid cursor position
-invalid_cursor_position_sqlstate=HY109
-invalid_cursor_position_sqlcode=29009
-
-invalid_column_name_msg=Invalid column name
-invalid_column_name_sqlstate=07009
-invalid_column_name_sqlcode=29010
-
-invalid_column_index_msg=Invalid column index or descriptor index
-invalid_column_index_sqlstate=07009
-invalid_column_index_sqlcode=29011
-
-restricted_data_type_msg=Restricted data type attribute violation
-restricted_data_type_sqlstate=07006
-restricted_data_type_sqlcode=29012
-
-invalid_fetch_size_msg=Fetch size is less than 0
-invalid_fetch_size_sqlstate=HY024
-invalid_fetch_size_sqlcode=29013
-
-fetch_output_inconsistent_msg=General Error - Programming error in next()
-fetch_output_inconsistent_sqlstate=HY000
-fetch_output_inconsistent_sqlcode=29014
-
-invalid_fetch_direction_msg=Invalid fetch direction
-invalid_fetch_direction_sqlstate=HY024
-invalid_fetch_direction_sqlcode=29015
-
-reverse_fetch_not_supported_msg=ResultSet.FETCH_REVERSE not supported
-reverse_fetch_not_supported_sqlstate=HYC00
-reverse_fetch_not_supported_sqlcode=29016
-
-datatype_not_supported_msg=SQL Data type not supported
-datatype_not_supported_sqlstate=HY004
-datatype_not_supported_sqlcode=29017
-
-invalid_cast_specification_msg=Invalid character value in cast specification
-invalid_cast_specification_sqlstate=22018
-invalid_cast_specification_sqlcode=29018
-
-parameter_not_set_msg=Parameter {0, number, integer} for {1, number, integer} set of parameters is not set
-parameter_not_set_sqlstate=07002
-parameter_not_set_sqlcode=29019
-
-invalid_parameter_index_msg=Invalid Parameter Index
-invalid_parameter_index_sqlstate=07009
-invalid_parameter_index_sqlcode=29020
-
-object_type_not_supported_msg=Object Type Not Supported
-object_type_not_supported_sqlstate=HY004
-object_type_not_supported_sqlcode=29021
-
-function_sequence_error_msg=Function Sequence Error
-function_sequence_error_sqlstate=HY010
-function_sequence_error_sqlcode=29022
-
-commit_not_allowed_msg=Commit not allowed in Transaction Aware driver
-commit_not_allowd_sqlstate=HY000
-commit_not_allowd_sqlcode=29023
-
-rollback_not_allowed_msg=Rollback not allowed in Transaction Aware Driver
-rollback_not_allowed_sqlstate=HY000
-rollback_not_allowed_sqlcode=29024
-
-setautocommit_not_allowed_msg=SetAutoCommit not allowed in Transaction Aware Driver
-setautocommit_not_allowed_sqlstate=HY000
-setautocommit_not_allowed_sqlcode=29025
-
-invalid_commit_mode_msg=Transaction can't be committed or rolled back when AutoCommit mode is on
-invalid_commit_mode_sqlstate=HY000
-invalid_commit_mode_sqlcode=29026
-
-autocommit_txn_in_progress_msg=SetAutoCommit not possible, since a transaction is active
-autocommit_txn_in_progress_sqlstate=HY011
-autocommit_txn_in_progress_sqlcode=29027
-
-read_only_connect_msg=Connection is set to read only
-read_only_connect_sqlstate=HY000
-read_only_connect_sqlcode=29028
-
-txn_isolation_txn_in_progress_msg=SetTransactionIsolation not possible, since a transaction is active
-txn_isolation_txn_in_progress_sqlstate=HY011
-txn_isolation_txn_in_progress_sqlcode=29029
-
-forward_only_cursor_msg=Result Set type is TYPE_FORWARD_ONLY
-forward_only_cursor_sqlstate=HY109
-forward_only_cursor_sqlcode=29029
-
-read_only_concur_msg=Result Set Concurrecy is CONCUR_READ_ONLY
-read_only_concur_sqlstate=HY109
-read_only_concur_sqlcode=29030
-
-select_in_batch_not_supported_msg=SELECT sql statements in batch is illgeal
-select_in_batch_not_supported_sqlstate=HY000
-select_in_batch_not_supported_sqlcode=29031
-
-row_modified_msg=The row is modified since it is last read
-row_modified_sqlstate=23000
-row_modified_sqlcode=29032
-
-primary_key_not_updateable_msg=The primary key column value can't be updated
-primary_key_not_updateable_sqlstate=23000
-primary_key_not_updateable_sqlcode=29033
-
-deprecated_method_msg=The method {0} is deprecated
-deprecated_method_sqlstate=HY000
-deprecated_method_sqlcode=29034
-
-io_exception_msg=IO Exception occurred {0}
-io_exception_sqlstate=HY000
-io_exception_sqlcode=29035
-
-unsupported_encoding_msg=Unsupported encoding {0}
-unsupported_encoding_sqlstate=HY000
-unsupported_encoding_sqlcode=29036
-
-forward_only_cursor_msg=The Result Set Type is TYPE_FORWARD_ONLY
-forward_only_cursor_sqlstate=HY106
-forward_only_cursor_sqlcode=29037
-
-invalid_row_number_msg=The row number is not valid
-invalid_row_number_sqlstate=HY107
-invalid_row_number_sqlcode=29038
-
-read_only_concur_msg=The concurrency mode of the result set is CONCUR_READ_ONLY
-read_only_concur_sqlstate=HY092
-read_only_concur_sqlcode=29039
-
-invalid_operation_msg=Operation invalid, since the current row is insert row
-invalid_operation_sqlstate=HY000
-invalid_operation_sqlcode=29040
-
-no_primary_key_msg=Operation not allowed since there is no primary key for the table
-no_primary_key_sqlstate=HY000
-no_primary_key_sqlcode=29041
-
-invalid_fetchSize_value_msg=Fetch size value is not valid
-invalid_fetchSize_value_sqlstate=HY000
-invalid_fetchSize_value_sqlcode=29042
-
-invalid_maxRows_value_msg=Max rows value is not valid
-invalid_maxRows_value_sqlstate=HY000
-invalid_maxRows_value_sqlcode=29043
-
-invalid_queryTimeout_value_msg=Query timeout value is not valid
-invalid_queryTimeout_value_sqlstate=HY000
-invalid_queryTimeout_value_sqlcode=29044
-
-data_truncation_msg=Fractional truncation
-data_truncation_sqlstate=01S07
-data_truncation_sqlcode=29045
-
-numeric_out_of_range_msg=Numeric value out of range
-numeric_out_of_range_sqlstate=22003
-numeric_out_of_range_sqlcode=29046
-
-batch_command_failed_msg=Batch Update Failed, See next exception for details
-batch_command_failed_sqlstate=HY000
-batch_command_failed_sqlcode=29047
-
-invalid_use_of_null_msg=Invalid use of null
-invalid_use_of_null_sqlstate=HY009
-invalid_use_of_null_sqlcode=29048
-
-invalid_transaction_state_msg=Invalid transaction state
-invalid_transaction_state_sqlstate=25000
-invalid_transaction_state_sqlcode=29049
-
-invalid_row_msg=Row value out of range
-invalid_row_sqlstate=HY107
-invalid_row_sqlcode=29050
-
-scrollResultSetChanged_msg=Result Set Type changed to TYPE_SCROLL_INSENSITIVE
-scrollResultSetChanged_sqlstate=01S02
-scrollResultSetChanged_sqlcode=29051
-
-invalid_holdability_state_msg=Invalid cursor holdability
-invalid_holdability_state_sqlstate=25000
-invalid_holdability_state_sqlcode=29052
-
-select_invalid_msg=Select SQL statement is invalid in executeUpdate() method
-select_invalid_sqlstate=HY000
-select_invalid_sqlcode=29053
-
-non_select_invalid_msg=Non-Select SQL statement is invalid in executeQuery() method
-non_select_invalid_sqlstate=HY000
-non_select_invalid_sqlcode=29054
-
-connection_in_use_msg=Connection is in use
-connection_in_use_sqlstate=HY000
-connection_in_use_sqlcode=29055
-
-stmt_closed_msg=Statement is already closed
-stmt_closed_sqlstate=HY000
-stmt_closed_sqlcode=29056
-
-auto_generated_keys_not_supported_msg=Auto generated keys not supported
-auto_generated_keys_not_supported_sqlstate=HY000
-auto_generated_keys_not_supported_sqlcode=29057
-
-null_pooled_connection_msg=Connection is not associated with a PooledConnection object
-null_pooled_connection_sqlstate=HY000
-null_pooled_connection_sqlcode=29058
-
-#
-# New messages for T4 driver
-#
-
-internal_error_msg=An internal error occurred
-internal_error_sqlstate=HY000
-internal_error_sqlcode=29100
-
-contact_hp_error_msg=Contact your service provider
-contact_hp_error_sqlstate=HY000
-contact_hp_error_sqlcode=29101
-
-address_parsing_error_msg=Error while parsing address {0}
-address_parsing_error_sqlstate=HY000
-address_parsing_error_sqlcode=29102
-
-address_null_error_msg=Address is null
-address_null_error_sqlstate=HY000
-address_null_error_sqlcode=29103
-
-odbc_server_suffix_error_msg=Expected suffix: {0}
-odbc_server_suffix_error_sqlstate=HY000
-odbc_server_suffix_error_sqlcode=29104
-
-unknown_prefix_error_msg=Unknown prefix for address
-unknown_prefix_error_sqlstate=HY000
-unknown_prefix_error_sqlcode=29105
-
-jdbc_address_error_msg=Expected address format: jdbc:subprotocol:subname
-jdbc_address_error_sqlstate=HY000
-jdbc_address_error_sqlcode=29106
-
-min_address_length_error_msg=Address is not long enough to be a valid address
-min_address_length_error_sqlstate=HY000
-min_address_length_error_sqlcode=29107
-
-address_format_1_error_msg=Expecting \\<machine name>.<process name>/<port number>
-address_format_1_error_sqlstate=HY000
-address_format_1_error_sqlcode=29108
-
-address_format_2_error_msg=//<{IP Address|Machine Name}[:port]>/<database name>
-address_format_2_error_sqlstate=HY000
-address_format_2_error_sqlcode=29109
-
-missing ip_or_name_error_msg=Address is missing an IP address or machine name
-missing ip_or_name_error_sqlstate=HY000
-missing ip_or_name_error_sqlcode=29110
-
-address_lookup_error_msg=Unable to evaluate address {0} Cause: {1}
-address_lookup_error_sqlstate=HY000
-address_lookup_error_sqlcode=29111
-
-address_missing_close_bracket_msg=Missing ']'
-address_missing_close_bracket_sqlstate=HY000
-address_missing_close_bracket_sqlcode=29112
-
-socket_open_error_msg=error while opening socket. Cause: {0}
-socket_open_error_sqlstate=HY000
-socket_open_error_sqlcode=29113
-
-socket_write_error_msg=error while writing to socket
-socket_write_error_sqlstate=HY000
-socket_write_error_sqlcode=29114
-
-socket_read_error_msg=error while reading from socket. Cause: {0}
-socket_read_error_sqlstate=HY000
-socket_read_error_sqlcode=29115
-
-socket_is_closed_error_msg=Socket is closed
-socket_is_closed_error_sqlstate=HY000
-socket_is_closed_error_sqlcode=29116
-
-session_close_error_msg=Error while closing session. Cause: {0}
-session_close_error_sqlstate=HY000
-session_close_error_sqlcode=29117
-
-bad_map_ptr=A write to a bad map pointer occurred
-bad_map_ptr_sqlstate=HY000
-bad_map_ptr_sqlcode=29118
-
-bad_par_ptr=A write to a bad par pointer occurred
-bad_par_ptr_sqlstate=HY000
-bad_par_ptr_sqlcode=29119
-
-dcs_connect_message_error_msg=An dcs server connect message error occurred. Cause: {0}
-dcs_connect_message_error_sqlstate=HY000
-dcs_connect_message_error_sqlcode=29120
-
-close_message_error_msg=A close message error occurred. Cause: {0}
-close_message_error_sqlstate=HY000
-close_message_error_sqlcode=29121
-
-end_transaction_message_error_msg=An end transaction message error occurred. Cause: {0}
-end_transaction_message_error_sqlstate=HY000
-end_transaction_message_error_sqlcode=29122
-
-execute_call_message_error_msg=An execute call message error occurred. Cause: {0}
-execute_call_message_error_sqlstate=HY000
-execute_call_message_error_sqlcode=29123
-
-execute_direct_message_error_msg=An execute direct message error occurred. Cause: {0}
-execute_direct_message_error_sqlstate=HY000
-execute_direct_message_error_sqlcode=29124
-
-execute_direct_rowset_message_error_msg=An execute direct rowset message error occurred. Cause: {0}
-execute_direct_rowset_message_error_sqlstate=HY000
-execute_direct_rowset_message_error_sqlcode=29125
-
-execute_n_message_error_msg =An execute N message error occurred. Cause: {0}
-execute_n_message_error_sqlstate=HY000
-execute_n_message_error_sqlcode=29126
-
-execute_rowset_message_error_msg=An execute rowset message error occurred. Cause: {0}
-execute_rowset_message_error_sqlstate=HY000
-execute_rowset_message_error_sqlcode=29127
-
-fetch_perf_message_error_msg=A fetch perf message error occurred. Cause: {0}
-fetch_perf_message_error_sqlstate=HY000
-fetch_perf_message_error_sqlcode=29128
-
-fetch_rowset_message_error_msg=A fetch rowset message error occurred. Cause: {0}
-fetch_rowset_message_error_sqlstate=HY000
-fetch_rowset_message_error_sqlcode=29129
-
-get_sql_catalogs_message_error_msg=A get sql catalogs message error occurred. Cause: {0}
-get_sql_catalogs_message_error_sqlstate=HY000
-get_sql_catalogs_message_error_sqlcode=29130
-
-initialize_dialogue_message_error=An initialize dialogue message error occurred. Cause: {0}
-initialize_dialogue_message_error_sqlstate=HY000
-initialize_dialogue_message_error_sqlcode=29131
-
-prepare_message_error_msg=A prepare message error occurred. Cause: {0}
-prepare_message_error_sqlstate=HY000
-prepare_message_error_sqlcode=29132
-
-prepare_rowset_message_error_msg=A prepare rowset message error occurred. Cause: {0}
-prepare_rowset_message_error_sqlstate=HY000
-prepare_rowset_message_error_sqlcode=29133
-
-set_connection_option_message_error_msg=A set connection option message error occurred. Cause: {0}
-set_connection_option_message_error_sqlstate=HY000
-set_connection_option_message_error_sqlcode=29134
-
-terminate_dialogue_message_error_msg=A terminate dialogue message error occurred: Cause {0}
-terminate_dialogue_message_error_sqlstate=HY000
-terminate_dialogue_message_error_sqlcode=29135
-
-dcs_connect_reply_error_msg=An dcs server connect reply error occurred. Exception: {0} Exception detail: {1} Error text/code: {2}
-dcs_connect_reply_error_sqlstate=HY000
-dcs_connect_reply_error_sqlcode=29136
-
-close_reply_error_msg=A close reply error occurred
-close_reply_error_sqlstate=HY000
-close_reply_error_sqlcode=29137
-
-end_transaction_reply_error_msg=An end transaction reply error occurred
-end_transaction_reply_error_sqlstate=HY000
-end_transaction_reply_error_sqlcode=29138
-
-execute_call_reply_error_msg=An execute call reply error occurred
-execute_call_reply_error_sqlstate=HY000
-execute_call_reply_error_sqlcode=29139
-
-execute_direct_reply_error_msg=An execute direct reply error occurred
-execute_direct_reply_error_sqlstate=HY000
-execute_direct_reply_error_sqlcode=29140
-
-execute_direct_rowset_reply_error_msg=An execute direct rowset reply error occurred
-execute_direct_rowset_reply_error_sqlstate=HY000
-execute_direct_rowset_reply_error_sqlcode=29141
-
-execute_n_reply_error_msg=An execute N reply error occurred
-execute_n_reply_error_sqlstate=HY000
-execute_n_reply_error_sqlcode=29142
-
-execute_rowset_reply_error_msg=An execute rowset reply error occurred
-execute_rowset_reply_error_sqlstate=HY000
-execute_rowset_reply_error_sqlcode=29143
-
-fetch_perf_reply_error_msg=A fetch perf reply error occurred
-fetch_perf_reply_error_sqlstate=HY000
-fetch_perf_reply_error_sqlcode=29144
-
-fetch_rowset_reply_error_msg=A fetch rowset reply error occurred
-fetch_rowset_reply_error_sqlstate=HY000
-fetch_rowset_reply_error_sqlcode=29145
-
-get_sql_catalogs_reply_error_msg=A get sql catalogs reply error occurred
-get_sql_catalogs_reply_error_sqlstate=HY000
-get_sql_catalogs_reply_error_sqlcode=29146
-
-initialize_dialogue_reply_error_msg=An initialize dialogue reply error occurred
-initialize_dialogue_reply_error_sqlstate=HY000
-initialize_dialogue_reply_error_sqlcode=29147
-
-prepare_reply_error_msg=A prepare reply error occurred
-prepare_reply_error_sqlstate=HY000
-prepare_reply_error_sqlcode=29148
-
-prepare_rowset_reply_error_msg=A prepare rowset reply error occurred
-prepare_rowset_reply_error_sqlstate=HY000
-prepare_rowset_reply_error_sqlcode=29149
-
-set_connection_option_reply_error_msg=A set connection option reply error occurred
-set_connection_option_reply_error_sqlstate=HY000
-set_connection_option_reply_error_sqlcode=29150
-
-terminate_dialogue_reply_error_msg=A terminate dialogue reply error occurred
-terminate_dialogue_reply_error_sqlstate=HY000
-terminate_dialogue_reply_error_sqlcode=29151
-
-ids_port_not_available_msg=No more ports available to start NDCS servers
-ids_port_not_available_sqlstate=HY000
-ids_port_not_available_sqlcode=29152
-
-ids_28_000_msg=Invalid authorization specification
-ids_28_000_sqlstate=HY000
-ids_28_000_sqlcode=29153
-
-ids_s1_t00_msg=Timeout expired
-ids_s1_t00_sqlstate=HY000
-ids_s1_t00_sqlcode=29154
-
-unknown_message_type_error_msg=Unknown message type
-unknown_message_type_error_sqlstate=HY000
-unknown_message_type_error_sqlcode=29155
-
-driver_err_error_from_server_msg=An error was returned from the server. Error: {0} Error detail: {1}
-driver_err_error_from_server_sqlstate=HY000
-driver_err_error_from_server_sqlcode=29156
-
-problem_with_server_read_msg=There was a problem reading from the server
-problem_with_server_read_sqlstate=HY000
-problem_with_server_read_sqlcode=29157
-
-wrong_header_version_msg=The message header contained the wrong version: {0}
-wrong_header_version_sqlstate=HY000
-wrong_header_version_sqlcode=29158
-
-wrong_header_signature_msg=The message header contained the wrong signature. Expected: {0} Actual: {1}
-wrong_header_signature_sqlstate=HY000
-wrong_header_signature_sqlcode=29159
-
-header_not_long_enough_msg=The message header was not long enough
-header_not_long_enough_sqlstate=HY000
-header_not_long_enough_sqlcode=29160
-
-ids_unable_to_logon_msg=Unable to authenticate the user because of an NT error: {0}
-ids_unable_to_logon_sqlstate=S1000
-ids_unable_to_logon_sqlcode=29161
-
-ids_program_error_msg=Unexpected programming exception has been found: {0}. Check the server event log on node {1} for details.
-ids_program_error_sqlstate=S1000
-ids_program_error_sqlcode=29162
-
-ids_dcs_srvr_not_available_msg=DCS Services not yet available: {0}
-ids_dcs_srvr_not_available_sqlstate=08001
-ids_dcs_srvr_not_available_sqlcode=29163
-
-ids_ds_not_available_msg=DataSource not yet available or not found: {0}
-ids_ds_not_available_sqlstate=08001
-ids_ds_not_available_sqlcode=29164
-
-unknown_connect_error_msg=Unknown connect reply error: {0}
-unknown_connect_error_sqlstate=HY000
-unknown_connect_error_sqlcode= 29165
-
-ids_08_004_01_msg=Data source rejected establishment of connection since the NDCS Server is connected to a different client now
-ids_08_004_01_sqlstate=08004
-ids_08_004_01_sqlcode=HY000
-
-ids_transaction_error_msg=A TIP transaction error {0} has been detected. Check the server event log on Node {1} for Transaction Error details.
-ids_transaction_error_sqlstate=S1000
-ids_transaction_error_sqlcode=HY000
-
-ids_08_s01_msg=Communication link failure. The server timed out or disappeared.
-ids_08_s01_sqlstate=08S01
-ids_08_s01_sqlcode=01032
-
-ids_s1_008_msg=Operation cancelled.
-ids_s1_008_sqlstate=S1008
-ids_s1_008_sqlcode=01118
-
-ids_25_000_msg=Invalid transaction state.
-ids_25_000_sqlstate=25000
-ids_25_000_sqlcode=01056
-
-internal_error_method_not_implemented_msg=Internal error. This method is not implemented.
-internal_error_method_not_implemented_sqlstate=HY000
-internal_error_method_not_implemented_sqlcode=29166
-
-internal_error_inconsistency_check_msg=Internal error. An internal index failed consistency check.
-internal_error_inconsistency_check_sqlstate=HY000
-internal_error_inconsistency_check_sqlcode=29167
-
-ids_unknown_reply_error_msg=Unknown reply message error: {0} error detail: {1}
-ids_unknown_reply_error_sqlstate=HY000
-ids_unknown_reply_error_sqlcode=29168
-
-ids_retry_attempt_exceeded_msg=Retry attempts to connect to the datasource failed. Maybe NDCS server is not available.
-ids_retry_attempt_exceeded_sqlstate=08001
-ids_retry_attempt_exceeded_sqlcode=HY000
-
-invalid_property_msg=Invalid connection property setting: {0}
-invalid_property_sqlstate=HY000
-invalid_property_sqlcode=29169
-
-invalid_parameter_value_msg=Invalid Parameter Value: {0}
-invalid_parameter_value_sqlstate=HY000
-invalid_parameter_value_sqlcode=29170
-
-resource_governing_msg=Failed since resource governing policy is hit
-resource_governing_sqlstate=S1000
-resource_governing_sqlcode=29171
-
-translation_of_parameter_failed_msg=Translation of parameter to {0} failed. Cause: {1}
-translation_of_parameter_failed_sqlstate=HY000
-translation_of_parameter_failed_sqlcode=29172
-
-#
-# New Messages for LOB Support From Type 2
-#
-
-no_blobTableName_msg='blobTableName' property is not set or set to null value or set to invalid value
-no_blobTableName_sqlstate=HY000
-no_blobTableName_sqlcode=29059
-
-no_clobTableName_msg='clobTableName' property is not set or set to null value or set to invalid value
-no_clobTableName_sqlstate=HY000
-no_clobTableName_sqlcode=29060
-
-invalid_lob_commit_state_msg=Autocommit is on and LOB objects are involved
-invalid_lob_commit_state_sqlstate=HY000
-invalid_lob_commit_state_sqlcode=29069
-
-lob_not_current_msg=Lob object {0} is not current
-lob_not_current_sqlstate=HY000
-lob_not_current_sqlcode=29061
-
-invalid_input_value_msg=Invalid input value in the method {0}
-invalid_input_value_sqlstate=07009
-invalid_input_value_sqlcode=29067
-
-invalid_position_value_msg=The value for position can be any value between 1 and one more than the length of the lob data
-invalid_position_value_sqlstate=07009
-invalid_position_value_sqlcode=29068
-
-problem_with_logging_msg=There was a problem while logging: {0}
-problem_with_logging_sqlstate=HY000
-problem_with_logging_sqlcode=29070
-
-initial_pool_creation_error_msg=Error occurred while creating the initial pool of {0} connection(s)
-initial_pool_creation_error_sqlstate=HY000
-initial_pool_creation_error_sqlcode=29173
-
-resultSet_updateRow_with_autocommit_msg=Autocommit is on and updateRow was called on the ResultSet object
-resultSet_updateRow_with_autocommit_sqlstate=HY000
-resultSet_updateRow_with_autocommit_sqlcode=29174
-
-unknown_error_msg=Unknown Error {0}
-unknown_error_sqlstate=HY000
-unknown_error_sqlcode=29175
-
-fill_in_SQL_Values_msg=Failed while converting objects to SQL values.
-fill_in_SQL_Values_sqlstate=HY000
-fill_in_SQL_Values_sqlcode=29176
-
-null_data_msg=Data cannot be null.
-null_data_sqlstate=HY000
-null_data_sqlcode=29177
-
-no_column_value_specified_msg=No column value has been inserted
-no_column_value_specified_sqlstate=HY000
-no_column_value_specified_sqlcode=29178
-
-
-execute_2_message_error_msg =An Execute2 message error occurred. Cause: {0}
-execute_2_message_error_sqlstate=HY000
-execute_2_message_error_sqlcode=29179
-
-infostats_invalid_error_msg=INFOSTATS command is supported only via the Statement.execute(String sql) method.
-infostats_invalid_error_sqlstate=HY000
-infostats_invalid_error_sqlcode=29180
-
-dcs_cancel_message_error_msg=A dcs server cancel message error occurred. Cause: {0}
-dcs_cancel_message_error_sqlstate=HY000
-dcs_cancel_message_error_sqlcode=29181
-
-connected_to_Default_DS_msg= General warning. Connected to the default data source: {0}
-connected_to_Default_DS_sqlstate=HY000
-connected_to_Default_DS_sqlcode=29182
-
-invalid_string_parameter_msg=Invalid Parameter Value: {0}
-invalid_string_parameter_sqlstate=22001
-invalid_string_parameter_sqlcode=29183
-
-null_parameter_for_not_null_column_msg=NULL cannot be assigned to a NOT NULL column, parameter {0}.
-null_parameter_for_not_null_column_sqlstate=23000
-null_parameter_for_not_null_column_sqlcode=29184
-
-security_error_msg=A Security Exception Occurred: {0}
-security_error_sqlstate=HY000
-security_error_sqlcode=29185
-
-certificate_download_error_msg=An error occurred while downloading the certificate: {0}
-certificate_download_error_sqlstate=HY000
-certificate_download_error_sqlcode=29186
-
-data_truncation_exceed_msg=The data length {0} exceeds the max length {1}
-data_truncation_exceed_sqlstate=HY000
-data_truncation_exceed_sqlcode=29187
-
-numeric_out_of_range_d_msg=Numeric value {0} is out of range [{1}, {2}]
-numeric_out_of_range_d_sqlstate=22003
-numeric_out_of_range_d_sqlcode=29188
-
-cursor_is_before_first_row_msg=The cursor is before the first row, therefore no data can be retrieved
-cursor_is_before_first_row_sqlstate=HY109
-cursor_is_before_first_row_sqlcode=29189
-
-cursor_after_last_row_msg=The cursor is after last row, which could be due to the result set containing no rows, or all rows have been retrieved.
-cursor_after_last_row_sqlstate=HY109
-cursor_after_last_row_sqlcode=29190
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Address.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Address.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Address.java
deleted file mode 100644
index d486f57..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Address.java
+++ /dev/null
@@ -1,117 +0,0 @@
-// @@@ 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;
-
-/**********************************************************
- * This class represents an address reference.
- *
- *
- **********************************************************/
-
-import java.net.InetAddress;
-import java.sql.SQLException;
-import java.util.Locale;
-import java.util.Properties;
-
-abstract class Address {
- protected Locale m_locale;
- protected T4Properties m_t4props;
- protected String m_ipAddress;
- protected String m_machineName;
- protected String m_processName;
- protected Integer m_portNumber;
- protected Properties m_properties;
- InetAddress[] m_inetAddrs;
- protected int m_type;
- protected String m_url;
- protected InputOutput m_io;
-
- /**
- * The constructor.
- *
- * @param addr
- * The addr has two forms:
- *
- * DriverManager getConnection addr parameter format for connecting via the
- * Fast JDBC Type 3 driver.
- *
- * jdbc:subprotocol:subname
- *
- * Where:
- *
- * subprotocol = t4jdbc
- *
- * subname = //<{IP Address|Machine Name}[:port]>/<database name>
- *
- * Example: jdbc:t4jdbc://130.168.200.30:1433/database1
- *
- *
- * ODBC server connect format returned by the ODBC Association Server.
- *
- * TCP:\<{IP Address|Machine Name}>.<Process Name>/<port>:ODBC
- *
- */
-
- // ----------------------------------------------------------
- Address(T4Properties t4props, Locale locale, String addr) throws SQLException {
- m_t4props = t4props;
- m_locale = locale;
- m_url = addr;
- }
-
- abstract String recreateAddress();
-
- // ----------------------------------------------------------
- String getIPorName() {
- if (m_machineName != null) {
- return m_machineName;
- } else {
- return m_ipAddress;
- }
- } // end getIPorName
-
- protected boolean validateAddress() throws SQLException {
- String IPorName = getIPorName();
- try {
- m_inetAddrs = InetAddress.getAllByName(IPorName);
- } catch (Exception e) {
- SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_lookup_error", m_url, e
- .getMessage());
- se.initCause(e);
- throw se;
- }
- return true;
- }
-
- // ----------------------------------------------------------
- Integer getPort() {
- return m_portNumber;
- } // end getIPorName
-
- void setInputOutput() {
- m_io = new InputOutput(m_locale, this);
- }
-
- InputOutput getInputOutput() {
- return m_io;
- }
-} // end class Address
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/BaseRow.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/BaseRow.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/BaseRow.java
deleted file mode 100644
index 3d28248..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/BaseRow.java
+++ /dev/null
@@ -1,65 +0,0 @@
-// @@@ 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 @@@
-
-/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package org.trafodion.jdbc.t4;
-
-import java.io.Serializable;
-import java.sql.SQLException;
-
-abstract class BaseRow implements Serializable, Cloneable {
-
- protected Object origVals[];
-
- BaseRow() {
- }
-
- protected abstract Object getColumnObject(int i) throws SQLException;
-
- protected Object[] getOrigRow() {
- return origVals;
- }
-
- protected abstract void setColumnObject(int i, Object obj) throws SQLException;
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Bytes.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Bytes.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Bytes.java
deleted file mode 100644
index 78803c3..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Bytes.java
+++ /dev/null
@@ -1,269 +0,0 @@
-// @@@ 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;
-
-/**
- * <code>Bytes</code> contains a set of static methods used for byte
- * manipulation. There are three basic types of methods:
- * <ul>
- * <li>extract</li>
- * <li>insert</li>
- * <li>create</li>
- * </ul>
- * <p>
- * Extract methods will copy from a raw byte array into a basic Java type.
- * Insert methods will copy from a basic Java type into a raw byte array. Create
- * methods will copy from a basic Java type into a new raw byte array which is
- * returned to the user.
- *
- * As Java is always BigEndian, set the swap parameter to <code>true</code> to
- * convert to and from LittleEndian.
- *
- * There is no error checking in order to improve performance. Length checking
- * should be done before calling these methods or the resulting exceptions
- * should be handled by the user.
- *
- */
-class Bytes {
-
- static short extractShort(byte[] array, int offset, boolean swap) {
- short value;
-
- if (swap) {
- value = (short) (((array[offset]) & 0x00ff) | ((array[offset + 1] << 8) & 0xff00));
- } else {
- value = (short) (((array[offset + 1]) & 0x00ff) | ((array[offset] << 8) & 0xff00));
- }
-
- return value;
- }
-
- static int extractUShort(byte[] array, int offset, boolean swap) {
- int value;
-
- if (swap) {
- value = ((array[offset]) & 0x00ff) | ((array[offset + 1] << 8) & 0xff00);
- } else {
- value = ((array[offset + 1]) & 0x00ff) | ((array[offset] << 8) & 0xff00);
- }
-
- return value & 0xffff;
- }
-
- static int extractInt(byte[] array, int offset, boolean swap) {
- int value;
-
- if (swap) {
- value = ((array[offset]) & 0x000000ff) | ((array[offset + 1] << 8) & 0x0000ff00)
- | ((array[offset + 2] << 16) & 0x00ff0000) | ((array[offset + 3] << 24) & 0xff000000);
- } else {
- value = ((array[offset + 3]) & 0x000000ff) | ((array[offset + 2] << 8) & 0x0000ff00)
- | ((array[offset + 1] << 16) & 0x00ff0000) | ((array[offset] << 24) & 0xff000000);
- }
-
- return value;
- }
-
- static long extractUInt(byte[] array, int offset, boolean swap) {
- long value;
-
- if (swap) {
- value = ((array[offset]) & 0x000000ff) | ((array[offset + 1] << 8) & 0x0000ff00)
- | ((array[offset + 2] << 16) & 0x00ff0000) | ((array[offset + 3] << 24) & 0xff000000);
- } else {
- value = ((array[offset + 3]) & 0x000000ff) | ((array[offset + 2] << 8) & 0x0000ff00)
- | ((array[offset + 1] << 16) & 0x00ff0000) | ((array[offset] << 24) & 0xff000000);
- }
-
- return value & 0xffffffffL;
- }
-
- static long extractLong(byte[] array, int offset, boolean swap) {
- long value = 0;
- int i=offset;
-
- if(swap) {
- for (int shift = 0; shift < 64; shift += 8) {
- value |= ( (long)( array[i] & 0xff ) ) << shift;
- i++;
- }
-
- }else {
- for (int shift = 56; shift >= 0; shift -= 8) {
- value |= ( (long)( array[i] & 0xff ) ) << shift;
- i++;
- }
- }
-
- return value;
- }
-
- static int insertShort(byte[] array, int offset, short value, boolean swap) {
- if (swap) {
- array[offset + 1] = (byte) ((value >>> 8) & 0xff);
- array[offset] = (byte) ((value) & 0xff);
- } else {
- array[offset] = (byte) ((value >>> 8) & 0xff);
- array[offset + 1] = (byte) ((value) & 0xff);
- }
-
- return offset + 2;
- }
-
- /*
- * static int insertUShort(byte[] array, int offset, int value, boolean
- * swap) {
- *
- * return offset + 2; }
- */
-
- static int insertInt(byte[] array, int offset, int value, boolean swap) {
- if (swap) {
- array[offset + 3] = (byte) ((value >>> 24) & 0xff);
- array[offset + 2] = (byte) ((value >>> 16) & 0xff);
- array[offset + 1] = (byte) ((value >>> 8) & 0xff);
- array[offset] = (byte) ((value) & 0xff);
- } else {
- array[offset] = (byte) ((value >>> 24) & 0xff);
- array[offset + 1] = (byte) ((value >>> 16) & 0xff);
- array[offset + 2] = (byte) ((value >>> 8) & 0xff);
- array[offset + 3] = (byte) ((value) & 0xff);
- }
-
- return offset + 4;
- }
-
- /*
- * static int insertUInt(byte[] array, int offset, long value, boolean swap) {
- * return offset + 4; }
- */
-
- static int insertLong(byte[] array, int offset, long value, boolean swap) {
- if (swap) {
- array[offset + 7] = (byte) ((value >>> 56) & 0xff);
- array[offset + 6] = (byte) ((value >>> 48) & 0xff);
- array[offset + 5] = (byte) ((value >>> 40) & 0xff);
- array[offset + 4] = (byte) ((value >>> 32) & 0xff);
- array[offset + 3] = (byte) ((value >>> 24) & 0xff);
- array[offset + 2] = (byte) ((value >>> 16) & 0xff);
- array[offset + 1] = (byte) ((value >>> 8) & 0xff);
- array[offset] = (byte) ((value) & 0xff);
- } else {
- array[offset] = (byte) ((value >>> 56) & 0xff);
- array[offset + 1] = (byte) ((value >>> 48) & 0xff);
- array[offset + 2] = (byte) ((value >>> 40) & 0xff);
- array[offset + 3] = (byte) ((value >>> 32) & 0xff);
- array[offset + 4] = (byte) ((value >>> 24) & 0xff);
- array[offset + 5] = (byte) ((value >>> 16) & 0xff);
- array[offset + 6] = (byte) ((value >>> 8) & 0xff);
- array[offset + 7] = (byte) ((value) & 0xff);
- }
-
- return offset + 8;
- }
-
- static byte[] createShortBytes(short value, boolean swap) {
- byte[] b = new byte[2];
- Bytes.insertShort(b, 0, value, swap);
-
- return b;
- }
-
- /*
- * static byte[] createUShortBytes(int value, boolean swap) { byte[] b = new
- * byte[2]; Bytes.insertUShort(b, 0, value, swap);
- *
- * return b; }
- */
-
- static byte[] createIntBytes(int value, boolean swap) {
- byte[] b = new byte[4];
- Bytes.insertInt(b, 0, value, swap);
-
-
- return b;
- }
-
- /*
- * static byte[] createUIntBytes(long value, boolean swap) { byte[] b = new
- * byte[4]; Bytes.insertUInt(b, 0, value, swap);
- *
- * return b; }
- */
-
- static byte[] createLongBytes(long value, boolean swap) {
- byte[] b = new byte[8];
- Bytes.insertLong(b, 0, value, swap);
-
- return b;
- }
-
- // -------------------------------------------------------------
- // -------------------------------------------------------------
- // ---------------TODO: get rid of these methods!---------------
- // -------------------------------------------------------------
- // -------------------------------------------------------------
-
- /**
- * @deprecated
- */
- static char[] read_chars(byte[] buffer, int index) {
- int len = 0;
-
- // find the null terminator
- while (buffer[index + len] != 0) {
- len = len + 1;
- }
-
- char[] temp1 = read_chars(buffer, index, len);
-
- return temp1;
- } // end read_chars
-
- /**
- * @deprecated
- */
- static char[] read_chars(byte[] buffer, int index, int tLen) {
- char[] la_chars;
- int len = tLen;
-
- if (len == -1) // must find null to get length
- {
- int ii = index;
- while (buffer[ii] != (byte) 0) {
- ii = ii + 1;
- }
- len = ii - index;
- }
-
- la_chars = new char[len];
-
- int i = 0;
- while (i < len) {
- la_chars[i] = (char) (buffer[index] & 0xff);
- i = i + 1;
- index = index + 1;
- }
-
- return la_chars;
- } // end read_chars
-}
[04/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
deleted file mode 100644
index 489904f..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
+++ /dev/null
@@ -1,2558 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.URL;
-import java.nio.ByteBuffer;
-import java.sql.Array;
-import java.sql.BatchUpdateException;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.DatabaseMetaData;
-import java.sql.Date;
-import java.sql.NClob;
-import java.sql.ParameterMetaData;
-import java.sql.Ref;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.RowId;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Locale;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql.PreparedStatement {
- // java.sql.PreparedStatement interface methods
- public void addBatch() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "addBatch", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("addBatch");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- if (inputDesc_ == null) {
- return;
- }
-
- // Check if all parameters are set for current set
- checkIfAllParamsSet();
- // Add to the number of Rows Count
- if (rowsValue_ == null) {
- rowsValue_ = new ArrayList();
- }
- rowsValue_.add(paramsValue_);
- paramRowCount_++;
- paramsValue_ = new Object[inputDesc_.length];
- if (isAnyLob_ && (lobObjects_ == null)) {
- lobObjects_ = new ArrayList();
- // Clear the isValueSet_ flag in inputDesc_ and add the lob objects
- // to the lobObject List
- }
- for (int i = 0; i < inputDesc_.length; i++) {
- // If isAnyLob_ is false: inputDesc_.paramValue_ for all
- // parameters should be null
- // If isAnyLob_ is true: one or more inputDesc_.parmValue will not
- // be null, based on the number of LOB columns in the query
- if (inputDesc_[i].paramValue_ != null) {
- lobObjects_.add(inputDesc_[i].paramValue_);
- inputDesc_[i].paramValue_ = null;
- }
- inputDesc_[i].isValueSet_ = false;
- }
- }
-
- public void clearBatch() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "clearBatch", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("clearBatch");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- if (inputDesc_ == null) {
- return;
- }
- if (rowsValue_ != null) {
- rowsValue_.clear();
- }
- if (lobObjects_ != null) {
- lobObjects_.clear();
- }
- paramRowCount_ = 0;
- // Clear the isValueSet_ flag in inputDesc_
- for (int i = 0; i < inputDesc_.length; i++) {
- inputDesc_[i].isValueSet_ = false;
- paramsValue_[i] = null;
- inputDesc_[i].paramValue_ = null;
- }
- isAnyLob_ = false;
- batchRowCount_ = new int[] {};
- }
-
- public void clearParameters() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "clearParameters", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("clearParameters");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- // Clear the isValueSet_ flag in inputDesc_
- if (inputDesc_ == null) {
- return;
- }
-
- for (int i = 0; i < inputDesc_.length; i++) {
- inputDesc_[i].isValueSet_ = false;
- paramsValue_[i] = null;
- inputDesc_[i].paramValue_ = null;
- }
- isAnyLob_ = false;
- }
-
- public void close() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "close", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("close");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- if (isClosed_) {
- return;
- }
- try {
- if (connection_._isClosed() == false) {
- if (!connection_.isStatementCachingEnabled()) {
- super.close();
- } else {
- logicalClose();
- }
- }
- } catch (SQLException e) {
- performConnectionErrorChecks(e);
- throw e;
- } finally {
- isClosed_ = true;
- if (!connection_.isStatementCachingEnabled()) {
- connection_.removeElement(pRef_);
- }
- }
-
- }
-
- public boolean execute() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "execute", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("execute");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- Object[] valueArray = null;
- int inDescLength = 0;
-
- validateExecuteInvocation();
-
- // *******************************************************************
- // * If LOB is involved with autocommit enabled we throw an exception
- // *******************************************************************
- if (isAnyLob_ && (connection_.getAutoCommit())) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_lob_commit_state", null);
- }
- if (inputDesc_ != null) {
- if (!usingRawRowset_)
- valueArray = getValueArray();
- inDescLength = inputDesc_.length;
- }
-
- execute(paramRowCount_ + 1, inDescLength, valueArray, queryTimeout_, isAnyLob_); // LOB
- // Support
- // - SB
- // 9/28/04
-
- // if (resultSet_[result_set_offset] != null)
- if (resultSet_ != null && resultSet_[result_set_offset] != null) {
- return true;
- } else {
- if (isAnyLob_) {
-
-
- }
- return false;
- }
- }
-
- public int[] executeBatch() throws SQLException, BatchUpdateException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "executeBatch", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("executeBatch");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- try {
- clearWarnings();
- HPT4Exception se;
- Object[] valueArray = null;
-
- if (inputDesc_ == null) {
- se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "batch_command_failed", null);
- throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
- }
- if (sqlStmtType_ == TRANSPORT.TYPE_SELECT) {
- se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "select_in_batch_not_supported", null);
- throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
- }
- if (connection_._isClosed()) {
- se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_connection",
- null);
- connection_.closeErroredConnection(se);
- throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
- }
- if (isAnyLob_ && (connection_.getAutoCommit())) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_lob_commit_state", null);
- }
-
- int prc = usingRawRowset_ ? (paramRowCount_ + 1) : paramRowCount_;
-
- if (paramRowCount_ < 1) {
- if (!connection_.props_.getDelayedErrorMode()) {
- return (new int[] {});
- }
- }
-
- try {
- if (!usingRawRowset_)
- valueArray = getValueArray();
-
- execute(prc, inputDesc_.length, valueArray, queryTimeout_, lobObjects_ != null);
-
-
- } catch (SQLException e) {
- BatchUpdateException be;
- se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "batch_command_failed", null);
- if (batchRowCount_ == null) // we failed before execute
- {
- batchRowCount_ = new int[paramRowCount_];
- Arrays.fill(batchRowCount_, -3);
- }
- be = new BatchUpdateException(se.getMessage(), se.getSQLState(), batchRowCount_);
- be.setNextException(e);
-
- throw be;
- }
-
- if (connection_.props_.getDelayedErrorMode()) {
- _lastCount = paramRowCount_;
- }
-
- return batchRowCount_;
- } finally {
- clearBatch();
- }
- }
-
- public ResultSet executeQuery() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "executeQuery", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("executeQuery");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- Object[] valueArray = null;
- int inDescLength = 0;
-
- validateExecuteInvocation();
- if (sqlStmtType_ != TRANSPORT.TYPE_SELECT) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "non_select_invalid",
- null);
- }
-
- if (inputDesc_ != null) {
- if (!usingRawRowset_)
- valueArray = getValueArray();
- inDescLength = inputDesc_.length;
- }
- execute(paramRowCount_ + 1, inDescLength, valueArray, queryTimeout_, isAnyLob_); // LOB
- // Support
- // - SB
- // 9/28/04
- return resultSet_[result_set_offset];
- }
-
- public int executeUpdate() throws SQLException {
- long count = executeUpdate64();
-
- if (count > Integer.MAX_VALUE)
- this.setSQLWarning(null, "numeric_out_of_range", null);
-
- return (int) count;
- }
-
- public long executeUpdate64() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "executeUpdate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("executeUpdate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- Object[] valueArray = null;
- int inDescLength = 0;
-
- validateExecuteInvocation();
- // if (sqlStmtType_ == TRANSPORT.TYPE_SELECT)
- if (sqlStmtType_ == TRANSPORT.TYPE_SELECT && (ist_.stmtIsLock != true)) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "select_invalid", null);
- }
-
- if (usingRawRowset_ == false) {
- if (inputDesc_ != null) {
- if (!usingRawRowset_)
- valueArray = getValueArray();
- inDescLength = inputDesc_.length;
- }
- } else {
- valueArray = this.paramsValue_; // send it along raw in case we need
- // it
- paramRowCount_ -= 1; // we need to make sure that paramRowCount
- // stays exactly what we set it to since we
- // add one during execute
- }
-
- // *******************************************************************
- // * If LOB is involved with autocommit enabled we throw an exception
- // *******************************************************************
- if (isAnyLob_ && (connection_.getAutoCommit())) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_lob_commit_state", null);
- }
-
- execute(paramRowCount_ + 1, inDescLength, valueArray, queryTimeout_, isAnyLob_);
- if (isAnyLob_) {
-
-
- }
- return ist_.getRowCount();
- }
-
- public ResultSetMetaData getMetaData() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "getMetaData", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("getMetaData");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- if (outputDesc_ != null) {
- return new HPT4ResultSetMetaData(this, outputDesc_);
- } else {
- return null;
- }
- }
-
- public ParameterMetaData getParameterMetaData() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "getParameterMetaData", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("getParameterMetaData");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- if (inputDesc_ != null) {
- return new HPT4ParameterMetaData(this, inputDesc_);
- } else {
- return null;
- }
- }
-
- // JDK 1.2
- public void setArray(int parameterIndex, Array x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setArray", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setArray");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateSetInvocation(parameterIndex);
- HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "setArray()");
- }
-
- public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setAsciiStream", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setAsciiStream");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- long dataLocator;
-
- validateSetInvocation(parameterIndex);
-
- dataType = inputDesc_[parameterIndex - 1].dataType_;
-
- switch (dataType) {
-
-
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.BINARY: // At this time Database does not have
- // this column data type
- case Types.VARBINARY: // At this time Database does not
- // have this column data type //#endif-java
- case Types.LONGVARBINARY: // At this time Database does not
- // have this column data type
- byte[] buffer = new byte[length];
- try {
- x.read(buffer);
- } catch (java.io.IOException e) {
- Object[] messageArguments = new Object[1];
- messageArguments[0] = e.getMessage();
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
- messageArguments);
- }
-
- try {
- addParamValue(parameterIndex, new String(buffer, "ASCII"));
- } catch (java.io.UnsupportedEncodingException e) {
- Object[] messageArguments = new Object[1];
- messageArguments[0] = e.getMessage();
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "unsupported_encoding", messageArguments);
- }
- break;
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_datatype_for_column", null);
- }
- }
-
- public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setBigDecimal", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setBigDecimal");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- validateSetInvocation(parameterIndex);
- inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
-
- if (x != null) {
- Utility.checkDecimalTruncation(parameterIndex, connection_.getLocale(), x,
- inputDesc_[parameterIndex - 1].precision_, inputDesc_[parameterIndex - 1].scale_);
- addParamValue(parameterIndex, x.toString());
- } else {
- addParamValue(parameterIndex, null);
- }
- }
-
- public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setBinaryStream",
- "setBinaryStream", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setBinaryStream");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- long dataLocator;
-
- validateSetInvocation(parameterIndex);
-
- dataType = inputDesc_[parameterIndex - 1].dataType_;
-
- switch (dataType) {
-
-
- case Types.DOUBLE:
- case Types.DECIMAL:
- case Types.NUMERIC:
- case Types.FLOAT:
- case Types.BIGINT:
- case Types.INTEGER:
- case Types.SMALLINT:
- case Types.TINYINT:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_datatype_for_column", null);
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.BINARY: // At this time Database does not have
- // this column data type
- case Types.VARBINARY: // At this time Database does not
- // have this column data type
- case Types.LONGVARBINARY: // At this time Database does not
- // have this column data type
- byte[] buffer2 = new byte[length];
-
- try {
- int temp = x.read(buffer2);
- } catch (java.io.IOException e) {
- Object[] messageArguments = new Object[1];
- messageArguments[0] = e.getMessage();
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
- messageArguments);
- }
- addParamValue(parameterIndex, buffer2);
- break;
- default:
- byte[] buffer = new byte[length];
-
- try {
- x.read(buffer);
- } catch (java.io.IOException e) {
- Object[] messageArguments = new Object[1];
- messageArguments[0] = e.getMessage();
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
- messageArguments);
- }
-
- // addParamValue(parameterIndex, new String(buffer));
- // just pass the raw buffer.
- addParamValue(parameterIndex, buffer);
- }
- }
-
- /*
- * Sets the designated parameter to the given <tt>Blob</tt> object. The
- * driver converts this to an SQL <tt>BLOB</tt> value when it sends it to
- * the database.
- *
- * @param i the first parameter is 1, the second is 2, ... @param x a <tt>Blob</tt>
- * object that maps an SQL <tt>BLOB</tt> value
- *
- * @throws SQLException invalid data type for column
- */
- public void setBlob(int parameterIndex, Blob x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setBlob", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setBlob");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- long dataLocator;
-
- validateSetInvocation(parameterIndex);
- dataType = inputDesc_[parameterIndex - 1].dataType_;
- switch (dataType) {
-
-
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_datatype_for_column", null);
- }
- }
-
- public void setBoolean(int parameterIndex, boolean x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setBoolean", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setBoolean");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateSetInvocation(parameterIndex);
- inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
- if (x) {
- addParamValue(parameterIndex, "1"); // true
- } else {
- addParamValue(parameterIndex, "0"); // false
- }
- }
-
- public void setByte(int parameterIndex, byte x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setByte", "setByte", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setByte");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateSetInvocation(parameterIndex);
- inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
- addParamValue(parameterIndex, Byte.toString(x));
- }
-
- public void setBytes(int parameterIndex, byte[] x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setBytes", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setBytes");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- long dataLocator;
-
- byte[] tmpArray = new byte[x.length];
- System.arraycopy(x, 0, tmpArray, 0, x.length);
- validateSetInvocation(parameterIndex);
- dataType = inputDesc_[parameterIndex - 1].dataType_;
- switch (dataType) {
-
-
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.LONGVARBINARY:
- addParamValue(parameterIndex, tmpArray);
- break;
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
- }
-
- public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, reader, length);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setCharacterStream", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, reader, length);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setCharacterStream");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- char[] value;
- int dataType;
- long dataLocator;
-
- validateSetInvocation(parameterIndex);
- dataType = inputDesc_[parameterIndex - 1].dataType_;
- switch (dataType) {
-
-
- case Types.DECIMAL:
- case Types.DOUBLE:
- case Types.FLOAT:
- case Types.NUMERIC:
- case Types.BIGINT:
- case Types.INTEGER:
- case Types.SMALLINT:
- case Types.TINYINT:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_datatype_for_column", null);
-
- default:
- value = new char[length];
- try {
- int valuePos = reader.read(value);
- if (valuePos < 1) {
- Object[] messageArguments = new Object[1];
- messageArguments[0] = "No data to read from the Reader";
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
- messageArguments);
- }
-
- while (valuePos < length) {
- char temp[] = new char[length - valuePos];
- int tempReadLen = reader.read(temp, 0, length - valuePos);
- System.arraycopy(temp, 0, value, valuePos, tempReadLen);
- valuePos += tempReadLen;
- }
- } catch (java.io.IOException e) {
- Object[] messageArguments = new Object[1];
- messageArguments[0] = e.getMessage();
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
- messageArguments);
- }
- addParamValue(parameterIndex, new String(value));
- break;
- }
- }
-
- /**
- * Sets the designated parameter to the given <tt>Clob</tt> object. The
- * driver converts this to an SQL <tt>CLOB</tt> value when it sends it to
- * the database.
- *
- * @param parameterIndex
- * the first parameter is 1, the second is 2, ...
- * @param x
- * a <tt>Clob</tt> object that maps an SQL <tt>CLOB</tt>
- *
- * @throws SQLException
- * invalid data type for column, or restricted data type.
- */
- public void setClob(int parameterIndex, Clob x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setClob", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setClob");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- long dataLocator;
-
- validateSetInvocation(parameterIndex);
- dataType = inputDesc_[parameterIndex - 1].dataType_;
- switch (dataType) {
-
-
- case Types.DECIMAL:
- case Types.DOUBLE:
- case Types.FLOAT:
- case Types.NUMERIC:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_datatype_for_column", null);
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
- }
-
- public void setDate(int parameterIndex, Date x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setDate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setDate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- Timestamp t1;
-
- validateSetInvocation(parameterIndex);
- dataType = inputDesc_[parameterIndex - 1].dataType_;
- if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
- && dataType != Types.DATE && dataType != Types.TIMESTAMP) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
- if (x != null) {
- if (dataType == Types.TIMESTAMP) {
- t1 = new Timestamp(x.getTime());
- addParamValue(parameterIndex, t1.toString());
- } else {
- addParamValue(parameterIndex, x.toString());
- }
- } else {
- addParamValue(parameterIndex, null);
- }
- }
-
- public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setDate", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setDate");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- long dateValue;
- Date adjustedDate;
- Timestamp t1;
-
- validateSetInvocation(parameterIndex);
- dataType = inputDesc_[parameterIndex - 1].dataType_;
- if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
- && dataType != Types.DATE && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
- // Ignore the cal, since SQL would expect it to store it in the local
- // time zone
- if (x != null) {
- if (dataType == Types.TIMESTAMP) {
- t1 = new Timestamp(x.getTime());
- addParamValue(parameterIndex, t1.toString());
- } else {
- addParamValue(parameterIndex, x.toString());
- }
- } else {
- addParamValue(parameterIndex, null);
-
- }
- }
-
- public void setDouble(int parameterIndex, double x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setDouble", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setDouble");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateSetInvocation(parameterIndex);
- inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
- addParamValue(parameterIndex, Double.toString(x));
- inputDesc_[parameterIndex - 1].isValueSet_ = true;
- }
-
- public void setFloat(int parameterIndex, float x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setFloat", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setFloat");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateSetInvocation(parameterIndex);
- inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
- addParamValue(parameterIndex, Float.toString(x));
- }
-
- public void setInt(int parameterIndex, int x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setInt", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setInt");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateSetInvocation(parameterIndex);
- inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
- addParamValue(parameterIndex, Integer.toString(x));
- }
-
- public void setLong(int parameterIndex, long x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setLong", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setLong");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateSetInvocation(parameterIndex);
- inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
- Utility.checkLongBoundary(connection_.getLocale(), BigDecimal.valueOf(x));
- addParamValue(parameterIndex, Long.toString(x));
- }
-
- public void setNull(int parameterIndex, int sqlType) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setNull", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setNull");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateSetInvocation(parameterIndex);
- addParamValue(parameterIndex, null);
- }
-
- public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, paramIndex, sqlType, typeName);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setNull", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, paramIndex, sqlType, typeName);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setNull");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- setNull(paramIndex, sqlType);
- }
-
- public void setObject(int parameterIndex, Object x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setObject", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setObject");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- if (x == null) {
- setNull(parameterIndex, Types.NULL);
- } else if (x instanceof BigDecimal) {
- setBigDecimal(parameterIndex, (BigDecimal) x);
- } else if (x instanceof java.sql.Date) {
- setDate(parameterIndex, (Date) x);
- } else if (x instanceof java.sql.Time) {
- setTime(parameterIndex, (Time) x);
- } else if (x instanceof java.sql.Timestamp) {
- setTimestamp(parameterIndex, (Timestamp) x);
- } else if (x instanceof Double) {
- setDouble(parameterIndex, ((Double) x).doubleValue());
- } else if (x instanceof Float) {
- setFloat(parameterIndex, ((Float) x).floatValue());
- } else if (x instanceof Long) {
- setLong(parameterIndex, ((Long) x).longValue());
- } else if (x instanceof Integer) {
- setInt(parameterIndex, ((Integer) x).intValue());
- } else if (x instanceof Short) {
- setShort(parameterIndex, ((Short) x).shortValue());
- } else if (x instanceof Byte) {
- setByte(parameterIndex, ((Byte) x).byteValue());
- } else if (x instanceof Boolean) {
- setBoolean(parameterIndex, ((Boolean) x).booleanValue());
- } else if (x instanceof String) {
- setString(parameterIndex, x.toString());
- } else if (x instanceof byte[]) {
- setBytes(parameterIndex, (byte[]) x);
- } else if (x instanceof Clob) {
- setClob(parameterIndex, (Clob) x);
- } else if (x instanceof Blob) {
- setBlob(parameterIndex, (Blob) x);
- /*
- * else if (x instanceof DataWrapper) {
- * validateSetInvocation(parameterIndex); setObject(parameterIndex,
- * x, inputDesc_[parameterIndex - 1].dataType_); }
- */
- } else if (x instanceof BigInteger) {
- setBigDecimal(parameterIndex, new BigDecimal((BigInteger) x));
- } else {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "object_type_not_supported", null);
- }
- }
-
- public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, targetSqlType);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setObject", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, targetSqlType);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setObject");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- setObject(parameterIndex, x, targetSqlType, -1);
- }
-
- public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, targetSqlType, scale);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setObject", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, targetSqlType, scale);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setObject");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- BigDecimal tmpbd;
- int precision;
- Locale locale = connection_.getLocale();
-
- if (x == null) {
- setNull(parameterIndex, Types.NULL);
- } else {
- switch (targetSqlType) {
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.BLOB:
- case Types.CLOB:
- setString(parameterIndex, x.toString());
- break;
- case Types.VARBINARY:
- case Types.BINARY:
- case Types.LONGVARBINARY:
- setBytes(parameterIndex, (byte[]) x);
- break;
- case Types.TIMESTAMP:
- if (x instanceof Timestamp) {
- setTimestamp(parameterIndex, (Timestamp) x);
- } else if (x instanceof Date) {
- setTimestamp(parameterIndex, Timestamp.valueOf(x.toString() + " 00:00:00.0"));
- } else {
- setString(parameterIndex, x.toString());
- }
- break;
- case Types.TIME:
- if (x instanceof Time) {
- setTime(parameterIndex, (Time) x);
- } else if (x instanceof Date) {
- setTime(parameterIndex, new Time(((Date) x).getTime()));
- } else if (x instanceof Timestamp) {
- setTime(parameterIndex, new Time(((Timestamp) x).getTime()));
- } else {
- setString(parameterIndex, x.toString());
- }
- break;
- case Types.DATE:
- try {
- if (x instanceof Date) {
- setDate(parameterIndex, (Date) x);
- } else if (x instanceof Time) {
- setDate(parameterIndex, new Date(((Time) x).getTime()));
- } else if (x instanceof Timestamp) {
- setDate(parameterIndex, new Date(((Timestamp) x).getTime()));
- } else {
- setDate(parameterIndex, Date.valueOf(x.toString()));
- }
- } catch (IllegalArgumentException iex) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_parameter_value", x.toString());
- }
- break;
- case Types.BOOLEAN:
- setBoolean(parameterIndex, (Boolean.valueOf(x.toString())).booleanValue());
- break;
- case Types.SMALLINT:
- tmpbd = Utility.getBigDecimalValue(locale, x);
- Utility.checkShortBoundary(locale, tmpbd);
- //Utility.checkLongTruncation(parameterIndex, tmpbd);
- setShort(parameterIndex, tmpbd.shortValue());
- break;
- case Types.INTEGER:
- tmpbd = Utility.getBigDecimalValue(locale, x);
- //Utility.checkLongTruncation(parameterIndex, tmpbd);
- //Utility.checkIntegerBoundary(locale, tmpbd);
- setInt(parameterIndex, tmpbd.intValue());
- break;
- case Types.BIGINT:
- tmpbd = Utility.getBigDecimalValue(locale, x);
- Utility.checkLongBoundary(locale, tmpbd);
- //Utility.checkLongTruncation(parameterIndex, tmpbd);
- setLong(parameterIndex, tmpbd.longValue());
- break;
- case Types.DECIMAL:
- // precision = getPrecision(parameterIndex - 1);
- tmpbd = Utility.getBigDecimalValue(locale, x);
- tmpbd = Utility.setScale(tmpbd, scale, BigDecimal.ROUND_HALF_EVEN);
- // Utility.checkDecimalBoundary(locale, tmpbd, precision);
- setBigDecimal(parameterIndex, tmpbd);
- break;
- case Types.NUMERIC:
- // precision = getPrecision(parameterIndex - 1);
- tmpbd = Utility.getBigDecimalValue(locale, x);
- tmpbd = Utility.setScale(tmpbd, scale, BigDecimal.ROUND_HALF_EVEN);
- // Utility.checkDecimalBoundary(locale, tmpbd, precision);
- setBigDecimal(parameterIndex, tmpbd);
- break;
- case Types.TINYINT:
- tmpbd = Utility.getBigDecimalValue(locale, x);
- tmpbd = Utility.setScale(tmpbd, scale, roundingMode_);
- Utility.checkTinyintBoundary(locale, tmpbd);
- setShort(parameterIndex, tmpbd.shortValue());
- break;
- case Types.FLOAT:
- tmpbd = Utility.getBigDecimalValue(locale, x);
- Utility.checkFloatBoundary(locale, tmpbd);
- setDouble(parameterIndex, tmpbd.doubleValue());
- break;
- case Types.DOUBLE:
- tmpbd = Utility.getBigDecimalValue(locale, x);
- Utility.checkDoubleBoundary(locale, tmpbd);
- setDouble(parameterIndex, tmpbd.doubleValue());
- break;
- case Types.REAL:
- tmpbd = Utility.getBigDecimalValue(locale, x);
- setFloat(parameterIndex, tmpbd.floatValue());
- break;
- case Types.OTHER:
- if (inputDesc_[parameterIndex].fsDataType_ == InterfaceResultSet.SQLTYPECODE_INTERVAL) {
- if (x instanceof byte[]) {
- addParamValue(parameterIndex, x);
- } else if (x instanceof String) {
- addParamValue(parameterIndex, x);
- } else {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "conversion_not_allowed", null);
- }
- break;
- }
- case Types.ARRAY:
- case Types.BIT:
- case Types.DATALINK:
- case Types.DISTINCT:
- case Types.JAVA_OBJECT:
- case Types.STRUCT:
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "object_type_not_supported", null);
- }
- }
- }
-
- // JDK 1.2
- public void setRef(int i, Ref x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, i, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setRef", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, i, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setRef");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateSetInvocation(i);
- HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "setRef()");
- }
-
- public void setShort(int parameterIndex, short x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setShort", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setShort");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateSetInvocation(parameterIndex);
- inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
- addParamValue(parameterIndex, Short.toString(x));
- }
-
- public void setString(int parameterIndex, String x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setString", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setString");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateSetInvocation(parameterIndex);
- int dataType = inputDesc_[parameterIndex - 1].dataType_;
-
- switch (dataType) {
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.DATE:
- case Types.TIME:
- case Types.TIMESTAMP:
- case Types.OTHER: // This type maps to the Database
- // INTERVAL
- addParamValue(parameterIndex, x);
- break;
-
-
- case Types.ARRAY:
- case Types.BINARY:
- case Types.BIT:
- case Types.DATALINK:
- case Types.JAVA_OBJECT:
- case Types.REF:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "datatype_not_supported", null);
- case Types.BIGINT:
- case Types.INTEGER:
- case Types.SMALLINT:
- case Types.TINYINT:
- case Types.DECIMAL:
- case Types.NUMERIC:
- if (x != null) {
- x = x.trim(); // SQLJ is using numeric string with
- // leading/trailing whitespace
- }
- setObject(parameterIndex, x, dataType);
- break;
- case Types.BLOB:
- case Types.BOOLEAN:
- case Types.DOUBLE:
- case Types.FLOAT:
- case Types.LONGVARBINARY:
- case Types.NULL:
- case Types.REAL:
- case Types.VARBINARY:
- setObject(parameterIndex, x, dataType);
- break;
- default:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "fetch_output_inconsistent", null);
- }
-
- }
-
- public void setTime(int parameterIndex, Time x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setTime", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setTime");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- Timestamp t1;
-
- validateSetInvocation(parameterIndex);
- dataType = inputDesc_[parameterIndex - 1].dataType_;
- if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
- && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
- if (x != null) {
- if (dataType == Types.TIMESTAMP) {
- t1 = new Timestamp(x.getTime());
- addParamValue(parameterIndex, t1.toString());
- } else {
- addParamValue(parameterIndex, x.toString());
- }
- } else {
- addParamValue(parameterIndex, null);
- }
- }
-
- public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setTime", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setTime");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- long timeValue;
- Time adjustedTime;
- Timestamp t1;
-
- validateSetInvocation(parameterIndex);
- dataType = inputDesc_[parameterIndex - 1].dataType_;
- if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
- && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
- // Ignore the cal, since SQL would expect it to store it in the local
- // time zone
- if (x != null) {
- if (dataType == Types.TIMESTAMP) {
- t1 = new Timestamp(x.getTime());
- addParamValue(parameterIndex, t1.toString());
- } else {
- addParamValue(parameterIndex, x.toString());
- }
- } else {
- addParamValue(parameterIndex, null);
- }
- }
-
- public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setTimestamp", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setTimestamp");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- Date d1;
- Time t1;
-
- validateSetInvocation(parameterIndex);
- dataType = inputDesc_[parameterIndex - 1].dataType_;
- if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
- && dataType != Types.DATE && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
- if (x != null) {
- switch (dataType) {
- case Types.DATE:
- d1 = new Date(x.getTime());
- addParamValue(parameterIndex, d1.toString());
- break;
- case Types.TIME:
- t1 = new Time(x.getTime());
- addParamValue(parameterIndex, t1.toString());
- break;
- default:
- addParamValue(parameterIndex, x.toString());
- break;
- }
- } else {
- addParamValue(parameterIndex, null);
- }
- }
-
- public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setTimestamp", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setTimestamp");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- int dataType;
- long timeValue;
- Timestamp adjustedTime;
- Date d1;
- Time t1;
-
- validateSetInvocation(parameterIndex);
- dataType = inputDesc_[parameterIndex - 1].dataType_;
- if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
- && dataType != Types.DATE && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
- null);
- }
- // Ignore the cal, since SQL would expect it to store it in the local
- // time zone
- if (x != null) {
- switch (dataType) {
- case Types.DATE:
- d1 = new Date(x.getTime());
- addParamValue(parameterIndex, d1.toString());
- break;
- case Types.TIME:
- t1 = new Time(x.getTime());
- addParamValue(parameterIndex, t1.toString());
- break;
- default:
- addParamValue(parameterIndex, x.toString());
- break;
- }
- } else {
- addParamValue(parameterIndex, null);
- }
- }
-
- public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setUnicodeStream", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setUnicodeStream");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- byte[] buffer = new byte[length]; // length = number of bytes in
- // stream
- validateSetInvocation(parameterIndex);
- String s;
-
- if (x == null) {
- addParamValue(parameterIndex, null);
- } else {
- int dataType = inputDesc_[parameterIndex - 1].dataType_;
- switch (dataType) {
- case Types.DECIMAL:
- case Types.DOUBLE:
- case Types.FLOAT:
- case Types.NUMERIC:
- case Types.SMALLINT:
- case Types.INTEGER:
- case Types.BIGINT:
- case Types.TINYINT:
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_datatype_for_column", null);
- default:
- try {
- x.read(buffer, 0, length);
- } catch (java.io.IOException e) {
- Object[] messageArguments = new Object[1];
- messageArguments[0] = e.getMessage();
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
- messageArguments);
- }
- try {
- s = new String(buffer, "UnicodeBig");
- addParamValue(parameterIndex, s);
- } catch (java.io.UnsupportedEncodingException e) {
- Object[] messageArguments = new Object[1];
- messageArguments[0] = e.getMessage();
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "unsupported_encoding", messageArguments);
- }
- break;
- }
- }
- }
-
- public void setURL(int parameterIndex, URL x) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setURL", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setURL");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- validateSetInvocation(parameterIndex);
- HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "setURL()");
- } // end setURL
-
- // -------------------------------------------------------------------------------------------
- /**
- * This method will associate user defined data with the prepared statement.
- * The user defined data must be in SQL/MX rowwise rowset format.
- *
- * @param numRows
- * the number of rows contained in buffer
- * @param buffer
- * a buffer containing the rows
- *
- * @exception A
- * SQLException is thrown
- */
- public void setDataBuffer(int numRows, ByteBuffer buffer) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, numRows, buffer);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setDataBuffer", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, numRows, buffer);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("setDataBuffer");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- usingRawRowset_ = true;
- paramRowCount_ = numRows;
- rowwiseRowsetBuffer_ = buffer;
- } // end setDataBufferBuffer
-
- // -------------------------------------------------------------------------------------------
-
- // Other methods
- protected void validateExecuteInvocation() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "validateExecuteInvocation", "", p);
- }
- clearWarnings();
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "stmt_closed", null);
- }
- // connection_.getServerHandle().isConnectionOpen();
- connection_.isConnectionOpen();
- // close the previous resultset, if any
- for (int i = 0; i < num_result_sets_; i++) {
- if (resultSet_[i] != null) {
- resultSet_[i].close();
- }
- }
- if (paramRowCount_ > 0 && usingRawRowset_ == false) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "function_sequence_error", null);
- }
-
- if (usingRawRowset_ == false)
- checkIfAllParamsSet();
-
- }
-
- private void checkIfAllParamsSet() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "checkIfAllParamsSet", "", p);
- }
- int paramNumber;
-
- if (inputDesc_ == null) {
- return;
- }
- for (paramNumber = 0; paramNumber < inputDesc_.length; paramNumber++) {
- if (!inputDesc_[paramNumber].isValueSet_) {
- Object[] messageArguments = new Object[2];
- messageArguments[0] = new Integer(paramNumber + 1);
- messageArguments[1] = new Integer(paramRowCount_ + 1);
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "parameter_not_set",
- messageArguments);
- }
- }
- }
-
- private void validateSetInvocation(int parameterIndex) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "validateSetInvocation", "", p);
- }
- if (isClosed_) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "stmt_closed", null);
- }
- // connection_.getServerHandle().isConnectionOpen();
- connection_.isConnectionOpen();
- if (inputDesc_ == null) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_parameter_index", null);
- }
- if (parameterIndex < 1 || parameterIndex > inputDesc_.length) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_parameter_index", null);
- }
- if (inputDesc_[parameterIndex - 1].paramMode_ == DatabaseMetaData.procedureColumnOut) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "is_a_output_parameter",
- null);
- }
- }
-
- void addParamValue(int parameterIndex, Object x) {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "addParamValue", "", p);
- }
-
- paramsValue_[parameterIndex - 1] = x;
- inputDesc_[parameterIndex - 1].isValueSet_ = true;
- }
-
- Object[] getValueArray() {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "getValueArray", "", p);
- }
- Object[] valueArray;
- int length;
- int i;
- int j;
- int index;
- Object[] rows;
-
- if (paramRowCount_ > 0) {
- valueArray = new Object[(paramRowCount_ + 1) * inputDesc_.length];
- length = rowsValue_.size();
- for (i = 0, index = 0; i < length; i++) {
- rows = (Object[]) rowsValue_.get(i);
- for (j = 0; j < rows.length; j++, index++) {
- valueArray[index] = rows[j];
- }
- }
- } else {
- valueArray = paramsValue_;
- }
- return valueArray;
- }
-
- void logicalClose() throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "logicalClose", "", p);
- }
- isClosed_ = true;
- if (rowsValue_ != null) {
- rowsValue_.clear();
-
- }
- if (lobObjects_ != null) {
- lobObjects_.clear();
-
- }
- paramRowCount_ = 0;
- for (int i = 0; i < num_result_sets_; i++) {
- if (resultSet_[i] != null) {
- resultSet_[i].close();
- // Clear the isValueSet_ flag in inputDesc_
- }
- }
- result_set_offset = 0;
- resultSet_[result_set_offset] = null;
- if (inputDesc_ != null) {
- for (int i = 0; i < inputDesc_.length; i++) {
- inputDesc_[i].isValueSet_ = false;
- paramsValue_[i] = null;
- }
- }
- isAnyLob_ = false;
- if (!connection_.closePreparedStatement(connection_, sql_, resultSetType_, resultSetConcurrency_,
- resultSetHoldability_)) {
- this.close(true); // if the statement is not in the cache
- // hardclose it afterall
- }
-
- }
-
- // ----------------------------------------------------------------------------------
- // Method used by JNI Layer to update the results of Prepare
- void setPrepareOutputs(HPT4Desc[] inputDesc, HPT4Desc[] outputDesc, int inputParamCount, int outputParamCount)
- throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, inputDesc, outputDesc, inputParamCount,
- outputParamCount);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "setPrepareOutputs", "", p);
- }
- inputDesc_ = inputDesc;
- outputDesc_ = outputDesc;
- paramRowCount_ = 0;
-
- // Prepare updares inputDesc_ and outputDesc_
- if (inputDesc_ != null) {
- paramsValue_ = new Object[inputDesc_.length];
- } else {
- paramsValue_ = null;
- }
- } // end setPrepareOutputs
-
- // ----------------------------------------------------------------------------------
- void setPrepareOutputs2(HPT4Desc[] inputDesc, HPT4Desc[] outputDesc, int inputParamCount, int outputParamCount,
- int inputParamsLength, int outputParamsLength, int inputDescLength, int outputDescLength)
- throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, inputDesc, outputDesc, inputParamCount,
- outputParamCount, inputParamsLength, outputParamsLength, inputDescLength, outputDescLength);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "setPrepareOutputs2", "", p);
- }
- inputParamCount_ = inputParamCount;
- outputParamCount_ = outputParamCount;
- inputParamsLength_ = inputParamsLength;
- outputParamsLength_ = outputParamsLength;
- inputDescLength_ = inputDescLength;
- outputDescLength_ = outputDescLength;
- setPrepareOutputs(inputDesc, outputDesc, inputParamCount, outputParamCount);
- } // end setPrepareOutputs2
-
- // ----------------------------------------------------------------------------------
- // Method used by JNI layer to update the results of Execute
- void setExecuteOutputs(int rowCount) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rowCount);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "setExecuteOutputs", "", p);
- }
- batchRowCount_ = new int[1];
- batchRowCount_[0] = rowCount;
- num_result_sets_ = 1;
- result_set_offset = 0;
- if (outputDesc_ != null) {
- resultSet_[result_set_offset] = new TrafT4ResultSet(this, outputDesc_);
- } else {
- resultSet_[result_set_offset] = null;
- }
- }
-
- /*
- * //----------------------------------------------------------------------------------
- * void setExecuteSingletonOutputs(SQLValue_def[] sqlValue_def_array, short
- * rowsAffected) throws SQLException { batchRowCount_ = new int[1];
- * batchRowCount_[0] = rowsAffected; if (outputDesc_ != null) { resultSet_ =
- * new TrafT4ResultSet(this, outputDesc_); } else { resultSet_ = null; } if
- * (rowsAffected == 0) { resultSet_.setFetchOutputs(new Row[0], 0, true, 0); }
- * else { resultSet_.irs_.setSingletonFetchOutputs(resultSet_, rowsAffected,
- * true, 0, sqlValue_def_array); } }
- */
-
- // ----------------------------------------------------------------------------------
- // Method used by JNI layer to update the results of Execute
- void setExecuteBatchOutputs(int[] rowCount) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rowCount);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "setExecuteBatchOutputs", "", p);
- }
- num_result_sets_ = 1;
- result_set_offset = 0;
- if (outputDesc_ != null) {
- resultSet_[result_set_offset] = new TrafT4ResultSet(this, outputDesc_);
- } else {
- resultSet_[result_set_offset] = null;
- }
- batchRowCount_ = rowCount;
- }
-
- void reuse(TrafT4Connection connection, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
- throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, resultSetType,
- resultSetConcurrency, resultSetHoldability);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "reuse", "", p);
- }
- if (resultSetType != ResultSet.TYPE_FORWARD_ONLY && resultSetType != ResultSet.TYPE_SCROLL_INSENSITIVE
- && resultSetType != ResultSet.TYPE_SCROLL_SENSITIVE) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_resultset_type", null);
- }
- if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) {
- resultSetType_ = ResultSet.TYPE_SCROLL_INSENSITIVE;
- setSQLWarning(null, "scrollResultSetChanged", null);
- } else {
- resultSetType_ = resultSetType;
- }
- if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY && resultSetConcurrency != ResultSet.CONCUR_UPDATABLE) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_resultset_concurrency", null);
- }
- resultSetConcurrency_ = resultSetConcurrency;
- resultSetHoldability_ = resultSetHoldability;
- queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
- fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
- maxRows_ = 0;
- fetchDirection_ = ResultSet.FETCH_FORWARD;
- isClosed_ = false;
- }
-
- public void close(boolean hardClose) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, hardClose);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "close", "", p);
- }
-
- if (connection_._isClosed()) {
- return;
- }
- try {
- if (hardClose) {
- ist_.close();
- } else {
- logicalClose();
- }
- } catch (SQLException e) {
- performConnectionErrorChecks(e);
- throw e;
- } finally {
- isClosed_ = true;
- if (hardClose) {
- connection_.removeElement(pRef_);
- }
- }
-
- }
-
-
- TrafT4PreparedStatement(TrafT4Connection connection, String sql, String stmtLabel) throws SQLException {
- this(connection, sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, connection.holdability_,
- stmtLabel);
- connection.ic_.t4props_.setUseArrayBinding(false);
- connection.ic_.t4props_.setBatchRecovery(false);
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "",
- "Note, this call is before previous constructor call.", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- }
-
- // Constructors with access specifier as "default"
- TrafT4PreparedStatement(TrafT4Connection connection, String sql) throws SQLException {
- this(connection, sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, connection.holdability_);
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "",
- "Note, this call is before previous constructor call.", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- }
-
- TrafT4PreparedStatement(TrafT4Connection connection, String sql, int resultSetType, int resultSetConcurrency)
- throws SQLException {
- this(connection, sql, resultSetType, resultSetConcurrency, connection.holdability_);
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
- resultSetConcurrency);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "",
- "Note, this call is before previous constructor call.", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
- resultSetConcurrency);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- }
- TrafT4PreparedStatement(TrafT4Connection connection, String sql, int resultSetType, int resultSetConcurrency,
- int resultSetHoldability, String stmtLabel) throws SQLException {
- super(connection, resultSetType, resultSetConcurrency, resultSetHoldability, stmtLabel);
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
- resultSetConcurrency, resultSetHoldability);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "",
- "Note, this call is before previous constructor call.", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
- resultSetConcurrency, resultSetHoldability);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- // connection_.getServerHandle().isConnectionOpen();
- connection_.isConnectionOpen();
- sqlStmtType_ = ist_.getSqlStmtType(sql);
- if (sqlStmtType_ == TRANSPORT.TYPE_STATS) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "infostats_invalid_error", null);
- } else if (sqlStmtType_ == TRANSPORT.TYPE_CONFIG) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "config_cmd_invalid_error", null);
- }
- ist_.setTransactionStatus(connection_, sql);
- sql_ = sql;
-
-
- // stmtLabel_ = generateStmtLabel();
- stmtLabel_ = stmtLabel;
- // System.out.println("TrafT4PreparedStatement stmtLabel_ " + stmtLabel_);
-
- usingRawRowset_ = false;
- }
-
- TrafT4PreparedStatement(TrafT4Connection connection, String sql, int resultSetType, int resultSetConcurrency,
- int resultSetHoldability) throws SQLException {
- super(connection, resultSetType, resultSetConcurrency, resultSetHoldability);
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
- resultSetConcurrency, resultSetHoldability);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "",
- "Note, this call is before previous constructor call.", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
- resultSetConcurrency, resultSetHoldability);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- // connection_.getServerHandle().isConnectionOpen();
- connection_.isConnectionOpen();
- sqlStmtType_ = ist_.getSqlStmtType(sql);
- if (sqlStmtType_ == TRANSPORT.TYPE_STATS) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "infostats_invalid_error", null);
- } else if (sqlStmtType_ == TRANSPORT.TYPE_CONFIG) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "config_cmd_invalid_error", null);
- }
- ist_.setTransactionStatus(connection_, sql);
- sql_ = sql;
-
-
- //stmtLabel_ = generateStmtLabel();
-
- usingRawRowset_ = false;
- }
-
- TrafT4PreparedStatement(TrafT4Connection connection, String moduleName, int moduleVersion, long moduleTimestamp,
- String stmtName, boolean isSelect, int holdability) {
- if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, moduleName, moduleVersion,
- moduleTimestamp, stmtName, isSelect, holdability);
- connection.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "", "", p);
- }
- try {
- if (connection.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, moduleName, moduleVersion,
- moduleTimestamp, stmtName, isSelect, holdability);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection.props_.getLogWriter().println(temp);
- }
- } catch (SQLException se) {
- // ignore
- }
- connection_ = connection;
- moduleName_ = moduleName;
- moduleVersion_ = moduleVersion;
- moduleTimestamp_ = moduleTimestamp;
- stmtLabel_ = stmtName;
- sqlStmtType_ = (isSelect) ? TRANSPORT.TYPE_SELECT : TRANSPORT.TYPE_UNKNOWN;
- usingRawRowset_ = false;
-
- // Make Sure you initialize the other fields to the right value
- fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
- maxRows_ = 0;
- fetchDirection_ = ResultSet.FETCH_FORWARD;
- queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
- resultSetType_ = ResultSet.TYPE_FORWARD_ONLY;
- resultSetHoldability_ = holdability;
- usingRawRowset_ = false;
- }
-
- // Interface methods
- public void prepare(String sql, int queryTimeout, int holdability) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, queryTimeout, holdability);
- connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "prepare", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, queryTimeout, holdability);
- lr.setParameters(p);
- lr.setSourceClassName("TrafT4PreparedStatement");
- lr.setSourceMethodName("prepare");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
- try {
- super.ist_.prepare(sql, queryTimeout, this);
- } catch (SQLException e) {
- performConnectionErrorChecks(e);
- throw e;
- }
- };
-
- public void setFetchSize(int rows) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rows);
- connection_.props_.t4Logger_.logp(Level.FINE, "SQLMXPreparedStatement", "setFetchSize", "", p);
- }
- if (connection_.props_.getLogWriter() != null) {
- LogRecord lr = new LogRecord(Level.FINE, "");
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rows);
- lr.setParameters(p);
- lr.setSourceClassName("SQLMXPreparedStatement");
- lr.setSourceMethodName("setFetchSize");
- T4LogFormatter lf = new T4LogFormatter();
- String temp = lf.format(lr);
- connection_.props_.getLogWriter().println(temp);
- }
-
- if (rows < 0) {
- throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
- "invalid_fetchSize_value", null);
- }
- if (rows > 0) {
- fetchSize_ = rows;
- }
- // If the value specified is zero, then the hint is ignored.
- }
-
- private void execute(int paramRowCount, int paramCount, Object[] paramValues, int queryTimeout, boolean isAnyLob
- ) throws SQLException {
- if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
- Object p[] = T4LoggingUtilities.makeParams(connection_.props_, paramRowCount, paramCount, paramValues,
- queryTimeout, isAnyLob);
- connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "execute", "", p);
- }
- try {
- ist_.execute(TRANSPORT.SRVR_API_SQLEXECUTE2, paramRowCount, paramCount, paramValues, queryTimeout, null,
- this);
- } catch (SQLException e) {
- performConnectionErrorChecks(e);
- throw e;
- }
- };
-
- /*
- * protected void setSingleton(boolean value) { singleton_ = value; }
- * protected boolean getSingleton() { return singleton_; }
- */
-
- /**
- * Use this method to retrieve the statement type that
<TRUNCATED>
[31/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceUtilities.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceUtilities.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceUtilities.java
new file mode 100644
index 0000000..95fa7f9
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceUtilities.java
@@ -0,0 +1,235 @@
+// @@@ 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;
+import java.math.BigInteger;
+import java.util.Hashtable;
+
+public class InterfaceUtilities {
+ static private Hashtable valueToCharset;
+ static {
+ valueToCharset = new Hashtable(11);
+ valueToCharset.put(new Integer(1), "ISO8859_1"); // ISO
+ valueToCharset.put(new Integer(10), "MS932"); // SJIS
+ valueToCharset.put(new Integer(11), "UTF-16BE"); // UCS2
+ valueToCharset.put(new Integer(12), "EUCJP"); // EUCJP
+ valueToCharset.put(new Integer(13), "MS950"); // BIG5
+ valueToCharset.put(new Integer(14), "GB18030"); // GB18030
+ valueToCharset.put(new Integer(15), "UTF-8"); // UTF8
+ valueToCharset.put(new Integer(16), "MS949"); // MB_KSC5601
+ valueToCharset.put(new Integer(17), "GB2312"); // GB2312
+ }
+ static private Hashtable charsetToValue;
+ static {
+ charsetToValue = new Hashtable(11);
+ charsetToValue.put("ISO8859_1", new Integer(1)); // ISO
+ charsetToValue.put("MS932", new Integer(10)); // SJIS
+ charsetToValue.put("UTF-16BE", new Integer(11)); // UCS2
+ charsetToValue.put("EUCJP", new Integer(12)); // EUCJP
+ charsetToValue.put("MS950", new Integer(13)); // BIG5
+ charsetToValue.put("GB18030", new Integer(14)); // GB18030
+ charsetToValue.put("UTF-8", new Integer(15)); // UTF8
+ charsetToValue.put("MS949", new Integer(16)); // MB_KSC5601
+ charsetToValue.put("GB2312", new Integer(17)); // GB2312
+ }
+
+ static final int SQLCHARSETCODE_UNKNOWN = 0;
+ static final String SQLCHARSET_UNKNOWN = "UNKNOWN";
+
+ // these are the only real column types
+ static final int SQLCHARSETCODE_ISO88591 = 1;
+ static final String SQLCHARSET_ISO88591 = "ISO88591";
+ static final int SQLCHARSETCODE_UNICODE = 11;
+ static final String SQLCHARSET_UNICODE = "UCS2";
+
+ // ISO_MAPPING values
+ static final int SQLCHARSETCODE_SJIS = 10;
+ static final int SQLCHARSETCODE_UTF8 = 15;
+
+ static String getCharsetName(int charset) {
+ String ret = (String) valueToCharset.get(new Integer(charset));
+
+ if (ret == null)
+ ret = SQLCHARSET_UNKNOWN;
+
+ return ret;
+ }
+
+ static int getCharsetValue(String charset) {
+ Integer i = (Integer) charsetToValue.get(charset);
+ int ret;
+
+ if (i == null)
+ ret = SQLCHARSETCODE_UNKNOWN;
+ else
+ ret = i.intValue();
+
+ return ret;
+ }
+
+ static private final int[] powersOfTen = { 10, 100, 1000, 10000 };
+
+ public static byte[] convertBigDecimalToSQLBigNum(BigDecimal bd, int targetLength, int targetScale) {
+ byte[] sourceData = bd.setScale(targetScale, BigDecimal.ROUND_DOWN).unscaledValue().toString().getBytes(); // add
+ // trailing
+ // 0s,
+ // remove decimal point,
+ // get the chars
+ byte[] targetData = new byte[targetLength];
+ int[] targetInShorts = new int[targetLength / 2];
+
+ int length;
+ int temp;
+ int tarPos = 1;
+
+ // remove leading 0s and sign character
+ int zeros = 0;
+ while (zeros < sourceData.length && (sourceData[zeros] == '0' || sourceData[zeros] == '-'))
+ zeros++;
+
+ // convert from characters to values
+ for (int i = zeros; i < sourceData.length; i++)
+ sourceData[i] -= '0';
+
+ length = sourceData.length - zeros; // we have a new length
+
+ // iterate through 4 bytes at a time
+ for (int i = 0; i < length; i += 4) {
+ int temp1 = 0;
+ int j = 0;
+
+ // get 4 bytes worth of data or as much that is left
+ for (j = 0; j < 4 && i + j < length; j++)
+ temp1 = temp1 * 10 + sourceData[zeros + i + j];
+
+ int power = powersOfTen[j - 1]; // get the power of ten based on how
+ // many digits we got
+
+ temp = targetInShorts[0] * power + temp1; // move the current
+ // digits over and then
+ // add our new value in
+ targetInShorts[0] = temp & 0xFFFF; // we save only up to 16bits --
+ // the rest gets carried over
+
+ // we do the same thing for the rest of the digits now that we have
+ // an upper bound
+ for (j = 1; j < targetInShorts.length; j++) {
+ int t = (temp & 0xFFFF0000) >> 16;
+ temp = targetInShorts[j] * power + t;
+
+ targetInShorts[j] = temp & 0xFFFF;
+ }
+
+ int carry = (temp & 0xFFFF0000) >> 16;
+ if (carry > 0) {
+ targetInShorts[tarPos++] = carry;
+ }
+ }
+
+ // convert the data back to bytes
+ for (int i = 0; i < targetInShorts.length; i++) {
+// targetData[i * 2] = (byte) ((targetInShorts[i] & 0xFF00) >> 8);
+// targetData[i * 2 + 1] = (byte) (targetInShorts[i] & 0xFF);
+ targetData[i * 2 ] = (byte) (targetInShorts[i] & 0xFF);
+ targetData[i * 2 + 1] = (byte) ((targetInShorts[i] & 0xFF00) >> 8);
+ }
+
+ // add sign
+ if ((bd.signum() < 0))
+ targetData[targetData.length - 2] |= 0x80;
+
+ return targetData;
+ }
+
+ public static BigDecimal convertSQLBigNumToBigDecimal(byte[] sourceData, int scale, boolean swap) {
+ String strVal = ""; // our final String
+
+ // we need the data in an array which can hold UNSIGNED 16 bit values
+ // in java we dont have unsigned datatypes so 32-bit signed is the best
+ // we can do
+ int[] dataInShorts = new int[sourceData.length / 2];
+ for (int i = 0; i < dataInShorts.length; i++)
+ dataInShorts[i] = Bytes.extractUShort(sourceData, i * 2, swap); // copy
+ // the
+ // data
+
+ boolean negative = ((dataInShorts[dataInShorts.length - 1] & 0x8000) > 0);
+ dataInShorts[dataInShorts.length - 1] &= 0x7FFF; // force sign to 0, continue
+ // normally
+
+ int curPos = dataInShorts.length - 1; // start at the end
+ while (curPos >= 0 && dataInShorts[curPos] == 0)
+ // get rid of any trailing 0's
+ curPos--;
+
+ int remainder = 0;
+ long temp; // we need to use a LONG since we will have to hold up to
+ // 32-bit UNSIGNED values
+
+ // we now have the huge value stored in 2 bytes chunks
+ // we will divide by 10000 many times, converting the remainder to
+ // String
+ // when we are left with a single chunk <10000 we will handle it using a
+ // special case
+ while (curPos >= 0 || dataInShorts[0] >= 10000) {
+ // start on the right, divide the 16 bit value by 10000
+ // use the remainder as the upper 16 bits for the next division
+ for (int j = curPos; j >= 0; j--) {
+ // these operations got messy when java tried to infer what size
+ // to store the value in
+ // leave these as separate operations for now...always casting
+ // back to a 64 bit value to avoid sign problems
+ temp = remainder;
+ temp &= 0xFFFF;
+ temp = temp << 16;
+ temp += dataInShorts[j];
+
+ dataInShorts[j] = (int) (temp / 10000);
+ remainder = (int) (temp % 10000);
+ }
+
+ // if we are done with the current 16bits, move on
+ if (dataInShorts[curPos] == 0)
+ curPos--;
+
+ // go through the remainder and add each digit to the final String
+ for (int j = 0; j < 4; j++) {
+ strVal = (remainder % 10) + strVal;
+ remainder /= 10;
+ }
+ }
+
+ // when we finish the above loop we still have 1 <10000 value to include
+ remainder = dataInShorts[0];
+ for (int j = 0; j < 4; j++) {
+ strVal = (remainder % 10) + strVal;
+ remainder /= 10;
+ }
+
+ BigInteger bi = new BigInteger(strVal); // create a java BigInt
+ if (negative)
+ bi = bi.negate();
+
+ return new BigDecimal(bi, scale); // create a new BigDecimal with the
+ // descriptor's scale
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Key.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Key.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Key.java
new file mode 100644
index 0000000..b143866
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Key.java
@@ -0,0 +1,161 @@
+/**********************************************************************
+// @@@ 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 @@@
+//
+**********************************************************************/
+
+/**
+ * Key.java
+ */
+
+package org.trafodion.jdbc.t4;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.security.cert.X509Certificate;
+import java.security.KeyFactory;
+import java.security.interfaces.RSAPublicKey;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.security.NoSuchAlgorithmException;
+import java.security.spec.InvalidKeySpecException;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+import javax.crypto.KeyGenerator;
+
+
+public class Key {
+ public Key(){}
+
+ /** Reads the public key from the certificate file and
+ * stores the key and the length of the public key
+ * in member data.
+ * @param X509Certificate - The certificate stored
+ * the public key
+ */
+ public void getPubKeyFromFile(X509Certificate cert)
+ {
+ m_pubKey = (RSAPublicKey) cert.getPublicKey();
+ if (((m_pubKey.getModulus().bitLength()) / 8) > 128)
+ m_pubKeyLen = 256;
+ else
+ m_pubKeyLen = 128;
+ }
+
+ /** Reads the private key from certificate file and
+ * stores the key in the member data.
+ * @param String - The file stored the private key
+ * @throw SecurityException
+ */
+ public void getPrivKeyFromFile(String inFile) throws SecurityException
+ {
+ InputStream inStream=null;
+
+ try{
+ // Loading private key file
+ inStream=new FileInputStream(inFile);
+ byte[] keyBytes=new byte[inStream.available()];
+ inStream.read(keyBytes);
+ inStream.close();
+
+ // Read the private key from file
+ PKCS8EncodedKeySpec privKeySpec=new PKCS8EncodedKeySpec(keyBytes);
+ KeyFactory keyFactory = KeyFactory.getInstance("RSA");
+ m_privKey= (RSAPrivateKey) keyFactory.generatePrivate
+ (privKeySpec);
+
+ }catch (FileNotFoundException fnf) {
+ throw new SecurityException(SecClientMsgKeys.FILE_NOTFOUND, new Object[]{inFile});
+ }catch (IOException io) {
+ throw new SecurityException(SecClientMsgKeys.ERR_OPEN_INPUT_FILE, new Object[]{inFile});
+ }catch (Exception e) {
+ throw new SecurityException(SecClientMsgKeys.ERR_RETRIEVE_KEY_FROM_FILE, new Object[]{inFile});
+ }finally {
+ try {
+ if (inStream != null)
+ inStream.close();
+ }catch (IOException io) {
+ // not much we can do at this point
+ }
+ }
+ }
+
+ /**
+ * Generates a secret key using AES algorithm and 128 bits key
+ * @param sessionKey the session key byte array used for symmetric key
+ * generation
+ * @return the SecretKey
+ * @throws SecurityException
+ */
+ static SecretKey generateSymmetricKey(byte [] sKey) throws SecurityException
+ {
+ if (sKey == null)
+ throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"sKey"});
+ try {
+ // Get the KeyGenerator
+ KeyGenerator kgen = KeyGenerator.getInstance("AES");
+ synchronized(kgen) {
+ kgen.init(128);
+ }
+ // Use the lower 16 bytes of the session key to generate the 128 bits secret
+ // key used for data encryption
+
+ SecretKey skey = new SecretKeySpec(sKey, kgen.getAlgorithm());
+
+ return skey;
+ }catch (NoSuchAlgorithmException nae) {
+ throw new SecurityException(SecClientMsgKeys.ERR_CREATE_SYMMETRIC_KEY, null);
+ }
+ }
+
+ /**
+ *
+ * @return the public key
+ */
+ public RSAPublicKey getPubKey()
+ {
+ return m_pubKey;
+ }
+
+ /**
+ *
+ * @return the private key
+ */
+ public RSAPrivateKey getPrivKey()
+ {
+ return m_privKey;
+ }
+
+ /**
+ *
+ * @return the length of the public key
+ */
+ public int getPubKeyLen()
+ {
+ return m_pubKeyLen;
+ }
+
+ private RSAPublicKey m_pubKey;
+ private RSAPrivateKey m_privKey;
+ private int m_pubKeyLen;
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/LogicalByteArray.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/LogicalByteArray.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/LogicalByteArray.java
new file mode 100644
index 0000000..ce0e3ac
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/LogicalByteArray.java
@@ -0,0 +1,345 @@
+// @@@ 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.ByteBuffer;
+
+class LogicalByteArray {
+ static private java.lang.ThreadLocal threadArray = new java.lang.ThreadLocal();
+
+ private byte[] array;
+ private ByteBuffer dataBuffer;
+ private byte[] trailer;
+
+ private boolean swap; // should we swap byte order
+ private int loc; // current position
+ private int length; // current bytes being used
+
+ LogicalByteArray(int size, int startingLoc, boolean byteSwap) {
+ loc = startingLoc;
+ length = 0;
+ swap = byteSwap;
+
+ // TRANSPORT.IO_BUFFER_LENGTH is our minimum length so it is always safe
+ // to read with the buffer
+ resize((size > TRANSPORT.IO_BUFFER_LENGTH) ? size : TRANSPORT.IO_BUFFER_LENGTH);
+ }
+
+ void resize(long l) {
+ byte[] old = (byte[]) threadArray.get();
+
+ if (old == null || old.length < l) {
+ array = new byte[(int) l];
+ if (old != null)
+ System.arraycopy(old, 0, array, 0, old.length);
+
+ threadArray.set(array);
+ } else {
+ array = old;
+ }
+ }
+
+ void reset() {
+ length = 0;
+ loc = 0;
+ }
+
+ byte[] getBuffer() {
+ return array;
+ }
+
+ int getTotalAllocated() {
+ return array.length;
+ }
+
+ int getLength() {
+ if (length < loc) {
+ length = loc;
+ }
+
+ return length;
+ }
+
+ int getLocation() {
+ return loc;
+ }
+
+ public void setLocation(int newLoc) {
+ if (newLoc > length) {
+ length = newLoc;
+ }
+
+ loc = newLoc;
+ }
+
+ void insertByte(byte value) {
+ array[loc++] = value;
+ }
+
+ void insertByteArray(byte[] value, int len) {
+ System.arraycopy(value, 0, array, loc, len);
+
+ loc += len;
+ }
+
+ void insertChar(char value) {
+ array[loc++] = (byte) value;
+ }
+
+ void insertShort(short value) {
+ if (swap) {
+ array[loc + 1] = (byte) ((value >>> 8) & 0xff);
+ array[loc] = (byte) ((value) & 0xff);
+ } else {
+ array[loc] = (byte) ((value >>> 8) & 0xff);
+ array[loc + 1] = (byte) ((value) & 0xff);
+ }
+
+ loc += 2;
+ }
+
+ void insertInt(int value) {
+ if (swap) {
+ array[loc + 3] = (byte) ((value >>> 24) & 0xff);
+ array[loc + 2] = (byte) ((value >>> 16) & 0xff);
+ array[loc + 1] = (byte) ((value >>> 8) & 0xff);
+ array[loc] = (byte) ((value) & 0xff);
+ } else {
+ array[loc] = (byte) ((value >>> 24) & 0xff);
+ array[loc + 1] = (byte) ((value >>> 16) & 0xff);
+ array[loc + 2] = (byte) ((value >>> 8) & 0xff);
+ array[loc + 3] = (byte) ((value) & 0xff);
+ }
+
+ loc += 4;
+ }
+
+ void insertLong(long value) {
+ if (swap) {
+ array[loc + 7] = (byte) ((value >>> 56) & 0xff);
+ array[loc + 6] = (byte) ((value >>> 48) & 0xff);
+ array[loc + 5] = (byte) ((value >>> 40) & 0xff);
+ array[loc + 4] = (byte) ((value >>> 32) & 0xff);
+ array[loc + 3] = (byte) ((value >>> 24) & 0xff);
+ array[loc + 2] = (byte) ((value >>> 16) & 0xff);
+ array[loc + 1] = (byte) ((value >>> 8) & 0xff);
+ array[loc] = (byte) ((value) & 0xff);
+ } else {
+ array[loc] = (byte) ((value >>> 56) & 0xff);
+ array[loc + 1] = (byte) ((value >>> 48) & 0xff);
+ array[loc + 2] = (byte) ((value >>> 40) & 0xff);
+ array[loc + 3] = (byte) ((value >>> 32) & 0xff);
+ array[loc + 4] = (byte) ((value >>> 24) & 0xff);
+ array[loc + 5] = (byte) ((value >>> 16) & 0xff);
+ array[loc + 6] = (byte) ((value >>> 8) & 0xff);
+ array[loc + 7] = (byte) ((value) & 0xff);
+ }
+
+ loc += 8;
+ }
+
+ void insertStringWithCharset(byte[] str, int charset) {
+ if (str != null && str.length > 0) {
+ this.insertString(str);
+ this.insertInt(charset);
+ } else {
+ this.insertInt(0);
+ }
+ }
+
+ void insertFixedString(byte[] buf, int len) {
+ int dataLength;
+
+ if(buf != null) {
+ dataLength = (buf.length > len-1)?len-1:buf.length; //-1 for the null, max dataLength is (len-1)
+ this.insertByteArray(buf, dataLength);
+ } else {
+ dataLength = 0;
+ }
+
+ byte [] padding = new byte[len-dataLength]; //this will always be at least 1 for the null padding
+ this.insertByteArray(padding, padding.length);
+ }
+
+ void insertString(byte[] buf) {
+ if (buf != null && buf.length > 0) {
+ this.insertInt(buf.length + 1);
+ this.insertByteArray(buf, buf.length);
+ this.insertByte((byte) 0);
+ } else { // buffer is null or length 0
+ this.insertInt(0);
+ }
+ }
+
+ void insertString(byte[] str, boolean fixForServer) {
+ if (str != null && str.length > 0) {
+ this.insertInt(str.length + 1); // +1 null term
+ this.insertByteArray(str, str.length);
+ this.insertByte((byte) 0);
+ } else {
+ this.insertInt(1);
+ this.insertByte((byte) 0);
+ }
+ }
+
+ // /////////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////////
+
+ boolean extractBoolean() {
+ return (extractByte() == 0) ? false : true;
+ }
+
+ byte extractByte() {
+ return array[loc++];
+ }
+
+ byte[] extractByteArray(long bufferLength) {
+ byte[] a = new byte[(int) bufferLength];
+
+ System.arraycopy(array, loc, a, 0, (int) bufferLength);
+ loc += bufferLength;
+
+ return a;
+ }
+
+ byte[] extractByteArray() {
+ return extractByteArray(this.extractInt());
+ }
+
+ char extractChar() {
+ return (char) extractByte();
+ }
+
+ short extractShort() {
+ int value;
+
+ if (swap) {
+ value = ((array[loc]) & 0x00ff) | ((array[loc + 1] << 8) & 0xff00);
+ } else {
+ value = ((array[loc + 1]) & 0x00ff) | ((array[loc] << 8) & 0xff00);
+ }
+
+ loc += 2;
+
+ return (short) value;
+ }
+
+ int extractInt() {
+ int value;
+
+ if (swap) {
+ value = ((array[loc]) & 0x000000ff) | ((array[loc + 1] << 8) & 0x0000ff00)
+ | ((array[loc + 2] << 16) & 0x00ff0000) | ((array[loc + 3] << 24) & 0xff000000);
+ } else {
+ value = ((array[loc + 3]) & 0x000000ff) | ((array[loc + 2] << 8) & 0x0000ff00)
+ | ((array[loc + 1] << 16) & 0x00ff0000) | ((array[loc] << 24) & 0xff000000);
+ }
+
+ loc += 4;
+
+ return value;
+ }
+
+ long extractLong() {
+ long value;
+
+ if (swap) {
+ value = ((array[loc]) & 0x00000000000000ffL) | ((array[loc + 1] << 8) & 0x000000000000ff00L)
+ | ((array[loc + 2] << 16) & 0x0000000000ff0000L) | ((array[loc + 3] << 24) & 0x00000000ff000000L)
+ | ((array[loc + 4] << 32) & 0x000000ff00000000L) | ((array[loc + 5] << 40) & 0x0000ff0000000000L)
+ | ((array[loc + 6] << 48) & 0x00ff000000000000L) | ((array[loc + 7] << 56) & 0xff00000000000000L);
+ } else {
+ value = ((array[loc + 7]) & 0x00000000000000ffL) | ((array[loc + 6] << 8) & 0x000000000000ff00L)
+ | ((array[loc + 5] << 16) & 0x0000000000ff0000L) | ((array[loc + 4] << 24) & 0x00000000ff000000L)
+ | ((array[loc + 3] << 32) & 0x000000ff00000000L) | ((array[loc + 2] << 40) & 0x0000ff0000000000L)
+ | ((array[loc + 1] << 48) & 0x00ff000000000000L) | ((array[loc] << 56) & 0xff00000000000000L);
+ }
+
+ loc += 8;
+
+ return value;
+ }
+
+ long extractUnsignedInt() {
+ long value;
+
+ if(swap) {
+ value = ((array[loc]) & 0x000000ff) | ((array[loc + 1] << 8) & 0x0000ff00)
+ | ((array[loc + 2] << 16) & 0x00ff0000) | ((array[loc + 3] << 24) & 0xff000000);
+ } else {
+ value = ((array[loc + 3]) & 0x000000ff) | ((array[loc + 2] << 8) & 0x0000ff00)
+ | ((array[loc + 1] << 16) & 0x00ff0000) | ((array[loc] << 24) & 0xff000000);
+ }
+
+ loc += 4;
+
+ return value & 0xffffffffL;
+ }
+
+ byte[] extractString() {
+ int len = extractInt();
+ byte[] str = new byte[0];
+
+ if (len > 0) {
+ str = extractByteArray(len - 1);
+ extractByte(); // trailing null
+ }
+ return str;
+ }
+
+ byte[] extractByteString() {
+ int len = extractInt();
+ byte[] b = new byte[0];
+
+ if (len > 0) {
+ b = extractByteArray(len); // the packed length DOES NOT include
+ // the null character
+ extractByte(); // trailing null
+ }
+
+ return b;
+ }
+
+ void setDataBuffer(ByteBuffer buf) {
+ this.dataBuffer = buf;
+ }
+
+ void setTrailer(byte[] buf) {
+ this.trailer = buf;
+ }
+
+ ByteBuffer getDataBuffer() {
+ return this.dataBuffer;
+ }
+
+ byte[] getTrailer() {
+ return this.trailer;
+ }
+
+ void setByteSwap(boolean byteSwap) {
+ this.swap = byteSwap;
+ }
+
+ boolean getByteSwap() {
+ return this.swap;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/MessageDigest.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/MessageDigest.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/MessageDigest.java
new file mode 100644
index 0000000..4484076
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/MessageDigest.java
@@ -0,0 +1,84 @@
+/**********************************************************************
+// @@@ 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 @@@
+//
+**********************************************************************/
+
+/**
+ * class MessageDigest - Computes the message authentication code using
+ * the SHA256 hash function
+ */
+
+package org.trafodion.jdbc.t4;
+
+public class MessageDigest
+{
+ private static class Holder
+ {
+ private static MessageDigest instance = new MessageDigest();
+ }
+
+ /**
+ *
+ * @return MessageDigest
+ */
+ public static MessageDigest getInstance()
+ {
+ return Holder.instance;
+ }
+
+ /**Digests message using HmacSHA256 algorithm.
+ * @param key - session key to use for create secret key used in HMAC digest
+ * @param data - The data used to create the digest
+ * @param md - returns the digested message
+ * @return the digested message's length or -1 in case of failure
+ * @throw SecurityException
+ */
+ public int digest(byte[] key, byte[] data, byte[] md) throws SecurityException
+ {
+ if (key == null)
+ throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL,
+ new Object[]{"key"});
+ if (data == null)
+ throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL,
+ new Object[]{"data"});
+ if (md == null)
+ throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL,
+ new Object[]{"md"});
+ try {
+ javax.crypto.spec.SecretKeySpec keySpec =
+ new javax.crypto.spec.SecretKeySpec(key, "HmacSHA256");
+ javax.crypto.Mac mac = javax.crypto.Mac.getInstance("HmacSHA256");
+ byte[] tmpMd;
+ synchronized (mac) {
+ mac.init(keySpec);
+
+ tmpMd = mac.doFinal(data);
+ }
+ System.arraycopy(tmpMd, 0, md, 0, tmpMd.length);
+
+ return tmpMd.length;
+ }catch (Exception ex) {
+ throw new SecurityException(SecClientMsgKeys.HMAC_FAILED, null);
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/NCSAddress.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/NCSAddress.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/NCSAddress.java
new file mode 100644
index 0000000..a23c7e6
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/NCSAddress.java
@@ -0,0 +1,220 @@
+// @@@ 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;
+
+/**********************************************************
+ * This class represents an address reference.
+ *
+ * @version 1.0
+ **********************************************************/
+
+import java.sql.SQLException;
+import java.util.Locale;
+
+final class NCSAddress extends Address {
+
+ private static final String ODBCServerPrefix = "TCP:";
+ private static final String ODBCServerSuffix = ":ODBC";
+ private static final int minODBCServerAddrLen = ODBCServerPrefix.length() + 7 + ODBCServerSuffix.length();
+
+ static final int OS_type = 2; // TCP:\<Machine Name>.<Process
+
+ // Name>/<port>:ODBC
+
+ /**
+ * The constructor.
+ *
+ * @param addr
+ * The addr has the format:
+ *
+ * ODBC server connect format returned by the ODBC Association Server.
+ *
+ * TCP:\<{IP Address|Machine Name}>.<Process Name>/<port>:ODBC
+ *
+ *
+ */
+ NCSAddress(T4Properties t4props, Locale locale, String addr) throws SQLException {
+ super(t4props, locale, addr);
+ int index0;
+ int index1;
+ int index2;
+ int index3;
+
+ m_locale = locale;
+
+ if (addr == null) {
+ SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_null_error", null);
+ throw se;
+ }
+
+ if (acceptsURL(addr) == true) {
+ //
+ // We are dealing with an address of the form:
+ //
+ // TCP:\<{IP Address|Machine Name}>.<Process
+ // Name>/<port>:ODBC
+ //
+ m_type = OS_type;
+ if (addr.endsWith(ODBCServerSuffix) == false) {
+ SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", addr);
+ SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "odbc_server_suffix_error",
+ ODBCServerSuffix);
+
+ se.setNextException(se2);
+ throw se;
+ }
+ if (addr.length() < minODBCServerAddrLen) {
+ SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", addr);
+ SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "min_address_length_error",
+ null);
+
+ se.setNextException(se2);
+ throw se;
+ }
+
+ addr = addr.substring(ODBCServerPrefix.length());
+ addr = addr.substring(0, addr.length() - ODBCServerSuffix.length());
+
+ if (addr.indexOf(",") > 0)
+ interpretNEOAddress(t4props, locale, addr);
+ else
+ interpretAddress(t4props, locale, addr);
+
+ if ((m_machineName == null && m_ipAddress == null) || m_processName == null || m_portNumber == null) {
+ SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", addr);
+ SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "address_format_1_error", null);
+
+ se.setNextException(se2);
+ throw se;
+ }
+ }
+ } // end Address
+
+ // ----------------------------------------------------------
+ void interpretAddress(T4Properties t4props, Locale locale, String addr) throws SQLException {
+ //
+ // We are now expecting addr = "\<machine name>.<process name>/<port
+ // number>"
+ //
+
+ int index1 = addr.indexOf("\\");
+ int index3 = addr.indexOf("/");
+
+ //
+ // Find <{IP Address|Machine Name}>
+ //
+ int index2 = addr.lastIndexOf(".", index3);
+
+ if ((-1 < index1 && index1 < index2 && index2 < index3 && index3 < addr.length()) == false) {
+ SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", addr);
+ SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "address_format_1_error", null);
+
+ se.setNextException(se2);
+ throw se;
+ }
+
+ String temp4 = addr.substring((index1 + 1), index2);
+
+ if (Character.isDigit(temp4.charAt(0)) || temp4.substring(0, 1).equals("[")) {
+ //
+ // If first letter is a digit or "[" (i.e. IPv6), I'll assume it is
+ // an IP address
+ //
+ m_ipAddress = temp4;
+ } else {
+ m_machineName = temp4;
+ }
+
+ m_processName = addr.substring((index2 + 1), index3);
+ m_portNumber = new Integer(addr.substring((index3 + 1), addr.length()));
+ }
+
+ void interpretNEOAddress(T4Properties t4props, Locale locale, String addr) throws SQLException {
+ //
+ // We are now expecting addr = "\<machine name>.<process name>,<{IP
+ // Address|Machine Name}>/<port number>"
+ //
+ //int index1 = addr.indexOf("\\");
+ int index3 = addr.indexOf("/");
+ int index4 = addr.indexOf(",");
+ //
+ // Find <{IP Address|Machine Name}>
+ //
+ int index2 = addr.indexOf(".", 0);
+
+ if ((/*-1 < index1 && index1 < index2 &&*/ index2 < index4 && index4 < index3 && index3 < addr.length()) == false) {
+ SQLException se = HPT4Messages.createSQLException(m_t4props, m_locale, "address_parsing_error", addr);
+ SQLException se2 = HPT4Messages.createSQLException(m_t4props, m_locale, "address_format_1_error", null);
+
+ se.setNextException(se2);
+ throw se;
+ }
+
+ String temp4 = addr.substring((index4 + 1), index3);
+
+ if (Character.isDigit(temp4.charAt(0)) || temp4.substring(0, 1).equals("[")) {
+ //
+ // If first letter is a digit or "[" (i.e. IPv6), I'll assume it is
+ // an IP address
+ //
+ m_ipAddress = temp4;
+ } else {
+ m_machineName = temp4;
+ }
+
+ m_processName = addr.substring((index2 + 1), index4);
+ m_portNumber = new Integer(addr.substring((index3 + 1), addr.length()));
+ }
+
+ // ----------------------------------------------------------
+ String recreateAddress() {
+ String addr = ODBCServerPrefix + "\\";
+
+ if (m_machineName != null) {
+ addr = addr + m_machineName;
+ }
+ addr = addr + ".";
+
+ if (m_processName != null) {
+ addr = addr + m_processName;
+
+ }
+ addr = addr + "/";
+
+ if (m_portNumber != null) {
+ addr = addr + m_portNumber;
+
+ }
+ addr = addr + ODBCServerSuffix;
+
+ return addr;
+ } // end recreateAddress
+
+ static boolean acceptsURL(String url) throws SQLException {
+ try {
+ return (url.toUpperCase().startsWith(ODBCServerPrefix));
+ } catch (Exception ex) {
+ throw new SQLException(ex.toString());
+ }
+ }
+
+} // end class Address
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/OUT_CONNECTION_CONTEXT_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/OUT_CONNECTION_CONTEXT_def.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/OUT_CONNECTION_CONTEXT_def.java
new file mode 100644
index 0000000..b7b07dc
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/OUT_CONNECTION_CONTEXT_def.java
@@ -0,0 +1,97 @@
+// @@@ 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 OUT_CONNECTION_CONTEXT_def {
+ static final long OUTCONTEXT_OPT1_ENFORCE_ISO88591 = 1; // (2^0)
+ static final long OUTCONTEXT_OPT1_IGNORE_SQLCANCEL = 1073741824; // (2^30)
+ static final long OUTCONTEXT_OPT1_EXTRA_OPTIONS = 2147483648L; // (2^31)
+ static final long OUTCONTEXT_OPT1_DOWNLOAD_CERTIFICATE = 536870912; //(2^29)
+
+ VERSION_LIST_def versionList;
+
+ short nodeId;
+ int processId;
+
+ String computerName;
+ String catalog;
+ String schema;
+
+ int optionFlags1;
+ int optionFlags2;
+
+ String _roleName;
+ boolean _enforceISO;
+ boolean _ignoreCancel;
+
+ byte [] certificate;
+
+ void extractFromByteArray(LogicalByteArray buf, InterfaceConnection ic) throws SQLException,
+ UnsupportedCharsetException, CharacterCodingException {
+ versionList = new VERSION_LIST_def();
+ versionList.extractFromByteArray(buf);
+
+ nodeId = buf.extractShort();
+ processId = buf.extractInt();
+ computerName = ic.decodeBytes(buf.extractString(), 1);
+
+ catalog = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ schema = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+
+ optionFlags1 = buf.extractInt();
+ optionFlags2 = buf.extractInt();
+
+ this._enforceISO = (optionFlags1 & OUTCONTEXT_OPT1_ENFORCE_ISO88591) > 0;
+ this._ignoreCancel = (optionFlags1 & OUTCONTEXT_OPT1_IGNORE_SQLCANCEL) > 0;
+ if((optionFlags1 & OUTCONTEXT_OPT1_DOWNLOAD_CERTIFICATE) > 0) {
+ certificate = buf.extractByteArray();
+ }
+ else if ((optionFlags1 & OUTCONTEXT_OPT1_EXTRA_OPTIONS) > 0) {
+ try {
+ this.decodeExtraOptions(ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8));
+ } catch (Exception e) {
+ ic.t4props_.logger.warning("An error occurred parsing OutConnectionContext: " + e.getMessage());
+ }
+ }
+ }
+
+ public void decodeExtraOptions(String options) {
+ String[] opts = options.split(";");
+ String token;
+ String value;
+ int index;
+
+ for (int i = 0; i < opts.length; i++) {
+ index = opts[i].indexOf('=');
+ token = opts[i].substring(0, index).toUpperCase();
+ value = opts[i].substring(index + 1);
+
+ if (token.equals("RN")) {
+ this._roleName = value;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/PrepareMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/PrepareMessage.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/PrepareMessage.java
new file mode 100644
index 0000000..2c7599a
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/PrepareMessage.java
@@ -0,0 +1,82 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class PrepareMessage {
+ // ----------------------------------------------------------
+ static LogicalByteArray marshal(int dialogueId, int sqlAsyncEnable, int queryTimeout, short stmtType,
+ int sqlStmtType, String stmtLabel, int stmtLabelCharset, String cursorName, int cursorNameCharset,
+ String moduleName, int moduleNameCharset, long moduleTimestamp, String sqlString, int sqlStringCharset,
+ String stmtOptions, String stmtExplainLabel, int maxRowsetSize, byte[] txId, InterfaceConnection ic)
+ throws CharacterCodingException, UnsupportedCharsetException {
+ int wlength = Header.sizeOf();
+ LogicalByteArray buf;
+
+ byte[] stmtLabelBytes = ic.encodeString(stmtLabel, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] cursorNameBytes = ic.encodeString(cursorName, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] moduleNameBytes = ic.encodeString(moduleName, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] sqlStringBytes = ic.encodeString(sqlString, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] stmtOptionsBytes = ic.encodeString(stmtOptions, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ byte[] stmtExplainLabelBytes = ic.encodeString(stmtExplainLabel, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+
+ wlength += TRANSPORT.size_int; // dialogueId
+ wlength += TRANSPORT.size_int; // sqlAsyncEnable
+ wlength += TRANSPORT.size_int; // queryTimeout
+ wlength += TRANSPORT.size_short; // stmtType
+ wlength += TRANSPORT.size_int; // sqlStmtType
+ wlength += TRANSPORT.size_bytesWithCharset(stmtLabelBytes); // +stmtCharset
+ wlength += TRANSPORT.size_bytesWithCharset(cursorNameBytes); // +cursorCharset
+ wlength += TRANSPORT.size_bytesWithCharset(moduleNameBytes);
+ if (moduleName != null && moduleName.length() > 0) {
+ wlength += TRANSPORT.size_long; // moduleTimestamp
+ }
+ wlength += TRANSPORT.size_bytesWithCharset(sqlStringBytes); // +sqlStringCharset
+ wlength += TRANSPORT.size_bytes(stmtOptionsBytes);
+ wlength += TRANSPORT.size_bytes(stmtExplainLabelBytes);
+ wlength += TRANSPORT.size_int; // maxRowsetSize
+ wlength += TRANSPORT.size_bytes(txId); // transId
+
+ buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
+
+ buf.insertInt(dialogueId);
+ buf.insertInt(sqlAsyncEnable);
+ buf.insertInt(queryTimeout);
+ buf.insertShort(stmtType);
+ buf.insertInt(sqlStmtType);
+ buf.insertStringWithCharset(stmtLabelBytes, stmtLabelCharset);
+ buf.insertStringWithCharset(cursorNameBytes, cursorNameCharset);
+ buf.insertStringWithCharset(moduleNameBytes, moduleNameCharset);
+ if (moduleName != null && moduleName.length() > 0) {
+ buf.insertLong(moduleTimestamp);
+ }
+ buf.insertStringWithCharset(sqlStringBytes, sqlStringCharset);
+ buf.insertString(stmtOptionsBytes);
+ buf.insertString(stmtExplainLabelBytes);
+ buf.insertInt(maxRowsetSize);
+ buf.insertString(txId);
+
+ return buf;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/PrepareReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/PrepareReply.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/PrepareReply.java
new file mode 100644
index 0000000..82b0448
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/PrepareReply.java
@@ -0,0 +1,103 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class PrepareReply {
+ int returnCode;
+ int totalErrorLength;
+ SQLWarningOrError[] errorList;
+ int sqlQueryType;
+ int stmtHandle;
+ int estimatedCost;
+
+ int inputDescLength;
+ int inputParamLength;
+ int inputNumberParams;
+ Descriptor2[] inputDesc;
+
+ int outputDescLength;
+ int outputParamLength;
+ int outputNumberParams;
+ Descriptor2[] outputDesc;
+
+ // -------------------------------------------------------------
+ PrepareReply(LogicalByteArray buf, InterfaceConnection ic) throws CharacterCodingException,
+ UnsupportedCharsetException {
+ buf.setLocation(Header.sizeOf());
+
+ returnCode = buf.extractInt();
+
+ // should check SQL_SUCCESS or SQL_SUCCESS_WITH_INFO
+ // if(returnCode == TRANSPORT.SQL_SUCCESS)
+ if (returnCode == TRANSPORT.SQL_SUCCESS || returnCode == TRANSPORT.SQL_SUCCESS_WITH_INFO) {
+ if (returnCode == TRANSPORT.SQL_SUCCESS_WITH_INFO) {
+ totalErrorLength = buf.extractInt();
+
+ if (totalErrorLength > 0) {
+ errorList = new SQLWarningOrError[buf.extractInt()];
+ for (int i = 0; i < errorList.length; i++) {
+ errorList[i] = new SQLWarningOrError(buf, ic, InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ }
+ }
+ }
+ sqlQueryType = buf.extractInt();
+ stmtHandle = buf.extractInt();
+ estimatedCost = buf.extractInt();
+
+ inputDescLength = buf.extractInt();
+ if (inputDescLength > 0) {
+ inputParamLength = buf.extractInt();
+ inputNumberParams = buf.extractInt();
+
+ inputDesc = new Descriptor2[inputNumberParams];
+ for (int i = 0; i < inputNumberParams; i++) {
+ inputDesc[i] = new Descriptor2(buf, ic);
+ inputDesc[i].setRowLength(inputParamLength);
+ }
+ }
+
+ outputDescLength = buf.extractInt();
+ if (outputDescLength > 0) {
+ outputParamLength = buf.extractInt();
+ outputNumberParams = buf.extractInt();
+
+ outputDesc = new Descriptor2[outputNumberParams];
+ for (int i = 0; i < outputNumberParams; i++) {
+ outputDesc[i] = new Descriptor2(buf, ic);
+ outputDesc[i].setRowLength(outputParamLength);
+ }
+ }
+ } else {
+ totalErrorLength = buf.extractInt();
+
+ if (totalErrorLength > 0) {
+ errorList = new SQLWarningOrError[buf.extractInt()];
+ for (int i = 0; i < errorList.length; i++) {
+ errorList[i] = new SQLWarningOrError(buf, ic, ic.getISOMapping());
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/PreparedStatementManager.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/PreparedStatementManager.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/PreparedStatementManager.java
new file mode 100644
index 0000000..801a4b1
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/PreparedStatementManager.java
@@ -0,0 +1,242 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.PrintWriter;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.logging.Level;
+
+public abstract class PreparedStatementManager extends HPT4Handle {
+
+ boolean isStatementCachingEnabled() {
+ if (maxStatements_ < 1) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ boolean makeRoom() throws SQLException {
+ if (out_ != null) {
+ if (traceLevel_ != Level.OFF) {
+ out_.println(traceId_ + "makeRoom()");
+ }
+ }
+
+ Iterator i;
+ CachedPreparedStatement cs;
+ long oldest;
+ long stmtTime;
+ String key;
+
+ i = (prepStmtsInCache_.values()).iterator();
+ if (!i.hasNext()) {
+ return false;
+ }
+ cs = (CachedPreparedStatement) i.next();
+ stmtTime = cs.getLastUsedTime();
+ key = cs.getLookUpKey();
+ oldest = stmtTime;
+
+ for (; i.hasNext();) {
+ cs = (CachedPreparedStatement) i.next();
+ stmtTime = cs.getLastUsedTime();
+ if (oldest > stmtTime) {
+ oldest = stmtTime;
+ key = cs.getLookUpKey();
+ }
+ }
+ cs = (CachedPreparedStatement) prepStmtsInCache_.remove(key);
+ if (cs != null) {
+ if (cs.inUse_ == false) // if the user has already closed the
+ // statement, hard close it
+ cs.close(true);
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ void closePreparedStatementsAll() throws SQLException {
+
+ if (out_ != null) {
+ if (traceLevel_ != Level.OFF) {
+ out_.println(traceId_ + "closePreparedStatementsAll()");
+ }
+ }
+
+ Object[] csArray;
+
+ CachedPreparedStatement cs;
+ int i = 0;
+
+ csArray = (prepStmtsInCache_.values()).toArray();
+ for (i = 0; i < csArray.length; i++) {
+ cs = (CachedPreparedStatement) csArray[i];
+ if (cs != null) {
+ cs.close(false);
+ }
+ }
+ }
+
+ private String createKey(TrafT4Connection connect, String sql, int resultSetHoldability) throws SQLException {
+ String lookupKey = sql + connect.getCatalog() + connect.getSchema() + connect.getTransactionIsolation()
+ + resultSetHoldability;
+
+ return lookupKey;
+ }
+
+ boolean closePreparedStatement(TrafT4Connection connect, String sql, int resultSetType, int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException {
+ if (out_ != null) {
+ if (traceLevel_ != Level.OFF) {
+ out_.println(traceId_ + "closePreparedStatement(" + connect + ",\"" + sql + "\"," + resultSetType + ","
+ + resultSetConcurrency + "," + resultSetHoldability + ")");
+ }
+ }
+
+ CachedPreparedStatement cs;
+
+ String lookupKey = createKey(connect, sql, resultSetHoldability);
+
+ cs = (CachedPreparedStatement) prepStmtsInCache_.get(lookupKey);
+ if (cs != null) {
+ cs.inUse_ = false;
+ return true;
+ }
+
+ return false;
+ }
+
+ void clearPreparedStatementsAll() {
+ if (out_ != null) {
+ if (traceLevel_ != Level.OFF) {
+ out_.println(traceId_ + "clearPreparedStatementsAll()");
+ }
+ }
+ if (prepStmtsInCache_ != null) {
+ prepStmtsInCache_.clear();
+ }
+ count_ = 0;
+ }
+
+ void addPreparedStatement(TrafT4Connection connect, String sql, PreparedStatement pStmt, int resultSetType,
+ int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+ if (out_ != null) {
+ if (traceLevel_ != Level.OFF) {
+ out_.println(traceId_ + "addPreparedStatement(" + connect + ",\"" + sql + "\"," + pStmt + ","
+ + resultSetType + "," + resultSetConcurrency + "," + resultSetHoldability + ")");
+ }
+ }
+
+ CachedPreparedStatement cachedStmt;
+
+ String lookupKey = createKey(connect, sql, resultSetHoldability);
+
+ cachedStmt = (CachedPreparedStatement) prepStmtsInCache_.get(lookupKey);
+ if (cachedStmt != null) {
+ // Update the last use time
+ cachedStmt.setLastUsedInfo();
+ } else {
+ if (count_ < maxStatements_) {
+ cachedStmt = new CachedPreparedStatement(pStmt, lookupKey);
+ prepStmtsInCache_.put(lookupKey, cachedStmt);
+ count_++;
+ } else {
+ if (makeRoom()) {
+ cachedStmt = new CachedPreparedStatement(pStmt, lookupKey);
+ prepStmtsInCache_.put(lookupKey, cachedStmt);
+ }
+ }
+ }
+ }
+
+ PreparedStatement getPreparedStatement(TrafT4Connection connect, String sql, int resultSetType,
+ int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+ if (out_ != null) {
+ if (traceLevel_ != Level.OFF) {
+ out_.println(traceId_ + "getPreparedStatement(" + connect + ",\"" + sql + "\"," + resultSetType + ","
+ + resultSetConcurrency + "," + resultSetHoldability + ")");
+ }
+ }
+
+ PreparedStatement pStmt = null;
+ CachedPreparedStatement cachedStmt;
+
+ String lookupKey = createKey(connect, sql, resultSetHoldability);
+
+ if (prepStmtsInCache_ != null) {
+ cachedStmt = (CachedPreparedStatement) prepStmtsInCache_.get(lookupKey);
+ if (cachedStmt != null) {
+ if (!cachedStmt.inUse_) {
+ pStmt = cachedStmt.getPreparedStatement();
+ ((org.trafodion.jdbc.t4.TrafT4PreparedStatement) pStmt).reuse(connect, resultSetType, resultSetConcurrency,
+ resultSetHoldability);
+ } else {
+ pStmt = null;
+ }
+ }
+ }
+ return pStmt;
+ }
+
+ void setLogInfo(Level traceLevel, PrintWriter out) {
+ this.traceLevel_ = traceLevel;
+ this.out_ = out;
+
+ }
+
+ PreparedStatementManager() {
+ super();
+ String className = getClass().getName();
+ traceId_ = "jdbcTrace:[" + Thread.currentThread() + "]:[" + hashCode() + "]:" + className + ".";
+ }
+
+ PreparedStatementManager(T4Properties t4props) {
+ super();
+
+ String className = getClass().getName();
+
+ String tmp;
+
+ if (t4props != null) {
+ maxStatements_ = t4props.getMaxStatements();
+
+ }
+ if (maxStatements_ > 0) {
+ prepStmtsInCache_ = new Hashtable();
+ }
+ traceId_ = "jdbcTrace:[" + Thread.currentThread() + "]:[" + hashCode() + "]:" + className + ".";
+ }
+
+ private Hashtable prepStmtsInCache_;
+ private int maxStatements_;
+ private int count_;
+
+ Level traceLevel_;
+ PrintWriter out_;
+ String traceId_;
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Row.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Row.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Row.java
new file mode 100644
index 0000000..21ee6f3
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Row.java
@@ -0,0 +1,233 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.util.BitSet;
+import java.util.Locale;
+
+// Referenced classes of package sun.jdbc.rowset:
+// BaseRow
+
+class Row extends BaseRow implements Serializable, Cloneable {
+
+ private Object currentVals[];
+ private BitSet colsChanged;
+ private boolean deleted;
+ private boolean updated;
+ private boolean inserted;
+ private int numCols;
+
+ Row(int i) {
+ origVals = new Object[i];
+ currentVals = new Object[i];
+ colsChanged = new BitSet(i);
+ numCols = i;
+ }
+
+ Row(int i, Object aobj[]) {
+ origVals = new Object[i];
+ for (int j = 0; j < i; j++) {
+ origVals[j] = aobj[j];
+
+ }
+ currentVals = new Object[i];
+ colsChanged = new BitSet(i);
+ numCols = i;
+ }
+
+ protected void clearDeleted() {
+ deleted = false;
+ }
+
+ protected void clearInserted() {
+ inserted = false;
+ }
+
+ protected void clearUpdated() {
+ updated = false;
+ for (int i = 0; i < numCols; i++) {
+ currentVals[i] = null;
+ colsChanged.clear(i);
+ }
+
+ }
+
+ protected boolean getColUpdated(int i) {
+ return colsChanged.get(i);
+ }
+
+ protected Object getColumnObject(int i) throws SQLException {
+ if (getColUpdated(i - 1)) {
+ return currentVals[i - 1];
+ } else {
+ return origVals[i - 1];
+ }
+ }
+
+ protected boolean getDeleted() {
+ return deleted;
+ }
+
+ protected boolean getInserted() {
+ return inserted;
+ }
+
+ protected boolean getUpdated() {
+ return updated;
+ }
+
+ protected void initColumnObject(int i, Object obj) {
+ origVals[i - 1] = obj;
+ }
+
+ protected void moveCurrentToOrig() {
+ for (int i = 0; i < numCols; i++) {
+ if (getColUpdated(i)) {
+ origVals[i] = currentVals[i];
+ currentVals[i] = null;
+ colsChanged.clear(i);
+ }
+ }
+ }
+
+ private void setColUpdated(int i) {
+ colsChanged.set(i);
+ }
+
+ protected void setColumnObject(int i, Object obj) {
+ currentVals[i - 1] = obj;
+ setColUpdated(i - 1);
+ }
+
+ protected void setLobObject(int i, Object obj) {
+ currentVals[i - 1] = obj;
+ origVals[i - 1] = obj;
+ }
+
+ protected void setDeleted() {
+ deleted = true;
+ }
+
+ protected void setInserted() {
+ inserted = true;
+ }
+
+ protected void setUpdated() {
+ updated = true;
+ }
+
+ protected void deleteRow(Locale locale, PreparedStatement deleteStmt, BitSet paramCols) throws SQLException {
+ int i;
+ int j;
+ int count;
+
+ for (i = 0, j = 1; i < numCols; i++) {
+ if (paramCols.get(i)) {
+ deleteStmt.setObject(j++, origVals[i]);
+ }
+ }
+ count = deleteStmt.executeUpdate();
+ if (count == 0) {
+ throw HPT4Messages.createSQLException(null, locale, "row_modified", null);
+ }
+ }
+
+ protected void updateRow(Locale locale, PreparedStatement updateStmt, BitSet paramCols, BitSet keyCols)
+ throws SQLException {
+ int i;
+ int j;
+ int count;
+
+ for (i = 0, j = 1; i < numCols; i++) {
+ if (keyCols.get(i)) {
+ if (getColUpdated(i)) {
+ throw HPT4Messages.createSQLException(null, locale, "primary_key_not_updateable", null);
+ }
+ } else {
+ if (paramCols.get(i)) { // LOB Support SB 10/8/2004
+ Object obj = getColumnObject((i + 1));
+
+
+ updateStmt.setObject(j++, getColumnObject(i + 1));
+ }
+ }
+ }
+
+ for (i = 0; i < numCols; i++) {
+ // if (paramCols.get(i))
+ if (keyCols.get(i)) {
+ Object obj = origVals[i];
+
+
+ updateStmt.setObject(j++, origVals[i]);
+ }
+ }
+
+ count = updateStmt.executeUpdate();
+ if (count == 0) {
+ throw HPT4Messages.createSQLException(null, locale, "row_modified", null);
+ }
+ moveCurrentToOrig();
+ setUpdated();
+ }
+
+ protected void refreshRow(Locale locale, PreparedStatement selectStmt, BitSet selectCols, BitSet keyCols)
+ throws SQLException {
+ int i;
+ int j;
+ ResultSet rs;
+ ResultSetMetaData rsmd;
+ int columnCount;
+
+ clearUpdated();
+
+ for (i = 0, j = 1; i < numCols; i++) {
+ if (keyCols.get(i)) {
+ selectStmt.setObject(j++, origVals[i]);
+ }
+ }
+ rs = selectStmt.executeQuery();
+ if (rs != null) {
+ try {
+ rsmd = rs.getMetaData();
+ columnCount = rsmd.getColumnCount();
+ rs.next();
+ for (i = 0, j = 1; i < numCols; i++) {
+ if (selectCols.get(i)) {
+ origVals[i] = rs.getObject(j++);
+ }
+ }
+ } catch (SQLException ex) {
+ throw ex;
+ } finally {
+ rs.close();
+ }
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLItemDescList_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLItemDescList_def.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLItemDescList_def.java
new file mode 100644
index 0000000..042772b
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLItemDescList_def.java
@@ -0,0 +1,46 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class SQLItemDescList_def {
+ SQLItemDesc_def[] list;
+
+ public SQLItemDescList_def(LogicalByteArray buf, boolean useOld, InterfaceConnection ic)
+ throws CharacterCodingException, UnsupportedCharsetException {
+ int length = buf.extractInt();
+
+ if (length > 0) {
+ if (!useOld) {
+ length = buf.extractInt();
+ }
+ list = new SQLItemDesc_def[length];
+
+ for (int i = 0; i < length; i++) {
+ list[i] = (useOld) ? new SQLItemDescOld_def() : new SQLItemDesc_def();
+ list[i].extractFromByteArray(buf, ic);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLItemDescOld_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLItemDescOld_def.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLItemDescOld_def.java
new file mode 100644
index 0000000..666f37c
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLItemDescOld_def.java
@@ -0,0 +1,54 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class SQLItemDescOld_def extends SQLItemDesc_def {
+ void extractFromByteArray(LogicalByteArray buf, InterfaceConnection ic) throws UnsupportedCharsetException,
+ CharacterCodingException {
+ version = buf.extractInt();
+ dataType = buf.extractInt();
+ datetimeCode = buf.extractInt();
+ maxLen = buf.extractInt();
+ precision = buf.extractShort();
+ scale = buf.extractShort();
+ nullInfo = buf.extractByte();
+
+ colHeadingNm = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+
+ signType = buf.extractByte();
+ ODBCDataType = buf.extractInt();
+ ODBCPrecision = buf.extractShort();
+ SQLCharset = buf.extractInt();
+ ODBCCharset = buf.extractInt();
+
+ TableName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ CatalogName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ SchemaName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ Heading = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+
+ intLeadPrec = buf.extractInt();
+ paramMode = buf.extractInt();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLItemDesc_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLItemDesc_def.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLItemDesc_def.java
new file mode 100644
index 0000000..24d0b04
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLItemDesc_def.java
@@ -0,0 +1,70 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+
+class SQLItemDesc_def {
+ int version;
+ int dataType;
+ int datetimeCode;
+ int maxLen;
+ short precision;
+ short scale;
+ byte nullInfo;
+ String colHeadingNm;
+ byte signType;
+ int ODBCDataType;
+ short ODBCPrecision;
+ int SQLCharset;
+ int ODBCCharset;
+ String TableName;
+ String CatalogName;
+ String SchemaName;
+ String Heading;
+ int intLeadPrec;
+ int paramMode;
+
+ void extractFromByteArray(LogicalByteArray buf, InterfaceConnection ic) throws UnsupportedCharsetException,
+ CharacterCodingException {
+ version = buf.extractInt();
+ dataType = buf.extractInt();
+ datetimeCode = buf.extractInt();
+ maxLen = buf.extractInt();
+ precision = buf.extractShort();
+ scale = buf.extractShort();
+ nullInfo = buf.extractByte();
+ signType = buf.extractByte();
+ ODBCDataType = buf.extractInt();
+ ODBCPrecision = buf.extractShort();
+ SQLCharset = buf.extractInt();
+ ODBCCharset = buf.extractInt();
+ colHeadingNm = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ TableName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ CatalogName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ SchemaName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ Heading = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+ intLeadPrec = buf.extractInt();
+ paramMode = buf.extractInt();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLValueList_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLValueList_def.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLValueList_def.java
new file mode 100644
index 0000000..a56b1c5
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLValueList_def.java
@@ -0,0 +1,64 @@
+// @@@ 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;
+
+class SQLValueList_def {
+ SQLValue_def[] buffer;
+
+ // ----------------------------------------------------------
+ int sizeof() {
+ int size = TRANSPORT.size_int;
+
+ if (buffer != null) {
+ for (int i = 0; i < buffer.length; i++) {
+ size += buffer[i].sizeof();
+ }
+ }
+ return size;
+ }
+
+ // ----------------------------------------------------------
+ void insertIntoByteArray(LogicalByteArray buf) {
+ if (buffer != null) {
+ buf.insertInt(buffer.length);
+ for (int i = 0; i < buffer.length; i++) {
+ buffer[i].insertIntoByteArray(buf);
+ }
+ } else {
+ buf.insertInt(0);
+ }
+ }
+
+ // ----------------------------------------------------------
+ void extractFromByteArray(LogicalByteArray buf) throws SQLException {
+ int len = buf.extractInt();
+
+ buffer = new SQLValue_def[len];
+
+ for (int i = 0; i < buffer.length; i++) {
+ buffer[i] = new SQLValue_def();
+ buffer[i].extractFromByteArray(buf);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLValue_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLValue_def.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLValue_def.java
new file mode 100644
index 0000000..5795e7c
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLValue_def.java
@@ -0,0 +1,55 @@
+// @@@ 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;
+
+class SQLValue_def {
+ int dataType;
+ short dataInd;
+ SQL_DataValue_def dataValue;
+ int dataCharSet;
+
+ // ----------------------------------------------------------
+ int sizeof() {
+ return TRANSPORT.size_int * 2 + TRANSPORT.size_short + dataValue.sizeof();
+ }
+
+ // ----------------------------------------------------------
+ void insertIntoByteArray(LogicalByteArray buf) {
+ buf.insertInt(dataType);
+ buf.insertShort(dataInd);
+ dataValue.insertIntoByteArray(buf);
+ buf.insertInt(dataCharSet);
+ }
+
+ // ----------------------------------------------------------
+ void extractFromByteArray(LogicalByteArray buf) throws SQLException {
+ dataType = buf.extractInt();
+ dataInd = buf.extractShort();
+
+ dataValue = new SQL_DataValue_def();
+ dataValue.extractFromByteArray(buf);
+
+ dataCharSet = buf.extractInt();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLWarningOrError.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLWarningOrError.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLWarningOrError.java
new file mode 100644
index 0000000..a95697e
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQLWarningOrError.java
@@ -0,0 +1,47 @@
+// @@@ 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;
+
+public class SQLWarningOrError {
+ int rowId;
+ int sqlCode;
+ String text;
+ String sqlState;
+
+ public SQLWarningOrError(int rowId, int sqlCode, String text, String sqlState) {
+ this.rowId = rowId;
+ this.sqlCode = sqlCode;
+ this.text = text;
+ this.sqlState = sqlState;
+ }
+
+ public SQLWarningOrError(LogicalByteArray buf, InterfaceConnection ic, int charset)
+ throws CharacterCodingException, UnsupportedCharsetException {
+ rowId = buf.extractInt();
+ sqlCode = buf.extractInt();
+ text = ic.decodeBytes(buf.extractString(), charset);
+ sqlState = new String(buf.extractByteArray(5));
+ buf.extractByte(); // null terminator
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQL_DataValue_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQL_DataValue_def.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQL_DataValue_def.java
new file mode 100644
index 0000000..edaada8
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SQL_DataValue_def.java
@@ -0,0 +1,54 @@
+// @@@ 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.ByteBuffer;
+
+class SQL_DataValue_def {
+ int length;
+ byte[] buffer;
+ ByteBuffer userBuffer;
+
+ // ----------------------------------------------------------
+ int sizeof() {
+ return (buffer != null) ? TRANSPORT.size_int + buffer.length + 1 : TRANSPORT.size_int;
+ }
+
+ // ----------------------------------------------------------
+ void insertIntoByteArray(LogicalByteArray buf) {
+ if (buffer != null) {
+ buf.insertInt(length);
+ buf.insertByteArray(buffer, length);
+ } else {
+ buf.insertInt(0);
+ }
+ }
+
+ // ----------------------------------------------------------
+ void extractFromByteArray(LogicalByteArray buf) {
+ length = buf.extractInt();
+
+ if (length > 0) {
+ buffer = buf.extractByteArray(length);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecClientMsgKeys.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecClientMsgKeys.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecClientMsgKeys.java
new file mode 100644
index 0000000..a1e4d01
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/SecClientMsgKeys.java
@@ -0,0 +1,58 @@
+/**********************************************************************
+// @@@ 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;
+
+public class SecClientMsgKeys
+{
+ /**
+ * Literal constants of java Security Client error messages.
+ */
+
+ public static final String ERR_RETRIEVE_KEY_FROM_FILE = "ERR_RETRIEVE_KEY_FROM_FILE";
+ public static final String SESSION_KEY_GENERATION_FAILED = "SESSION_KEY_GENERATION_FAILED";
+ public static final String INPUT_PARAMETER_IS_NULL = "INPUT_PARAMETER_IS_NULL";
+ public static final String PWD_LENGTH_TOO_LONG = "PWD_LENGTH_TOO_LONG";
+ public static final String ENCRYPTION_FAILED = "ENCRYPTION_FAILED";
+ public static final String HMAC_FAILED = "HMAC_FAILED";
+ public static final String PUBKEY_LENGTH_IS_ZERO = "PUBKEY_LENGTH_IS_ZERO";
+ public static final String ERR_READ_CERT_FILE = "ERR_READ_CERT_FILE";
+ public static final String FAILED_GENERATE_RANDOM_NUM = "FAILED_GENERATE_RANDOM_NUM";
+ public static final String CIPHER_TEXT_LEN_NOT_EQUAL_KEY_LEN = "CIPHER_TEXT_LEN_NOT_EQUAL_KEY_LEN";
+ public static final String BAD_MESSAGE_DIGEST_LEN = "BAD_MESSAGE_DIGEST_LEN";
+ public static final String FILE_NOTFOUND = "FILE_NOTFOUND";
+ public static final String DATA_ENCRYPTION_FAILED = "DATA_ENCRYPTION_FAILED";
+ public static final String DECRYPTION_FAILED = "DECRYPTION_FAILED";
+ public static final String ERR_WRITE_CERT_FILE = "ERR_WRITE_CERT_FILE";
+ public static final String GET_LOCAL_HOST_NAME_FAILED = "GET_LOCAL_HOST_NAME_FAILED";
+ public static final String BAD_TOKEN_LEN = "BAD_TOKEN_LEN";
+ public static final String INCORRECT_TOKEN_FORMAT = "INCORRECT_TOKEN_FORMAT";
+ public static final String HOME_ENVIRONMENT_VAR_IS_NULL = "HOME_ENVIRONMENT_VAR_IS_NULL";
+ public static final String ERR_CREATE_SYMMETRIC_KEY = "ERR_CREATE_SYMMETRIC_KEY";
+ public static final String FAILED_BUILDING_PWDKEY = "FAILED_BUILDING_PWDKEY";
+ public static final String DIR_NOTFOUND = "DIR_NOTFOUND";
+ public static final String ERR_OPEN_INPUT_FILE = "ERR_OPEN_INPUT_FILE";
+ public static final String FILE_CORRUPTION = "FILE_CORRUPTION";
+}
+
[40/60] incubator-trafodion git commit: Minor fixes
Posted by db...@apache.org.
Minor fixes
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/90667eea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/90667eea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/90667eea
Branch: refs/heads/master
Commit: 90667eeab9a1dbb20982470eec320e84603f5baf
Parents: 500d207
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Tue Apr 19 15:33:06 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Tue Apr 19 15:33:06 2016 +0000
----------------------------------------------------------------------
core/conn/jdbcT4/Makefile | 2 +-
core/sqf/sqenvcom.sh | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/90667eea/core/conn/jdbcT4/Makefile
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/Makefile b/core/conn/jdbcT4/Makefile
index b6c23d7..6006abb 100644
--- a/core/conn/jdbcT4/Makefile
+++ b/core/conn/jdbcT4/Makefile
@@ -28,7 +28,7 @@ all: build_all
build_all:
echo "$(MAVEN) package -DskipTests"
set -o pipefail && $(MAVEN) package -DskipTests | tee build_jdbct4.log | grep --line-buffered -E -e '^\[[^WId]' -e '^\[INFO\] B[Uu][Ii][Ll][Dd]' -e 'to compile'
- cp target/jdbcT4-${TRAFODION_VER}.jar ${MY_SQROOT}/export/lib/jdbcT4.jar
+ cp target/jdbcT4-${TRAFODION_VER}.jar ${MY_SQROOT}/export/lib
mkdir -p ../clients
mv target/jdbcT4-${TRAFODION_VER}.zip ../clients
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/90667eea/core/sqf/sqenvcom.sh
----------------------------------------------------------------------
diff --git a/core/sqf/sqenvcom.sh b/core/sqf/sqenvcom.sh
index 5aa5f33..f15e2ff 100644
--- a/core/sqf/sqenvcom.sh
+++ b/core/sqf/sqenvcom.sh
@@ -163,6 +163,7 @@ export HBASE_TRX_JAR=${HBASE_TRX_ID_CDH}-${TRAFODION_VER}.jar
export DTM_COMMON_JAR=trafodion-dtm-${TRAFODION_VER}.jar
export SQL_JAR=trafodion-sql-${TRAFODION_VER}.jar
export UTIL_JAR=trafodion-utility-${TRAFODION_VER}.jar
+export JDBCT4_JAR=jdbcT4-${TRAFODION_VER}.jar
HBVER=""
if [[ "$HBASE_DISTRO" = "HDP" ]]; then
@@ -853,7 +854,7 @@ ${HBASE_TRXDIR}/${HBASE_TRX_JAR}:\
$MY_SQROOT/export/lib/${DTM_COMMON_JAR}:\
$MY_SQROOT/export/lib/${SQL_JAR}:\
$MY_SQROOT/export/lib/${UTIL_JAR}:\
-$MY_SQROOT/export/lib/jdbcT4.jar:\
+$MY_SQROOT/export/lib/${JDBCT4_JAR}:\
$MY_SQROOT/export/lib/jdbcT2.jar
[47/60] incubator-trafodion git commit: Merge branch 'master' of
github.com:apache/incubator-trafodion into wrkbrnch
Posted by db...@apache.org.
Merge branch 'master' of github.com:apache/incubator-trafodion into wrkbrnch
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/8a8d2ad7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/8a8d2ad7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/8a8d2ad7
Branch: refs/heads/master
Commit: 8a8d2ad7bdf7fd36cf5c45adb2d3e5e57b662be5
Parents: 3253e72 1edc994
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Fri Apr 22 00:20:35 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Fri Apr 22 00:20:35 2016 +0000
----------------------------------------------------------------------
.rat-excludes | 2 +
core/conn/jdbc_type2/native/SqlInterface.cpp | 2 -
core/conn/odb/odb.sln | 28 +
core/conn/odb/odb/odb.vcxproj | 165 ++++++
core/conn/odb/odb/odb.vcxproj.filters | 36 ++
core/conn/odb/odb/odb.vcxproj.user | 4 +
core/conn/odb/src/memcpy_wrapper.c | 2 +
core/conn/odb/src/odb.c | 1 +
core/conn/odb/src/verslib.h | 3 +
core/conn/odb/src/versodb.c | 2 +
core/sqf/conf/install_features | 1 +
.../sqf/conf/log4cxx.trafodion.masterexe.config | 1 +
core/sqf/sqenvcom.sh | 23 +-
core/sqf/sql/scripts/ilh_cleanhb | 31 +-
core/sql/arkcmp/CmpContext.h | 1 +
core/sql/arkcmp/NATableSt.cpp | 30 +-
core/sql/cli/Cli.cpp | 130 ++--
core/sql/cli/Cli.h | 9 +-
core/sql/cli/CliExtern.cpp | 18 +-
core/sql/cli/SQLCLIdev.h | 7 -
core/sql/cli/SessionDefaults.cpp | 1 -
core/sql/cli/Statement.cpp | 2 +-
core/sql/cli/sqlcli.h | 6 +
core/sql/comexe/ComTdb.cpp | 8 +-
core/sql/comexe/ComTdb.h | 1 +
core/sql/comexe/ComTdbExeUtil.cpp | 74 +++
core/sql/comexe/ComTdbExeUtil.h | 122 ++++
core/sql/common/ComResWords.cpp | 1 -
core/sql/executor/ExComTdb.cpp | 8 +
core/sql/executor/ExExeUtil.h | 176 ++++++
core/sql/executor/ExExeUtilGet.cpp | 586 +++++++++++++++++-
core/sql/executor/ExExeUtilLoad.cpp | 4 +-
core/sql/exp/ExpLOBaccess.cpp | 441 ++++++++++----
core/sql/exp/ExpLOBaccess.h | 10 +-
core/sql/exp/ExpLOBexternal.h | 9 +-
core/sql/exp/ExpLOBprocess.cpp | 4 +-
core/sql/export/ComDiags.cpp | 8 +-
core/sql/generator/GenRelExeUtil.cpp | 161 ++++-
core/sql/optimizer/NATable.cpp | 25 +-
core/sql/optimizer/NATable.h | 4 +
core/sql/optimizer/RelExeUtil.cpp | 119 ++++
core/sql/optimizer/RelExeUtil.h | 42 ++
core/sql/parser/ParKeyWords.cpp | 1 -
core/sql/parser/sqlparser.y | 23 +-
core/sql/regress/core/EXPECTED005.SB | 8 +-
core/sql/regress/core/EXPECTED037.SB | 9 +-
core/sql/regress/core/TEST005 | 2 +-
core/sql/regress/executor/EXPECTED130 | 161 ++++-
core/sql/regress/executor/FILTER130 | 4 +
core/sql/regress/executor/TEST130 | 38 ++
core/sql/regress/hive/EXPECTED009 | 2 +-
core/sql/regress/hive/TEST009 | 2 +-
core/sql/sqlci/SqlciEnv.cpp | 8 +-
core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp | 6 +-
core/sql/sqlcomp/CmpSeabaseDDLschema.cpp | 16 +-
core/sql/sqlcomp/CmpSeabaseDDLtable.cpp | 12 +-
core/sql/sqlmxevents/logmxevent_traf.cpp | 8 +-
core/sql/sqlmxevents/logmxevent_traf.h | 2 +-
install/installer/traf_add_sudoAccess | 10 +-
install/installer/traf_apache_mods | 247 ++++++++
install/installer/traf_cloudera_mods | 397 +++++++++++++
install/installer/traf_cloudera_mods98 | 418 -------------
install/installer/traf_config_check | 92 ++-
install/installer/traf_config_setup | 307 ++++++++--
install/installer/traf_getHadoopNodes | 1 -
install/installer/traf_getMultiHadoopNodes | 145 +++++
install/installer/traf_hortonworks_mods | 572 ++++++++++++++++++
install/installer/traf_hortonworks_mods98 | 592 -------------------
install/installer/traf_package_setup | 2 +-
install/installer/trafodion_install | 35 +-
70 files changed, 4078 insertions(+), 1350 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8a8d2ad7/core/sqf/sqenvcom.sh
----------------------------------------------------------------------
[21/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java
new file mode 100644
index 0000000..c181bee
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java
@@ -0,0 +1,5389 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URL;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.UnsupportedCharsetException;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DataTruncation;
+import java.sql.DatabaseMetaData;
+import java.sql.Date;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Calendar;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+public class TrafT4ResultSet extends HPT4Handle implements java.sql.ResultSet {
+
+ // java.sql.ResultSet interface methods
+ public boolean absolute(int row) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, row);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "absolute", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, row);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("absolute");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ boolean flag = false;
+ int absRow;
+
+ clearWarnings();
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (getType() == ResultSet.TYPE_FORWARD_ONLY) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "forward_only_cursor",
+ null);
+ }
+ if (row == 0) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_row_number",
+ null);
+ }
+
+
+ if (row > 0) {
+ if (row <= numRows_) {
+ currentRow_ = row;
+ isBeforeFirst_ = false;
+ isAfterLast_ = false;
+ onInsertRow_ = false;
+ flag = true;
+ } else {
+ do {
+ flag = next();
+ if (!flag) {
+ break;
+ }
+ } while (currentRow_ < row);
+ }
+ } else {
+ absRow = -row;
+ afterLast();
+ if (absRow <= numRows_) {
+ currentRow_ = numRows_ - absRow + 1;
+ isAfterLast_ = false;
+ isBeforeFirst_ = false;
+ onInsertRow_ = false;
+ flag = true;
+ } else {
+ beforeFirst();
+ }
+ }
+ return flag;
+ }
+
+ public void afterLast() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "afterLast", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("afterLast");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (getType() == ResultSet.TYPE_FORWARD_ONLY) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "forward_only_cursor",
+ null);
+ }
+ last();
+ // currentRow_++;
+ isAfterLast_ = true;
+ isBeforeFirst_ = false;
+ }
+
+ public void beforeFirst() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "beforeFirst", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("beforeFirst");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (getType() == ResultSet.TYPE_FORWARD_ONLY) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "forward_only_cursor",
+ null);
+ }
+
+
+ currentRow_ = 0;
+ isBeforeFirst_ = true;
+ isAfterLast_ = false;
+ onInsertRow_ = false;
+ }
+
+ public void cancelRowUpdates() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "cancelRowUpdates", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("cancelRowUpdates");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (getConcurrency() == ResultSet.CONCUR_READ_ONLY) {
+ throw HPT4Messages
+ .createSQLException(connection_.props_, connection_.getLocale(), "read_only_concur", null);
+ }
+ if (onInsertRow_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cursor_position", null);
+ }
+ Row row = (Row) getCurrentRow();
+ if (!row.getUpdated()) {
+ row.clearUpdated();
+ }
+ }
+
+ /**
+ * Close the resultSet. This method is synchronized to prevent many threads
+ * talking to the same server after close().
+ *
+ * @throws SQLException
+ */
+ synchronized public void close() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "close", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("close");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ if (isClosed_) {
+ return;
+ }
+ if (connection_._isClosed()) {
+ connection_.closeErroredConnection(null);
+ return;
+ }
+
+
+ if (stmt_ instanceof org.trafodion.jdbc.t4.TrafT4PreparedStatement) {
+ close(false);
+ } else {
+ close(true);
+ }
+ }
+
+ public void deleteRow() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "deleteRow", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("deleteRow");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (getConcurrency() == ResultSet.CONCUR_READ_ONLY) {
+ throw HPT4Messages
+ .createSQLException(connection_.props_, connection_.getLocale(), "read_only_concur", null);
+ }
+ if (onInsertRow_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cursor_position", null);
+ }
+
+
+ try {
+ prepareDeleteStmt();
+ Row row = (Row) getCurrentRow();
+ // Remove the row from database
+ row.deleteRow(connection_.getLocale(), deleteStmt_, paramCols_);
+ // Remove the row from the resultSet
+ cachedRows_.remove(--currentRow_);
+ --numRows_;
+
+ if ((getType() == ResultSet.TYPE_FORWARD_ONLY) && (getConcurrency() == ResultSet.CONCUR_UPDATABLE)) {
+ int temp;
+ temp = currentRowCount_;
+
+ if (!next()) {
+ if (temp == 1) {
+ isBeforeFirst_ = true;
+ }
+ currentRowCount_ = 0;
+ } else {
+ --currentRowCount_;
+ }
+ } else {
+ if (currentRow_ == 0) {
+ isBeforeFirst_ = true;
+ }
+ }
+ } catch (SQLException e) {
+ performConnectionErrorChecks(e);
+ throw e;
+ }
+ }
+
+ public int findColumn(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "findColumn", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("findColumn");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int i;
+
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ for (i = 0; i < outputDesc_.length; i++) {
+ if (columnName.equalsIgnoreCase(outputDesc_[i].name_)) {
+ return i + 1;
+ }
+ }
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_column_name", null);
+ }
+
+ public boolean first() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "first", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("first");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ boolean flag = true;
+
+ clearWarnings();
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (getType() == ResultSet.TYPE_FORWARD_ONLY) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "forward_only_cursor",
+ null);
+ }
+
+
+ if (isBeforeFirst_) {
+ flag = next();
+ }
+ if (numRows_ > 0) {
+ currentRow_ = 1;
+ isAfterLast_ = false;
+ isBeforeFirst_ = false;
+ onInsertRow_ = false;
+ }
+ return flag;
+ }
+
+ // JDK 1.2
+ public Array getArray(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getArray", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getArray");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateGetInvocation(columnIndex);
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getArray()");
+ return null;
+ }
+
+ // JDK 1.2
+ public Array getArray(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getArray", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getArray");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getArray(columnIndex);
+ }
+
+ public InputStream getAsciiStream(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getAsciiStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getAsciiStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+ // For LOB Support - SB 10/8/2004
+ int dataType;
+
+
+ dataType = outputDesc_[columnIndex - 1].dataType_;
+ switch (dataType) {
+
+
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BINARY:
+ case Types.VARBINARY:
+ case Types.LONGVARBINARY:
+ case Types.BLOB:
+ case Types.CLOB:
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ try {
+ return new java.io.DataInputStream(new java.io.ByteArrayInputStream(data.getBytes("ASCII")));
+ } catch (java.io.UnsupportedEncodingException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "unsupported_encoding", messageArguments);
+ }
+ } else {
+ return null;
+ }
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+
+ }
+
+ public InputStream getAsciiStream(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getAsciiStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getAsciiStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getAsciiStream(columnIndex);
+ }
+
+ public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBigDecimal", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBigDecimal");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+
+ String data;
+ BigDecimal retValue;
+ Double d;
+
+ validateGetInvocation(columnIndex);
+ outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ // String returned may not be numeric in case of SQL_CHAR, SQL_VARCHAR
+ // and SQL_LONGVARCHAR
+ // fields. Hoping that java might throw invalid value exception
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ data = data.trim();
+ try {
+ retValue = new BigDecimal(data);
+ } catch (NumberFormatException e) {
+ try {
+ d = new Double(data);
+ } catch (NumberFormatException e1) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ retValue = new BigDecimal(d.doubleValue());
+ }
+ return retValue;
+ } else {
+ return null;
+ }
+ }
+
+ public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, scale);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBigDecimal", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, scale);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBigDecimal");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ BigDecimal retValue;
+
+ retValue = getBigDecimal(columnIndex);
+ if (retValue != null) {
+ return retValue.setScale(scale);
+ } else {
+ return null;
+ }
+ }
+
+ public BigDecimal getBigDecimal(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBigDecimal", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBigDecimal");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getBigDecimal(columnIndex);
+ }
+
+ public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, scale);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBigDecimal", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, scale);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBigDecimal");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getBigDecimal(columnIndex, scale);
+ }
+
+ public InputStream getBinaryStream(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBinaryStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBinaryStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateGetInvocation(columnIndex);
+ byte[] data;
+
+ // For LOB Support - SB 10/8/2004
+ int dataType;
+
+
+ dataType = outputDesc_[columnIndex - 1].dataType_;
+ switch (dataType) {
+
+
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BINARY:
+ case Types.VARBINARY:
+ case Types.LONGVARBINARY:
+ case Types.BLOB:
+ case Types.CLOB:
+ data = getBytes(columnIndex);
+ if (data != null) {
+ return new java.io.ByteArrayInputStream(data);
+ } else {
+ return null;
+ }
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ }
+
+ public InputStream getBinaryStream(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBinaryStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBinaryStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getBinaryStream(columnIndex);
+ }
+
+
+ public boolean getBoolean(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBoolean", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBoolean");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+ short shortValue;
+
+ validateGetInvocation(columnIndex);
+ outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ data = data.trim();
+ if ((data.equalsIgnoreCase("true")) || (data.equalsIgnoreCase("1"))) {
+ return true;
+ } else if ((data.equalsIgnoreCase("false")) || (data.equalsIgnoreCase("false"))) {
+ return false;
+ } else {
+ try {
+ shortValue = getShort(columnIndex);
+ } catch (NumberFormatException e) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ switch (shortValue) {
+ case 0:
+ return false;
+ case 1:
+ return true;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "numeric_out_of_range", null);
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public boolean getBoolean(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBoolean", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBoolean");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getBoolean(columnIndex);
+ }
+
+ public byte getByte(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getByte", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getByte");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+ byte retValue;
+ Double d;
+ double d1;
+
+ validateGetInvocation(columnIndex);
+ outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ try {
+ retValue = Byte.parseByte(data);
+ } catch (NumberFormatException e) {
+ try {
+ d = new Double(data);
+ } catch (NumberFormatException e1) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ d1 = d.doubleValue();
+ // To allow -128.999.. and 127.999...
+ if (d1 > (double) Byte.MIN_VALUE - 1 && d1 < (double) Byte.MAX_VALUE + 1) {
+ retValue = d.byteValue();
+ if ((double) retValue != d1) {
+ setSQLWarning(null, "data_truncation", null);
+ }
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "numeric_out_of_range", null);
+ }
+ }
+ return retValue;
+ } else {
+ return 0;
+ }
+ }
+
+ public byte getByte(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getByte", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getByte");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getByte(columnIndex);
+ }
+
+ public byte[] getBytes(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBytes", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBytes");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateGetInvocation(columnIndex);
+ int dataType;
+
+
+ dataType = outputDesc_[columnIndex - 1].dataType_;
+
+ switch (dataType) {
+ case Types.BINARY:
+ case Types.VARBINARY:
+ case Types.LONGVARBINARY:
+ case Types.CHAR:
+ case Types.VARCHAR: // Extension allows varchar and
+ case Types.LONGVARCHAR: // longvarchar data types
+ case Types.BLOB:
+ case Types.CLOB:
+
+ Object x = getCurrentRow().getColumnObject(columnIndex);
+ if (x == null) {
+ wasNull_ = true;
+ return null;
+ } else {
+ wasNull_ = false;
+ if (x instanceof byte[]) {
+ return (byte[]) x;
+ } else if (x instanceof String) {
+ return ((String) x).getBytes();
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ }
+
+
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ }
+
+ public byte[] getBytes(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getBytes", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getBytes");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getBytes(columnIndex);
+ }
+
+ public Reader getCharacterStream(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getCharacterStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getCharacterStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+ int dataType;
+
+
+ validateGetInvocation(columnIndex);
+ dataType = outputDesc_[columnIndex - 1].dataType_;
+ switch (dataType) {
+
+
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BINARY:
+ case Types.VARBINARY:
+ case Types.LONGVARBINARY:
+ case Types.BLOB:
+ case Types.CLOB:
+ data = getString(columnIndex);
+ if (data != null) {
+ return new java.io.StringReader(data);
+ } else {
+ return null;
+ }
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+
+ }
+
+ public Reader getCharacterStream(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getCharacterStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getCharacterStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getCharacterStream(columnIndex);
+ }
+
+ public int getConcurrency() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getConcurrency", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getConcurrency");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (stmt_ != null) {
+ return stmt_.resultSetConcurrency_;
+ } else {
+ return ResultSet.CONCUR_READ_ONLY;
+ }
+ }
+
+ public String getCursorName() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getCursorName", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getCursorName");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (spj_rs_ && stmtLabel_ != null) {
+ return stmtLabel_;
+ } else if (stmt_ != null) {
+ String cursorName;
+ cursorName = stmt_.cursorName_;
+ if (cursorName == null) {
+ cursorName = stmt_.stmtLabel_;
+ }
+ return cursorName;
+ } else {
+ return null;
+ }
+ }
+
+ // wm_merge - AM
+ static String convertDateFormat(String dt) {
+ String tokens[] = dt.split("[/]", 3);
+
+ if (tokens.length != 3) {
+ return dt;
+ }
+ StringBuffer sb = new StringBuffer();
+ sb.append(tokens[0]).append("-").append(tokens[1]).append("-").append(tokens[2]);
+ return sb.toString();
+ }
+
+ public Date getDate(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ String data;
+ Date retValue;
+ int endIndex;
+
+ validateGetInvocation(columnIndex);
+ dataType = outputDesc_[columnIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.DATE && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ try {
+ boolean convertDate = connection_.getDateConversion();
+
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ String temp = "Convert Date=" + convertDate;
+ connection_.props_.t4Logger_.logp(Level.FINEST, "TrafT4ResultSet", "getDate", temp, p);
+ }
+ if (convertDate) {
+ String dt = convertDateFormat(data);
+ retValue = valueOf(dt);
+ } else {
+ retValue = Date.valueOf(data);
+ }
+ } catch (IllegalArgumentException e) {
+ data = data.trim();
+ if ((endIndex = data.indexOf(' ')) != -1) {
+ data = data.substring(0, endIndex);
+ }
+ try {
+ retValue = Date.valueOf(data);
+ setSQLWarning(null, "data_truncation", null);
+
+ } catch (IllegalArgumentException ex) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ }
+ return retValue;
+ } else {
+ return null;
+ }
+ }
+
+ /* TODO: this is a horrible hack but what else can be done with random 2 digit/4 digit years for dates?
+ * Note: The date constructor wants (year-1900) as a parameter
+ * We use the following table for conversion:
+ *
+ * Year Value Assumed Year Action
+ * <50 Value + 2000 must add 100
+ * >=100 Value must subtract 1900
+ * >=50 Value + 1900 no change in value needed
+ *
+ */
+ static Date valueOf(String s) {
+ int year;
+ int month;
+ int day;
+ int firstDash;
+ int secondDash;
+
+ if (s == null)
+ throw new java.lang.IllegalArgumentException();
+
+ firstDash = s.indexOf('-');
+ secondDash = s.indexOf('-', firstDash + 1);
+ if ((firstDash > 0) & (secondDash > 0) & (secondDash < s.length() - 1)) {
+ year = Integer.parseInt(s.substring(0, firstDash));
+
+ if (year < 50) {//handles 2 digit years: <50 assume 2000, >=50 assume 1900
+ year += 100;
+ }
+ else if(year >= 100) { //handles 4 digit years
+ year -= 1900;
+ }
+
+ month = Integer.parseInt(s.substring(firstDash + 1, secondDash)) - 1;
+ day = Integer.parseInt(s.substring(secondDash + 1));
+ } else {
+ throw new java.lang.IllegalArgumentException();
+ }
+
+ return new Date(year, month, day);
+ }
+
+ public Date getDate(int columnIndex, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Date sqlDate;
+ java.util.Date d;
+
+ sqlDate = getDate(columnIndex);
+ if (sqlDate != null) {
+ if (cal != null) {
+ cal.setTime(sqlDate);
+ d = cal.getTime();
+ sqlDate = new Date(d.getTime());
+ }
+ return sqlDate;
+ } else {
+ return (sqlDate);
+ }
+ }
+
+ public Date getDate(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getDate(columnIndex);
+ }
+
+ public Date getDate(String columnName, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getDate(columnIndex, cal);
+ }
+
+ public double getDouble(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDouble", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getDouble");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+
+ validateGetInvocation(columnIndex);
+ outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ try {
+ return Double.parseDouble(data);
+ } catch (NumberFormatException e1) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ } else {
+ return 0;
+ }
+ }
+
+ public double getDouble(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getDouble", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getDouble");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getDouble(columnIndex);
+ }
+
+ public int getFetchDirection() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getFetchDirection", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getFetchDirection");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ return fetchDirection_;
+ }
+
+ public int getFetchSize() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getFetchSize", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getFetchSize");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ return fetchSize_;
+ }
+
+ public float getFloat(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getFloat", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getFloat");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ double data;
+ validateGetInvocation(columnIndex);
+
+ outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ // parseFloat doesn't return error when
+ // the value exceds the float max
+ data = getDouble(columnIndex);
+ if (data >= Float.NEGATIVE_INFINITY && data <= Float.POSITIVE_INFINITY) {
+ return (float) data;
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "numeric_out_of_range",
+ null);
+ }
+ }
+
+ public float getFloat(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getFloat", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getFloat");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getFloat(columnIndex);
+ }
+
+ public int getInt(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getInt", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getInt");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+ int retValue;
+ double d;
+
+ validateGetInvocation(columnIndex);
+ outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ try {
+ retValue = Integer.parseInt(data);
+ } catch (NumberFormatException e) {
+ try {
+ d = new Double(data).doubleValue();
+ } catch (NumberFormatException e1) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+
+ if (d > (double) Integer.MIN_VALUE - 1 && d < (double) Integer.MAX_VALUE + 1) {
+ retValue = (int) d;
+ if ((double) retValue != d) {
+ setSQLWarning(null, "data_truncation", null);
+ }
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "numeric_out_of_range", null);
+ }
+ }
+ } else {
+ retValue = 0;
+ }
+
+ return retValue;
+ }
+
+ public int getInt(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getInt", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getInt");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getInt(columnIndex);
+ }
+
+ public long getLong(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getLong", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getLong");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+ long retValue;
+ double d;
+
+ BigDecimal bd;
+
+ validateGetInvocation(columnIndex);
+ outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ data = getLocalString(columnIndex);
+
+ if (data != null) {
+ try {
+ retValue = Long.parseLong(data);
+ } catch (NumberFormatException e) {
+ try {
+ bd = new BigDecimal(data);
+ retValue = bd.longValue();
+ if (bd.compareTo(BigDecimal.valueOf(Long.MAX_VALUE)) <= 0
+ && bd.compareTo(BigDecimal.valueOf(Long.MIN_VALUE)) >= 0) {
+
+ if (bd.compareTo(BigDecimal.valueOf(retValue)) != 0) {
+ setSQLWarning(null, "data_truncation", null);
+ }
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "numeric_out_of_range", null);
+ }
+ } catch (NumberFormatException e2) {
+
+ try {
+ d = new Double(data).doubleValue();
+ } catch (NumberFormatException e1) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+
+ if (d >= Long.MIN_VALUE && d <= Long.MAX_VALUE) {
+ retValue = (long) d;
+
+ if ((double) retValue != d) {
+ setSQLWarning(null, "data_truncation", null);
+ }
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "numeric_out_of_range", null);
+ }
+ }
+ }
+ } else {
+ retValue = 0;
+ }
+
+ return retValue;
+ }
+
+ public long getLong(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getLong", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getLong");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getLong(columnIndex);
+ }
+
+ public ResultSetMetaData getMetaData() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getMetaData", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getMetaData");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ return new HPT4ResultSetMetaData(this, outputDesc_);
+ }
+
+ public Object getObject(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ int precision;
+ byte byteValue;
+ short shortValue;
+ int intValue;
+ long longValue;
+ float floatValue;
+ double doubleValue;
+ boolean booleanValue;
+
+ validateGetInvocation(columnIndex);
+ dataType = outputDesc_[columnIndex - 1].dataType_;
+ precision = outputDesc_[columnIndex - 1].sqlPrecision_;
+ switch (dataType) {
+ case Types.TINYINT:
+ byteValue = getByte(columnIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Byte(byteValue);
+ }
+ case Types.SMALLINT:
+ shortValue = getShort(columnIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Short(shortValue);
+ }
+ case Types.INTEGER:
+ intValue = getInt(columnIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Integer(intValue);
+ }
+ case Types.BIGINT:
+ longValue = getLong(columnIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Long(longValue);
+ }
+ case Types.REAL:
+ floatValue = getFloat(columnIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Float(floatValue);
+ }
+ case Types.FLOAT:
+ case Types.DOUBLE:
+ doubleValue = getDouble(columnIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Double(doubleValue);
+ }
+ case Types.DECIMAL:
+ case Types.NUMERIC:
+ return getBigDecimal(columnIndex);
+ case Types.BIT:
+ booleanValue = getBoolean(columnIndex);
+ if (wasNull_) {
+ return null;
+ } else {
+ return new Boolean(booleanValue);
+ }
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BLOB:
+ case Types.CLOB:
+ return getString(columnIndex);
+ case Types.BINARY:
+ case Types.VARBINARY:
+ return getBytes(columnIndex);
+ case Types.LONGVARBINARY:
+ return getBinaryStream(columnIndex);
+ case Types.DATE:
+ return getDate(columnIndex);
+ case Types.TIME:
+ if (precision > 0)
+ return getString(columnIndex);
+
+ return getTime(columnIndex);
+ case Types.TIMESTAMP:
+ return getTimestamp(columnIndex);
+ // For LOB Support - SB 10/8/2004
+
+
+ case Types.OTHER:
+ return getString(columnIndex);
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ }
+
+ // JDK 1.2
+ public Object getObject(int columnIndex, Map map) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateGetInvocation(columnIndex);
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getObject()");
+ return null;
+ }
+
+ public Object getObject(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getObject(columnIndex);
+ }
+
+ // JDK 1.2
+ public Object getObject(String columnName, Map map) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, map);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, map);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getObject(columnIndex, map);
+ }
+
+ // JDK 1.2
+ public Ref getRef(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getRef", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getRef");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateGetInvocation(columnIndex);
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "getRef()");
+ return null;
+ }
+
+ // JDK 1.2
+ public Ref getRef(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getRef", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getRef");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getRef(columnIndex);
+ }
+
+ public int getRow() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getRow", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getRow");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ clearWarnings();
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (isBeforeFirst_ || isAfterLast_ || onInsertRow_) {
+ return 0;
+ }
+
+ if ((getType() == ResultSet.TYPE_FORWARD_ONLY) && (getConcurrency() == ResultSet.CONCUR_UPDATABLE)) {
+ return currentRowCount_;
+ }
+ return currentRow_;
+ }
+
+ public short getShort(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getShort", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getShort");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ String data;
+ short retValue;
+ double d;
+
+ validateGetInvocation(columnIndex);
+ outputDesc_[columnIndex - 1].checkValidNumericConversion(connection_.getLocale());
+
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ try {
+ retValue = Short.parseShort(data);
+ } catch (NumberFormatException e) {
+ try {
+ d = new Double(data).doubleValue();
+ } catch (NumberFormatException e1) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+
+ if (d > (double) Short.MIN_VALUE - 1 && d < (double) Short.MAX_VALUE + 1) {
+ retValue = (short) d;
+ if ((double) retValue != d)
+
+ {
+ setSQLWarning(null, "data_truncation", null);
+ }
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "numeric_out_of_range", null);
+ }
+ }
+
+ } else {
+ retValue = 0;
+ }
+
+ return retValue;
+ }
+
+ public short getShort(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getShort", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getShort");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getShort(columnIndex);
+ }
+
+ public Statement getStatement() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getStatement", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getStatement");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ return stmt_;
+ }
+
+ public String getString(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getString", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getString");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+ int targetSqlType;
+ int precision;
+ Object x;
+ BaseRow currentRow;
+
+ validateGetInvocation(columnIndex);
+ currentRow = getCurrentRow();
+ x = currentRow.getColumnObject(columnIndex);
+
+ if (x == null) {
+ wasNull_ = true;
+ return null;
+ }
+
+ wasNull_ = false;
+ targetSqlType = outputDesc_[columnIndex - 1].dataType_;
+ precision = outputDesc_[columnIndex - 1].sqlPrecision_;
+ switch (targetSqlType) {
+
+
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BLOB:
+ case Types.CLOB:
+ data = getLocalString(columnIndex);
+ if (stmt_ != null && stmt_.maxFieldSize_ != 0) {
+ if (data.length() > stmt_.maxFieldSize_) {
+ data = data.substring(0, stmt_.maxFieldSize_);
+ }
+ }
+ break;
+ case Types.VARBINARY:
+ case Types.BINARY:
+ case Types.LONGVARBINARY:
+ data = String.valueOf(getBytes(columnIndex));
+ break;
+ case Types.TIMESTAMP:
+ Timestamp t = getTimestamp(columnIndex);
+ data = "" + t.getNanos();
+ int l = data.length();
+ data = t.toString();
+
+ if(precision > 0) {
+ for(int i=0;i<precision-l;i++)
+ data += '0';
+ } else {
+ data = data.substring(0,data.lastIndexOf('.'));
+ }
+
+ break;
+ case Types.TIME:
+ if (precision > 0)
+ data = x.toString();
+ else
+ data = String.valueOf(getTime(columnIndex));
+ break;
+ case Types.DATE:
+ data = String.valueOf(getDate(columnIndex));
+ break;
+ case Types.BOOLEAN:
+ data = String.valueOf(getBoolean(columnIndex));
+ break;
+ case Types.SMALLINT:
+ data = String.valueOf(getShort(columnIndex));
+ break;
+ case Types.TINYINT:
+ data = String.valueOf(getByte(columnIndex));
+ break;
+ case Types.REAL:
+ data = String.valueOf(getFloat(columnIndex));
+ break;
+ case Types.DOUBLE:
+ case Types.FLOAT:
+ data = String.valueOf(getDouble(columnIndex));
+ break;
+ case Types.DECIMAL:
+ case Types.NUMERIC:
+ BigDecimal bd = getBigDecimal(columnIndex);
+ if (_javaVersion >= 1.5) {
+ // as of Java 5.0 and above, BigDecimal.toPlainString() should be used.
+ try {
+ data = (String) _toPlainString.invoke(bd, (Object[]) null);
+ } catch (Exception e) {
+ data = bd.toString();
+ }
+ } else {
+ data = bd.toString();
+ }
+ break;
+ case Types.BIGINT:
+ data = String.valueOf(getLong(columnIndex));
+ break;
+ case Types.INTEGER:
+ data = String.valueOf(getInt(columnIndex));
+ break;
+ case Types.OTHER: {
+ if (x instanceof byte[]) {
+ try {
+ data = new String((byte[]) x, "ASCII");
+ } catch (Exception e) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "unsupported_encoding", "ASCII");
+ }
+ } else {
+ data = x.toString();
+ }
+ // only 2 supported today
+ // 1. SQLTYPECODE_INTERVAL
+ // 2. SQLTYPECODE_DATETIME
+ // Within DATETIME we check for only the SQL/MP specific data types
+ // in another switch-case statement
+ switch (outputDesc_[columnIndex - 1].fsDataType_) {
+ case InterfaceResultSet.SQLTYPECODE_INTERVAL: {
+ // if data does no start with a hyphen (representing a negative
+ // sign)
+ // then send back data without the byte that holds the hyphen
+ // Reason: for Interval data types first byte is holding either
+ // the
+ // a negative sign or if number is positive, it is just an extra
+ // space
+ data = Utility.trimRightZeros(data);
+ if (!data.startsWith(hyphen_string)) {
+ data = data.substring(1);
+ }
+ }
+ break;
+ case InterfaceResultSet.SQLTYPECODE_DATETIME: {
+ switch (outputDesc_[columnIndex - 1].sqlDatetimeCode_) {
+ case HPT4Desc.SQLDTCODE_YEAR:
+ case HPT4Desc.SQLDTCODE_YEAR_TO_MONTH:
+ case HPT4Desc.SQLDTCODE_MONTH:
+ case HPT4Desc.SQLDTCODE_MONTH_TO_DAY:
+ case HPT4Desc.SQLDTCODE_DAY:
+ case HPT4Desc.SQLDTCODE_HOUR:
+ case HPT4Desc.SQLDTCODE_HOUR_TO_MINUTE:
+ case HPT4Desc.SQLDTCODE_MINUTE:
+ case HPT4Desc.SQLDTCODE_MINUTE_TO_SECOND:
+ // case HPT4Desc.SQLDTCODE_MINUTE_TO_FRACTION:
+ case HPT4Desc.SQLDTCODE_SECOND:
+ // case HPT4Desc.SQLDTCODE_SECOND_TO_FRACTION:
+ case HPT4Desc.SQLDTCODE_YEAR_TO_HOUR:
+ case HPT4Desc.SQLDTCODE_YEAR_TO_MINUTE:
+ case HPT4Desc.SQLDTCODE_MONTH_TO_HOUR:
+ case HPT4Desc.SQLDTCODE_MONTH_TO_MINUTE:
+ case HPT4Desc.SQLDTCODE_MONTH_TO_SECOND:
+ // case HPT4Desc.SQLDTCODE_MONTH_TO_FRACTION:
+ case HPT4Desc.SQLDTCODE_DAY_TO_HOUR:
+ case HPT4Desc.SQLDTCODE_DAY_TO_MINUTE:
+ case HPT4Desc.SQLDTCODE_DAY_TO_SECOND:
+ // case HPT4Desc.SQLDTCODE_DAY_TO_FRACTION:
+ case HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION:
+ break;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "object_type_not_supported", null);
+ }
+ }
+ break;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "object_type_not_supported", null);
+ }
+ }
+ break;
+ case Types.ARRAY:
+ case Types.BIT:
+ case Types.REF:
+ case Types.DATALINK:
+ case Types.DISTINCT:
+ case Types.JAVA_OBJECT:
+ case Types.STRUCT:
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "object_type_not_supported", null);
+ }
+ return data;
+ }
+
+ public String getString(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getString", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getString");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getString(columnIndex);
+ }
+
+ public Time getTime(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ String data;
+ Time retValue;
+ Timestamp timestamp;
+
+ validateGetInvocation(columnIndex);
+ dataType = outputDesc_[columnIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ switch (dataType) {
+ case Types.TIMESTAMP:
+ try {
+ timestamp = Timestamp.valueOf(data);
+ retValue = new Time(timestamp.getTime());
+ } catch (IllegalArgumentException e) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ break;
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BLOB:
+ case Types.CLOB:
+ data = data.trim(); // Fall Thru
+ case Types.TIME:
+ try {
+ retValue = Time.valueOf(data);
+ } catch (IllegalArgumentException e) {
+ try {
+ timestamp = Timestamp.valueOf(data);
+ retValue = new Time(timestamp.getTime());
+ } catch (IllegalArgumentException ex) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ }
+ break;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "restricted_data_type", null);
+ }
+ return retValue;
+ } else {
+ return null;
+ }
+ }
+
+ public Time getTime(int columnIndex, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Time sqlTime;
+ java.util.Date d;
+
+ sqlTime = getTime(columnIndex);
+ if (sqlTime != null) {
+ if (cal != null) {
+ cal.setTime(sqlTime);
+ d = cal.getTime();
+ sqlTime = new Time(d.getTime());
+ }
+ return sqlTime;
+ } else {
+ return (sqlTime);
+ }
+ }
+
+ public Time getTime(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getTime(columnIndex);
+ }
+
+ public Time getTime(String columnName, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getTime(columnIndex, cal);
+ }
+
+ public Timestamp getTimestamp(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ String data;
+ Timestamp retValue;
+ Date dateValue;
+ Time timeValue;
+
+ validateGetInvocation(columnIndex);
+ dataType = outputDesc_[columnIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.DATE && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ switch (dataType) {
+ case Types.DATE:
+ try {
+ dateValue = Date.valueOf(data);
+ retValue = new Timestamp(dateValue.getTime());
+ } catch (IllegalArgumentException e) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+ break;
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BLOB:
+ case Types.CLOB:
+ data = data.trim();
+ case Types.TIMESTAMP:
+ case Types.TIME:
+ try {
+ retValue = Timestamp.valueOf(data);
+ } catch (IllegalArgumentException e) {
+ try {
+ dateValue = Date.valueOf(data);
+ retValue = new Timestamp(dateValue.getTime());
+ } catch (IllegalArgumentException e1) {
+ try {
+ int nano = 0;
+ if (outputDesc_[columnIndex - 1].sqlPrecision_ > 0) {
+ nano = Integer.parseInt(data.substring(data.indexOf(".") + 1));
+ nano *= Math.pow(10, 9 - outputDesc_[columnIndex - 1].sqlPrecision_);
+ data = data.substring(0, data.indexOf("."));
+ }
+
+ timeValue = Time.valueOf(data);
+ retValue = new Timestamp(timeValue.getTime());
+ retValue.setNanos(nano);
+ } catch (IllegalArgumentException e2) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_cast_specification", null);
+ }
+
+ }
+ }
+ break;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "restricted_data_type", null);
+ }
+ return retValue;
+ } else {
+ return null;
+ }
+ }
+
+ public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Timestamp sqlTimestamp;
+ java.util.Date d;
+ int nanos;
+
+ sqlTimestamp = getTimestamp(columnIndex);
+ if (sqlTimestamp != null) {
+ if (cal != null) {
+ nanos = sqlTimestamp.getNanos();
+ cal.setTime(sqlTimestamp);
+ d = cal.getTime();
+ sqlTimestamp = new Timestamp(d.getTime());
+ sqlTimestamp.setNanos(nanos);
+ }
+ return sqlTimestamp;
+ } else {
+ return (sqlTimestamp);
+ }
+ }
+
+ public Timestamp getTimestamp(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getTimestamp(columnIndex);
+ }
+
+ public Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getTimestamp(columnIndex, cal);
+ }
+
+ public int getType() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getType", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getType");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_cursor_state",
+ null);
+ }
+ if (stmt_ != null) {
+ return stmt_.resultSetType_;
+ } else {
+ return ResultSet.TYPE_FORWARD_ONLY;
+ }
+
+ }
+
+ public InputStream getUnicodeStream(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getUnicodeStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getUnicodeStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ String data;
+
+ validateGetInvocation(columnIndex);
+ data = getLocalString(columnIndex);
+ if (data != null) {
+ try {
+ return new java.io.ByteArrayInputStream(data.getBytes((String) InterfaceUtilities
+ .getCharsetName(InterfaceUtilities.SQLCHARSETCODE_UNICODE)));
+ } catch (java.io.UnsupportedEncodingException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "unsupported_encoding", messageArguments);
+ }
+ } else {
+ return null;
+ }
+
+ }
+
+ public InputStream getUnicodeStream(String columnName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4ResultSet", "getUnicodeStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4ResultSet");
+ lr.setSourceMethodName("getUnicodeStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int columnIndex = validateGetInvocation(columnName);
+ return getUnicodeStream(columnIndex);
+ }
+
+ public URL getURL(int columnIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, columnIndex);
+ conn
<TRUNCATED>
[55/60] incubator-trafodion git commit: Merge branch 'master' of
github.com:apache/incubator-trafodion into wrkbrnch
Posted by db...@apache.org.
Merge branch 'master' of github.com:apache/incubator-trafodion into wrkbrnch
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/b5082994
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/b5082994
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/b5082994
Branch: refs/heads/master
Commit: b50829942facca522efc41fbece00720717a3cf1
Parents: 1ca6f60 00d5111
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Fri Apr 29 15:34:06 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Fri Apr 29 15:34:06 2016 +0000
----------------------------------------------------------------------
core/conn/jdbc_type2/native/SqlInterface.cpp | 3 ---
1 file changed, 3 deletions(-)
----------------------------------------------------------------------
[58/60] incubator-trafodion git commit: Updated .gitignore file to
ignore Vproc.java file
Posted by db...@apache.org.
Updated .gitignore file to ignore Vproc.java file
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/755c3835
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/755c3835
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/755c3835
Branch: refs/heads/master
Commit: 755c383580828e702a137342318a000bb682c239
Parents: 6897f88
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Fri Apr 29 19:16:25 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Fri Apr 29 19:16:25 2016 +0000
----------------------------------------------------------------------
core/conn/jdbcT4/.gitignore | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/755c3835/core/conn/jdbcT4/.gitignore
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/.gitignore b/core/conn/jdbcT4/.gitignore
index 90bf5f8..0cd8557 100644
--- a/core/conn/jdbcT4/.gitignore
+++ b/core/conn/jdbcT4/.gitignore
@@ -2,3 +2,4 @@
*.log
/LICENSE
/NOTICE
+src/main/java/org/trafodion/jdbc/t4/Vproc.java
[12/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PrepareMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PrepareMessage.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PrepareMessage.java
deleted file mode 100644
index 2c7599a..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PrepareMessage.java
+++ /dev/null
@@ -1,82 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class PrepareMessage {
- // ----------------------------------------------------------
- static LogicalByteArray marshal(int dialogueId, int sqlAsyncEnable, int queryTimeout, short stmtType,
- int sqlStmtType, String stmtLabel, int stmtLabelCharset, String cursorName, int cursorNameCharset,
- String moduleName, int moduleNameCharset, long moduleTimestamp, String sqlString, int sqlStringCharset,
- String stmtOptions, String stmtExplainLabel, int maxRowsetSize, byte[] txId, InterfaceConnection ic)
- throws CharacterCodingException, UnsupportedCharsetException {
- int wlength = Header.sizeOf();
- LogicalByteArray buf;
-
- byte[] stmtLabelBytes = ic.encodeString(stmtLabel, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] cursorNameBytes = ic.encodeString(cursorName, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] moduleNameBytes = ic.encodeString(moduleName, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] sqlStringBytes = ic.encodeString(sqlString, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] stmtOptionsBytes = ic.encodeString(stmtOptions, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] stmtExplainLabelBytes = ic.encodeString(stmtExplainLabel, InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- wlength += TRANSPORT.size_int; // dialogueId
- wlength += TRANSPORT.size_int; // sqlAsyncEnable
- wlength += TRANSPORT.size_int; // queryTimeout
- wlength += TRANSPORT.size_short; // stmtType
- wlength += TRANSPORT.size_int; // sqlStmtType
- wlength += TRANSPORT.size_bytesWithCharset(stmtLabelBytes); // +stmtCharset
- wlength += TRANSPORT.size_bytesWithCharset(cursorNameBytes); // +cursorCharset
- wlength += TRANSPORT.size_bytesWithCharset(moduleNameBytes);
- if (moduleName != null && moduleName.length() > 0) {
- wlength += TRANSPORT.size_long; // moduleTimestamp
- }
- wlength += TRANSPORT.size_bytesWithCharset(sqlStringBytes); // +sqlStringCharset
- wlength += TRANSPORT.size_bytes(stmtOptionsBytes);
- wlength += TRANSPORT.size_bytes(stmtExplainLabelBytes);
- wlength += TRANSPORT.size_int; // maxRowsetSize
- wlength += TRANSPORT.size_bytes(txId); // transId
-
- buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
-
- buf.insertInt(dialogueId);
- buf.insertInt(sqlAsyncEnable);
- buf.insertInt(queryTimeout);
- buf.insertShort(stmtType);
- buf.insertInt(sqlStmtType);
- buf.insertStringWithCharset(stmtLabelBytes, stmtLabelCharset);
- buf.insertStringWithCharset(cursorNameBytes, cursorNameCharset);
- buf.insertStringWithCharset(moduleNameBytes, moduleNameCharset);
- if (moduleName != null && moduleName.length() > 0) {
- buf.insertLong(moduleTimestamp);
- }
- buf.insertStringWithCharset(sqlStringBytes, sqlStringCharset);
- buf.insertString(stmtOptionsBytes);
- buf.insertString(stmtExplainLabelBytes);
- buf.insertInt(maxRowsetSize);
- buf.insertString(txId);
-
- return buf;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PrepareReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PrepareReply.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PrepareReply.java
deleted file mode 100644
index 82b0448..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PrepareReply.java
+++ /dev/null
@@ -1,103 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class PrepareReply {
- int returnCode;
- int totalErrorLength;
- SQLWarningOrError[] errorList;
- int sqlQueryType;
- int stmtHandle;
- int estimatedCost;
-
- int inputDescLength;
- int inputParamLength;
- int inputNumberParams;
- Descriptor2[] inputDesc;
-
- int outputDescLength;
- int outputParamLength;
- int outputNumberParams;
- Descriptor2[] outputDesc;
-
- // -------------------------------------------------------------
- PrepareReply(LogicalByteArray buf, InterfaceConnection ic) throws CharacterCodingException,
- UnsupportedCharsetException {
- buf.setLocation(Header.sizeOf());
-
- returnCode = buf.extractInt();
-
- // should check SQL_SUCCESS or SQL_SUCCESS_WITH_INFO
- // if(returnCode == TRANSPORT.SQL_SUCCESS)
- if (returnCode == TRANSPORT.SQL_SUCCESS || returnCode == TRANSPORT.SQL_SUCCESS_WITH_INFO) {
- if (returnCode == TRANSPORT.SQL_SUCCESS_WITH_INFO) {
- totalErrorLength = buf.extractInt();
-
- if (totalErrorLength > 0) {
- errorList = new SQLWarningOrError[buf.extractInt()];
- for (int i = 0; i < errorList.length; i++) {
- errorList[i] = new SQLWarningOrError(buf, ic, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- }
- }
- }
- sqlQueryType = buf.extractInt();
- stmtHandle = buf.extractInt();
- estimatedCost = buf.extractInt();
-
- inputDescLength = buf.extractInt();
- if (inputDescLength > 0) {
- inputParamLength = buf.extractInt();
- inputNumberParams = buf.extractInt();
-
- inputDesc = new Descriptor2[inputNumberParams];
- for (int i = 0; i < inputNumberParams; i++) {
- inputDesc[i] = new Descriptor2(buf, ic);
- inputDesc[i].setRowLength(inputParamLength);
- }
- }
-
- outputDescLength = buf.extractInt();
- if (outputDescLength > 0) {
- outputParamLength = buf.extractInt();
- outputNumberParams = buf.extractInt();
-
- outputDesc = new Descriptor2[outputNumberParams];
- for (int i = 0; i < outputNumberParams; i++) {
- outputDesc[i] = new Descriptor2(buf, ic);
- outputDesc[i].setRowLength(outputParamLength);
- }
- }
- } else {
- totalErrorLength = buf.extractInt();
-
- if (totalErrorLength > 0) {
- errorList = new SQLWarningOrError[buf.extractInt()];
- for (int i = 0; i < errorList.length; i++) {
- errorList[i] = new SQLWarningOrError(buf, ic, ic.getISOMapping());
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PreparedStatementManager.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PreparedStatementManager.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PreparedStatementManager.java
deleted file mode 100644
index 801a4b1..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PreparedStatementManager.java
+++ /dev/null
@@ -1,242 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.io.PrintWriter;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.logging.Level;
-
-public abstract class PreparedStatementManager extends HPT4Handle {
-
- boolean isStatementCachingEnabled() {
- if (maxStatements_ < 1) {
- return false;
- } else {
- return true;
- }
- }
-
- boolean makeRoom() throws SQLException {
- if (out_ != null) {
- if (traceLevel_ != Level.OFF) {
- out_.println(traceId_ + "makeRoom()");
- }
- }
-
- Iterator i;
- CachedPreparedStatement cs;
- long oldest;
- long stmtTime;
- String key;
-
- i = (prepStmtsInCache_.values()).iterator();
- if (!i.hasNext()) {
- return false;
- }
- cs = (CachedPreparedStatement) i.next();
- stmtTime = cs.getLastUsedTime();
- key = cs.getLookUpKey();
- oldest = stmtTime;
-
- for (; i.hasNext();) {
- cs = (CachedPreparedStatement) i.next();
- stmtTime = cs.getLastUsedTime();
- if (oldest > stmtTime) {
- oldest = stmtTime;
- key = cs.getLookUpKey();
- }
- }
- cs = (CachedPreparedStatement) prepStmtsInCache_.remove(key);
- if (cs != null) {
- if (cs.inUse_ == false) // if the user has already closed the
- // statement, hard close it
- cs.close(true);
-
- return true;
- } else {
- return false;
- }
- }
-
- void closePreparedStatementsAll() throws SQLException {
-
- if (out_ != null) {
- if (traceLevel_ != Level.OFF) {
- out_.println(traceId_ + "closePreparedStatementsAll()");
- }
- }
-
- Object[] csArray;
-
- CachedPreparedStatement cs;
- int i = 0;
-
- csArray = (prepStmtsInCache_.values()).toArray();
- for (i = 0; i < csArray.length; i++) {
- cs = (CachedPreparedStatement) csArray[i];
- if (cs != null) {
- cs.close(false);
- }
- }
- }
-
- private String createKey(TrafT4Connection connect, String sql, int resultSetHoldability) throws SQLException {
- String lookupKey = sql + connect.getCatalog() + connect.getSchema() + connect.getTransactionIsolation()
- + resultSetHoldability;
-
- return lookupKey;
- }
-
- boolean closePreparedStatement(TrafT4Connection connect, String sql, int resultSetType, int resultSetConcurrency,
- int resultSetHoldability) throws SQLException {
- if (out_ != null) {
- if (traceLevel_ != Level.OFF) {
- out_.println(traceId_ + "closePreparedStatement(" + connect + ",\"" + sql + "\"," + resultSetType + ","
- + resultSetConcurrency + "," + resultSetHoldability + ")");
- }
- }
-
- CachedPreparedStatement cs;
-
- String lookupKey = createKey(connect, sql, resultSetHoldability);
-
- cs = (CachedPreparedStatement) prepStmtsInCache_.get(lookupKey);
- if (cs != null) {
- cs.inUse_ = false;
- return true;
- }
-
- return false;
- }
-
- void clearPreparedStatementsAll() {
- if (out_ != null) {
- if (traceLevel_ != Level.OFF) {
- out_.println(traceId_ + "clearPreparedStatementsAll()");
- }
- }
- if (prepStmtsInCache_ != null) {
- prepStmtsInCache_.clear();
- }
- count_ = 0;
- }
-
- void addPreparedStatement(TrafT4Connection connect, String sql, PreparedStatement pStmt, int resultSetType,
- int resultSetConcurrency, int resultSetHoldability) throws SQLException {
- if (out_ != null) {
- if (traceLevel_ != Level.OFF) {
- out_.println(traceId_ + "addPreparedStatement(" + connect + ",\"" + sql + "\"," + pStmt + ","
- + resultSetType + "," + resultSetConcurrency + "," + resultSetHoldability + ")");
- }
- }
-
- CachedPreparedStatement cachedStmt;
-
- String lookupKey = createKey(connect, sql, resultSetHoldability);
-
- cachedStmt = (CachedPreparedStatement) prepStmtsInCache_.get(lookupKey);
- if (cachedStmt != null) {
- // Update the last use time
- cachedStmt.setLastUsedInfo();
- } else {
- if (count_ < maxStatements_) {
- cachedStmt = new CachedPreparedStatement(pStmt, lookupKey);
- prepStmtsInCache_.put(lookupKey, cachedStmt);
- count_++;
- } else {
- if (makeRoom()) {
- cachedStmt = new CachedPreparedStatement(pStmt, lookupKey);
- prepStmtsInCache_.put(lookupKey, cachedStmt);
- }
- }
- }
- }
-
- PreparedStatement getPreparedStatement(TrafT4Connection connect, String sql, int resultSetType,
- int resultSetConcurrency, int resultSetHoldability) throws SQLException {
- if (out_ != null) {
- if (traceLevel_ != Level.OFF) {
- out_.println(traceId_ + "getPreparedStatement(" + connect + ",\"" + sql + "\"," + resultSetType + ","
- + resultSetConcurrency + "," + resultSetHoldability + ")");
- }
- }
-
- PreparedStatement pStmt = null;
- CachedPreparedStatement cachedStmt;
-
- String lookupKey = createKey(connect, sql, resultSetHoldability);
-
- if (prepStmtsInCache_ != null) {
- cachedStmt = (CachedPreparedStatement) prepStmtsInCache_.get(lookupKey);
- if (cachedStmt != null) {
- if (!cachedStmt.inUse_) {
- pStmt = cachedStmt.getPreparedStatement();
- ((org.trafodion.jdbc.t4.TrafT4PreparedStatement) pStmt).reuse(connect, resultSetType, resultSetConcurrency,
- resultSetHoldability);
- } else {
- pStmt = null;
- }
- }
- }
- return pStmt;
- }
-
- void setLogInfo(Level traceLevel, PrintWriter out) {
- this.traceLevel_ = traceLevel;
- this.out_ = out;
-
- }
-
- PreparedStatementManager() {
- super();
- String className = getClass().getName();
- traceId_ = "jdbcTrace:[" + Thread.currentThread() + "]:[" + hashCode() + "]:" + className + ".";
- }
-
- PreparedStatementManager(T4Properties t4props) {
- super();
-
- String className = getClass().getName();
-
- String tmp;
-
- if (t4props != null) {
- maxStatements_ = t4props.getMaxStatements();
-
- }
- if (maxStatements_ > 0) {
- prepStmtsInCache_ = new Hashtable();
- }
- traceId_ = "jdbcTrace:[" + Thread.currentThread() + "]:[" + hashCode() + "]:" + className + ".";
- }
-
- private Hashtable prepStmtsInCache_;
- private int maxStatements_;
- private int count_;
-
- Level traceLevel_;
- PrintWriter out_;
- String traceId_;
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Row.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Row.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Row.java
deleted file mode 100644
index 21ee6f3..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Row.java
+++ /dev/null
@@ -1,233 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.io.Serializable;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.util.BitSet;
-import java.util.Locale;
-
-// Referenced classes of package sun.jdbc.rowset:
-// BaseRow
-
-class Row extends BaseRow implements Serializable, Cloneable {
-
- private Object currentVals[];
- private BitSet colsChanged;
- private boolean deleted;
- private boolean updated;
- private boolean inserted;
- private int numCols;
-
- Row(int i) {
- origVals = new Object[i];
- currentVals = new Object[i];
- colsChanged = new BitSet(i);
- numCols = i;
- }
-
- Row(int i, Object aobj[]) {
- origVals = new Object[i];
- for (int j = 0; j < i; j++) {
- origVals[j] = aobj[j];
-
- }
- currentVals = new Object[i];
- colsChanged = new BitSet(i);
- numCols = i;
- }
-
- protected void clearDeleted() {
- deleted = false;
- }
-
- protected void clearInserted() {
- inserted = false;
- }
-
- protected void clearUpdated() {
- updated = false;
- for (int i = 0; i < numCols; i++) {
- currentVals[i] = null;
- colsChanged.clear(i);
- }
-
- }
-
- protected boolean getColUpdated(int i) {
- return colsChanged.get(i);
- }
-
- protected Object getColumnObject(int i) throws SQLException {
- if (getColUpdated(i - 1)) {
- return currentVals[i - 1];
- } else {
- return origVals[i - 1];
- }
- }
-
- protected boolean getDeleted() {
- return deleted;
- }
-
- protected boolean getInserted() {
- return inserted;
- }
-
- protected boolean getUpdated() {
- return updated;
- }
-
- protected void initColumnObject(int i, Object obj) {
- origVals[i - 1] = obj;
- }
-
- protected void moveCurrentToOrig() {
- for (int i = 0; i < numCols; i++) {
- if (getColUpdated(i)) {
- origVals[i] = currentVals[i];
- currentVals[i] = null;
- colsChanged.clear(i);
- }
- }
- }
-
- private void setColUpdated(int i) {
- colsChanged.set(i);
- }
-
- protected void setColumnObject(int i, Object obj) {
- currentVals[i - 1] = obj;
- setColUpdated(i - 1);
- }
-
- protected void setLobObject(int i, Object obj) {
- currentVals[i - 1] = obj;
- origVals[i - 1] = obj;
- }
-
- protected void setDeleted() {
- deleted = true;
- }
-
- protected void setInserted() {
- inserted = true;
- }
-
- protected void setUpdated() {
- updated = true;
- }
-
- protected void deleteRow(Locale locale, PreparedStatement deleteStmt, BitSet paramCols) throws SQLException {
- int i;
- int j;
- int count;
-
- for (i = 0, j = 1; i < numCols; i++) {
- if (paramCols.get(i)) {
- deleteStmt.setObject(j++, origVals[i]);
- }
- }
- count = deleteStmt.executeUpdate();
- if (count == 0) {
- throw HPT4Messages.createSQLException(null, locale, "row_modified", null);
- }
- }
-
- protected void updateRow(Locale locale, PreparedStatement updateStmt, BitSet paramCols, BitSet keyCols)
- throws SQLException {
- int i;
- int j;
- int count;
-
- for (i = 0, j = 1; i < numCols; i++) {
- if (keyCols.get(i)) {
- if (getColUpdated(i)) {
- throw HPT4Messages.createSQLException(null, locale, "primary_key_not_updateable", null);
- }
- } else {
- if (paramCols.get(i)) { // LOB Support SB 10/8/2004
- Object obj = getColumnObject((i + 1));
-
-
- updateStmt.setObject(j++, getColumnObject(i + 1));
- }
- }
- }
-
- for (i = 0; i < numCols; i++) {
- // if (paramCols.get(i))
- if (keyCols.get(i)) {
- Object obj = origVals[i];
-
-
- updateStmt.setObject(j++, origVals[i]);
- }
- }
-
- count = updateStmt.executeUpdate();
- if (count == 0) {
- throw HPT4Messages.createSQLException(null, locale, "row_modified", null);
- }
- moveCurrentToOrig();
- setUpdated();
- }
-
- protected void refreshRow(Locale locale, PreparedStatement selectStmt, BitSet selectCols, BitSet keyCols)
- throws SQLException {
- int i;
- int j;
- ResultSet rs;
- ResultSetMetaData rsmd;
- int columnCount;
-
- clearUpdated();
-
- for (i = 0, j = 1; i < numCols; i++) {
- if (keyCols.get(i)) {
- selectStmt.setObject(j++, origVals[i]);
- }
- }
- rs = selectStmt.executeQuery();
- if (rs != null) {
- try {
- rsmd = rs.getMetaData();
- columnCount = rsmd.getColumnCount();
- rs.next();
- for (i = 0, j = 1; i < numCols; i++) {
- if (selectCols.get(i)) {
- origVals[i] = rs.getObject(j++);
- }
- }
- } catch (SQLException ex) {
- throw ex;
- } finally {
- rs.close();
- }
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDescList_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDescList_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDescList_def.java
deleted file mode 100644
index 042772b..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDescList_def.java
+++ /dev/null
@@ -1,46 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class SQLItemDescList_def {
- SQLItemDesc_def[] list;
-
- public SQLItemDescList_def(LogicalByteArray buf, boolean useOld, InterfaceConnection ic)
- throws CharacterCodingException, UnsupportedCharsetException {
- int length = buf.extractInt();
-
- if (length > 0) {
- if (!useOld) {
- length = buf.extractInt();
- }
- list = new SQLItemDesc_def[length];
-
- for (int i = 0; i < length; i++) {
- list[i] = (useOld) ? new SQLItemDescOld_def() : new SQLItemDesc_def();
- list[i].extractFromByteArray(buf, ic);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDescOld_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDescOld_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDescOld_def.java
deleted file mode 100644
index 666f37c..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDescOld_def.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class SQLItemDescOld_def extends SQLItemDesc_def {
- void extractFromByteArray(LogicalByteArray buf, InterfaceConnection ic) throws UnsupportedCharsetException,
- CharacterCodingException {
- version = buf.extractInt();
- dataType = buf.extractInt();
- datetimeCode = buf.extractInt();
- maxLen = buf.extractInt();
- precision = buf.extractShort();
- scale = buf.extractShort();
- nullInfo = buf.extractByte();
-
- colHeadingNm = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- signType = buf.extractByte();
- ODBCDataType = buf.extractInt();
- ODBCPrecision = buf.extractShort();
- SQLCharset = buf.extractInt();
- ODBCCharset = buf.extractInt();
-
- TableName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- CatalogName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- SchemaName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- Heading = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- intLeadPrec = buf.extractInt();
- paramMode = buf.extractInt();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDesc_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDesc_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDesc_def.java
deleted file mode 100644
index 24d0b04..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDesc_def.java
+++ /dev/null
@@ -1,70 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class SQLItemDesc_def {
- int version;
- int dataType;
- int datetimeCode;
- int maxLen;
- short precision;
- short scale;
- byte nullInfo;
- String colHeadingNm;
- byte signType;
- int ODBCDataType;
- short ODBCPrecision;
- int SQLCharset;
- int ODBCCharset;
- String TableName;
- String CatalogName;
- String SchemaName;
- String Heading;
- int intLeadPrec;
- int paramMode;
-
- void extractFromByteArray(LogicalByteArray buf, InterfaceConnection ic) throws UnsupportedCharsetException,
- CharacterCodingException {
- version = buf.extractInt();
- dataType = buf.extractInt();
- datetimeCode = buf.extractInt();
- maxLen = buf.extractInt();
- precision = buf.extractShort();
- scale = buf.extractShort();
- nullInfo = buf.extractByte();
- signType = buf.extractByte();
- ODBCDataType = buf.extractInt();
- ODBCPrecision = buf.extractShort();
- SQLCharset = buf.extractInt();
- ODBCCharset = buf.extractInt();
- colHeadingNm = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- TableName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- CatalogName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- SchemaName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- Heading = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- intLeadPrec = buf.extractInt();
- paramMode = buf.extractInt();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLValueList_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLValueList_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLValueList_def.java
deleted file mode 100644
index a56b1c5..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLValueList_def.java
+++ /dev/null
@@ -1,64 +0,0 @@
-// @@@ 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;
-
-class SQLValueList_def {
- SQLValue_def[] buffer;
-
- // ----------------------------------------------------------
- int sizeof() {
- int size = TRANSPORT.size_int;
-
- if (buffer != null) {
- for (int i = 0; i < buffer.length; i++) {
- size += buffer[i].sizeof();
- }
- }
- return size;
- }
-
- // ----------------------------------------------------------
- void insertIntoByteArray(LogicalByteArray buf) {
- if (buffer != null) {
- buf.insertInt(buffer.length);
- for (int i = 0; i < buffer.length; i++) {
- buffer[i].insertIntoByteArray(buf);
- }
- } else {
- buf.insertInt(0);
- }
- }
-
- // ----------------------------------------------------------
- void extractFromByteArray(LogicalByteArray buf) throws SQLException {
- int len = buf.extractInt();
-
- buffer = new SQLValue_def[len];
-
- for (int i = 0; i < buffer.length; i++) {
- buffer[i] = new SQLValue_def();
- buffer[i].extractFromByteArray(buf);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLValue_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLValue_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLValue_def.java
deleted file mode 100644
index 5795e7c..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLValue_def.java
+++ /dev/null
@@ -1,55 +0,0 @@
-// @@@ 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;
-
-class SQLValue_def {
- int dataType;
- short dataInd;
- SQL_DataValue_def dataValue;
- int dataCharSet;
-
- // ----------------------------------------------------------
- int sizeof() {
- return TRANSPORT.size_int * 2 + TRANSPORT.size_short + dataValue.sizeof();
- }
-
- // ----------------------------------------------------------
- void insertIntoByteArray(LogicalByteArray buf) {
- buf.insertInt(dataType);
- buf.insertShort(dataInd);
- dataValue.insertIntoByteArray(buf);
- buf.insertInt(dataCharSet);
- }
-
- // ----------------------------------------------------------
- void extractFromByteArray(LogicalByteArray buf) throws SQLException {
- dataType = buf.extractInt();
- dataInd = buf.extractShort();
-
- dataValue = new SQL_DataValue_def();
- dataValue.extractFromByteArray(buf);
-
- dataCharSet = buf.extractInt();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLWarningOrError.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLWarningOrError.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLWarningOrError.java
deleted file mode 100644
index a95697e..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLWarningOrError.java
+++ /dev/null
@@ -1,47 +0,0 @@
-// @@@ 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;
-
-public class SQLWarningOrError {
- int rowId;
- int sqlCode;
- String text;
- String sqlState;
-
- public SQLWarningOrError(int rowId, int sqlCode, String text, String sqlState) {
- this.rowId = rowId;
- this.sqlCode = sqlCode;
- this.text = text;
- this.sqlState = sqlState;
- }
-
- public SQLWarningOrError(LogicalByteArray buf, InterfaceConnection ic, int charset)
- throws CharacterCodingException, UnsupportedCharsetException {
- rowId = buf.extractInt();
- sqlCode = buf.extractInt();
- text = ic.decodeBytes(buf.extractString(), charset);
- sqlState = new String(buf.extractByteArray(5));
- buf.extractByte(); // null terminator
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQL_DataValue_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQL_DataValue_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQL_DataValue_def.java
deleted file mode 100644
index edaada8..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQL_DataValue_def.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// @@@ 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.ByteBuffer;
-
-class SQL_DataValue_def {
- int length;
- byte[] buffer;
- ByteBuffer userBuffer;
-
- // ----------------------------------------------------------
- int sizeof() {
- return (buffer != null) ? TRANSPORT.size_int + buffer.length + 1 : TRANSPORT.size_int;
- }
-
- // ----------------------------------------------------------
- void insertIntoByteArray(LogicalByteArray buf) {
- if (buffer != null) {
- buf.insertInt(length);
- buf.insertByteArray(buffer, length);
- } else {
- buf.insertInt(0);
- }
- }
-
- // ----------------------------------------------------------
- void extractFromByteArray(LogicalByteArray buf) {
- length = buf.extractInt();
-
- if (length > 0) {
- buffer = buf.extractByteArray(length);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecClientMsgKeys.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecClientMsgKeys.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecClientMsgKeys.java
deleted file mode 100644
index a1e4d01..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecClientMsgKeys.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**********************************************************************
-// @@@ 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;
-
-public class SecClientMsgKeys
-{
- /**
- * Literal constants of java Security Client error messages.
- */
-
- public static final String ERR_RETRIEVE_KEY_FROM_FILE = "ERR_RETRIEVE_KEY_FROM_FILE";
- public static final String SESSION_KEY_GENERATION_FAILED = "SESSION_KEY_GENERATION_FAILED";
- public static final String INPUT_PARAMETER_IS_NULL = "INPUT_PARAMETER_IS_NULL";
- public static final String PWD_LENGTH_TOO_LONG = "PWD_LENGTH_TOO_LONG";
- public static final String ENCRYPTION_FAILED = "ENCRYPTION_FAILED";
- public static final String HMAC_FAILED = "HMAC_FAILED";
- public static final String PUBKEY_LENGTH_IS_ZERO = "PUBKEY_LENGTH_IS_ZERO";
- public static final String ERR_READ_CERT_FILE = "ERR_READ_CERT_FILE";
- public static final String FAILED_GENERATE_RANDOM_NUM = "FAILED_GENERATE_RANDOM_NUM";
- public static final String CIPHER_TEXT_LEN_NOT_EQUAL_KEY_LEN = "CIPHER_TEXT_LEN_NOT_EQUAL_KEY_LEN";
- public static final String BAD_MESSAGE_DIGEST_LEN = "BAD_MESSAGE_DIGEST_LEN";
- public static final String FILE_NOTFOUND = "FILE_NOTFOUND";
- public static final String DATA_ENCRYPTION_FAILED = "DATA_ENCRYPTION_FAILED";
- public static final String DECRYPTION_FAILED = "DECRYPTION_FAILED";
- public static final String ERR_WRITE_CERT_FILE = "ERR_WRITE_CERT_FILE";
- public static final String GET_LOCAL_HOST_NAME_FAILED = "GET_LOCAL_HOST_NAME_FAILED";
- public static final String BAD_TOKEN_LEN = "BAD_TOKEN_LEN";
- public static final String INCORRECT_TOKEN_FORMAT = "INCORRECT_TOKEN_FORMAT";
- public static final String HOME_ENVIRONMENT_VAR_IS_NULL = "HOME_ENVIRONMENT_VAR_IS_NULL";
- public static final String ERR_CREATE_SYMMETRIC_KEY = "ERR_CREATE_SYMMETRIC_KEY";
- public static final String FAILED_BUILDING_PWDKEY = "FAILED_BUILDING_PWDKEY";
- public static final String DIR_NOTFOUND = "DIR_NOTFOUND";
- public static final String ERR_OPEN_INPUT_FILE = "ERR_OPEN_INPUT_FILE";
- public static final String FILE_CORRUPTION = "FILE_CORRUPTION";
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecPwd.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecPwd.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecPwd.java
deleted file mode 100644
index 60da5da..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecPwd.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/**********************************************************************
-// @@@ 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 @@@
- //
- **********************************************************************/
-
-/**
- * class SecPwd - builds the password key, encrypts password,
- * creates HMAC message based on password, rolename
- * process info and time stamp. It also gets expiration
- * date of a certificate.
- *
- */
-
-package org.trafodion.jdbc.t4;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.sql.Connection;
-
-
-public class SecPwd {
- /**
- *
- *
- * @return SecPwd
- */
- public static SecPwd getInstance(Connection con, String directory, String fileName,
- String serverName, boolean spjMode, byte[] procInfo) throws SecurityException
- {
- if (con == null)
- throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"connection"});
- SecPwd secpwd = new SecPwd(directory, fileName, serverName, spjMode, procInfo);
-
- SymCrypto.insert(con, secpwd);
-
-
- return secpwd;
- }
-
- public static void removeInstance(Connection con)
- {
- SymCrypto.remove(con);
- }
-
- /**
- * Ctor for the SecPwd. There are two possible certificates: active
- * certificate and certificate that is going to be active.
- *
- * If autodownload is true, certificate will always come from the
- * server. In this case, only active certificate is used.
- *
- * If autodownload is false, active certificate is used to encrypt the
- * password. When there is a new certificate, it will be stored in
- * "certificate". As soon as this new certificate is activated on the
- * server, the current active certificate will become stale, and the new
- * certificate will be copied over and becomes the active certificate.
- *
- * If spjMode is true, the OS name is NONSTOP_KERNEL and the host name
- * is the same as the server name then just setSpj mode to true
- * and does nothing.
- *
- * @param directory
- * specifies the directory to locate the certificate. The default
- * value is %HOME% if set else %HOMEDRIVE%%HOMEPATH%.
- * @param fileName
- * specifies the certificate that is in waiting. The default
- * value is the first 5 characters of server name.
- * @param activeFileName
- * specifies the current certificate in use. The default value is
- * the first 5 character of server name + Active
- * @param spjMode
- * true - and if os.name == NSK and the host name
- * matches the local host - token case. Certificate is not
- * handled in this case.
- * false - handles certificate
- * @param serverName
- * server name for this certificate.
- * @throws SecurityException
- */
- private SecPwd(String directory, String fileName,
- String serverName, boolean spjMode, byte[] procInfo) throws SecurityException {
- String hostName = null;
-
- try {
- hostName = java.net.InetAddress.getLocalHost().getHostName();
- } catch (java.net.UnknownHostException ex) {
- throw new SecurityException(
- SecClientMsgKeys.GET_LOCAL_HOST_NAME_FAILED, null);
- }
-
- // check USERID env variable for MXCI testing of SPJs. If set use normal password
- // encryption
- if ((spjMode == true) &&
- // ((hostName.substring(0, 5)).compareToIgnoreCase(serverName.substring(0, 5)) == 0) &&
- (System.getenv("USERID") == null))// token
- {
- m_spjMode = spjMode;
- }
- else // password
- {
- if (procInfo == null)
- throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"procInfo"});
- // Stores procInfo with the time stamp for data message encryption used
- m_procInfo = new byte [SecdefsCommon.PROCINFO_SIZE + SecdefsCommon.TIMESTAMP_SIZE];
- System.arraycopy(procInfo, 0, m_procInfo, 0, (SecdefsCommon.PROCINFO_SIZE + SecdefsCommon.TIMESTAMP_SIZE));
- directory = (directory != null) ? directory : System.getenv("HOME");
- if (directory == null)
- {
- String hmdrive = System.getenv("HOMEDRIVE");
- String hmpath = System.getenv("HOMEPATH");
- if (hmdrive != null && hmpath != null)
- {
- directory = hmdrive + File.separator + hmpath;
- }
- else
- {
- directory = System.getProperty("user.home");
- if (directory == null)
- throw new SecurityException (SecClientMsgKeys.HOME_ENVIRONMENT_VAR_IS_NULL, null);
- }
- }
- fileName = (fileName != null) ? fileName : serverName + ".cer";
-
- File dir = new File(directory);
- if (dir.isDirectory() == false)
- throw new SecurityException(SecClientMsgKeys.DIR_NOTFOUND, new Object[]{dir.getPath()});
-
- certFile = new File(directory, fileName);
- }
- }
-
- /**
- * Processes the active certificate when spjMode is false
- * else does nothing. The certificate is processed by calling
- * the Security ctor to creates the password key and initializes it
- * with password id. Gets public key and the length of the public
- * key from the certificate file. Generates nonce and session key.
- * @throws SecurityException
- */
- public void openCertificate() throws SecurityException {
- if (m_spjMode == false) // do nothing for the token case
- m_sec = new Security(certFile);
- }
-
- /** This method builds the password key which consists 4 bytes of password id,
- * 128 bytes of role name which would be 128 spaces when role name is null,
- * 32 bytes of the digest message calculated using the session key on the data made up of
- * the procInfo and the encrypted data and 256 bytes (if the 2048 public key is used) or
- * 128 bytes (if the1024 public key is used) encrypted data calculated using the public key
- * on the plain text made up of the session key, the nonce and the password.
- * The password key is generated only when the spjMode is false. When
- * the spjMode is true, 26 bytes of the token is returned instead.
- * Builds password key
- * @param pwd
- * password to be encrypted
- * @param rolename
- * role name to build password key
- * @param procInfo
- * process information (PIN, CPU, segment name and time stamp)
- * @return pwdkey
- * returns the password key if spjMode is false
- * returns the token when spjMode is true
- * @throws SecurityException
- */
-
- public void encryptPwd(byte[] pwd, byte[] rolename, byte[] pwdkey) throws SecurityException {
- // rolename is optional so can be NULL
- if (pwd == null)
- throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"password"});
- if (pwdkey == null)
- throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"password key"});
- if (m_spjMode == true) // token
- {
- if (pwd.length != SecdefsCommon.TOKENSIZE)
- throw new SecurityException(SecClientMsgKeys.BAD_TOKEN_LEN, null);
- if ((pwd[0] != SecdefsCommon.USERTOKEN_ID_1)
- || (pwd[1] != SecdefsCommon.USERTOKEN_ID_2))
- throw new SecurityException(
- SecClientMsgKeys.INCORRECT_TOKEN_FORMAT, null);
- ByteBuffer.wrap(pwd).get(pwdkey, 0, SecdefsCommon.TOKENSIZE);
- }
- else
- {
- m_sec.encryptPwd(pwd, rolename, m_procInfo, pwdkey);
- }
- }
-
- /** Gets length of buffer for password encryption (public)
- * or the length of the token if it is the SPJ mode
- * @returns
- * If the spjMode is false
- * the length of the password key is returnd if success
- * 0 if failed
- * If spjMode is true
- * the length of the token is returned
- * @throws SecurityException
- */
- public int getPwdEBufferLen() throws SecurityException {
- if (m_spjMode == true)
- return SecdefsCommon.TOKENSIZE;
- else
- return m_sec.getPwdEBufferLen();
- }
-
- /** Gets the expiration date of the certificate
- * @return an array of bytes
- * presents the certificate's
- * expiration day in the format YYMMDDHHMMSS
- * or a zero length byte array if the it is in the SPJ mode
- */
- public byte[] getCertExpDate() {
- if (m_spjMode == false)
- return m_sec.getCertExpDate();
- else
- return new byte[0];
- }
-
- /**
- * When autodownload is on, client will download the certificate from server
- * when there is no certificate or certificate is stale.
- *
- * @param buf
- * content of the certificate pushed from server.
- */
- public void switchCertificate(byte[] buf) throws SecurityException {
- FileChannel outChannel = null;
- try {
- outChannel = new FileOutputStream(certFile).getChannel();
- outChannel.write(ByteBuffer.wrap(buf));
- } catch (Exception e) {
- throw new SecurityException(SecClientMsgKeys.ERR_WRITE_CERT_FILE, new Object[]{certFile});
- } finally {
- try {
- if (outChannel != null)
- outChannel.close();
- } catch (Exception e) {
- }
- }
- m_sec = new Security(certFile);
- }
-
- public byte[] getProcInfo()
- {
- return m_procInfo;
- }
-
- private Security m_sec;
- private File certFile;
- private boolean m_spjMode;
- private byte[] m_procInfo; //stores only 4 bytes pid + 4 bytes nid
-
-
-};
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecResourceBundle.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecResourceBundle.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecResourceBundle.java
deleted file mode 100644
index 5400d55..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecResourceBundle.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**********************************************************************
-// @@@ 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.ResourceBundle;
-import java.text.MessageFormat;
-
-public class SecResourceBundle
-{
-
- private static ResourceBundle rb = ResourceBundle.getBundle("secClient");
-
- /**
- * This method is used to obtain parameterized message text
- *
- */
- static String obtainMessageText (String key, Object[] params) {
- String pattern;
- try {
- pattern = rb.getString(key);
- } catch (Exception e) {
- return key;
- }
- if(pattern == null) {
- return key;
- }
- String message;
- try {
- message = MessageFormat.format(pattern, params);
- } catch (Exception e) {
- return pattern;
- }
- return message;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecdefsCommon.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecdefsCommon.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecdefsCommon.java
deleted file mode 100644
index f003588..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecdefsCommon.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**********************************************************************
-// @@@ 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;
-
-/**
- * This class contains defines
- *
- */
-
-public class SecdefsCommon {
-
- public static final int NONCE_RANDOM = 24;
- public static final int NONCE_SEQNUM = 8;
- public static final int NONCE_SIZE = (NONCE_RANDOM+NONCE_SEQNUM);
- public static final int SESSION_KEYLEN = 32;
- public static final int DIGEST_LENGTH = 32;
- // AES block size used in data encryption
- public static final int AES_BLOCKSIZE = 16;
- public static final int KEY_REFRESH = 30;
- public static final int TIMESTAMP_SIZE = 8;
- public static final int ROLENAME_SIZE = 128;
- public static final int PROCINFO_SIZE = 8;
- public static final int PWDID_SIZE = 4;
- public static final int EXPDATESIZE = 12;
- public static final int PWDKEY_SIZE_LESS_LOGINDATA = (PWDID_SIZE + ROLENAME_SIZE + DIGEST_LENGTH + TIMESTAMP_SIZE);
- // For public key encryption, the number of bytes
- // to be encrypted is 11 bytes less than the public key length
- public static final int UNUSEDBYTES = 11;
- public static final int TOKENSIZE = 68;
- // User tokens begin with byte values 3,4.
- public static final byte USERTOKEN_ID_1 = '\3'; // User token identifier, must be a sequence
- public static final byte USERTOKEN_ID_2 = '\4'; // not allowed in password
- public static final int DATA_BLOCK_BIT_SIZE = 128; // data encryption block size in bits. Java
- // supports block size of 128 bits for AES
- // algorithm using cryptographic key of 256 bits only.
-
-
- // Structure used to describe layout of Encrypted data
- // in login message
- public static class LoginData {
- //000 Session key
- byte[] session_key = new byte[SecdefsCommon.SESSION_KEYLEN];
- //032 Nonce
- byte[] nonce = new byte[SecdefsCommon.NONCE_SIZE];
- Byte password; // 064 User's password
- } // 128 for 1024 or 256 for 2048
-
-// Structure used to describe layout of password key
-
- public static class PwdKey {
- //000 Key identifier, binary values 1,2,3,4
- //or 1,2,2,4 keys, optional mode only
- byte[] id= new byte[SecdefsCommon.PWDID_SIZE];
- //004 RolenameA
- byte[] rolename = new byte[SecdefsCommon.ROLENAME_SIZE];
- //132 Digest of server id and encrypted data
- byte[] digest = new byte[SecdefsCommon.DIGEST_LENGTH];
- // 164 time stamp
- byte[] ts = new byte[SecdefsCommon.TIMESTAMP_SIZE];
- LoginData data; //172 Encrypted data
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Security.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Security.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Security.java
deleted file mode 100644
index 1a02021..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Security.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/**********************************************************************
-// @@@ 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.ByteBuffer;
-import java.security.SecureRandom;
-import java.util.Date;
-import java.security.NoSuchAlgorithmException;
-import java.io.File;
-import javax.crypto.SecretKey;
-
-
-
-class Security
-{
- public static final Cipher cipher = org.trafodion.jdbc.t4.Cipher.getInstance();
- public static final MessageDigest msgDigest = MessageDigest.getInstance();
-
- /** Ctor - Creates the password key and initializes it with
- * password id. Gets public key and the length of the public key
- * from the certificate file. Generates nonce and session key.
- * @param cert_file - fully qualified name of certificate file
- * @throw SecurityException
- */
- public Security(File certFile) throws SecurityException
- {
- // m_encrypted = 0;
- m_pwdkey = new SecdefsCommon.PwdKey();
- m_pwdkey.data = new SecdefsCommon.LoginData();
- m_pwdkey.id[0] = '\1';
- m_pwdkey.id[1] = '\2';
- m_pwdkey.id[2] = '\3';
- m_pwdkey.id[3] = '\4';
-
- try {
- m_keyObj = new Key();
- m_cert = new Certificate(certFile);
- m_keyObj.getPubKeyFromFile(m_cert.getCert());
- generateSessionKey();
- }catch (SecurityException se) {
- throw se;
- }
- }
-
- /** This method builds the password key which consists 4 bytes of password id,
- * 128 bytes of role name which would be 128 spaces when role name is null,
- * 32 bytes of the digest message calculated using the session key on the data made up of
- * the procInfo and the encrypted data and 256 bytes (if the 2048 public key is used) or
- * 128 bytes (if the1024 public key is used) encrypted data calculated using the public key
- * on the plain text made up of the session key, the nonce and the password.
- * Builds password key
- * @param pwd
- * password to be encrypted
- * @param rolename
- * role name to build password key
- * @param procInfo
- * process information (PIN, CPU, segment name and time stamp)
- * @return pwdkey
- * returned password key
- * @throws SecurityException
- */
- public void encryptPwd(byte[] pwd, byte[] rolename, byte[] procInfo,
- byte[] pwdkey)
- throws SecurityException
- {
- // Get public key length
- int pubKeyLen = m_keyObj.getPubKeyLen();
- int maxPlainTextLen = pubKeyLen - SecdefsCommon.UNUSEDBYTES;
-
- // Password + nonce + session key can't be longer than the public
- // key's length
- if ((SecdefsCommon.NONCE_SIZE + SecdefsCommon.SESSION_KEYLEN
- + pwd.length) > maxPlainTextLen)
- throw new SecurityException(SecClientMsgKeys.
- PWD_LENGTH_TOO_LONG, null);
-
- byte[] to_encrypt = new byte[SecdefsCommon.SESSION_KEYLEN +
- SecdefsCommon.NONCE_SIZE + pwd.length];
- byte[] cipherText = new byte[pubKeyLen];
- byte[] to_digest = new byte[SecdefsCommon.PROCINFO_SIZE +
- SecdefsCommon.TIMESTAMP_SIZE + pubKeyLen];
- byte[] digestedMsg = new byte[SecdefsCommon.DIGEST_LENGTH];
-
- try {
- // Build password key
- // Copy 4 bytes of id
- System.arraycopy(m_pwdkey.id, 0, pwdkey, 0, SecdefsCommon.PWDID_SIZE);
- // Copy rolename
- if (rolename != null)
- System.arraycopy(rolename, 0, pwdkey, SecdefsCommon.PWDID_SIZE,
- rolename.length);
- // Copy 12 bytes of procInfo and 8 bytes of timestamp to
- // password key store procInfo in the digest starting from
- // digest[20]
- System.arraycopy(procInfo, 0, pwdkey, (SecdefsCommon.PWDID_SIZE +
- SecdefsCommon.ROLENAME_SIZE + SecdefsCommon.DIGEST_LENGTH -
- SecdefsCommon.PROCINFO_SIZE), (SecdefsCommon.PROCINFO_SIZE +
- SecdefsCommon.TIMESTAMP_SIZE));
-
- // Build plain text to encrypt
- System.arraycopy(m_pwdkey.data.session_key, 0, to_encrypt, 0,
- SecdefsCommon.SESSION_KEYLEN);
- System.arraycopy(m_pwdkey.data.nonce, 0, to_encrypt,
- SecdefsCommon.SESSION_KEYLEN, SecdefsCommon.NONCE_SIZE);
- System.arraycopy(pwd, 0, to_encrypt,
- (SecdefsCommon.SESSION_KEYLEN + SecdefsCommon.NONCE_SIZE), pwd.length);
-
- // Encrypt the data
- int cipherTextLen = cipher.encrypt(to_encrypt, cipherText,
- (java.security.Key)(m_keyObj.getPubKey()));
-
- if(cipherTextLen != pubKeyLen)
- throw new SecurityException(SecClientMsgKeys.
- CIPHER_TEXT_LEN_NOT_EQUAL_KEY_LEN, null);
-
- // Copy cipherText to pwdkey
- System.arraycopy(cipherText, 0, pwdkey,
- SecdefsCommon.PWDKEY_SIZE_LESS_LOGINDATA, cipherTextLen);
-
- // Create digest
- // Get bytes from digest[20] on
- System.arraycopy(pwdkey, (SecdefsCommon.PWDKEY_SIZE_LESS_LOGINDATA -
- SecdefsCommon.TIMESTAMP_SIZE - SecdefsCommon.PROCINFO_SIZE),
- to_digest, 0, (SecdefsCommon.PROCINFO_SIZE +
- SecdefsCommon.TIMESTAMP_SIZE + cipherTextLen));
-
- int mdLen = msgDigest.digest(m_pwdkey.data.session_key,
- to_digest, digestedMsg);
-
- if (mdLen != SecdefsCommon.DIGEST_LENGTH)
- throw new SecurityException(SecClientMsgKeys.
- BAD_MESSAGE_DIGEST_LEN, null);
-
- // copy digestedMsg into pwdkey
- System.arraycopy(digestedMsg, 0, pwdkey,
- (SecdefsCommon.PWDKEY_SIZE_LESS_LOGINDATA
- - SecdefsCommon.TIMESTAMP_SIZE - SecdefsCommon.DIGEST_LENGTH), mdLen );
-
- }catch (SecurityException se) {
- throw se;
- }catch (Exception e) {
- throw new SecurityException(SecClientMsgKeys.FAILED_BUILDING_PWDKEY, null);
- }finally {
- if (to_digest != null)
- to_digest = null;
- if (digestedMsg != null)
- digestedMsg = null;
- if (to_encrypt != null)
- to_encrypt = null;
- }
- }
-
- /** Encrypts the data using AES256 algorithm.
- *
- * @param data - data to be encrypted
- * @return array of bytes of 2 bytes PIN,
- * 2 bytes of CPU, 8 bytes of seg_name
- * and the encrypted data
- * @throw SecurityException
- */
-
- public byte[] encryptData(byte[] data) throws SecurityException
- {
- //Creates a secret key from the session key
- byte[] skey = new byte[SecdefsCommon.AES_BLOCKSIZE];
- System.arraycopy(m_pwdkey.data.session_key, SecdefsCommon.AES_BLOCKSIZE,
- skey, 0, SecdefsCommon.AES_BLOCKSIZE);
- SecretKey seckey = Key.generateSymmetricKey(skey);
- byte [] iv = new byte [SecdefsCommon.AES_BLOCKSIZE];
- System.arraycopy(m_pwdkey.data.nonce, SecdefsCommon.AES_BLOCKSIZE,
- iv, 0, SecdefsCommon.AES_BLOCKSIZE);
- m_cipher = Cipher.getEASInstance("AES/CBC/PKCS5Padding");
- return Cipher.encryptData(data, seckey, iv, m_cipher);
- }
-
- // Currently not implemented
- // Generate message digest
- // str - message to digest
- // hmacMsg - Hashed message in bytes
- // hmacMsgLen - Length of hashed message
- public void HMAC_Message_Generate(byte[] str, byte[] hmacMsg,
- int hmacMsgLen) throws SecurityException
- {
- // Not implemented yet
- }
-
- // Currently not implemented
- // Verify message digest
- // str - message digest
- // length - message digest length
- public boolean HMAC_Message_Verify(byte[] str) throws SecurityException
- {
- // Not implemented yet
- return false;
- }
-
- /** increment the nonce sequence
- *
- */
- public void incrementNonceSeq ()
- {
- m_nonceSeq++;
- }
-
- /** Gets length of buffer for password encryption (public)
- * @Return pass word key length if success and 0 if failed
- * @throw SecurityException
- */
- public int getPwdEBufferLen() throws SecurityException
- {
- int pubKLen = m_keyObj.getPubKeyLen();
- if(pubKLen <= 0)
- throw new SecurityException(SecClientMsgKeys.
- PUBKEY_LENGTH_IS_ZERO, null);
- else
- return (pubKLen + SecdefsCommon.PWDKEY_SIZE_LESS_LOGINDATA);
- }
-
- /** Gets certificate's expiration date
- * @Return an array of bytes represents the certificate's
- * expiration day in the string format YYMMDDHHMMSS
- */
- public byte[] getCertExpDate()
- {
- return m_cert.getCertExpDate();
- }
-
- // Generates session key and nonce
- private void generateSessionKey() throws SecurityException
- {
- //try {
- SecureRandom random = new SecureRandom();
- try {
- random.setSeed(System.currentTimeMillis());
-
- random.setSeed(Runtime.getRuntime().freeMemory());
- random.setSeed(Runtime.getRuntime().totalMemory());
- random.setSeed(Runtime.getRuntime().maxMemory());
-
- String p = null;
-
- p = System.getProperty("java.version", "unknown java version");
- random.setSeed(p.getBytes());
- p = System.getProperty("java.vendor", "unknown vendor");
- random.setSeed(p.getBytes());
- p = System.getProperty("os.name", "unknown os");
- random.setSeed(p.getBytes());
- p = System.getProperty("os.version", "unknown os version");
- random.setSeed(p.getBytes());
-
- // Add current time again
-
- random.setSeed(System.currentTimeMillis());
- }
- catch(Exception e ) {
- // Ignore
- }
- byte bytes[] = new byte[SecdefsCommon.SESSION_KEYLEN +
- SecdefsCommon.NONCE_SIZE];
- synchronized(random) {
- random.nextBytes(bytes);
- }
-
- // Assign bytes to members m_pwdkey.data.session_key
- // and m_pwdkey.data.nonce
-
- System.arraycopy(bytes, 0, m_pwdkey.data.session_key, 0, SecdefsCommon.SESSION_KEYLEN);
- System.arraycopy(bytes, SecdefsCommon.SESSION_KEYLEN, m_pwdkey.data.nonce, 0, SecdefsCommon.NONCE_SIZE);
-
- m_nonceSeq = (ByteBuffer.wrap(m_pwdkey.data.nonce)).getLong(
- SecdefsCommon.SESSION_KEYLEN -
- SecdefsCommon.NONCE_SEQNUM);
-
- // Set time when session key is generated
- m_keyTime = (new Date()).getTime();
- /*}catch (NoSuchAlgorithmException nae) {
- throw new SecurityException(SecClientMsgKeys.SESSION_KEY_GENERATION_FAILED, null);
- }*/
- }
-
- // encryption is required or not for replied message 0-yes, 1-no
- //int m_encrypted;
- // security option - mandatory - 1 or undocumented option - 0
- // Time when session key is generated
- private long m_keyTime;
- // sequence nonce used in nonce increment
- // Need to use 64 bit number type here
- private long m_nonceSeq;
- // certificate
- private Certificate m_cert;
- // key
- private Key m_keyObj;
- // password key
- private SecdefsCommon.PwdKey m_pwdkey;
- private javax.crypto.Cipher m_cipher;
-
-};
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecurityException.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecurityException.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecurityException.java
deleted file mode 100644
index 64d1a3d..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecurityException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**********************************************************************
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-//
- **********************************************************************/
-package org.trafodion.jdbc.t4;
-
-import java.lang.String;
-import java.lang.Integer;
-import java.sql.SQLException;
-
-public class SecurityException extends SQLException
-{
- private static final String SQLState = "38001";
-
- public SecurityException(String key, Object[] params)
- {
- // Get the text message from the file secClient.properties.
- // Parse the message for the error message and error number.
- this((SecResourceBundle.obtainMessageText(key, params)).substring(6),
- Integer.parseInt((SecResourceBundle.obtainMessageText(key, params)).substring(0, 5)));
- }
-
- public SecurityException(String errMsg, int errNum)
- {
- super(errMsg, SQLState, errNum);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SetConnectionOptionMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SetConnectionOptionMessage.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SetConnectionOptionMessage.java
deleted file mode 100644
index 8ee7c6c..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SetConnectionOptionMessage.java
+++ /dev/null
@@ -1,50 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class SetConnectionOptionMessage {
- // ----------------------------------------------------------
- static LogicalByteArray marshal(int dialogueId, short connectionOption, int optionValueNum, String optionValueStr,
- InterfaceConnection ic) throws CharacterCodingException, UnsupportedCharsetException {
- int wlength = Header.sizeOf();
- LogicalByteArray buf;
-
- byte[] optionValueBytes = ic.encodeString(optionValueStr, InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- wlength += TRANSPORT.size_int; // dialogueId
- wlength += TRANSPORT.size_short; // connectionOption
- wlength += TRANSPORT.size_int; // optionValueNum
- wlength += TRANSPORT.size_bytes(optionValueBytes); // optionValueStr
-
- buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
-
- buf.insertInt(dialogueId);
- buf.insertShort(connectionOption);
- buf.insertInt(optionValueNum);
- buf.insertString(optionValueBytes);
-
- return buf;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SetConnectionOptionReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SetConnectionOptionReply.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SetConnectionOptionReply.java
deleted file mode 100644
index fa3ecc0..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SetConnectionOptionReply.java
+++ /dev/null
@@ -1,45 +0,0 @@
-// @@@ 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 SetConnectionOptionReply {
- odbc_SQLSvc_SetConnectionOption_exc_ m_p1;
- ERROR_DESC_LIST_def m_p2;
-
- // -------------------------------------------------------------
- SetConnectionOptionReply(LogicalByteArray buf, String addr, InterfaceConnection ic)
- throws CharacterCodingException, UnsupportedCharsetException, SQLException {
- buf.setLocation(Header.sizeOf());
-
- m_p1 = new odbc_SQLSvc_SetConnectionOption_exc_();
- m_p1.extractFromByteArray(buf, addr, ic);
-
- if (m_p1.exception_nr == TRANSPORT.CEE_SUCCESS) {
- m_p2 = new ERROR_DESC_LIST_def();
- m_p2.extractFromByteArray(buf, ic);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SymCrypto.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SymCrypto.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SymCrypto.java
deleted file mode 100644
index a0e10ad..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SymCrypto.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**********************************************************************
-// @@@ 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 @@@
- //
- **********************************************************************/
-
-/**
- * class SymCrypto - Stores connections and correspondence SecPwd
- * objects.
- */
-
-package org.trafodion.jdbc.t4;
-
-import java.util.HashMap;
-import java.sql.Connection;
-
-public class SymCrypto
-{
- static HashMap<Connection, SymCrypto> storage = new HashMap<Connection, SymCrypto> ();
-
- /**
- * Ctor -
- * @param secpwd
- */
- private SymCrypto(SecPwd secpwd)
- {
- m_secPwd = secpwd;
- }
-
- /**
- * Returns the SymCrypto object correspondence to the connection passed in
- * @param con
- * @return the value to which the SymCrypto object maps the connection passed in or
- * null if the map contains no mapping for the connection.
- * @throws SecurityException
- */
- public static SymCrypto getInstance(Connection con) throws SecurityException
- {
- if (con == null)
- throw new SecurityException (SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"connection"});
- return storage.get(con);
- }
-
- /**
- * Creates and SymCrypto object from the SecPwd object and inserts the connection
- * and the equivalent SymCRypto object into the hash table storage. If the table previously
- * contained a mapping for the connection, the old value is replaced.
- * @param con - the JDBC connection
- * @param secpwd - the SecPwd object associated with the JDBC connection
- */
- public static void insert(Connection con, SecPwd secpwd)
- {
- SymCrypto symcrypto = new SymCrypto(secpwd);
- storage.put(con, symcrypto);
- }
-
- /**
- * Removed the mapping of this JDBC connection from the hash table if present
- * @param con - JDBC connection whose entry is to be removed from the hash table storage
- */
- public static void remove(Connection con)
- {
- if (con != null)
- storage.remove(con);
- }
-
- private SecPwd m_secPwd;
-
-}
[45/60] incubator-trafodion git commit: Merge branch 'master' of
github.com:apache/incubator-trafodion into wrkbrnch
Posted by db...@apache.org.
Merge branch 'master' of github.com:apache/incubator-trafodion into wrkbrnch
Conflicts:
core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/BaseRow.java
core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InsertRow.java
core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Row.java
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/a0f21cde
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/a0f21cde
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/a0f21cde
Branch: refs/heads/master
Commit: a0f21cde508487d96f62bcf4c930f015e9fa57b8
Parents: 90667ee 119d471
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Tue Apr 19 18:07:06 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Tue Apr 19 18:07:06 2016 +0000
----------------------------------------------------------------------
NOTICE | 2 +-
.../java/org/trafodion/jdbc/t4/BaseRow.java | 65 ---
.../java/org/trafodion/jdbc/t4/InsertRow.java | 82 ----
.../trafodion/jdbc/t4/InterfaceResultSet.java | 30 +-
.../java/org/trafodion/jdbc/t4/ObjectArray.java | 86 ++++
.../main/java/org/trafodion/jdbc/t4/Row.java | 233 ----------
.../trafodion/jdbc/t4/T4DatabaseMetaData.java | 26 +-
.../jdbc/t4/TrafT4PreparedStatement.java | 2 +-
.../org/trafodion/jdbc/t4/TrafT4ResultSet.java | 435 ++++---------------
.../org/trafodion/jdbc/t4/TrafT4Statement.java | 2 +-
core/sqf/sqenvcom.sh | 2 +-
.../regionserver/transactional/IdTmId.java | 10 -
.../odbcclient/DSNConverter/DSNConverter.def | 2 +-
win-odbc64/odbcclient/Drvr35Res/Drvr35Res.rc | 2 +-
.../TranslationDll/TranslationDll.def | 2 +-
.../odbcclient/TranslationDll/TranslationDll.rc | 2 +-
win-odbc64/odbcclient/drvr35/TCPIPV4/TCPIPV4.RC | 2 +-
win-odbc64/odbcclient/drvr35/TCPIPV6/TCPIPV6.RC | 2 +-
win-odbc64/odbcclient/drvr35/drvr35.rc | 2 +-
win-odbc64/odbcclient/drvr35adm/drvr35adm.rc | 2 +-
win-odbc64/odbcclient/drvr35msg/DrvMsg35.rc | 2 +-
21 files changed, 203 insertions(+), 790 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a0f21cde/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java
----------------------------------------------------------------------
diff --cc core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java
index 0d7c0b4,0000000..8dbbc2f
mode 100644,000000..100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java
@@@ -1,927 -1,0 +1,927 @@@
+// @@@ 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;
+import java.math.BigInteger;
+import java.sql.Date;
+import java.sql.SQLException;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.text.DecimalFormat;
+import java.text.FieldPosition;
+import java.util.Properties;
+import java.util.logging.Level;
+
+class InterfaceResultSet {
+ InterfaceConnection ic_;
+ String stmtLabel_;
+
+ /* CHAR/CHARACTER */
+ static final int SQLTYPECODE_CHAR = 1;
+
+ /* NUMERIC */
+ static final int SQLTYPECODE_NUMERIC = 2;
+ static final int SQLTYPECODE_NUMERIC_UNSIGNED = -201;
+
+ /* DECIMAL */
+ static final int SQLTYPECODE_DECIMAL = 3;
+
+ static final int SQLTYPECODE_DECIMAL_UNSIGNED = -301;
+ static final int SQLTYPECODE_DECIMAL_LARGE = -302;
+ static final int SQLTYPECODE_DECIMAL_LARGE_UNSIGNED = -303;
+
+ /* INTEGER/INT */
+ static final int SQLTYPECODE_INTEGER = 4;
+
+ static final int SQLTYPECODE_INTEGER_UNSIGNED = -401;
+ static final int SQLTYPECODE_LARGEINT = -402;
+
+ /* SMALLINT */
+ static final int SQLTYPECODE_SMALLINT = 5;
+
+ static final int SQLTYPECODE_SMALLINT_UNSIGNED = -502;
+
+ static final int SQLTYPECODE_BPINT_UNSIGNED = -503;
+
+ /*
+ * DOUBLE depending on precision
+ */
+ static final int SQLTYPECODE_FLOAT = 6;
+
+ /*
+ */
+ static final int SQLTYPECODE_REAL = 7;
+
+ /*
+ */
+ static final int SQLTYPECODE_DOUBLE = 8;
+
+ /* DATE,TIME,TIMESTAMP */
+ static final int SQLTYPECODE_DATETIME = 9;
+
+ /* TIMESTAMP */
+ static final int SQLTYPECODE_INTERVAL = 10;
+
+ /* no ANSI value 11 */
+
+ /* VARCHAR/CHARACTER VARYING */
+ static final int SQLTYPECODE_VARCHAR = 12;
+
+ /* SQL/MP stype VARCHAR with length prefix:
+ * */
+ static final int SQLTYPECODE_VARCHAR_WITH_LENGTH = -601;
+ static final int SQLTYPECODE_BLOB = -602;
+ static final int SQLTYPECODE_CLOB = -603;
+
+ /* LONG VARCHAR/ODBC CHARACTER VARYING */
+ static final int SQLTYPECODE_VARCHAR_LONG = -1; /* ## NEGATIVE??? */
+
+ /* no ANSI value 13 */
+
+ /* BIT */
+ static final int SQLTYPECODE_BIT = 14; /* not supported */
+
+ /* BIT VARYING */
+ static final int SQLTYPECODE_BITVAR = 15; /* not supported */
+
+ /* NCHAR -- CHAR(n) CHARACTER SET s -- where s uses two bytes per char */
+ static final int SQLTYPECODE_CHAR_DBLBYTE = 16;
+
+ /* NCHAR VARYING -- VARCHAR(n) CHARACTER SET s -- s uses 2 bytes per char */
+ static final int SQLTYPECODE_VARCHAR_DBLBYTE = 17;
+
+ /* Date/Time/TimeStamp related constants */
+ static final int SQLDTCODE_DATE = 1;
+ static final int SQLDTCODE_TIME = 2;
+ static final int SQLDTCODE_TIMESTAMP = 3;
+ static final int SQLDTCODE_MPDATETIME = 4;
+ static final int dateLength = 10;
+ static final int timeLength = 8;
+ static final int timestampLength = 26;
+
+ T4ResultSet t4resultSet_;
+
+ static Properties javaLangToJavaNio = null;
+
+ TrafT4ResultSet rs_;
+
+ InterfaceResultSet(TrafT4ResultSet rs) throws SQLException {
+ this.ic_ = ((TrafT4Connection) rs.connection_).getServerHandle();
+ stmtLabel_ = rs.stmtLabel_;
+ t4resultSet_ = new T4ResultSet(this);
+ rs_ = rs;
+ };
+
+ // -------------------------------------------------------------------
+ // from nskieee.cpp -- find the length for the data based on datatype
+ //
+ static int dataLengthFetchPerf(int SQLDataType, int SQLDateTimeCode, int SQLOctetLength, int maxRowLen,
+ int bufferLen, int ODBCDataType, int ODBCPrecision) {
+ int allocLength = 0;
+ switch (SQLDataType) {
+ case SQLTYPECODE_INTERVAL:
+ allocLength = SQLOctetLength;
+ break;
+ case SQLTYPECODE_VARCHAR_WITH_LENGTH:
+ case SQLTYPECODE_VARCHAR_LONG:
+ case SQLTYPECODE_VARCHAR_DBLBYTE:
+ case SQLTYPECODE_BITVAR:
+ case SQLTYPECODE_BLOB:
+ case SQLTYPECODE_CLOB:
+ allocLength = bufferLen + 2;
+ break;
+ case SQLTYPECODE_CHAR:
+
+ // allocLength = SQLOctetLength - 1; // no null at the end
+ allocLength = SQLOctetLength;
+ if (maxRowLen > 0) {
+ allocLength = (allocLength > maxRowLen) ? (maxRowLen + 1) : (allocLength);
+ }
+ break;
+ case SQLTYPECODE_BIT:
+ case SQLTYPECODE_CHAR_DBLBYTE:
+ case SQLTYPECODE_VARCHAR:
+ allocLength = SQLOctetLength - 1; // no null at the end
+ if (maxRowLen > 0) {
+ allocLength = (allocLength > maxRowLen) ? (maxRowLen + 1) : (allocLength);
+ }
+ break;
+ case SQLTYPECODE_DATETIME:
+ switch (SQLDateTimeCode) {
+ case SQLDTCODE_DATE:
+ allocLength = dateLength;
+ break;
+ case SQLDTCODE_TIME:
+ if (ODBCDataType == java.sql.Types.OTHER) // For
+ // HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION
+ {
+ allocLength = SQLOctetLength;
+ } else {
+ allocLength = timeLength;
+ }
+ break;
+ case SQLDTCODE_TIMESTAMP:
+
+ /*
+ * allocLength = timestampLength; if (SQLOctetLength <
+ * timestampLength) { allocLength = 19; // timestamp without
+ * fraction }
+ */
+ allocLength = ODBCPrecision;
+ break;
+ default:
+ allocLength = SQLOctetLength;
+ break;
+ }
+
+ break;
+ default:
+ allocLength = SQLOctetLength; // exclude nullable
+ break;
+ }
+ return allocLength;
+ }
+
+ // -------------------------------------------------------------------
+ // get the column value data in String format
+ Object getFetchString(TrafT4Connection conn, int scale, int SQLDataType, int SQLDatetimeCode, int FSDataType,
+ byte[] ibuffer, int byteIndex, int byteLen, int SQLcharset, int ODBCDataType) throws SQLException {
+ Object retObj;
+ String tmpStr;
+ byte[] tbuffer;
+ BigDecimal tmpbd;
+
+ switch (SQLDataType) {
+
+ case SQLTYPECODE_CHAR:
+ tbuffer = new byte[byteLen];
+ System.arraycopy(ibuffer, byteIndex, tbuffer, 0, byteLen);
+ retObj = tbuffer;
+ break;
+ case SQLTYPECODE_VARCHAR:
+ tbuffer = new byte[byteLen];
+ System.arraycopy(ibuffer, byteIndex, tbuffer, 0, byteLen);
+ retObj = tbuffer;
+ break;
+ case SQLTYPECODE_INTERVAL:
+ tbuffer = new byte[byteLen];
+ System.arraycopy(ibuffer, byteIndex, tbuffer, 0, byteLen);
+ retObj = tbuffer;
+ break;
+ case SQLTYPECODE_VARCHAR_WITH_LENGTH:
+ case SQLTYPECODE_VARCHAR_LONG:
+ case SQLTYPECODE_BLOB:
+ case SQLTYPECODE_CLOB:
+ tbuffer = new byte[byteLen - 2];
+ System.arraycopy(ibuffer, byteIndex + 2, tbuffer, 0, byteLen - 2);
+
+ // retObj = new String(tbuffer); Swastik for LOB Support 10/29/2004
+ retObj = tbuffer;
+ break;
+ case SQLTYPECODE_DATETIME:
+ tmpStr = new String(Bytes.read_chars(ibuffer, byteIndex, byteLen));
+ switch (SQLDatetimeCode) {
+ case SQLDTCODE_DATE:
+ retObj = Date.valueOf(tmpStr);
+ break;
+ case SQLDTCODE_TIMESTAMP:
+ retObj = Timestamp.valueOf(tmpStr);
+ break;
+ case SQLDTCODE_TIME:
+
+ // Need to add code here to check if it's
+ // HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION
+ if (ODBCDataType != java.sql.Types.OTHER) {
+ retObj = Time.valueOf(tmpStr);
+ break;
+ } else {
+ // Do default processing as it is
+ // HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION
+ }
+ default:
+ retObj = tmpStr;
+ break;
+ }
+ break;
+ case SQLTYPECODE_SMALLINT:
+ short sValue = Bytes.extractShort(ibuffer, byteIndex, this.ic_.getByteSwap());
+ retObj = new Short(sValue);
+ if (scale > 0) {
+ retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
+ }
+ break;
+ case SQLTYPECODE_SMALLINT_UNSIGNED:
+ retObj = new Integer(Bytes.extractUShort(ibuffer, byteIndex, this.ic_.getByteSwap()));
+ if (scale > 0) {
+ retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
+ }
+ break;
+ case SQLTYPECODE_INTEGER:
+ retObj = new Integer(Bytes.extractInt(ibuffer, byteIndex, this.ic_.getByteSwap()));
+ if (scale > 0) {
+ retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
+ }
+ break;
+ case SQLTYPECODE_INTEGER_UNSIGNED:
+ retObj = new Long(Bytes.extractUInt(ibuffer, byteIndex, this.ic_.getByteSwap()));
+ if (scale > 0) {
+ retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
+ }
+ break;
+ case SQLTYPECODE_LARGEINT:
+ tbuffer = new byte[byteLen];
+ System.arraycopy(ibuffer, byteIndex, tbuffer, 0, byteLen);
+ retObj = new BigInteger(tbuffer);
+ if (scale > 0) {
+ retObj = new BigDecimal((BigInteger) retObj, scale);
+ }
+ break;
+ case SQLTYPECODE_NUMERIC:
+ case SQLTYPECODE_NUMERIC_UNSIGNED:
+ switch (FSDataType) {
+ case 130:
+ case 131:
+ tmpStr = String.valueOf(Bytes.extractShort(ibuffer, byteIndex, this.ic_.getByteSwap()));
+ break;
+ case 132:
+ case 133:
+ tmpStr = String.valueOf(Bytes.extractInt(ibuffer, byteIndex, this.ic_.getByteSwap()));
+ break;
+ case 134:
+ tmpStr = String.valueOf(Bytes.extractLong(ibuffer, byteIndex, this.ic_.getByteSwap()));
+ break;
+ default:
+ throw HPT4Messages.createSQLException(conn.props_, conn.getLocale(), "restricted_data_type", null);
+ }
+ retObj = new BigDecimal((new BigInteger(tmpStr)), scale);
+ break;
+ case SQLTYPECODE_DECIMAL:
+ case SQLTYPECODE_DECIMAL_UNSIGNED:
+ case SQLTYPECODE_DECIMAL_LARGE:
+ case SQLTYPECODE_DECIMAL_LARGE_UNSIGNED:
+ String retStr;
+
+ // check if the sign is minus (-80)
+ byte sign = (byte) (ibuffer[byteIndex] & (byte) (-80));
+
+ // first byte = inbyte - (-80)
+ if (sign == (byte) (-80)) {
+ byte firstByte = (byte) (ibuffer[byteIndex] - (byte) (-80));
+ retStr = "-" + firstByte + String.valueOf(Bytes.read_chars(ibuffer, byteIndex + 1, byteLen - 1));
+ } else {
+ retStr = String.valueOf(Bytes.read_chars(ibuffer, byteIndex, byteLen));
+ }
+ retObj = new BigDecimal(new BigInteger(retStr), scale);
+ break;
+ case SQLTYPECODE_REAL:
+ retObj = new Float(Float.intBitsToFloat(Bytes.extractInt(ibuffer, byteIndex, this.ic_.getByteSwap())));
+ break;
+ case SQLTYPECODE_DOUBLE:
+ case SQLTYPECODE_FLOAT:
+ retObj = new Double(Double.longBitsToDouble(Bytes.extractLong(ibuffer, byteIndex, this.ic_.getByteSwap())));
+ break;
+ case SQLTYPECODE_BIT:
+ case SQLTYPECODE_BITVAR:
+ case SQLTYPECODE_BPINT_UNSIGNED:
+ default:
+ throw HPT4Messages.createSQLException(conn.props_, conn.getLocale(), "restricted_data_type", null);
+ }
+ return retObj;
+ } // end getFetchString
+
+ private static String padZero(long i, int len) {
+ String s = String.valueOf(i);
+
+ while (s.length() < len)
+ s = '0' + s;
+
+ return s;
+ }
+
+ // -------------------------------------------------------------------
+ // get the column value data from Execute2 in String format
+ static Object getExecute2FetchString(TrafT4Connection conn, HPT4Desc desc, byte[] values, int noNullValue,
+ int ODBCDataType, boolean useOldDateFormat, boolean swap) throws SQLException {
+ Object retObj;
+ String tmpStr;
+ byte[] tbuffer;
+ BigDecimal tmpbd;
+ int length;
+ int year, month, day, hour, minute, second;
+ long nanoSeconds;
+
+ switch (desc.sqlDataType_) {
+ case SQLTYPECODE_CHAR:
+ length = desc.sqlOctetLength_;
+ tbuffer = new byte[length];
+ System.arraycopy(values, noNullValue, tbuffer, 0, length);
+ retObj = tbuffer;
+ break;
+ case SQLTYPECODE_VARCHAR:
+ case SQLTYPECODE_VARCHAR_WITH_LENGTH:
+ case SQLTYPECODE_VARCHAR_LONG:
+ case SQLTYPECODE_BLOB:
+ case SQLTYPECODE_CLOB:
+ boolean shortLength = desc.precision_ < Math.pow(2, 15);
+ int dataOffset = noNullValue + ((shortLength) ? 2 : 4);
+
+ length = (shortLength) ? Bytes.extractShort(values, noNullValue, swap) : Bytes.extractInt(values, noNullValue, swap);
+
+ tbuffer = new byte[length];
+ int len = values.length - (dataOffset);
+ System.arraycopy(values, (dataOffset), tbuffer, 0, (length > len) ? len : length);
+ retObj = tbuffer;
+ break;
+ case SQLTYPECODE_INTERVAL:
+ length = desc.sqlOctetLength_;
+ tbuffer = new byte[length];
+ System.arraycopy(values, noNullValue, tbuffer, 0, length);
+ retObj = tbuffer;
+ break;
+ case SQLTYPECODE_DATETIME:
+ switch (desc.sqlDatetimeCode_) {
+ case SQLDTCODE_DATE:
+ if (!useOldDateFormat) // new date format, only for bulk move
+ {
+ // "yyyy-mm-dd"
+ year = Bytes.extractUShort(values, noNullValue, swap);
+ month = values[noNullValue + 2];
+ day = values[noNullValue + 3];
+ String t = padZero(year,4) + "-" + padZero(month,2) + "-" + padZero(day,2);
+ retObj = Date.valueOf(t);
+ } else {// do the old way
+ length = dateLength;
+ retObj = Date.valueOf(new String(Bytes.read_chars(values, noNullValue, length)));
+ }
+ break;
+ case SQLDTCODE_TIMESTAMP:
+ if (!useOldDateFormat) // new date format, if not SQLCatalogs
+ {
+ // yyyy-mm-dd hh:mm:ss.fffffffff
+ year = Bytes.extractUShort(values, noNullValue, swap);
+ month = values[noNullValue + 2];
+ day = values[noNullValue + 3];
+ hour = values[noNullValue + 4];
+ minute = values[noNullValue + 5];
+ second = values[noNullValue + 6];
+
+ if (desc.sqlPrecision_ > 0) {
+ nanoSeconds = Bytes.extractUInt(values, noNullValue + 7, swap);
+
+ if (nanoSeconds > 999999) // returned in microseconds
+ nanoSeconds = 0;
+
+ // apply leading 0's for string conversion
+ tmpStr = "" + nanoSeconds;
+ length = tmpStr.length();
+ for (int i = 0; i < desc.sqlPrecision_ - length; i++) {
+ tmpStr = "0" + tmpStr;
+ }
+ } else {
+ tmpStr = "0";
+ }
+
+ retObj = Timestamp.valueOf(padZero((int) year, 4) + "-" + padZero(month, 2) + "-" + padZero(day, 2)
+ + " " + padZero(hour, 2) + ":" + padZero(minute, 2) + ":" + padZero(second, 2) + "."
+ + tmpStr);
+ } else { // do the old way
+ length = desc.precision_;
+ retObj = Timestamp.valueOf(new String(Bytes.read_chars(values, noNullValue, length)));
+ }
+ break;
+
+ case SQLDTCODE_TIME:
+ if (ODBCDataType == java.sql.Types.OTHER) // For
+ // HPT4Desc.SQLDTCODE_HOUR_TO_FRACTION
+ {
+ length = desc.sqlOctetLength_;
+ retObj = new String(Bytes.read_chars(values, noNullValue, length));
+ } else {
+ length = timeLength;
+ if (!useOldDateFormat) // new date format, only for bulk
+ // move
+ {
+ // "hh:mm:ss"
+ hour = values[noNullValue];
+ minute = values[noNullValue + 1];
+ second = values[noNullValue + 2];
+
+ if (desc.sqlPrecision_ > 0) {
+ nanoSeconds = Bytes.extractUInt(values, noNullValue + 3, swap);
+
+ if (nanoSeconds > 999999) // returned in microseconds
+ nanoSeconds = 0;
+
+ String formatStr = "";
+ for(int i=0;i<desc.sqlPrecision_;i++)
+ formatStr += "0";
+
+ StringBuffer sb = new StringBuffer();
+ DecimalFormat format = new DecimalFormat("00");
+ format.format(hour, sb, new FieldPosition(0));
+ sb.append(':');
+ format.format(minute, sb, new FieldPosition(0));
+ sb.append(':');
+ format.format(second, sb, new FieldPosition(0));
+ sb.append('.');
+ format = new DecimalFormat(formatStr);
+ format.format(nanoSeconds, sb, new FieldPosition(0));
+
+ retObj = sb.toString();
+ } else {
+ retObj = Time.valueOf(String.valueOf(hour) + ":" + String.valueOf(minute) + ":"
+ + String.valueOf(second));
+ }
+ } else
+ // do the old way
+ retObj = Time.valueOf(new String(Bytes.read_chars(values, noNullValue, length)));
+ }
+ break;
+ default:
+ length = desc.sqlOctetLength_;
+ retObj = new String(Bytes.read_chars(values, noNullValue, length));
+ break;
+ }
+ break;
+ case SQLTYPECODE_SMALLINT:
+ short sValue = Bytes.extractShort(values, noNullValue, swap);
+ retObj = new Short(sValue);
+ if (desc.scale_ > 0) {
+ retObj = new BigDecimal(new BigInteger(retObj.toString()), desc.scale_);
+ }
+ break;
+ case SQLTYPECODE_SMALLINT_UNSIGNED:
+ int signedSValue = Bytes.extractUShort(values, noNullValue, swap);
+ if (desc.scale_ > 0) {
+ tmpbd = new BigDecimal(new BigInteger(String.valueOf(signedSValue)), (int) desc.scale_);
+ } else {
+ tmpbd = new BigDecimal(String.valueOf(signedSValue));
+ }
+ retObj = tmpbd;
+ break;
+ case SQLTYPECODE_INTEGER:
+ retObj = new Integer(Bytes.extractInt(values, noNullValue,swap));
+ if (desc.scale_ > 0) {
+ retObj = new BigDecimal(new BigInteger(retObj.toString()), desc.scale_);
+ }
+ break;
+ case SQLTYPECODE_INTEGER_UNSIGNED:
+ retObj = new Long(Bytes.extractUInt(values, noNullValue, swap));
+ if (desc.scale_ > 0) {
+ retObj = new BigDecimal(new BigInteger(retObj.toString()), desc.scale_);
+ }
+ break;
+ case SQLTYPECODE_LARGEINT:
+ retObj = new Long(Bytes.extractLong(values, noNullValue, swap));
+ if (desc.scale_ > 0) {
+ retObj = new BigDecimal(new BigInteger(retObj.toString()), desc.scale_);
+ }
+ break;
+ case SQLTYPECODE_NUMERIC:
+ case SQLTYPECODE_NUMERIC_UNSIGNED:
+ tbuffer = new byte[desc.sqlOctetLength_];
+ System.arraycopy(values, noNullValue, tbuffer, 0, desc.sqlOctetLength_);
+ retObj = InterfaceUtilities.convertSQLBigNumToBigDecimal(tbuffer, desc.scale_, swap);
+ break;
+ case SQLTYPECODE_DECIMAL:
+ case SQLTYPECODE_DECIMAL_UNSIGNED:
+ case SQLTYPECODE_DECIMAL_LARGE:
+ case SQLTYPECODE_DECIMAL_LARGE_UNSIGNED:
+ String retStr;
+
+ // check if the sign is minus (-80)
+ byte sign = (byte) (values[noNullValue] & (byte) (-80));
+
+ // first byte = inbyte - (-80)
+ if (sign == (byte) (-80)) {
+ byte firstByte = (byte) (values[noNullValue] - (byte) (-80));
+ retStr = "-" + firstByte
+ + String.valueOf(Bytes.read_chars(values, noNullValue + 1, desc.sqlOctetLength_ - 1));
+ } else {
+ retStr = String.valueOf(Bytes.read_chars(values, noNullValue, desc.sqlOctetLength_));
+ }
+ retObj = new BigDecimal(new BigInteger(retStr), desc.scale_);
+ break;
+ case SQLTYPECODE_REAL:
+ retObj = new Float(Float.intBitsToFloat(Bytes.extractInt(values, noNullValue, swap)));
+ break;
+ case SQLTYPECODE_DOUBLE:
+ case SQLTYPECODE_FLOAT:
+ retObj = new Double(Double.longBitsToDouble(Bytes.extractLong(values, noNullValue, swap)));
+ break;
+ case SQLTYPECODE_BIT:
+ case SQLTYPECODE_BITVAR:
+ case SQLTYPECODE_BPINT_UNSIGNED:
+ default:
+ throw HPT4Messages.createSQLException(conn.props_, conn.getLocale(), "restricted_data_type", null);
+ }
+ return retObj;
+ } // end getExecute2FetchString
+
+ // -------------------------------------------------------------------
+ void setFetchOutputs(TrafT4ResultSet rs, int rowsAffected, boolean endOfData, byte[] outputDataValue)
+ throws SQLException
+
+ {
- Row[] rowArray;
- Object[] objectArray;
++ ObjectArray[] rowArray;
++ Object[] columnArray;
+ Object columnValue;
+
+ int columnCount;
+ int rowIndex;
+ int columnIndex;
+ int byteIndex = 0;
+ short SQLDataInd = 0;
+ int byteLen = 0;
+ int maxRowLen = rs.connection_.ic_.getTransportBufferSize(); // maxRowLen
+
- rowArray = new Row[rowsAffected];
++ rowArray = new ObjectArray[rowsAffected];
+
+ // get the number of colums
+ columnCount = rs.getNoOfColumns();
+
+ for (rowIndex = 0; rowIndex < rowsAffected; rowIndex++) {
+ if (rs.connection_.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, rs, outputDataValue, rowsAffected,
+ endOfData, 0);
+ String temp = "Reading row = " + rowIndex;
+ rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "setFetchOutputs", temp, p);
+ }
- objectArray = new Object[columnCount];
++ columnArray = new Object[columnCount];
+
+ for (columnIndex = 0; columnIndex < columnCount; columnIndex++) {
+ if (rs.connection_.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, rs, outputDataValue,
+ rowsAffected, endOfData, 0);
+ String temp = "Reading column = " + columnIndex;
+ rs.connection_.props_.t4Logger_
+ .logp(Level.FINEST, "InterfaceResultSet", "setFetchOutputs", temp, p);
+ }
+ SQLDataInd = new Byte(outputDataValue[byteIndex++]).shortValue();
+ if (rs.connection_.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, rs, outputDataValue,
+ rowsAffected, endOfData, 0);
+ String temp = "Row = " + rowIndex + "," + "Column = " + columnIndex + " SQLDataInd is = "
+ + SQLDataInd;
+ rs.connection_.props_.t4Logger_
+ .logp(Level.FINEST, "InterfaceResultSet", "setFetchOutputs", temp, p);
+ }
+ if (SQLDataInd == 0) {
+ short varDataLen;
+ if (outputDataValue.length > (byteIndex + 2)) {
+ varDataLen = Bytes.extractShort(outputDataValue, byteIndex, this.ic_.getByteSwap());
+ } else {
+ varDataLen = 0;
+
+ }
+ byteLen = dataLengthFetchPerf(rs.outputDesc_[columnIndex].sqlDataType_,
+ rs.outputDesc_[columnIndex].sqlDatetimeCode_, rs.outputDesc_[columnIndex].sqlOctetLength_,
+ maxRowLen, // maxLength
+ varDataLen, rs.outputDesc_[columnIndex].dataType_, rs.outputDesc_[columnIndex].precision_);
+
+ columnValue = getFetchString(rs.connection_, rs.outputDesc_[columnIndex].scale_,
+ rs.outputDesc_[columnIndex].sqlDataType_, rs.outputDesc_[columnIndex].sqlDatetimeCode_,
+ rs.outputDesc_[columnIndex].fsDataType_, outputDataValue, byteIndex, byteLen,
+ rs.outputDesc_[columnIndex].sqlCharset_, rs.outputDesc_[columnIndex].dataType_);
+
+ byteIndex = byteIndex + byteLen;
+
+ switch (rs.outputDesc_[columnIndex].sqlDataType_) {
+ case SQLTYPECODE_VARCHAR_WITH_LENGTH:
+ case SQLTYPECODE_VARCHAR_LONG:
+ case SQLTYPECODE_VARCHAR_DBLBYTE:
+ case SQLTYPECODE_BITVAR:
+ case SQLTYPECODE_CHAR:
+ case SQLTYPECODE_CHAR_DBLBYTE:
+ case SQLTYPECODE_VARCHAR:
+ case SQLTYPECODE_BLOB:
+ case SQLTYPECODE_CLOB:
+ byteIndex++;
+ break;
+ }
+
+ if (columnValue == null) {
+ throw HPT4Messages
+ .createSQLException(rs.connection_.props_, ic_.getLocale(), "null_data", null);
+ }
+ } else {
+ columnValue = null;
+
+ }
- objectArray[columnIndex] = columnValue;
++ columnArray[columnIndex] = columnValue;
+ }
- rowArray[rowIndex] = new Row(columnCount, objectArray);
++ rowArray[rowIndex] = new ObjectArray(columnCount, columnArray);
+ }
+ rs.setFetchOutputs(rowArray, rowsAffected, endOfData);
+ }
+
+ // ----------------------------------------------------------------------------
+ void setExecute2FetchOutputs(TrafT4ResultSet rs, int rowsAffected, boolean endOfData, byte[] values)
+ throws SQLException {
+ if (rs.useOldDateFormat()) {
+ setFetchOutputs(rs, rowsAffected, endOfData, values);
+ return;
+ }
- Object[] objectArray;
++ Object[] columnArray;
+ Object columnValue;
- Row[] rowArray = new Row[rowsAffected];
++ ObjectArray[] rowArray = new ObjectArray[rowsAffected];
+
+ int columnCount = rs.getNoOfColumns();
+ int rowIndex;
+ int columnIndex;
+ int byteIndex = 0;
+ int SQLDataInd = 0;
+ int byteLen = 0;
+ int maxRowLen = rs.connection_.ic_.getTransportBufferSize(); // maxRowLen
+
- objectArray = new Object[columnCount];
++ columnArray = new Object[columnCount];
+
+ int dataLength = 0;
+
+ if (rs.outputDesc_ != null && rs.outputDesc_.length > 0) {
+ dataLength = rs.outputDesc_[0].rowLength_;
+ }
+
+ int rowOffset = 0;
+ for (rowIndex = 0; rowIndex < rowsAffected; rowIndex++) {
+ rowOffset = rowIndex * dataLength;
+
+ for (columnIndex = 0; columnIndex < columnCount; columnIndex++) {
+ int noNullValueOffset = rs.outputDesc_[columnIndex].noNullValue_;
+ int nullValueOffset = rs.outputDesc_[columnIndex].nullValue_;
+
+ if (nullValueOffset != -1)
+ nullValueOffset += rowOffset;
+ if (noNullValueOffset != -1)
+ noNullValueOffset += rowOffset;
+
+ if (rs.connection_.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, rs, endOfData, values);
+ String temp = "Processing column = " + columnIndex + ": noNullValueOffset = " + noNullValueOffset
+ + ": nullValueOffset = " + nullValueOffset;
+ rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "setExecute2FetchOutputs",
+ temp, p);
+ }
+
+ if (nullValueOffset != -1 && Bytes.extractShort(values, nullValueOffset, this.ic_.getByteSwap()) == -1) {
+ columnValue = null;
+ } else {
+ columnValue = getExecute2FetchString(rs.connection_, rs.outputDesc_[columnIndex], values,
+ noNullValueOffset, rs.outputDesc_[columnIndex].dataType_, rs.useOldDateFormat(), this.ic_.getByteSwap());
+ if (columnValue == null) {
+ throw HPT4Messages
+ .createSQLException(rs.connection_.props_, ic_.getLocale(), "null_data", null);
+ }
+ } // end if else
+
- objectArray[columnIndex] = columnValue;
++ columnArray[columnIndex] = columnValue;
+ } // end for
+
- rowArray[rowIndex] = new Row(columnCount, objectArray);
++ rowArray[rowIndex] = new ObjectArray(columnCount, columnArray);
+ }
+ rs.setFetchOutputs(rowArray, rowsAffected, endOfData);
+
+ } // end setExectue2FetchOutputs
+
+ // ----------------------------------------------------------------------------
+ // Interface methods
+ boolean fetch(String stmtLabel, int maxRowCnt, int queryTimeout, int holdability, TrafT4ResultSet rs)
+ throws SQLException {
+ int sqlAsyncEnable = 0;
+ int stmtHandle = 0;
+ int stmtCharset = 1;
+ String cursorName = "";
+ int cursorCharset = 1;
+ String stmtOptions = "";
+
+ boolean endOfData = false;
+ boolean dataFound = false;
+ String sqlStmt = ""; // qs_interface
+
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, stmtLabel, maxRowCnt, queryTimeout,
+ holdability);
+ String temp = "Entering Fetch";
+ rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "fetch", temp, p);
+ }
+
+ if (rs_.stmt_ != null && rs_.stmt_.sql_ != null) {
+ sqlStmt = rs_.stmt_.sql_.toUpperCase();
+ }
+
+ FetchReply fr;
+
+ try {
+ fr = t4resultSet_.Fetch(sqlAsyncEnable, queryTimeout, stmtHandle, stmtCharset, maxRowCnt, cursorName,
+ cursorCharset, stmtOptions);
+
+ } catch (SQLException tex) {
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, stmtLabel, maxRowCnt, queryTimeout,
+ holdability);
+ String temp = "SQLException while fetching.";
+ rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "fetch", temp, p);
+ }
+ throw tex;
+ }
+
+ switch (fr.returnCode) {
+ case TRANSPORT.CEE_SUCCESS:
+ case TRANSPORT.SQL_SUCCESS_WITH_INFO:
+
+ // do warning processing
+ if (fr.errorList.length != 0) {
+ HPT4Messages.setSQLWarning(rs.connection_.props_, rs, fr.errorList);
+ }
+ //endOfData = (fr.rowsAffected < maxRowCnt) ? true : false;
+
+ if (fr.rowsAffected > 0) {
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, stmtLabel, maxRowCnt,
+ queryTimeout, holdability);
+ String temp = "Data Found. Setting fetch outputs";
+ rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "fetch", temp, p);
+ }
+ if (rs.keepRawBuffer_ == true) {
+ rs.rawBuffer_ = fr.outValues;
+ }
+
+ setExecute2FetchOutputs(rs, fr.rowsAffected, endOfData, fr.outValues);
+
+ dataFound = true;
+ }
+ break;
+ case 100: // fix this
+ case odbc_SQLSvc_Fetch_exc_.odbc_SQLSvc_Fetch_SQLNoDataFound_exn_:
+ dataFound = false;
+ endOfData = true;
+ break;
+
+ default:
+ HPT4Messages.throwSQLException(rs.connection_.props_, fr.errorList);
+
+ }
+
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs.connection_.props_, stmtLabel, maxRowCnt, queryTimeout,
+ holdability);
+ String temp = "Exiting Fetch.";
+ rs.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "fetch", temp, p);
+ }
+
+ // see if the rows fetched is valid
+ return dataFound;
+ };
+
+ void close() throws SQLException {
+ ic_.isConnectionOpen();
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs_.connection_.props_);
+ String temp = "Closing resultset.";
+ rs_.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "close", temp, p);
+ }
+
+ int rval = 0;
+ CloseReply cry_ = null;
+
+ //
+ // If the query is non-unique, then close the result set (cursor).
+ // If the query was a unique select, then the result set was implicitly
+ // closed by NCS.
+ //
+ if (rs_ != null && rs_.stmt_ != null && rs_.stmt_.ist_ != null
+ && rs_.stmt_.ist_.sqlQueryType_ != TRANSPORT.SQL_SELECT_UNIQUE) {
+ cry_ = t4resultSet_.Close();
+
+ switch (cry_.m_p1.exception_nr) {
+ case TRANSPORT.CEE_SUCCESS:
+
+ // ignore the SQLWarning for the static close
+ break;
+ case odbc_SQLSvc_Close_exc_.odbc_SQLSvc_Close_SQLError_exn_:
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs_.connection_.props_);
+ String temp = "odbc_SQLSvc_Close_SQLError_exn_";
+ rs_.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "close", temp, p);
+ }
+
+ HPT4Messages.throwSQLException(rs_.connection_.props_, cry_.m_p1.SQLError);
+ default:
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs_.connection_.props_);
+ String temp = "UnknownException occurred during close.";
+ rs_.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "close", temp, p);
+ }
+ throw HPT4Messages.createSQLException(rs_.connection_.props_, ic_.getLocale(),
+ "ids_unknown_reply_error", null);
+ } // end switch
+ } // end if
+
+ if (ic_.t4props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(rs_.connection_.props_);
+ String temp = "Closed resultset.";
+ rs_.connection_.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "close", temp, p);
+ }
+ };
+
+ // ----------------------------------------------------------------------------
+ static Object[] getExecute2Outputs(TrafT4Connection conn, HPT4Desc[] desc, byte[] values, boolean swap) throws SQLException
+
+ {
- Object[] objectArray;
++ Object[] columnArray;
+ Object columnValue;
+ int columnIndex;
+ int columnCount = (desc == null) ? 0 : desc.length;
+
- objectArray = new Object[columnCount];
++ columnArray = new Object[columnCount];
+
+ for (columnIndex = 0; columnIndex < columnCount; columnIndex++) {
+ int noNullValueOffset = desc[columnIndex].noNullValue_;
+ int nullValueOffset = desc[columnIndex].nullValue_;
+
+ if (conn.props_.t4Logger_.isLoggable(Level.FINEST) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(conn.props_, conn, desc, values);
+ String temp = "Processing column = " + columnIndex + ": noNullValueOffset = " + noNullValueOffset
+ + ": nullValueOffset = " + nullValueOffset;
+ conn.props_.t4Logger_.logp(Level.FINEST, "InterfaceResultSet", "getExecute2Outputs", temp, p);
+ }
+
+ if ((nullValueOffset != -1 && Bytes.extractShort(values, nullValueOffset, swap) == -1)
+ || (desc[columnIndex].paramMode_ == HPT4ParameterMetaData.parameterModeIn)) {
+ columnValue = null;
+ } else {
+ columnValue = getExecute2FetchString(conn, desc[columnIndex], values, noNullValueOffset,
+ desc[columnIndex].dataType_, false, swap);
+ if (columnValue == null) {
+ throw HPT4Messages.createSQLException(conn.props_, conn.getLocale(), "null_data", null);
+ }
+ } // end if else
+
- objectArray[columnIndex] = columnValue;
++ columnArray[columnIndex] = columnValue;
+ } // end for
+
- return objectArray;
++ return columnArray;
+
+ } // end getExectue2Outputs
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a0f21cde/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ObjectArray.java
----------------------------------------------------------------------
diff --cc core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ObjectArray.java
index 0000000,0000000..fd3f6ee
new file mode 100644
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/ObjectArray.java
@@@ -1,0 -1,0 +1,86 @@@
++// @@@ START COPYRIGHT @@@
++//
++// Licensed to the Apache Software Foundation (ASF) under one
++// or more contributor license agreements. See the NOTICE file
++// distributed with this work for additional information
++// regarding copyright ownership. The ASF licenses this file
++// to you under the Apache License, Version 2.0 (the
++// "License"); you may not use this file except in compliance
++// with the License. You may obtain a copy of the License at
++//
++// http://www.apache.org/licenses/LICENSE-2.0
++//
++// Unless required by applicable law or agreed to in writing,
++// software distributed under the License is distributed on an
++// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
++// KIND, either express or implied. See the License for the
++// specific language governing permissions and limitations
++// under the License.
++//
++// @@@ END COPYRIGHT @@@
++
++package org.trafodion.jdbc.t4;
++
++import java.io.Serializable;
++import java.util.BitSet;
++
++
++// ****************************************************************************
++// Class: ObjectArray
++//
++// This class describes an array of Objects, a corresponding array of
++// updated objects, and a bitmap containing the updated element positions
++// It is used by TrafT4ResultSets to handle result set rows.
++// ****************************************************************************
++
++class ObjectArray implements Serializable, Cloneable {
++
++ // Class members
++ private BitSet arrayElements_;
++ private int arraySize_;
++ private Object objectArray_[];
++ private Object updatedArray_[];
++
++ // Constructors
++ ObjectArray(int arraySize) {
++ arraySize_ = arraySize;
++ objectArray_ = new Object[arraySize];
++ updatedArray_ = new Object[arraySize];
++
++ // Initializes bit map of elements to false
++ arrayElements_ = new BitSet(arraySize_);
++ }
++
++ ObjectArray(int arraySize, Object objectArray[]) {
++ arraySize_ = arraySize;
++ objectArray_ = new Object[arraySize];
++ updatedArray_ = new Object[arraySize];
++
++ // Initializes bit map of elements to false
++ arrayElements_ = new BitSet(arraySize_);
++
++ // populate object array with passed in object array
++ for (int idx = 0; idx < arraySize_; idx++) {
++ objectArray_[idx] = objectArray[idx];
++ }
++ }
++
++ // Helpers
++ protected int getSize() { return arraySize_; }
++
++ protected Object getUpdatedArrayElement(int idx) {
++ if (arrayElements_ .get(idx - 1)) {
++ return updatedArray_[idx - 1];
++ }
++ else {
++ return objectArray_[idx - 1];
++ }
++ }
++
++ protected void updateArrayElement(int idx, Object obj) {
++ updatedArray_[idx - 1] = obj;
++ arrayElements_.set(idx - 1);
++ }
++
++}
++
[22/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
new file mode 100644
index 0000000..489904f
--- /dev/null
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
@@ -0,0 +1,2558 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URL;
+import java.nio.ByteBuffer;
+import java.sql.Array;
+import java.sql.BatchUpdateException;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.DatabaseMetaData;
+import java.sql.Date;
+import java.sql.NClob;
+import java.sql.ParameterMetaData;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Locale;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql.PreparedStatement {
+ // java.sql.PreparedStatement interface methods
+ public void addBatch() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "addBatch", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("addBatch");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (inputDesc_ == null) {
+ return;
+ }
+
+ // Check if all parameters are set for current set
+ checkIfAllParamsSet();
+ // Add to the number of Rows Count
+ if (rowsValue_ == null) {
+ rowsValue_ = new ArrayList();
+ }
+ rowsValue_.add(paramsValue_);
+ paramRowCount_++;
+ paramsValue_ = new Object[inputDesc_.length];
+ if (isAnyLob_ && (lobObjects_ == null)) {
+ lobObjects_ = new ArrayList();
+ // Clear the isValueSet_ flag in inputDesc_ and add the lob objects
+ // to the lobObject List
+ }
+ for (int i = 0; i < inputDesc_.length; i++) {
+ // If isAnyLob_ is false: inputDesc_.paramValue_ for all
+ // parameters should be null
+ // If isAnyLob_ is true: one or more inputDesc_.parmValue will not
+ // be null, based on the number of LOB columns in the query
+ if (inputDesc_[i].paramValue_ != null) {
+ lobObjects_.add(inputDesc_[i].paramValue_);
+ inputDesc_[i].paramValue_ = null;
+ }
+ inputDesc_[i].isValueSet_ = false;
+ }
+ }
+
+ public void clearBatch() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "clearBatch", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("clearBatch");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (inputDesc_ == null) {
+ return;
+ }
+ if (rowsValue_ != null) {
+ rowsValue_.clear();
+ }
+ if (lobObjects_ != null) {
+ lobObjects_.clear();
+ }
+ paramRowCount_ = 0;
+ // Clear the isValueSet_ flag in inputDesc_
+ for (int i = 0; i < inputDesc_.length; i++) {
+ inputDesc_[i].isValueSet_ = false;
+ paramsValue_[i] = null;
+ inputDesc_[i].paramValue_ = null;
+ }
+ isAnyLob_ = false;
+ batchRowCount_ = new int[] {};
+ }
+
+ public void clearParameters() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "clearParameters", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("clearParameters");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ // Clear the isValueSet_ flag in inputDesc_
+ if (inputDesc_ == null) {
+ return;
+ }
+
+ for (int i = 0; i < inputDesc_.length; i++) {
+ inputDesc_[i].isValueSet_ = false;
+ paramsValue_[i] = null;
+ inputDesc_[i].paramValue_ = null;
+ }
+ isAnyLob_ = false;
+ }
+
+ public void close() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "close", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("close");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (isClosed_) {
+ return;
+ }
+ try {
+ if (connection_._isClosed() == false) {
+ if (!connection_.isStatementCachingEnabled()) {
+ super.close();
+ } else {
+ logicalClose();
+ }
+ }
+ } catch (SQLException e) {
+ performConnectionErrorChecks(e);
+ throw e;
+ } finally {
+ isClosed_ = true;
+ if (!connection_.isStatementCachingEnabled()) {
+ connection_.removeElement(pRef_);
+ }
+ }
+
+ }
+
+ public boolean execute() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "execute", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("execute");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Object[] valueArray = null;
+ int inDescLength = 0;
+
+ validateExecuteInvocation();
+
+ // *******************************************************************
+ // * If LOB is involved with autocommit enabled we throw an exception
+ // *******************************************************************
+ if (isAnyLob_ && (connection_.getAutoCommit())) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_lob_commit_state", null);
+ }
+ if (inputDesc_ != null) {
+ if (!usingRawRowset_)
+ valueArray = getValueArray();
+ inDescLength = inputDesc_.length;
+ }
+
+ execute(paramRowCount_ + 1, inDescLength, valueArray, queryTimeout_, isAnyLob_); // LOB
+ // Support
+ // - SB
+ // 9/28/04
+
+ // if (resultSet_[result_set_offset] != null)
+ if (resultSet_ != null && resultSet_[result_set_offset] != null) {
+ return true;
+ } else {
+ if (isAnyLob_) {
+
+
+ }
+ return false;
+ }
+ }
+
+ public int[] executeBatch() throws SQLException, BatchUpdateException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "executeBatch", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("executeBatch");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ try {
+ clearWarnings();
+ HPT4Exception se;
+ Object[] valueArray = null;
+
+ if (inputDesc_ == null) {
+ se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "batch_command_failed", null);
+ throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+ }
+ if (sqlStmtType_ == TRANSPORT.TYPE_SELECT) {
+ se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "select_in_batch_not_supported", null);
+ throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+ }
+ if (connection_._isClosed()) {
+ se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_connection",
+ null);
+ connection_.closeErroredConnection(se);
+ throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+ }
+ if (isAnyLob_ && (connection_.getAutoCommit())) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_lob_commit_state", null);
+ }
+
+ int prc = usingRawRowset_ ? (paramRowCount_ + 1) : paramRowCount_;
+
+ if (paramRowCount_ < 1) {
+ if (!connection_.props_.getDelayedErrorMode()) {
+ return (new int[] {});
+ }
+ }
+
+ try {
+ if (!usingRawRowset_)
+ valueArray = getValueArray();
+
+ execute(prc, inputDesc_.length, valueArray, queryTimeout_, lobObjects_ != null);
+
+
+ } catch (SQLException e) {
+ BatchUpdateException be;
+ se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "batch_command_failed", null);
+ if (batchRowCount_ == null) // we failed before execute
+ {
+ batchRowCount_ = new int[paramRowCount_];
+ Arrays.fill(batchRowCount_, -3);
+ }
+ be = new BatchUpdateException(se.getMessage(), se.getSQLState(), batchRowCount_);
+ be.setNextException(e);
+
+ throw be;
+ }
+
+ if (connection_.props_.getDelayedErrorMode()) {
+ _lastCount = paramRowCount_;
+ }
+
+ return batchRowCount_;
+ } finally {
+ clearBatch();
+ }
+ }
+
+ public ResultSet executeQuery() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "executeQuery", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("executeQuery");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Object[] valueArray = null;
+ int inDescLength = 0;
+
+ validateExecuteInvocation();
+ if (sqlStmtType_ != TRANSPORT.TYPE_SELECT) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "non_select_invalid",
+ null);
+ }
+
+ if (inputDesc_ != null) {
+ if (!usingRawRowset_)
+ valueArray = getValueArray();
+ inDescLength = inputDesc_.length;
+ }
+ execute(paramRowCount_ + 1, inDescLength, valueArray, queryTimeout_, isAnyLob_); // LOB
+ // Support
+ // - SB
+ // 9/28/04
+ return resultSet_[result_set_offset];
+ }
+
+ public int executeUpdate() throws SQLException {
+ long count = executeUpdate64();
+
+ if (count > Integer.MAX_VALUE)
+ this.setSQLWarning(null, "numeric_out_of_range", null);
+
+ return (int) count;
+ }
+
+ public long executeUpdate64() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "executeUpdate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("executeUpdate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Object[] valueArray = null;
+ int inDescLength = 0;
+
+ validateExecuteInvocation();
+ // if (sqlStmtType_ == TRANSPORT.TYPE_SELECT)
+ if (sqlStmtType_ == TRANSPORT.TYPE_SELECT && (ist_.stmtIsLock != true)) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "select_invalid", null);
+ }
+
+ if (usingRawRowset_ == false) {
+ if (inputDesc_ != null) {
+ if (!usingRawRowset_)
+ valueArray = getValueArray();
+ inDescLength = inputDesc_.length;
+ }
+ } else {
+ valueArray = this.paramsValue_; // send it along raw in case we need
+ // it
+ paramRowCount_ -= 1; // we need to make sure that paramRowCount
+ // stays exactly what we set it to since we
+ // add one during execute
+ }
+
+ // *******************************************************************
+ // * If LOB is involved with autocommit enabled we throw an exception
+ // *******************************************************************
+ if (isAnyLob_ && (connection_.getAutoCommit())) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_lob_commit_state", null);
+ }
+
+ execute(paramRowCount_ + 1, inDescLength, valueArray, queryTimeout_, isAnyLob_);
+ if (isAnyLob_) {
+
+
+ }
+ return ist_.getRowCount();
+ }
+
+ public ResultSetMetaData getMetaData() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "getMetaData", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("getMetaData");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (outputDesc_ != null) {
+ return new HPT4ResultSetMetaData(this, outputDesc_);
+ } else {
+ return null;
+ }
+ }
+
+ public ParameterMetaData getParameterMetaData() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "getParameterMetaData", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("getParameterMetaData");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (inputDesc_ != null) {
+ return new HPT4ParameterMetaData(this, inputDesc_);
+ } else {
+ return null;
+ }
+ }
+
+ // JDK 1.2
+ public void setArray(int parameterIndex, Array x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setArray", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setArray");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "setArray()");
+ }
+
+ public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setAsciiStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setAsciiStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ long dataLocator;
+
+ validateSetInvocation(parameterIndex);
+
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+
+ switch (dataType) {
+
+
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BINARY: // At this time Database does not have
+ // this column data type
+ case Types.VARBINARY: // At this time Database does not
+ // have this column data type //#endif-java
+ case Types.LONGVARBINARY: // At this time Database does not
+ // have this column data type
+ byte[] buffer = new byte[length];
+ try {
+ x.read(buffer);
+ } catch (java.io.IOException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
+ messageArguments);
+ }
+
+ try {
+ addParamValue(parameterIndex, new String(buffer, "ASCII"));
+ } catch (java.io.UnsupportedEncodingException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "unsupported_encoding", messageArguments);
+ }
+ break;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_datatype_for_column", null);
+ }
+ }
+
+ public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setBigDecimal", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setBigDecimal");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ validateSetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+
+ if (x != null) {
+ Utility.checkDecimalTruncation(parameterIndex, connection_.getLocale(), x,
+ inputDesc_[parameterIndex - 1].precision_, inputDesc_[parameterIndex - 1].scale_);
+ addParamValue(parameterIndex, x.toString());
+ } else {
+ addParamValue(parameterIndex, null);
+ }
+ }
+
+ public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setBinaryStream",
+ "setBinaryStream", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setBinaryStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ long dataLocator;
+
+ validateSetInvocation(parameterIndex);
+
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+
+ switch (dataType) {
+
+
+ case Types.DOUBLE:
+ case Types.DECIMAL:
+ case Types.NUMERIC:
+ case Types.FLOAT:
+ case Types.BIGINT:
+ case Types.INTEGER:
+ case Types.SMALLINT:
+ case Types.TINYINT:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_datatype_for_column", null);
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BINARY: // At this time Database does not have
+ // this column data type
+ case Types.VARBINARY: // At this time Database does not
+ // have this column data type
+ case Types.LONGVARBINARY: // At this time Database does not
+ // have this column data type
+ byte[] buffer2 = new byte[length];
+
+ try {
+ int temp = x.read(buffer2);
+ } catch (java.io.IOException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
+ messageArguments);
+ }
+ addParamValue(parameterIndex, buffer2);
+ break;
+ default:
+ byte[] buffer = new byte[length];
+
+ try {
+ x.read(buffer);
+ } catch (java.io.IOException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
+ messageArguments);
+ }
+
+ // addParamValue(parameterIndex, new String(buffer));
+ // just pass the raw buffer.
+ addParamValue(parameterIndex, buffer);
+ }
+ }
+
+ /*
+ * Sets the designated parameter to the given <tt>Blob</tt> object. The
+ * driver converts this to an SQL <tt>BLOB</tt> value when it sends it to
+ * the database.
+ *
+ * @param i the first parameter is 1, the second is 2, ... @param x a <tt>Blob</tt>
+ * object that maps an SQL <tt>BLOB</tt> value
+ *
+ * @throws SQLException invalid data type for column
+ */
+ public void setBlob(int parameterIndex, Blob x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setBlob", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setBlob");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ long dataLocator;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ switch (dataType) {
+
+
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_datatype_for_column", null);
+ }
+ }
+
+ public void setBoolean(int parameterIndex, boolean x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setBoolean", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setBoolean");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ if (x) {
+ addParamValue(parameterIndex, "1"); // true
+ } else {
+ addParamValue(parameterIndex, "0"); // false
+ }
+ }
+
+ public void setByte(int parameterIndex, byte x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setByte", "setByte", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setByte");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ addParamValue(parameterIndex, Byte.toString(x));
+ }
+
+ public void setBytes(int parameterIndex, byte[] x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setBytes", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setBytes");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ long dataLocator;
+
+ byte[] tmpArray = new byte[x.length];
+ System.arraycopy(x, 0, tmpArray, 0, x.length);
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ switch (dataType) {
+
+
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BINARY:
+ case Types.VARBINARY:
+ case Types.LONGVARBINARY:
+ addParamValue(parameterIndex, tmpArray);
+ break;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ }
+
+ public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, reader, length);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setCharacterStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, reader, length);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setCharacterStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ char[] value;
+ int dataType;
+ long dataLocator;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ switch (dataType) {
+
+
+ case Types.DECIMAL:
+ case Types.DOUBLE:
+ case Types.FLOAT:
+ case Types.NUMERIC:
+ case Types.BIGINT:
+ case Types.INTEGER:
+ case Types.SMALLINT:
+ case Types.TINYINT:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_datatype_for_column", null);
+
+ default:
+ value = new char[length];
+ try {
+ int valuePos = reader.read(value);
+ if (valuePos < 1) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = "No data to read from the Reader";
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
+ messageArguments);
+ }
+
+ while (valuePos < length) {
+ char temp[] = new char[length - valuePos];
+ int tempReadLen = reader.read(temp, 0, length - valuePos);
+ System.arraycopy(temp, 0, value, valuePos, tempReadLen);
+ valuePos += tempReadLen;
+ }
+ } catch (java.io.IOException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
+ messageArguments);
+ }
+ addParamValue(parameterIndex, new String(value));
+ break;
+ }
+ }
+
+ /**
+ * Sets the designated parameter to the given <tt>Clob</tt> object. The
+ * driver converts this to an SQL <tt>CLOB</tt> value when it sends it to
+ * the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * a <tt>Clob</tt> object that maps an SQL <tt>CLOB</tt>
+ *
+ * @throws SQLException
+ * invalid data type for column, or restricted data type.
+ */
+ public void setClob(int parameterIndex, Clob x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setClob", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setClob");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ long dataLocator;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ switch (dataType) {
+
+
+ case Types.DECIMAL:
+ case Types.DOUBLE:
+ case Types.FLOAT:
+ case Types.NUMERIC:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_datatype_for_column", null);
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ }
+
+ public void setDate(int parameterIndex, Date x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ Timestamp t1;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.DATE && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ if (x != null) {
+ if (dataType == Types.TIMESTAMP) {
+ t1 = new Timestamp(x.getTime());
+ addParamValue(parameterIndex, t1.toString());
+ } else {
+ addParamValue(parameterIndex, x.toString());
+ }
+ } else {
+ addParamValue(parameterIndex, null);
+ }
+ }
+
+ public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ long dateValue;
+ Date adjustedDate;
+ Timestamp t1;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.DATE && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ // Ignore the cal, since SQL would expect it to store it in the local
+ // time zone
+ if (x != null) {
+ if (dataType == Types.TIMESTAMP) {
+ t1 = new Timestamp(x.getTime());
+ addParamValue(parameterIndex, t1.toString());
+ } else {
+ addParamValue(parameterIndex, x.toString());
+ }
+ } else {
+ addParamValue(parameterIndex, null);
+
+ }
+ }
+
+ public void setDouble(int parameterIndex, double x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setDouble", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setDouble");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ addParamValue(parameterIndex, Double.toString(x));
+ inputDesc_[parameterIndex - 1].isValueSet_ = true;
+ }
+
+ public void setFloat(int parameterIndex, float x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setFloat", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setFloat");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ addParamValue(parameterIndex, Float.toString(x));
+ }
+
+ public void setInt(int parameterIndex, int x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setInt", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setInt");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ addParamValue(parameterIndex, Integer.toString(x));
+ }
+
+ public void setLong(int parameterIndex, long x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setLong", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setLong");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ Utility.checkLongBoundary(connection_.getLocale(), BigDecimal.valueOf(x));
+ addParamValue(parameterIndex, Long.toString(x));
+ }
+
+ public void setNull(int parameterIndex, int sqlType) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setNull", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setNull");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ addParamValue(parameterIndex, null);
+ }
+
+ public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, paramIndex, sqlType, typeName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setNull", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, paramIndex, sqlType, typeName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setNull");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ setNull(paramIndex, sqlType);
+ }
+
+ public void setObject(int parameterIndex, Object x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (x == null) {
+ setNull(parameterIndex, Types.NULL);
+ } else if (x instanceof BigDecimal) {
+ setBigDecimal(parameterIndex, (BigDecimal) x);
+ } else if (x instanceof java.sql.Date) {
+ setDate(parameterIndex, (Date) x);
+ } else if (x instanceof java.sql.Time) {
+ setTime(parameterIndex, (Time) x);
+ } else if (x instanceof java.sql.Timestamp) {
+ setTimestamp(parameterIndex, (Timestamp) x);
+ } else if (x instanceof Double) {
+ setDouble(parameterIndex, ((Double) x).doubleValue());
+ } else if (x instanceof Float) {
+ setFloat(parameterIndex, ((Float) x).floatValue());
+ } else if (x instanceof Long) {
+ setLong(parameterIndex, ((Long) x).longValue());
+ } else if (x instanceof Integer) {
+ setInt(parameterIndex, ((Integer) x).intValue());
+ } else if (x instanceof Short) {
+ setShort(parameterIndex, ((Short) x).shortValue());
+ } else if (x instanceof Byte) {
+ setByte(parameterIndex, ((Byte) x).byteValue());
+ } else if (x instanceof Boolean) {
+ setBoolean(parameterIndex, ((Boolean) x).booleanValue());
+ } else if (x instanceof String) {
+ setString(parameterIndex, x.toString());
+ } else if (x instanceof byte[]) {
+ setBytes(parameterIndex, (byte[]) x);
+ } else if (x instanceof Clob) {
+ setClob(parameterIndex, (Clob) x);
+ } else if (x instanceof Blob) {
+ setBlob(parameterIndex, (Blob) x);
+ /*
+ * else if (x instanceof DataWrapper) {
+ * validateSetInvocation(parameterIndex); setObject(parameterIndex,
+ * x, inputDesc_[parameterIndex - 1].dataType_); }
+ */
+ } else if (x instanceof BigInteger) {
+ setBigDecimal(parameterIndex, new BigDecimal((BigInteger) x));
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "object_type_not_supported", null);
+ }
+ }
+
+ public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, targetSqlType);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, targetSqlType);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ setObject(parameterIndex, x, targetSqlType, -1);
+ }
+
+ public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, targetSqlType, scale);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, targetSqlType, scale);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ BigDecimal tmpbd;
+ int precision;
+ Locale locale = connection_.getLocale();
+
+ if (x == null) {
+ setNull(parameterIndex, Types.NULL);
+ } else {
+ switch (targetSqlType) {
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BLOB:
+ case Types.CLOB:
+ setString(parameterIndex, x.toString());
+ break;
+ case Types.VARBINARY:
+ case Types.BINARY:
+ case Types.LONGVARBINARY:
+ setBytes(parameterIndex, (byte[]) x);
+ break;
+ case Types.TIMESTAMP:
+ if (x instanceof Timestamp) {
+ setTimestamp(parameterIndex, (Timestamp) x);
+ } else if (x instanceof Date) {
+ setTimestamp(parameterIndex, Timestamp.valueOf(x.toString() + " 00:00:00.0"));
+ } else {
+ setString(parameterIndex, x.toString());
+ }
+ break;
+ case Types.TIME:
+ if (x instanceof Time) {
+ setTime(parameterIndex, (Time) x);
+ } else if (x instanceof Date) {
+ setTime(parameterIndex, new Time(((Date) x).getTime()));
+ } else if (x instanceof Timestamp) {
+ setTime(parameterIndex, new Time(((Timestamp) x).getTime()));
+ } else {
+ setString(parameterIndex, x.toString());
+ }
+ break;
+ case Types.DATE:
+ try {
+ if (x instanceof Date) {
+ setDate(parameterIndex, (Date) x);
+ } else if (x instanceof Time) {
+ setDate(parameterIndex, new Date(((Time) x).getTime()));
+ } else if (x instanceof Timestamp) {
+ setDate(parameterIndex, new Date(((Timestamp) x).getTime()));
+ } else {
+ setDate(parameterIndex, Date.valueOf(x.toString()));
+ }
+ } catch (IllegalArgumentException iex) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_parameter_value", x.toString());
+ }
+ break;
+ case Types.BOOLEAN:
+ setBoolean(parameterIndex, (Boolean.valueOf(x.toString())).booleanValue());
+ break;
+ case Types.SMALLINT:
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ Utility.checkShortBoundary(locale, tmpbd);
+ //Utility.checkLongTruncation(parameterIndex, tmpbd);
+ setShort(parameterIndex, tmpbd.shortValue());
+ break;
+ case Types.INTEGER:
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ //Utility.checkLongTruncation(parameterIndex, tmpbd);
+ //Utility.checkIntegerBoundary(locale, tmpbd);
+ setInt(parameterIndex, tmpbd.intValue());
+ break;
+ case Types.BIGINT:
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ Utility.checkLongBoundary(locale, tmpbd);
+ //Utility.checkLongTruncation(parameterIndex, tmpbd);
+ setLong(parameterIndex, tmpbd.longValue());
+ break;
+ case Types.DECIMAL:
+ // precision = getPrecision(parameterIndex - 1);
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ tmpbd = Utility.setScale(tmpbd, scale, BigDecimal.ROUND_HALF_EVEN);
+ // Utility.checkDecimalBoundary(locale, tmpbd, precision);
+ setBigDecimal(parameterIndex, tmpbd);
+ break;
+ case Types.NUMERIC:
+ // precision = getPrecision(parameterIndex - 1);
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ tmpbd = Utility.setScale(tmpbd, scale, BigDecimal.ROUND_HALF_EVEN);
+ // Utility.checkDecimalBoundary(locale, tmpbd, precision);
+ setBigDecimal(parameterIndex, tmpbd);
+ break;
+ case Types.TINYINT:
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ tmpbd = Utility.setScale(tmpbd, scale, roundingMode_);
+ Utility.checkTinyintBoundary(locale, tmpbd);
+ setShort(parameterIndex, tmpbd.shortValue());
+ break;
+ case Types.FLOAT:
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ Utility.checkFloatBoundary(locale, tmpbd);
+ setDouble(parameterIndex, tmpbd.doubleValue());
+ break;
+ case Types.DOUBLE:
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ Utility.checkDoubleBoundary(locale, tmpbd);
+ setDouble(parameterIndex, tmpbd.doubleValue());
+ break;
+ case Types.REAL:
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ setFloat(parameterIndex, tmpbd.floatValue());
+ break;
+ case Types.OTHER:
+ if (inputDesc_[parameterIndex].fsDataType_ == InterfaceResultSet.SQLTYPECODE_INTERVAL) {
+ if (x instanceof byte[]) {
+ addParamValue(parameterIndex, x);
+ } else if (x instanceof String) {
+ addParamValue(parameterIndex, x);
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "conversion_not_allowed", null);
+ }
+ break;
+ }
+ case Types.ARRAY:
+ case Types.BIT:
+ case Types.DATALINK:
+ case Types.DISTINCT:
+ case Types.JAVA_OBJECT:
+ case Types.STRUCT:
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "object_type_not_supported", null);
+ }
+ }
+ }
+
+ // JDK 1.2
+ public void setRef(int i, Ref x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, i, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setRef", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, i, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setRef");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(i);
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "setRef()");
+ }
+
+ public void setShort(int parameterIndex, short x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setShort", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setShort");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ addParamValue(parameterIndex, Short.toString(x));
+ }
+
+ public void setString(int parameterIndex, String x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setString", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setString");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ int dataType = inputDesc_[parameterIndex - 1].dataType_;
+
+ switch (dataType) {
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.DATE:
+ case Types.TIME:
+ case Types.TIMESTAMP:
+ case Types.OTHER: // This type maps to the Database
+ // INTERVAL
+ addParamValue(parameterIndex, x);
+ break;
+
+
+ case Types.ARRAY:
+ case Types.BINARY:
+ case Types.BIT:
+ case Types.DATALINK:
+ case Types.JAVA_OBJECT:
+ case Types.REF:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "datatype_not_supported", null);
+ case Types.BIGINT:
+ case Types.INTEGER:
+ case Types.SMALLINT:
+ case Types.TINYINT:
+ case Types.DECIMAL:
+ case Types.NUMERIC:
+ if (x != null) {
+ x = x.trim(); // SQLJ is using numeric string with
+ // leading/trailing whitespace
+ }
+ setObject(parameterIndex, x, dataType);
+ break;
+ case Types.BLOB:
+ case Types.BOOLEAN:
+ case Types.DOUBLE:
+ case Types.FLOAT:
+ case Types.LONGVARBINARY:
+ case Types.NULL:
+ case Types.REAL:
+ case Types.VARBINARY:
+ setObject(parameterIndex, x, dataType);
+ break;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "fetch_output_inconsistent", null);
+ }
+
+ }
+
+ public void setTime(int parameterIndex, Time x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ Timestamp t1;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ if (x != null) {
+ if (dataType == Types.TIMESTAMP) {
+ t1 = new Timestamp(x.getTime());
+ addParamValue(parameterIndex, t1.toString());
+ } else {
+ addParamValue(parameterIndex, x.toString());
+ }
+ } else {
+ addParamValue(parameterIndex, null);
+ }
+ }
+
+ public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ long timeValue;
+ Time adjustedTime;
+ Timestamp t1;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ // Ignore the cal, since SQL would expect it to store it in the local
+ // time zone
+ if (x != null) {
+ if (dataType == Types.TIMESTAMP) {
+ t1 = new Timestamp(x.getTime());
+ addParamValue(parameterIndex, t1.toString());
+ } else {
+ addParamValue(parameterIndex, x.toString());
+ }
+ } else {
+ addParamValue(parameterIndex, null);
+ }
+ }
+
+ public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ Date d1;
+ Time t1;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.DATE && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ if (x != null) {
+ switch (dataType) {
+ case Types.DATE:
+ d1 = new Date(x.getTime());
+ addParamValue(parameterIndex, d1.toString());
+ break;
+ case Types.TIME:
+ t1 = new Time(x.getTime());
+ addParamValue(parameterIndex, t1.toString());
+ break;
+ default:
+ addParamValue(parameterIndex, x.toString());
+ break;
+ }
+ } else {
+ addParamValue(parameterIndex, null);
+ }
+ }
+
+ public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ long timeValue;
+ Timestamp adjustedTime;
+ Date d1;
+ Time t1;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.DATE && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ // Ignore the cal, since SQL would expect it to store it in the local
+ // time zone
+ if (x != null) {
+ switch (dataType) {
+ case Types.DATE:
+ d1 = new Date(x.getTime());
+ addParamValue(parameterIndex, d1.toString());
+ break;
+ case Types.TIME:
+ t1 = new Time(x.getTime());
+ addParamValue(parameterIndex, t1.toString());
+ break;
+ default:
+ addParamValue(parameterIndex, x.toString());
+ break;
+ }
+ } else {
+ addParamValue(parameterIndex, null);
+ }
+ }
+
+ public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setUnicodeStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setUnicodeStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ byte[] buffer = new byte[length]; // length = number of bytes in
+ // stream
+ validateSetInvocation(parameterIndex);
+ String s;
+
+ if (x == null) {
+ addParamValue(parameterIndex, null);
+ } else {
+ int dataType = inputDesc_[parameterIndex - 1].dataType_;
+ switch (dataType) {
+ case Types.DECIMAL:
+ case Types.DOUBLE:
+ case Types.FLOAT:
+ case Types.NUMERIC:
+ case Types.SMALLINT:
+ case Types.INTEGER:
+ case Types.BIGINT:
+ case Types.TINYINT:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_datatype_for_column", null);
+ default:
+ try {
+ x.read(buffer, 0, length);
+ } catch (java.io.IOException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
+ messageArguments);
+ }
+ try {
+ s = new String(buffer, "UnicodeBig");
+ addParamValue(parameterIndex, s);
+ } catch (java.io.UnsupportedEncodingException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "unsupported_encoding", messageArguments);
+ }
+ break;
+ }
+ }
+ }
+
+ public void setURL(int parameterIndex, URL x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setURL", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setURL");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "setURL()");
+ } // end setURL
+
+ // -------------------------------------------------------------------------------------------
+ /**
+ * This method will associate user defined data with the prepared statement.
+ * The user defined data must be in SQL/MX rowwise rowset format.
+ *
+ * @param numRows
+ * the number of rows contained in buffer
+ * @param buffer
+ * a buffer containing the rows
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+ public void setDataBuffer(int numRows, ByteBuffer buffer) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, numRows, buffer);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setDataBuffer", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, numRows, buffer);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setDataBuffer");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ usingRawRowset_ = true;
+ paramRowCount_ = numRows;
+ rowwiseRowsetBuffer_ = buffer;
+ } // end setDataBufferBuffer
+
+ // -------------------------------------------------------------------------------------------
+
+ // Other methods
+ protected void validateExecuteInvocation() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "validateExecuteInvocation", "", p);
+ }
+ clearWarnings();
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "stmt_closed", null);
+ }
+ // connection_.getServerHandle().isConnectionOpen();
+ connection_.isConnectionOpen();
+ // close the previous resultset, if any
+ for (int i = 0; i < num_result_sets_; i++) {
+ if (resultSet_[i] != null) {
+ resultSet_[i].close();
+ }
+ }
+ if (paramRowCount_ > 0 && usingRawRowset_ == false) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "function_sequence_error", null);
+ }
+
+ if (usingRawRowset_ == false)
+ checkIfAllParamsSet();
+
+ }
+
+ private void checkIfAllParamsSet() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "checkIfAllParamsSet", "", p);
+ }
+ int paramNumber;
+
+ if (inputDesc_ == null) {
+ return;
+ }
+ for (paramNumber = 0; paramNumber < inputDesc_.length; paramNumber++) {
+ if (!inputDesc_[paramNumber].isValueSet_) {
+ Object[] messageArguments = new Object[2];
+ messageArguments[0] = new Integer(paramNumber + 1);
+ messageArguments[1] = new Integer(paramRowCount_ + 1);
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "parameter_not_set",
+ messageArguments);
+ }
+ }
+ }
+
+ private void validateSetInvocation(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "validateSetInvocation", "", p);
+ }
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "stmt_closed", null);
+ }
+ // connection_.getServerHandle().isConnectionOpen();
+ connection_.isConnectionOpen();
+ if (inputDesc_ == null) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_parameter_index", null);
+ }
+ if (parameterIndex < 1 || parameterIndex > inputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_parameter_index", null);
+ }
+ if (inputDesc_[parameterIndex - 1].paramMode_ == DatabaseMetaData.procedureColumnOut) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "is_a_output_parameter",
+ null);
+ }
+ }
+
+ void addParamValue(int parameterIndex, Object x) {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "addParamValue", "", p);
+ }
+
+ paramsValue_[parameterIndex - 1] = x;
+ inputDesc_[parameterIndex - 1].isValueSet_ = true;
+ }
+
+ Object[] getValueArray() {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "getValueArray", "", p);
+ }
+ Object[] valueArray;
+ int length;
+ int i;
+ int j;
+ int index;
+ Object[] rows;
+
+ if (paramRowCount_ > 0) {
+ valueArray = new Object[(paramRowCount_ + 1) * inputDesc_.length];
+ length = rowsValue_.size();
+ for (i = 0, index = 0; i < length; i++) {
+ rows = (Object[]) rowsValue_.get(i);
+ for (j = 0; j < rows.length; j++, index++) {
+ valueArray[index] = rows[j];
+ }
+ }
+ } else {
+ valueArray = paramsValue_;
+ }
+ return valueArray;
+ }
+
+ void logicalClose() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "logicalClose", "", p);
+ }
+ isClosed_ = true;
+ if (rowsValue_ != null) {
+ rowsValue_.clear();
+
+ }
+ if (lobObjects_ != null) {
+ lobObjects_.clear();
+
+ }
+ paramRowCount_ = 0;
+ for (int i = 0; i < num_result_sets_; i++) {
+ if (resultSet_[i] != null) {
+ resultSet_[i].close();
+ // Clear the isValueSet_ flag in inputDesc_
+ }
+ }
+ result_set_offset = 0;
+ resultSet_[result_set_offset] = null;
+ if (inputDesc_ != null) {
+ for (int i = 0; i < inputDesc_.length; i++) {
+ inputDesc_[i].isValueSet_ = false;
+ paramsValue_[i] = null;
+ }
+ }
+ isAnyLob_ = false;
+ if (!connection_.closePreparedStatement(connection_, sql_, resultSetType_, resultSetConcurrency_,
+ resultSetHoldability_)) {
+ this.close(true); // if the statement is not in the cache
+ // hardclose it afterall
+ }
+
+ }
+
+ // ----------------------------------------------------------------------------------
+ // Method used by JNI Layer to update the results of Prepare
+ void setPrepareOutputs(HPT4Desc[] inputDesc, HPT4Desc[] outputDesc, int inputParamCount, int outputParamCount)
+ throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, inputDesc, outputDesc, inputParamCount,
+ outputParamCount);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "setPrepareOutputs", "", p);
+ }
+ inputDesc_ = inputDesc;
+ outputDesc_ = outputDesc;
+ paramRowCount_ = 0;
+
+ // Prepare updares inputDesc_ and outputDesc_
+ if (inputDesc_ != null) {
+ paramsValue_ = new Object[inputDesc_.length];
+ } else {
+ paramsValue_ = null;
+ }
+ } // end setPrepareOutputs
+
+ // ----------------------------------------------------------------------------------
+ void setPrepareOutputs2(HPT4Desc[] inputDesc, HPT4Desc[] outputDesc, int inputParamCount, int outputParamCount,
+ int inputParamsLength, int outputParamsLength, int inputDescLength, int outputDescLength)
+ throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, inputDesc, outputDesc, inputParamCount,
+ outputParamCount, inputParamsLength, outputParamsLength, inputDescLength, outputDescLength);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "setPrepareOutputs2", "", p);
+ }
+ inputParamCount_ = inputParamCount;
+ outputParamCount_ = outputParamCount;
+ inputParamsLength_ = inputParamsLength;
+ outputParamsLength_ = outputParamsLength;
+ inputDescLength_ = inputDescLength;
+ outputDescLength_ = outputDescLength;
+ setPrepareOutputs(inputDesc, outputDesc, inputParamCount, outputParamCount);
+ } // end setPrepareOutputs2
+
+ // ----------------------------------------------------------------------------------
+ // Method used by JNI layer to update the results of Execute
+ void setExecuteOutputs(int rowCount) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rowCount);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "setExecuteOutputs", "", p);
+ }
+ batchRowCount_ = new int[1];
+ batchRowCount_[0] = rowCount;
+ num_result_sets_ = 1;
+ result_set_offset = 0;
+ if (outputDesc_ != null) {
+ resultSet_[result_set_offset] = new TrafT4ResultSet(this, outputDesc_);
+ } else {
+ resultSet_[result_set_offset] = null;
+ }
+ }
+
+ /*
+ * //----------------------------------------------------------------------------------
+ * void setExecuteSingletonOutputs(SQLValue_def[] sqlValue_def_array, short
+ * rowsAffected) throws SQLException { batchRowCount_ = new int[1];
+ * batchRowCount_[0] = rowsAffected; if (outputDesc_ != null) { resultSet_ =
+ * new TrafT4ResultSet(this, outputDesc_); } else { resultSet_ = null; } if
+ * (rowsAffected == 0) { resultSet_.setFetchOutputs(new Row[0], 0, true, 0); }
+ * else { resultSet_.irs_.setSingletonFetchOutputs(resultSet_, rowsAffected,
+ * true, 0, sqlValue_def_array); } }
+ */
+
+ // ----------------------------------------------------------------------------------
+ // Method used by JNI layer to update the results of Execute
+ void setExecuteBatchOutputs(int[] rowCount) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rowCount);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "setExecuteBatchOutputs", "", p);
+ }
+ num_result_sets_ = 1;
+ result_set_offset = 0;
+ if (outputDesc_ != null) {
+ resultSet_[result_set_offset] = new TrafT4ResultSet(this, outputDesc_);
+ } else {
+ resultSet_[result_set_offset] = null;
+ }
+ batchRowCount_ = rowCount;
+ }
+
+ void reuse(TrafT4Connection connection, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "reuse", "", p);
+ }
+ if (resultSetType != ResultSet.TYPE_FORWARD_ONLY && resultSetType != ResultSet.TYPE_SCROLL_INSENSITIVE
+ && resultSetType != ResultSet.TYPE_SCROLL_SENSITIVE) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_resultset_type", null);
+ }
+ if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) {
+ resultSetType_ = ResultSet.TYPE_SCROLL_INSENSITIVE;
+ setSQLWarning(null, "scrollResultSetChanged", null);
+ } else {
+ resultSetType_ = resultSetType;
+ }
+ if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY && resultSetConcurrency != ResultSet.CONCUR_UPDATABLE) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_resultset_concurrency", null);
+ }
+ resultSetConcurrency_ = resultSetConcurrency;
+ resultSetHoldability_ = resultSetHoldability;
+ queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
+ fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
+ maxRows_ = 0;
+ fetchDirection_ = ResultSet.FETCH_FORWARD;
+ isClosed_ = false;
+ }
+
+ public void close(boolean hardClose) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, hardClose);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "close", "", p);
+ }
+
+ if (connection_._isClosed()) {
+ return;
+ }
+ try {
+ if (hardClose) {
+ ist_.close();
+ } else {
+ logicalClose();
+ }
+ } catch (SQLException e) {
+ performConnectionErrorChecks(e);
+ throw e;
+ } finally {
+ isClosed_ = true;
+ if (hardClose) {
+ connection_.removeElement(pRef_);
+ }
+ }
+
+ }
+
+
+ TrafT4PreparedStatement(TrafT4Connection connection, String sql, String stmtLabel) throws SQLException {
+ this(connection, sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, connection.holdability_,
+ stmtLabel);
+ connection.ic_.t4props_.setUseArrayBinding(false);
+ connection.ic_.t4props_.setBatchRecovery(false);
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "",
+ "Note, this call is before previous constructor call.", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ }
+
+ // Constructors with access specifier as "default"
+ TrafT4PreparedStatement(TrafT4Connection connection, String sql) throws SQLException {
+ this(connection, sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, connection.holdability_);
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "",
+ "Note, this call is before previous constructor call.", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ }
+
+ TrafT4PreparedStatement(TrafT4Connection connection, String sql, int resultSetType, int resultSetConcurrency)
+ throws SQLException {
+ this(connection, sql, resultSetType, resultSetConcurrency, connection.holdability_);
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
+ resultSetConcurrency);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "",
+ "Note, this call is before previous constructor call.", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
+ resultSetConcurrency);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ }
+ TrafT4PreparedStatement(TrafT4Connection connection, String sql, int resultSetType, int resultSetConcurrency,
+ int resultSetHoldability, String stmtLabel) throws SQLException {
+ super(connection, resultSetType, resultSetConcurrency, resultSetHoldability, stmtLabel);
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "",
+ "Note, this call is before previous constructor call.", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ // connection_.getServerHandle().isConnectionOpen();
+ connection_.isConnectionOpen();
+ sqlStmtType_ = ist_.getSqlStmtType(sql);
+ if (sqlStmtType_ == TRANSPORT.TYPE_STATS) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "infostats_invalid_error", null);
+ } else if (sqlStmtType_ == TRANSPORT.TYPE_CONFIG) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "config_cmd_invalid_error", null);
+ }
+ ist_.setTransactionStatus(connection_, sql);
+ sql_ = sql;
+
+
+ // stmtLabel_ = generateStmtLabel();
+ stmtLabel_ = stmtLabel;
+ // System.out.println("TrafT4PreparedStatement stmtLabel_ " + stmtLabel_);
+
+ usingRawRowset_ = false;
+ }
+
+ TrafT4PreparedStatement(TrafT4Connection connection, String sql, int resultSetType, int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException {
+ super(connection, resultSetType, resultSetConcurrency, resultSetHoldability);
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "",
+ "Note, this call is before previous constructor call.", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ // connection_.getServerHandle().isConnectionOpen();
+ connection_.isConnectionOpen();
+ sqlStmtType_ = ist_.getSqlStmtType(sql);
+ if (sqlStmtType_ == TRANSPORT.TYPE_STATS) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "infostats_invalid_error", null);
+ } else if (sqlStmtType_ == TRANSPORT.TYPE_CONFIG) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "config_cmd_invalid_error", null);
+ }
+ ist_.setTransactionStatus(connection_, sql);
+ sql_ = sql;
+
+
+ //stmtLabel_ = generateStmtLabel();
+
+ usingRawRowset_ = false;
+ }
+
+ TrafT4PreparedStatement(TrafT4Connection connection, String moduleName, int moduleVersion, long moduleTimestamp,
+ String stmtName, boolean isSelect, int holdability) {
+ if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, moduleName, moduleVersion,
+ moduleTimestamp, stmtName, isSelect, holdability);
+ connection.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "", "", p);
+ }
+ try {
+ if (connection.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, moduleName, moduleVersion,
+ moduleTimestamp, stmtName, isSelect, holdability);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection.props_.getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+ connection_ = connection;
+ moduleName_ = moduleName;
+ moduleVersion_ = moduleVersion;
+ moduleTimestamp_ = moduleTimestamp;
+ stmtLabel_ = stmtName;
+ sqlStmtType_ = (isSelect) ? TRANSPORT.TYPE_SELECT : TRANSPORT.TYPE_UNKNOWN;
+ usingRawRowset_ = false;
+
+ // Make Sure you initialize the other fields to the right value
+ fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
+ maxRows_ = 0;
+ fetchDirection_ = ResultSet.FETCH_FORWARD;
+ queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
+ resultSetType_ = ResultSet.TYPE_FORWARD_ONLY;
+ resultSetHoldability_ = holdability;
+ usingRawRowset_ = false;
+ }
+
+ // Interface methods
+ public void prepare(String sql, int queryTimeout, int holdability) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, queryTimeout, holdability);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "prepare", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, queryTimeout, holdability);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("prepare");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ try {
+ super.ist_.prepare(sql, queryTimeout, this);
+ } catch (SQLException e) {
+ performConnectionErrorChecks(e);
+ throw e;
+ }
+ };
+
+ public void setFetchSize(int rows) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rows);
+ connection_.props_.t4Logger_.logp(Level.FINE, "SQLMXPreparedStatement", "setFetchSize", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rows);
+ lr.setParameters(p);
+ lr.setSourceClassName("SQLMXPreparedStatement");
+ lr.setSourceMethodName("setFetchSize");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (rows < 0) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_fetchSize_value", null);
+ }
+ if (rows > 0) {
+ fetchSize_ = rows;
+ }
+ // If the value specified is zero, then the hint is ignored.
+ }
+
+ private void execute(int paramRowCount, int paramCount, Object[] paramValues, int queryTimeout, boolean isAnyLob
+ ) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, paramRowCount, paramCount, paramValues,
+ queryTimeout, isAnyLob);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "execute", "", p);
+ }
+ try {
+ ist_.execute(TRANSPORT.SRVR_API_SQLEXECUTE2, paramRowCount, paramCount, paramValues, queryTimeout, null,
+ this);
+ } catch (SQLException e) {
+ performConnectionErrorChecks(e);
+ throw e;
+ }
+ };
+
+ /*
+ * protected void setSingleton(boolean value) { singleton_ = value; }
+ * protected boolean getSingleton() { return singleton_; }
+ */
+
+ /**
+ * Use this method to retrieve the
<TRUNCATED>
[41/60] incubator-trafodion git commit: Merge branch 'master' of
github.com:apache/incubator-trafodion into wrkbrnch
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a0f21cde/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Statement.java
----------------------------------------------------------------------
diff --cc core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Statement.java
index d0daff1,0000000..d28746f
mode 100644,000000..100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Statement.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Statement.java
@@@ -1,1690 -1,0 +1,1690 @@@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.lang.ref.WeakReference;
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+import java.sql.BatchUpdateException;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+/**
+ * <p>
+ * JDBC Type 4 TrafT4Statement class.
+ * </p>
+ * <p>
+ * Description: The <code>TrafT4Statement</code> class is an implementation of
+ * the <code>java.sql.Statement</code> interface.
+ * </p>
+ */
+public class TrafT4Statement extends HPT4Handle implements java.sql.Statement {
+ // java.sql.Statement interface Methods
+
+ public void addBatch(String sql) throws SQLException {
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("addBatch");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "addBatch", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("addBatch");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (batchCommands_ == null) {
+ batchCommands_ = new ArrayList();
+ }
+
+
+ batchCommands_.add(sql);
+ }
+
+ public void cancel() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "cancel", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("cancel");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ // Donot clear warning, since the warning may pertain to
+ // previous opertation and it is not yet seen by the application
+ //
+ // We must decide if this statement is currently being processed or
+ // if it has a result set associated with it, and if that
+ // result set is currently active (i.e. we are fetching rows).
+ if ((ist_.t4statement_ != null && ist_.t4statement_.m_processing == true)
+ || (resultSet_ != null && resultSet_[result_set_offset] != null
+ && resultSet_[result_set_offset].irs_ != null
+ && resultSet_[result_set_offset].irs_.t4resultSet_ != null && resultSet_[result_set_offset].irs_.t4resultSet_.m_processing == true))
+ ist_.cancel();
+ }
+
+ public void clearBatch() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "clearBatch", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("clearBatch");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ batchCommands_.clear();
+ }
+
+ /**
+ * Closes the statement object. Synchronized to prevent the same resource
+ * issued free command twice on the server.
+ *
+ * @throws SQLException
+ */
+ synchronized public void close() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "close", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("close");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (isClosed_) {
+ return;
+ }
+
+ try {
+ if (connection_._isClosed() == false) {
+ for (int i = 0; i < num_result_sets_; i++) {
+ if (resultSet_[i] != null) {
+ resultSet_[i].close(false);
+ }
+ }
+ ist_.close();
+ }
+ } finally {
+ isClosed_ = true;
+ connection_.removeElement(pRef_);
+ initResultSets();
+ }
+ }
+
+ void initResultSets() {
+ num_result_sets_ = 1;
+ result_set_offset = 0;
+ resultSet_[result_set_offset] = null;
+ }
+
+ // ------------------------------------------------------------------
+ /**
+ * This method will execute an operation.
+ *
+ * @return true
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+
+ public boolean execute() throws SQLException {
+ try {
+ ist_.executeDirect(queryTimeout_, this);
+ } catch (SQLException se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ return true;
+ } // end execute
+
+ // ------------------------------------------------------------------
+
+ public boolean execute(String sql) throws SQLException {
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("execute");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "execute", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("execute");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateExecDirectInvocation(sql);
+ try {
+ ist_.execute(TRANSPORT.SRVR_API_SQLEXECDIRECT, 0, 0, null, queryTimeout_, sql_, this);
+
+ checkSQLWarningAndClose();
+ } catch (SQLException se) {
+ try {
+ if (num_result_sets_ == 1 && resultSet_[result_set_offset] == null)
+ ;
+ {
+ internalClose();
+ }
+ } catch (SQLException closeException) {
+ se.setNextException(closeException);
+ }
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ if (resultSet_[result_set_offset] != null) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, autoGeneratedKeys);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "execute", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, autoGeneratedKeys);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("execute");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ boolean ret;
+
+ if (autoGeneratedKeys == TrafT4Statement.NO_GENERATED_KEYS) {
+ ret = execute(sql);
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "auto_generated_keys_not_supported", null);
+ }
+ return ret;
+ }
+
+ public boolean execute(String sql, int[] columnIndexes) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnIndexes);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "execute", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnIndexes);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("execute");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ boolean ret;
+
+ if (columnIndexes == null) {
+ ret = execute(sql);
+ } else if (columnIndexes.length == 0) {
+ ret = execute(sql);
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "auto_generated_keys_not_supported", null);
+ }
+ return ret;
+ }
+
+ public boolean execute(String sql, String[] columnNames) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnNames);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "execute", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnNames);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("execute");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ boolean ret;
+
+ if (columnNames == null) {
+ ret = execute(sql);
+ } else if (columnNames.length == 0) {
+ ret = execute(sql);
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "auto_generated_keys_not_supported", null);
+ }
+ return ret;
+ }
+
+ public int[] executeBatch() throws SQLException, BatchUpdateException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeBatch", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("executeBatch");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ try {
+ int i = 0;
+ SQLException se;
+
+ validateExecDirectInvocation();
+ if ((batchCommands_ == null) || (batchCommands_.isEmpty())) {
+ return new int[]
+
+ {};
+ }
+
+ batchRowCount_ = new int[batchCommands_.size()];
+ for (i = 0; i < batchCommands_.size(); i++) {
+ String sql = (String) batchCommands_.get(i);
+
+ if (sql == null) {
+ se = HPT4Messages.createSQLException(connection_.props_, this.ist_.ic_.getLocale(),
+ "batch_command_failed", "Invalid SQL String");
+ throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+ }
+
+ sqlStmtType_ = ist_.getSqlStmtType(sql);
+
+ if (sqlStmtType_ == TRANSPORT.TYPE_SELECT) {
+ se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "select_in_batch_not_supported", null);
+ throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+ } else if (sqlStmtType_ == TRANSPORT.TYPE_STATS) {
+ se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "infostats_invalid_error", null);
+ throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+ } else if (sqlStmtType_ == TRANSPORT.TYPE_CONFIG) {
+ se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "config_cmd_invalid_error", null);
+ throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+ }
+ ist_.setTransactionStatus(connection_, sql);
+ }
+
+ Object[] commands = batchCommands_.toArray();
+ int[] batchRowCount = new int[commands.length];
+ String sql;
+ int rowCount = 0;
+
+ try {
+ for (i = 0; i < commands.length; i++) {
+ sql = String.valueOf(commands[i]);
+
+ validateExecDirectInvocation(sql);
+
+ ist_.execute(TRANSPORT.SRVR_API_SQLEXECDIRECT, 0, 0, null, queryTimeout_, sql_, this);
+
+ checkSQLWarningAndClose();
+
+ batchRowCount[i] = batchRowCount_[0]; // the member will
+ // be set by
+ // execute...keep
+ // them in our local
+ // array
+ rowCount += ist_.getRowCount();
+ }
+ // CTS requirement.
+ if (commands.length < 1) {
+ batchRowCount = new int[] {};
+ }
+ } catch (SQLException e) {
+ ist_.setRowCount(rowCount);
+ batchRowCount_ = new int[i];
+ System.arraycopy(batchRowCount, 0, batchRowCount_, 0, i);
+
+ BatchUpdateException be;
+
+ se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "batch_command_failed", null);
+ be = new BatchUpdateException(se.getMessage(), se.getSQLState(), batchRowCount_);
+ be.setNextException(e);
+
+ try {
+ if (resultSet_[result_set_offset] == null) {
+ internalClose();
+ }
+ } catch (SQLException closeException) {
+ be.setNextException(closeException);
+ }
+ performConnectionErrorChecks(e);
+
+ throw be;
+ }
+
+ ist_.setRowCount(rowCount);
+ batchRowCount_ = new int[i];
+ System.arraycopy(batchRowCount, 0, batchRowCount_, 0, i);
+ return batchRowCount_;
+ } finally {
+ clearBatch();
+ }
+
+ }
+
+ public ResultSet executeQuery(String sql) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeQuery", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("executeQuery");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ validateExecDirectInvocation(sql);
+ if (sqlStmtType_ != TRANSPORT.TYPE_SELECT && sqlStmtType_ != TRANSPORT.TYPE_STATS) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "non_select_invalid",
+ null);
+ }
+ try {
+ ist_.execute(TRANSPORT.SRVR_API_SQLEXECDIRECT, 0, 0, null, queryTimeout_, sql_, this);
+
+ checkSQLWarningAndClose();
+ } catch (SQLException se) {
+ try {
+ if (resultSet_[result_set_offset] == null) {
+ internalClose();
+ }
+ } catch (SQLException closeException) {
+ se.setNextException(closeException);
+ }
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ return resultSet_[result_set_offset];
+ }
+
+ public int executeUpdate(String sql) throws SQLException {
+ long count = executeUpdate64(sql);
+
+ if (count > Integer.MAX_VALUE)
+ this.setSQLWarning(null, "numeric_out_of_range", null);
+
+ return (int) count;
+ }
+
+ public long executeUpdate64(String sql) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeUpdate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("executeUpdate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateExecDirectInvocation(sql);
+ // 7708
+ if (sqlStmtType_ == TRANSPORT.TYPE_SELECT && (ist_.stmtIsLock != true)) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "select_invalid", null);
+ }
+ try {
+ ist_.execute(TRANSPORT.SRVR_API_SQLEXECDIRECT, 0, 0, null, queryTimeout_, sql_, this);
+
+ checkSQLWarningAndClose();
+ } catch (SQLException se) {
+ try {
+ if (resultSet_[result_set_offset] == null) {
+ internalClose();
+ }
+ } catch (SQLException closeException) {
+ se.setNextException(closeException);
+ }
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ return ist_.getRowCount();
+ }
+
+ public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, autoGeneratedKeys);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeUpdate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, autoGeneratedKeys);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("executeUpdate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int ret;
+
+ if (autoGeneratedKeys == TrafT4Statement.NO_GENERATED_KEYS) {
+ ret = executeUpdate(sql);
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "auto_generated_keys_not_supported", null);
+ }
+ return ret;
+ }
+
+ public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnIndexes);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeUpdate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnIndexes);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("executeUpdate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int ret;
+
+ if (columnIndexes == null) {
+ ret = executeUpdate(sql);
+ } else if (columnIndexes.length == 0) {
+ ret = executeUpdate(sql);
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "auto_generated_keys_not_supported", null);
+ }
+ return ret;
+ }
+
+ public int executeUpdate(String sql, String[] columnNames) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnNames);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "executeUpdate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, columnNames);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("executeUpdate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int ret;
+
+ if (columnNames == null) {
+ ret = executeUpdate(sql);
+ } else if (columnNames.length == 0) {
+ ret = executeUpdate(sql);
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "auto_generated_keys_not_supported", null);
+ }
+ return ret;
+ }
+
+ public Connection getConnection() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getConnection", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getConnection");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ return connection_;
+ }
+
+ public int getFetchDirection() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getFetchDirection", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getFetchDirection");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return fetchDirection_;
+ }
+
+ public int getFetchSize() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getFetchSize", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getFetchSize");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return fetchSize_;
+ }
+
+ public ResultSet getGeneratedKeys() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getGeneratedKeys", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getGeneratedKeys");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "auto_generated_keys_not_supported", null);
+ }
+
+ public int getMaxFieldSize() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getMaxFieldSize", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getMaxFieldSize");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return maxFieldSize_;
+ }
+
+ public int getMaxRows() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getMaxRows", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getMaxRows");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return maxRows_;
+ }
+
+ public boolean getMoreResults() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getMoreResults", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getMoreResults");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return getMoreResults(Statement.CLOSE_CURRENT_RESULT);
+ }
+
+ public boolean getMoreResults(int current) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, current);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getMoreResults", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, current);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getMoreResults");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ switch (current) {
+ case Statement.CLOSE_ALL_RESULTS:
+ for (int i = 0; i <= result_set_offset; i++) {
+ if (resultSet_[i] != null) {
+ resultSet_[i].close();
+ }
+ }
+ break;
+ case Statement.KEEP_CURRENT_RESULT:
+ break;
+ case Statement.CLOSE_CURRENT_RESULT: // this is the default action
+ default:
+ if (resultSet_[result_set_offset] != null) {
+ resultSet_[result_set_offset].close();
+ }
+ break;
+ }
+ ist_.setRowCount(-1);
+ if (result_set_offset < num_result_sets_ - 1) {
+ result_set_offset++;
+ return true;
+ }
+ return false;
+ }
+
+ public int getQueryTimeout() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getQueryTimeout", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getQueryTimeout");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return queryTimeout_;
+ }
+
+ public ResultSet getResultSet() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getResultSet", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getResultSet");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return resultSet_[result_set_offset];
+ }
+
+ public int getResultSetConcurrency() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getResultSetConcurrency", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getResultSetConcurrency");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return resultSetConcurrency_;
+ }
+
+ public int getResultSetHoldability() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getResultSetHoldability", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getResultSetHoldability");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return resultSetHoldability_;
+ }
+
+ public int getResultSetType() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getResultSetType", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getResultSetType");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ return resultSetType_;
+ }
+
+ public int getUpdateCount() throws SQLException {
+ long count = getUpdateCount64();
+
+ if (count > Integer.MAX_VALUE)
+ this.setSQLWarning(null, "numeric_out_of_range", null);
+
+ return (int) count;
+ }
+
+ public long getUpdateCount64() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "getUpdateCount", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("getUpdateCount");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (ist_ == null) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_statement_handle", null);
+ }
+
+ // Spec wants -1 when the resultset is current and no more rows.
+ long count = ist_.getRowCount();
+ if ((count == 0) && resultSet_ != null && resultSet_[result_set_offset] != null) {
+ count = -1;
+ }
+
+ return count;
+ }
+
+ // ------------------------------------------------------------------
+ /**
+ * This method will get the operation ID for this statement. -1 is returned
+ * if the operation ID has not been set.
+ *
+ * @retrun The operation ID or -1 if the operation ID has not been set.
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+ public short getOperationID() throws SQLException {
+ return operationID_;
+ } // end getOperationID
+
+ // ------------------------------------------------------------------
+ /**
+ * This method will get the operation buffer for this statement. Null is
+ * returned if the operation buffer has not been set.
+ *
+ * @retrun The operation buffer or null if the operation ID has not been
+ * set.
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+ public byte[] getOperationBuffer() throws SQLException {
+ // System.out.println("in getOperation");
+ return operationBuffer_;
+ }
+
+ // ------------------------------------------------------------------
+ /**
+ * This method will get the operation reply buffer for this statement. Null
+ * is returned if the operation reply buffer has not been set.
+ *
+ * @retrun The operation reply buffer or null.
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+ public byte[] getOperationReplyBuffer() throws SQLException {
+ // System.out.println("in getOperationReplyBuffer");
+ return operationReply_;
+ }
+
+ // ------------------------------------------------------------------
+
+ public void setCursorName(String name) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, name);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setCursorName", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, name);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("setCursorName");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ // TODO: May need to check the Statement STATE
+ cursorName_ = name;
+ }
+
+ public void setEscapeProcessing(boolean enable) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, enable);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setEscapeProcessing", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, enable);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("setEscapeProcessing");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ escapeProcess_ = enable;
+
+ }
+
+ public void setFetchDirection(int direction) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, direction);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setFetchDirection", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, direction);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("setFetchDirection");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ switch (direction) {
+ case ResultSet.FETCH_FORWARD:
+ fetchDirection_ = direction;
+ break;
+ case ResultSet.FETCH_REVERSE:
+ case ResultSet.FETCH_UNKNOWN:
+ fetchDirection_ = ResultSet.FETCH_FORWARD;
+ break;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_fetch_direction", null);
+ }
+ }
+
+ public void setFetchSize(int rows) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rows);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setFetchSize", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rows);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("setFetchSize");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (rows < 0) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_fetch_size",
+ null);
+ } else if (rows == 0) {
+ fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
+ } else {
+ fetchSize_ = rows;
+ }
+ }
+
+ public void setMaxFieldSize(int max) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, max);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setMaxFieldSize", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, max);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("setMaxFieldSize");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (max < 0) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_maxFieldSize_value", null);
+ }
+ maxFieldSize_ = max;
+ }
+
+ public void setMaxRows(int max) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, max);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setMaxRows", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, max);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("setMaxRows");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (max < 0) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_maxRows_value",
+ null);
+ }
+ maxRows_ = max;
+ }
+
+ public void setQueryTimeout(int seconds) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, seconds);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "setQueryTimeout", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, seconds);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("setQueryTimeout");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ //HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "setQueryTimeout()");
+
+ if (seconds < 0) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_queryTimeout_value", null);
+ }
+ queryTimeout_ = seconds;
+ }
+
+ // ------------------------------------------------------------------
+ /**
+ * This method will set the operation ID for this statement.
+ *
+ * @param opID
+ * the operation ID to associate with this statement.
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+ public void setOperationID(short opID) throws SQLException {
+ operationID_ = opID;
+ } // end setOperationID
+
+ // ------------------------------------------------------------------
+ /**
+ * This method will set the operation buffer for this statement.
+ *
+ * @param The
+ * operation buffer.
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+ public void setOperationBuffer(byte[] opBuffer) throws SQLException {
+ operationBuffer_ = opBuffer;
+ }
+
+
+ void validateExecDirectInvocation(String sql) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "validateExecDirectInvocation", "", p);
+ }
+
+ validateExecDirectInvocation();
+ sqlStmtType_ = ist_.getSqlStmtType(sql);
+ ist_.setTransactionStatus(connection_, sql);
+ sql_ = sql;
+
+ }
+
+ void validateExecDirectInvocation() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "validateExecDirectInvocation", "", p);
+ }
+ ist_.setRowCount(-1);
+ clearWarnings();
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_statement",
+ null);
+ }
+ try {
+ // connection_.getServerHandle().isConnectionOpen();
+ connection_.isConnectionOpen();
+
+ // close the previous resultset, if any
+ for (int i = 0; i < num_result_sets_; i++) {
+ if (resultSet_[i] != null) {
+ resultSet_[i].close();
+ }
+ }
+ } catch (SQLException se) {
+ performConnectionErrorChecks(se);
+ throw se;
+ }
+ }
+
+ // This functions ensure that Database Resources are cleaned up,
+ // but leave the java Statement object
+ // intact.
+ void internalClose() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "internalClose", "", p);
+ }
+ if (connection_._isClosed() == false) {
+ ist_.close();
+ }
+ }
+
+ private void setResultSet(HPT4Desc[] outputDesc) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, outputDesc);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "setResultSet", "", p);
+ }
+ initResultSets();
+ if (outputDesc != null) {
+ resultSet_[result_set_offset] = new TrafT4ResultSet(this, outputDesc);
+ } else {
+ resultSet_[result_set_offset] = null;
+ }
+ }
+
+ public void setTransactionToJoin(byte[] txid) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, txid);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "setTransactionToJoin", "", p);
+ }
+
+ this.transactionToJoin = txid;
+ }
+
+ void setMultipleResultSets(int num_result_sets, HPT4Desc[][] output_descriptors, String[] stmt_labels,
+ String[] proxySyntax) throws SQLException {
+ if (num_result_sets < 1)
+ return;
+
+ resultSet_ = new TrafT4ResultSet[num_result_sets];
+ num_result_sets_ = num_result_sets;
+ for (int i = 0; i < num_result_sets; i++) {
+ HPT4Desc[] desc = output_descriptors[i];
+ if (desc == null) {
+ resultSet_[i] = null;
+ } else {
+ resultSet_[i] = new TrafT4ResultSet(this, desc, stmt_labels[i], true);
+ resultSet_[i].proxySyntax_ = proxySyntax[i];
+ }
+ }
+ }
+
+ // ----------------------------------------------------------------------------------
+ void setExecute2Outputs(byte[] values, short rowsAffected, boolean endOfData, String[] proxySyntax, HPT4Desc[] desc)
+ throws SQLException {
+ num_result_sets_ = 1;
+ result_set_offset = 0;
+
+ // if NO DATA FOUND is returned from the server, desc = null but
+ // we still want to save our descriptors from PREPARE
+ if (desc != null)
+ outputDesc_ = desc;
+
+ resultSet_ = new TrafT4ResultSet[num_result_sets_];
+
+ if (outputDesc_ != null) {
+ resultSet_[result_set_offset] = new TrafT4ResultSet(this, outputDesc_);
+ resultSet_[result_set_offset].proxySyntax_ = proxySyntax[result_set_offset];
+
+ if (rowsAffected == 0) {
+ if (endOfData == true) {
- resultSet_[result_set_offset].setFetchOutputs(new Row[0], 0, true);
++ resultSet_[result_set_offset].setFetchOutputs(new ObjectArray[0], 0, true);
+ }
+ } else {
+ if(resultSet_[result_set_offset].keepRawBuffer_ == true)
+ resultSet_[result_set_offset].rawBuffer_ = values;
+
+ resultSet_[result_set_offset].irs_.setExecute2FetchOutputs(resultSet_[result_set_offset], 1, true,
+ values);
+ }
+ } else {
+ resultSet_[result_set_offset] = null;
+ }
+ }
+
+ // Constructors with access specifier as "default"
+ TrafT4Statement() {
+ if (T4Properties.t4GlobalLogger.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(null);
+ T4Properties.t4GlobalLogger.logp(Level.FINE, "TrafT4Statement", "<init>", "", p);
+ }
+ resultSet_ = new TrafT4ResultSet[1];
+ initResultSets();
+ }
+
+ /*
+ * * For closing statements using label.
+ */
+ TrafT4Statement(TrafT4Connection connection, String stmtLabel) throws SQLException {
+ if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, stmtLabel);
+ connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>", "", p);
+ }
+ if (connection.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("Note, this constructor was called before the previous constructor");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection.props_.getLogWriter().println(temp);
+ }
+ int hashcode;
+
+ connection_ = connection;
+ operationID_ = -1;
+
+ resultSetType_ = ResultSet.TYPE_FORWARD_ONLY;
+ resultSetConcurrency_ = ResultSet.CONCUR_READ_ONLY;
+ resultSetHoldability_ = TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT;
+ queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
+
+ stmtLabel_ = stmtLabel;
+ fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
+ maxRows_ = 0;
+ fetchDirection_ = ResultSet.FETCH_FORWARD;
+ pRef_ = new WeakReference(this, connection_.refStmtQ_);
+ ist_ = new InterfaceStatement(this);
+ connection_.addElement(pRef_, stmtLabel_);
+
+ resultSet_ = new TrafT4ResultSet[1];
+ initResultSets();
+ }
+
+ TrafT4Statement(TrafT4Connection connection) throws SQLException {
+ this(connection, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT);
+ if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection);
+ connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>",
+ "Note, this constructor was called before the previous constructor", p);
+ }
+ if (connection.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("<init>");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection.props_.getLogWriter().println(temp);
+ }
+ resultSet_ = new TrafT4ResultSet[1];
+ roundingMode_ = connection_.props_.getRoundingMode();
+ initResultSets();
+ }
+
+ TrafT4Statement(TrafT4Connection connection, int resultSetType, int resultSetConcurrency) throws SQLException {
+ this(connection, resultSetType, resultSetConcurrency, TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT);
+ if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+ resultSetConcurrency);
+ connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>",
+ "Note, this constructor was called before the previous constructor", p);
+ }
+ if (connection.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+ resultSetConcurrency);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("<init>");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection.props_.getLogWriter().println(temp);
+ }
+ resultSet_ = new TrafT4ResultSet[1];
+ roundingMode_ = connection_.props_.getRoundingMode();
+ initResultSets();
+ }
+ TrafT4Statement(TrafT4Connection connection, int resultSetType, int resultSetConcurrency, int resultSetHoldability,
+ String stmtLabel) throws SQLException {
+ if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>", "", p);
+ }
+ if (connection.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("<init>");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection.props_.getLogWriter().println(temp);
+ }
+ int hashcode;
+
+ connection_ = connection;
+ operationID_ = -1;
+
+ if (resultSetType != ResultSet.TYPE_FORWARD_ONLY && resultSetType != ResultSet.TYPE_SCROLL_INSENSITIVE
+ && resultSetType != ResultSet.TYPE_SCROLL_SENSITIVE) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_resultset_type", null);
+ }
+
+ if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) {
+ resultSetType_ = ResultSet.TYPE_SCROLL_INSENSITIVE;
+ connection_.setSQLWarning(null, "scrollResultSetChanged", null);
+ //setSQLWarning(null, "scrollResultSetChanged", null);
+ } else {
+ resultSetType_ = resultSetType;
+ }
+ if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY && resultSetConcurrency != ResultSet.CONCUR_UPDATABLE) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_resultset_concurrency", null);
+ }
+
+ if ((resultSetHoldability != 0) && (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT)
+ && (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_holdability",
+ null);
+ }
+
+ resultSetConcurrency_ = resultSetConcurrency;
+ resultSetHoldability_ = resultSetHoldability;
+ queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
+
+ stmtLabel_ = stmtLabel;
+ fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
+ maxRows_ = 0;
+ fetchDirection_ = ResultSet.FETCH_FORWARD;
+
+ connection_.gcStmts();
+ pRef_ = new WeakReference(this, connection_.refStmtQ_);
+ ist_ = new InterfaceStatement(this);
+ connection_.addElement(pRef_, stmtLabel_);
+ roundingMode_ = connection_.props_.getRoundingMode();
+
+ resultSet_ = new TrafT4ResultSet[1];
+ }
+
+ TrafT4Statement(TrafT4Connection connection, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException {
+ if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ connection.props_.t4Logger_.logp(Level.FINE, "TrafT4Statement", "<init>", "", p);
+ }
+ if (connection.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4Statement");
+ lr.setSourceMethodName("<init>");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection.props_.getLogWriter().println(temp);
+ }
+ int hashcode;
+
+ connection_ = connection;
+ operationID_ = -1;
+
+ if (resultSetType != ResultSet.TYPE_FORWARD_ONLY && resultSetType != ResultSet.TYPE_SCROLL_INSENSITIVE
+ && resultSetType != ResultSet.TYPE_SCROLL_SENSITIVE) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_resultset_type", null);
+ }
+
+ if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) {
+ resultSetType_ = ResultSet.TYPE_SCROLL_INSENSITIVE;
+ connection_.setSQLWarning(null, "scrollResultSetChanged", null);
+ //setSQLWarning(null, "scrollResultSetChanged", null);
+ } else {
+ resultSetType_ = resultSetType;
+ }
+ if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY && resultSetConcurrency != ResultSet.CONCUR_UPDATABLE) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_resultset_concurrency", null);
+ }
+
+ if ((resultSetHoldability != 0) && (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT)
+ && (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_holdability",
+ null);
+ }
+
+ resultSetConcurrency_ = resultSetConcurrency;
+ resultSetHoldability_ = resultSetHoldability;
+ queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
+
+ stmtLabel_ = generateStmtLabel();
+ fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
+ maxRows_ = 0;
+ fetchDirection_ = ResultSet.FETCH_FORWARD;
+
+ connection_.gcStmts();
+ pRef_ = new WeakReference(this, connection_.refStmtQ_);
+ ist_ = new InterfaceStatement(this);
+ connection_.addElement(pRef_, stmtLabel_);
+
+ resultSet_ = new TrafT4ResultSet[1];
+ roundingMode_ = connection_.props_.getRoundingMode();
+ initResultSets();
+ }
+
+ //max length for a label is 32 characters.
+ String generateStmtLabel() {
+ String id = String.valueOf(this.connection_.ic_.getSequenceNumber());
+ if(id.length() > 24) {
+ id = id.substring(id.length()-24);
+ }
+
+ return "SQL_CUR_" + id;
+ }
+
+ // Database statement are not deallocated when there is a
+ // SQLWarning or SQLException or when a resultSet is produced
+ void checkSQLWarningAndClose() {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4Statement", "checkSQLWarningAndClose", "", p);
+ }
+ if (sqlWarning_ != null) {
+ if (resultSet_[result_set_offset] == null) {
+ try {
+ internalClose();
+ } catch (SQLException closeException1) {
+ }
+ }
+ }
+ }
+
+ public void setRoundingMode(int roundingMode) {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, roundingMode);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setRoundingMode", "", p);
+ }
+ roundingMode_ = Utility.getRoundingMode(roundingMode);
+ }
+
+ public void setRoundingMode(String roundingMode) {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, roundingMode);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setRoundingMode", "", p);
+ }
+ roundingMode_ = Utility.getRoundingMode(roundingMode);
+ }
+
+ void closeErroredConnection(HPT4Exception sme) {
+ connection_.closeErroredConnection(sme);
+ }
+
+ /**
+ * Use this method to retrieve the statement-label name that was used when
+ * creating the statement through the Trafodion connectivity service. You can
+ * subsequently use the name retrieved as the cursor name when invoking
+ * INFOSTATS to gather resource statistics through either the
+ * <code>executeQuery(String sql)</code> or
+ * <code>execute(String sql)</code> methods.
+ */
+ public String getStatementLabel() {
+ return new String(stmtLabel_);
+ }
+
+ /**
+ * Returns the raw SQL associated with the statement
+ *
+ * @return the SQL text
+ */
+ public String getSQL() {
+ return this.sql_;
+ }
+
+ /**
+ * Returns the MXCS statement handle
+ *
+ * @return the MXCS statement handle
+ */
+ public int getStmtHandle() {
+ return this.ist_.stmtHandle_;
+ }
+
+ // static fields
+ public static final int NO_GENERATED_KEYS = 2;
+ // Fields
+ TrafT4Connection connection_;
+ int resultSetType_;
+ int resultSetConcurrency_;
+ String sql_;
+ int queryTimeout_;
+ int maxRows_;
+ int maxFieldSize_;
+ int fetchSize_;
+ int fetchDirection_;
+ boolean escapeProcess_;
+ String cursorName_ = "";
+ TrafT4ResultSet[] resultSet_; // Added for SPJ RS - SB 11/21/2005
+ int num_result_sets_; // Added for SPJ RS - SB 11/21/2005
+ int result_set_offset; // Added for SPJ RS - SB 11/21/2005
+ String stmtLabel_;
+ short sqlStmtType_;
+ boolean isClosed_;
+ ArrayList batchCommands_;
+ int[] batchRowCount_;
+ WeakReference pRef_;
+ int resultSetHoldability_;
+ InterfaceStatement ist_;
+
+ int inputParamsLength_;
+ int outputParamsLength_;
+ int inputDescLength_;
+ int outputDescLength_;
+
+ int inputParamCount_;
+ int outputParamCount_;
+
+ int roundingMode_ = BigDecimal.ROUND_HALF_EVEN;
+
+ HPT4Desc[] inputDesc_, outputDesc_;
+
+ short operationID_;
+ byte[] operationBuffer_;
+ byte[] operationReply_;
+
+ boolean usingRawRowset_;
+ ByteBuffer rowwiseRowsetBuffer_;
+
+ byte[] transactionToJoin;
+
+ int _lastCount = -1;
+
+ /**
+ * @return the inputParamsLength_
+ */
+ public int getInputParamsLength_() {
+ return inputParamsLength_;
+ }
+
+ /**
+ * @return the outputParamsLength_
+ */
+ public int getOutputParamsLength_() {
+ return outputParamsLength_;
+ }
+
+ public Object unwrap(Class iface) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isWrapperFor(Class iface) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isClosed() throws SQLException {
+ // TODO Auto-generated method stub
+ return isClosed_;
+ }
+
+ public void setPoolable(boolean poolable) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isPoolable() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void closeOnCompletion() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isCloseOnCompletion() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a0f21cde/core/sqf/sqenvcom.sh
----------------------------------------------------------------------
[43/60] incubator-trafodion git commit: Merge branch 'master' of
github.com:apache/incubator-trafodion into wrkbrnch
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a0f21cde/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
----------------------------------------------------------------------
diff --cc core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
index 489904f,0000000..0d4fe28
mode 100644,000000..100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
@@@ -1,2558 -1,0 +1,2558 @@@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+
+package org.trafodion.jdbc.t4;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URL;
+import java.nio.ByteBuffer;
+import java.sql.Array;
+import java.sql.BatchUpdateException;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.DatabaseMetaData;
+import java.sql.Date;
+import java.sql.NClob;
+import java.sql.ParameterMetaData;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Locale;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+public class TrafT4PreparedStatement extends TrafT4Statement implements java.sql.PreparedStatement {
+ // java.sql.PreparedStatement interface methods
+ public void addBatch() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "addBatch", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("addBatch");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (inputDesc_ == null) {
+ return;
+ }
+
+ // Check if all parameters are set for current set
+ checkIfAllParamsSet();
+ // Add to the number of Rows Count
+ if (rowsValue_ == null) {
+ rowsValue_ = new ArrayList();
+ }
+ rowsValue_.add(paramsValue_);
+ paramRowCount_++;
+ paramsValue_ = new Object[inputDesc_.length];
+ if (isAnyLob_ && (lobObjects_ == null)) {
+ lobObjects_ = new ArrayList();
+ // Clear the isValueSet_ flag in inputDesc_ and add the lob objects
+ // to the lobObject List
+ }
+ for (int i = 0; i < inputDesc_.length; i++) {
+ // If isAnyLob_ is false: inputDesc_.paramValue_ for all
+ // parameters should be null
+ // If isAnyLob_ is true: one or more inputDesc_.parmValue will not
+ // be null, based on the number of LOB columns in the query
+ if (inputDesc_[i].paramValue_ != null) {
+ lobObjects_.add(inputDesc_[i].paramValue_);
+ inputDesc_[i].paramValue_ = null;
+ }
+ inputDesc_[i].isValueSet_ = false;
+ }
+ }
+
+ public void clearBatch() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "clearBatch", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("clearBatch");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (inputDesc_ == null) {
+ return;
+ }
+ if (rowsValue_ != null) {
+ rowsValue_.clear();
+ }
+ if (lobObjects_ != null) {
+ lobObjects_.clear();
+ }
+ paramRowCount_ = 0;
+ // Clear the isValueSet_ flag in inputDesc_
+ for (int i = 0; i < inputDesc_.length; i++) {
+ inputDesc_[i].isValueSet_ = false;
+ paramsValue_[i] = null;
+ inputDesc_[i].paramValue_ = null;
+ }
+ isAnyLob_ = false;
+ batchRowCount_ = new int[] {};
+ }
+
+ public void clearParameters() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "clearParameters", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("clearParameters");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ // Clear the isValueSet_ flag in inputDesc_
+ if (inputDesc_ == null) {
+ return;
+ }
+
+ for (int i = 0; i < inputDesc_.length; i++) {
+ inputDesc_[i].isValueSet_ = false;
+ paramsValue_[i] = null;
+ inputDesc_[i].paramValue_ = null;
+ }
+ isAnyLob_ = false;
+ }
+
+ public void close() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "close", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("close");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (isClosed_) {
+ return;
+ }
+ try {
+ if (connection_._isClosed() == false) {
+ if (!connection_.isStatementCachingEnabled()) {
+ super.close();
+ } else {
+ logicalClose();
+ }
+ }
+ } catch (SQLException e) {
+ performConnectionErrorChecks(e);
+ throw e;
+ } finally {
+ isClosed_ = true;
+ if (!connection_.isStatementCachingEnabled()) {
+ connection_.removeElement(pRef_);
+ }
+ }
+
+ }
+
+ public boolean execute() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "execute", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("execute");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Object[] valueArray = null;
+ int inDescLength = 0;
+
+ validateExecuteInvocation();
+
+ // *******************************************************************
+ // * If LOB is involved with autocommit enabled we throw an exception
+ // *******************************************************************
+ if (isAnyLob_ && (connection_.getAutoCommit())) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_lob_commit_state", null);
+ }
+ if (inputDesc_ != null) {
+ if (!usingRawRowset_)
+ valueArray = getValueArray();
+ inDescLength = inputDesc_.length;
+ }
+
+ execute(paramRowCount_ + 1, inDescLength, valueArray, queryTimeout_, isAnyLob_); // LOB
+ // Support
+ // - SB
+ // 9/28/04
+
+ // if (resultSet_[result_set_offset] != null)
+ if (resultSet_ != null && resultSet_[result_set_offset] != null) {
+ return true;
+ } else {
+ if (isAnyLob_) {
+
+
+ }
+ return false;
+ }
+ }
+
+ public int[] executeBatch() throws SQLException, BatchUpdateException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "executeBatch", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("executeBatch");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ try {
+ clearWarnings();
+ HPT4Exception se;
+ Object[] valueArray = null;
+
+ if (inputDesc_ == null) {
+ se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "batch_command_failed", null);
+ throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+ }
+ if (sqlStmtType_ == TRANSPORT.TYPE_SELECT) {
+ se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "select_in_batch_not_supported", null);
+ throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+ }
+ if (connection_._isClosed()) {
+ se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "invalid_connection",
+ null);
+ connection_.closeErroredConnection(se);
+ throw new BatchUpdateException(se.getMessage(), se.getSQLState(), new int[0]);
+ }
+ if (isAnyLob_ && (connection_.getAutoCommit())) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_lob_commit_state", null);
+ }
+
+ int prc = usingRawRowset_ ? (paramRowCount_ + 1) : paramRowCount_;
+
+ if (paramRowCount_ < 1) {
+ if (!connection_.props_.getDelayedErrorMode()) {
+ return (new int[] {});
+ }
+ }
+
+ try {
+ if (!usingRawRowset_)
+ valueArray = getValueArray();
+
+ execute(prc, inputDesc_.length, valueArray, queryTimeout_, lobObjects_ != null);
+
+
+ } catch (SQLException e) {
+ BatchUpdateException be;
+ se = HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "batch_command_failed", null);
+ if (batchRowCount_ == null) // we failed before execute
+ {
+ batchRowCount_ = new int[paramRowCount_];
+ Arrays.fill(batchRowCount_, -3);
+ }
+ be = new BatchUpdateException(se.getMessage(), se.getSQLState(), batchRowCount_);
+ be.setNextException(e);
+
+ throw be;
+ }
+
+ if (connection_.props_.getDelayedErrorMode()) {
+ _lastCount = paramRowCount_;
+ }
+
+ return batchRowCount_;
+ } finally {
+ clearBatch();
+ }
+ }
+
+ public ResultSet executeQuery() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "executeQuery", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("executeQuery");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Object[] valueArray = null;
+ int inDescLength = 0;
+
+ validateExecuteInvocation();
+ if (sqlStmtType_ != TRANSPORT.TYPE_SELECT) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "non_select_invalid",
+ null);
+ }
+
+ if (inputDesc_ != null) {
+ if (!usingRawRowset_)
+ valueArray = getValueArray();
+ inDescLength = inputDesc_.length;
+ }
+ execute(paramRowCount_ + 1, inDescLength, valueArray, queryTimeout_, isAnyLob_); // LOB
+ // Support
+ // - SB
+ // 9/28/04
+ return resultSet_[result_set_offset];
+ }
+
+ public int executeUpdate() throws SQLException {
+ long count = executeUpdate64();
+
+ if (count > Integer.MAX_VALUE)
+ this.setSQLWarning(null, "numeric_out_of_range", null);
+
+ return (int) count;
+ }
+
+ public long executeUpdate64() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "executeUpdate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("executeUpdate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ Object[] valueArray = null;
+ int inDescLength = 0;
+
+ validateExecuteInvocation();
+ // if (sqlStmtType_ == TRANSPORT.TYPE_SELECT)
+ if (sqlStmtType_ == TRANSPORT.TYPE_SELECT && (ist_.stmtIsLock != true)) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "select_invalid", null);
+ }
+
+ if (usingRawRowset_ == false) {
+ if (inputDesc_ != null) {
+ if (!usingRawRowset_)
+ valueArray = getValueArray();
+ inDescLength = inputDesc_.length;
+ }
+ } else {
+ valueArray = this.paramsValue_; // send it along raw in case we need
+ // it
+ paramRowCount_ -= 1; // we need to make sure that paramRowCount
+ // stays exactly what we set it to since we
+ // add one during execute
+ }
+
+ // *******************************************************************
+ // * If LOB is involved with autocommit enabled we throw an exception
+ // *******************************************************************
+ if (isAnyLob_ && (connection_.getAutoCommit())) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_lob_commit_state", null);
+ }
+
+ execute(paramRowCount_ + 1, inDescLength, valueArray, queryTimeout_, isAnyLob_);
+ if (isAnyLob_) {
+
+
+ }
+ return ist_.getRowCount();
+ }
+
+ public ResultSetMetaData getMetaData() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "getMetaData", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("getMetaData");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ if (outputDesc_ != null) {
+ return new HPT4ResultSetMetaData(this, outputDesc_);
+ } else {
+ return null;
+ }
+ }
+
+ public ParameterMetaData getParameterMetaData() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "getParameterMetaData", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("getParameterMetaData");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (inputDesc_ != null) {
+ return new HPT4ParameterMetaData(this, inputDesc_);
+ } else {
+ return null;
+ }
+ }
+
+ // JDK 1.2
+ public void setArray(int parameterIndex, Array x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setArray", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setArray");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "setArray()");
+ }
+
+ public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setAsciiStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setAsciiStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ long dataLocator;
+
+ validateSetInvocation(parameterIndex);
+
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+
+ switch (dataType) {
+
+
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BINARY: // At this time Database does not have
+ // this column data type
+ case Types.VARBINARY: // At this time Database does not
+ // have this column data type //#endif-java
+ case Types.LONGVARBINARY: // At this time Database does not
+ // have this column data type
+ byte[] buffer = new byte[length];
+ try {
+ x.read(buffer);
+ } catch (java.io.IOException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
+ messageArguments);
+ }
+
+ try {
+ addParamValue(parameterIndex, new String(buffer, "ASCII"));
+ } catch (java.io.UnsupportedEncodingException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "unsupported_encoding", messageArguments);
+ }
+ break;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_datatype_for_column", null);
+ }
+ }
+
+ public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setBigDecimal", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setBigDecimal");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ validateSetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+
+ if (x != null) {
+ Utility.checkDecimalTruncation(parameterIndex, connection_.getLocale(), x,
+ inputDesc_[parameterIndex - 1].precision_, inputDesc_[parameterIndex - 1].scale_);
+ addParamValue(parameterIndex, x.toString());
+ } else {
+ addParamValue(parameterIndex, null);
+ }
+ }
+
+ public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setBinaryStream",
+ "setBinaryStream", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setBinaryStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ long dataLocator;
+
+ validateSetInvocation(parameterIndex);
+
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+
+ switch (dataType) {
+
+
+ case Types.DOUBLE:
+ case Types.DECIMAL:
+ case Types.NUMERIC:
+ case Types.FLOAT:
+ case Types.BIGINT:
+ case Types.INTEGER:
+ case Types.SMALLINT:
+ case Types.TINYINT:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_datatype_for_column", null);
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BINARY: // At this time Database does not have
+ // this column data type
+ case Types.VARBINARY: // At this time Database does not
+ // have this column data type
+ case Types.LONGVARBINARY: // At this time Database does not
+ // have this column data type
+ byte[] buffer2 = new byte[length];
+
+ try {
+ int temp = x.read(buffer2);
+ } catch (java.io.IOException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
+ messageArguments);
+ }
+ addParamValue(parameterIndex, buffer2);
+ break;
+ default:
+ byte[] buffer = new byte[length];
+
+ try {
+ x.read(buffer);
+ } catch (java.io.IOException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
+ messageArguments);
+ }
+
+ // addParamValue(parameterIndex, new String(buffer));
+ // just pass the raw buffer.
+ addParamValue(parameterIndex, buffer);
+ }
+ }
+
+ /*
+ * Sets the designated parameter to the given <tt>Blob</tt> object. The
+ * driver converts this to an SQL <tt>BLOB</tt> value when it sends it to
+ * the database.
+ *
+ * @param i the first parameter is 1, the second is 2, ... @param x a <tt>Blob</tt>
+ * object that maps an SQL <tt>BLOB</tt> value
+ *
+ * @throws SQLException invalid data type for column
+ */
+ public void setBlob(int parameterIndex, Blob x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setBlob", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setBlob");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ long dataLocator;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ switch (dataType) {
+
+
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_datatype_for_column", null);
+ }
+ }
+
+ public void setBoolean(int parameterIndex, boolean x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setBoolean", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setBoolean");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ if (x) {
+ addParamValue(parameterIndex, "1"); // true
+ } else {
+ addParamValue(parameterIndex, "0"); // false
+ }
+ }
+
+ public void setByte(int parameterIndex, byte x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setByte", "setByte", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setByte");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ addParamValue(parameterIndex, Byte.toString(x));
+ }
+
+ public void setBytes(int parameterIndex, byte[] x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setBytes", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setBytes");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ long dataLocator;
+
+ byte[] tmpArray = new byte[x.length];
+ System.arraycopy(x, 0, tmpArray, 0, x.length);
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ switch (dataType) {
+
+
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BINARY:
+ case Types.VARBINARY:
+ case Types.LONGVARBINARY:
+ addParamValue(parameterIndex, tmpArray);
+ break;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ }
+
+ public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, reader, length);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setCharacterStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, reader, length);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setCharacterStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ char[] value;
+ int dataType;
+ long dataLocator;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ switch (dataType) {
+
+
+ case Types.DECIMAL:
+ case Types.DOUBLE:
+ case Types.FLOAT:
+ case Types.NUMERIC:
+ case Types.BIGINT:
+ case Types.INTEGER:
+ case Types.SMALLINT:
+ case Types.TINYINT:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_datatype_for_column", null);
+
+ default:
+ value = new char[length];
+ try {
+ int valuePos = reader.read(value);
+ if (valuePos < 1) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = "No data to read from the Reader";
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
+ messageArguments);
+ }
+
+ while (valuePos < length) {
+ char temp[] = new char[length - valuePos];
+ int tempReadLen = reader.read(temp, 0, length - valuePos);
+ System.arraycopy(temp, 0, value, valuePos, tempReadLen);
+ valuePos += tempReadLen;
+ }
+ } catch (java.io.IOException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
+ messageArguments);
+ }
+ addParamValue(parameterIndex, new String(value));
+ break;
+ }
+ }
+
+ /**
+ * Sets the designated parameter to the given <tt>Clob</tt> object. The
+ * driver converts this to an SQL <tt>CLOB</tt> value when it sends it to
+ * the database.
+ *
+ * @param parameterIndex
+ * the first parameter is 1, the second is 2, ...
+ * @param x
+ * a <tt>Clob</tt> object that maps an SQL <tt>CLOB</tt>
+ *
+ * @throws SQLException
+ * invalid data type for column, or restricted data type.
+ */
+ public void setClob(int parameterIndex, Clob x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setClob", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setClob");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ long dataLocator;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ switch (dataType) {
+
+
+ case Types.DECIMAL:
+ case Types.DOUBLE:
+ case Types.FLOAT:
+ case Types.NUMERIC:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_datatype_for_column", null);
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ }
+
+ public void setDate(int parameterIndex, Date x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ Timestamp t1;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.DATE && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ if (x != null) {
+ if (dataType == Types.TIMESTAMP) {
+ t1 = new Timestamp(x.getTime());
+ addParamValue(parameterIndex, t1.toString());
+ } else {
+ addParamValue(parameterIndex, x.toString());
+ }
+ } else {
+ addParamValue(parameterIndex, null);
+ }
+ }
+
+ public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setDate", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setDate");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ long dateValue;
+ Date adjustedDate;
+ Timestamp t1;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.DATE && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ // Ignore the cal, since SQL would expect it to store it in the local
+ // time zone
+ if (x != null) {
+ if (dataType == Types.TIMESTAMP) {
+ t1 = new Timestamp(x.getTime());
+ addParamValue(parameterIndex, t1.toString());
+ } else {
+ addParamValue(parameterIndex, x.toString());
+ }
+ } else {
+ addParamValue(parameterIndex, null);
+
+ }
+ }
+
+ public void setDouble(int parameterIndex, double x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setDouble", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setDouble");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ addParamValue(parameterIndex, Double.toString(x));
+ inputDesc_[parameterIndex - 1].isValueSet_ = true;
+ }
+
+ public void setFloat(int parameterIndex, float x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setFloat", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setFloat");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ addParamValue(parameterIndex, Float.toString(x));
+ }
+
+ public void setInt(int parameterIndex, int x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setInt", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setInt");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ addParamValue(parameterIndex, Integer.toString(x));
+ }
+
+ public void setLong(int parameterIndex, long x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setLong", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setLong");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ Utility.checkLongBoundary(connection_.getLocale(), BigDecimal.valueOf(x));
+ addParamValue(parameterIndex, Long.toString(x));
+ }
+
+ public void setNull(int parameterIndex, int sqlType) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setNull", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, sqlType);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setNull");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ addParamValue(parameterIndex, null);
+ }
+
+ public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, paramIndex, sqlType, typeName);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setNull", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, paramIndex, sqlType, typeName);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setNull");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ setNull(paramIndex, sqlType);
+ }
+
+ public void setObject(int parameterIndex, Object x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ if (x == null) {
+ setNull(parameterIndex, Types.NULL);
+ } else if (x instanceof BigDecimal) {
+ setBigDecimal(parameterIndex, (BigDecimal) x);
+ } else if (x instanceof java.sql.Date) {
+ setDate(parameterIndex, (Date) x);
+ } else if (x instanceof java.sql.Time) {
+ setTime(parameterIndex, (Time) x);
+ } else if (x instanceof java.sql.Timestamp) {
+ setTimestamp(parameterIndex, (Timestamp) x);
+ } else if (x instanceof Double) {
+ setDouble(parameterIndex, ((Double) x).doubleValue());
+ } else if (x instanceof Float) {
+ setFloat(parameterIndex, ((Float) x).floatValue());
+ } else if (x instanceof Long) {
+ setLong(parameterIndex, ((Long) x).longValue());
+ } else if (x instanceof Integer) {
+ setInt(parameterIndex, ((Integer) x).intValue());
+ } else if (x instanceof Short) {
+ setShort(parameterIndex, ((Short) x).shortValue());
+ } else if (x instanceof Byte) {
+ setByte(parameterIndex, ((Byte) x).byteValue());
+ } else if (x instanceof Boolean) {
+ setBoolean(parameterIndex, ((Boolean) x).booleanValue());
+ } else if (x instanceof String) {
+ setString(parameterIndex, x.toString());
+ } else if (x instanceof byte[]) {
+ setBytes(parameterIndex, (byte[]) x);
+ } else if (x instanceof Clob) {
+ setClob(parameterIndex, (Clob) x);
+ } else if (x instanceof Blob) {
+ setBlob(parameterIndex, (Blob) x);
+ /*
+ * else if (x instanceof DataWrapper) {
+ * validateSetInvocation(parameterIndex); setObject(parameterIndex,
+ * x, inputDesc_[parameterIndex - 1].dataType_); }
+ */
+ } else if (x instanceof BigInteger) {
+ setBigDecimal(parameterIndex, new BigDecimal((BigInteger) x));
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "object_type_not_supported", null);
+ }
+ }
+
+ public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, targetSqlType);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, targetSqlType);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ setObject(parameterIndex, x, targetSqlType, -1);
+ }
+
+ public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, targetSqlType, scale);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setObject", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, targetSqlType, scale);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setObject");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ BigDecimal tmpbd;
+ int precision;
+ Locale locale = connection_.getLocale();
+
+ if (x == null) {
+ setNull(parameterIndex, Types.NULL);
+ } else {
+ switch (targetSqlType) {
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.BLOB:
+ case Types.CLOB:
+ setString(parameterIndex, x.toString());
+ break;
+ case Types.VARBINARY:
+ case Types.BINARY:
+ case Types.LONGVARBINARY:
+ setBytes(parameterIndex, (byte[]) x);
+ break;
+ case Types.TIMESTAMP:
+ if (x instanceof Timestamp) {
+ setTimestamp(parameterIndex, (Timestamp) x);
+ } else if (x instanceof Date) {
+ setTimestamp(parameterIndex, Timestamp.valueOf(x.toString() + " 00:00:00.0"));
+ } else {
+ setString(parameterIndex, x.toString());
+ }
+ break;
+ case Types.TIME:
+ if (x instanceof Time) {
+ setTime(parameterIndex, (Time) x);
+ } else if (x instanceof Date) {
+ setTime(parameterIndex, new Time(((Date) x).getTime()));
+ } else if (x instanceof Timestamp) {
+ setTime(parameterIndex, new Time(((Timestamp) x).getTime()));
+ } else {
+ setString(parameterIndex, x.toString());
+ }
+ break;
+ case Types.DATE:
+ try {
+ if (x instanceof Date) {
+ setDate(parameterIndex, (Date) x);
+ } else if (x instanceof Time) {
+ setDate(parameterIndex, new Date(((Time) x).getTime()));
+ } else if (x instanceof Timestamp) {
+ setDate(parameterIndex, new Date(((Timestamp) x).getTime()));
+ } else {
+ setDate(parameterIndex, Date.valueOf(x.toString()));
+ }
+ } catch (IllegalArgumentException iex) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_parameter_value", x.toString());
+ }
+ break;
+ case Types.BOOLEAN:
+ setBoolean(parameterIndex, (Boolean.valueOf(x.toString())).booleanValue());
+ break;
+ case Types.SMALLINT:
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ Utility.checkShortBoundary(locale, tmpbd);
+ //Utility.checkLongTruncation(parameterIndex, tmpbd);
+ setShort(parameterIndex, tmpbd.shortValue());
+ break;
+ case Types.INTEGER:
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ //Utility.checkLongTruncation(parameterIndex, tmpbd);
+ //Utility.checkIntegerBoundary(locale, tmpbd);
+ setInt(parameterIndex, tmpbd.intValue());
+ break;
+ case Types.BIGINT:
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ Utility.checkLongBoundary(locale, tmpbd);
+ //Utility.checkLongTruncation(parameterIndex, tmpbd);
+ setLong(parameterIndex, tmpbd.longValue());
+ break;
+ case Types.DECIMAL:
+ // precision = getPrecision(parameterIndex - 1);
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ tmpbd = Utility.setScale(tmpbd, scale, BigDecimal.ROUND_HALF_EVEN);
+ // Utility.checkDecimalBoundary(locale, tmpbd, precision);
+ setBigDecimal(parameterIndex, tmpbd);
+ break;
+ case Types.NUMERIC:
+ // precision = getPrecision(parameterIndex - 1);
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ tmpbd = Utility.setScale(tmpbd, scale, BigDecimal.ROUND_HALF_EVEN);
+ // Utility.checkDecimalBoundary(locale, tmpbd, precision);
+ setBigDecimal(parameterIndex, tmpbd);
+ break;
+ case Types.TINYINT:
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ tmpbd = Utility.setScale(tmpbd, scale, roundingMode_);
+ Utility.checkTinyintBoundary(locale, tmpbd);
+ setShort(parameterIndex, tmpbd.shortValue());
+ break;
+ case Types.FLOAT:
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ Utility.checkFloatBoundary(locale, tmpbd);
+ setDouble(parameterIndex, tmpbd.doubleValue());
+ break;
+ case Types.DOUBLE:
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ Utility.checkDoubleBoundary(locale, tmpbd);
+ setDouble(parameterIndex, tmpbd.doubleValue());
+ break;
+ case Types.REAL:
+ tmpbd = Utility.getBigDecimalValue(locale, x);
+ setFloat(parameterIndex, tmpbd.floatValue());
+ break;
+ case Types.OTHER:
+ if (inputDesc_[parameterIndex].fsDataType_ == InterfaceResultSet.SQLTYPECODE_INTERVAL) {
+ if (x instanceof byte[]) {
+ addParamValue(parameterIndex, x);
+ } else if (x instanceof String) {
+ addParamValue(parameterIndex, x);
+ } else {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "conversion_not_allowed", null);
+ }
+ break;
+ }
+ case Types.ARRAY:
+ case Types.BIT:
+ case Types.DATALINK:
+ case Types.DISTINCT:
+ case Types.JAVA_OBJECT:
+ case Types.STRUCT:
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "object_type_not_supported", null);
+ }
+ }
+ }
+
+ // JDK 1.2
+ public void setRef(int i, Ref x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, i, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setRef", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, i, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setRef");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(i);
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "setRef()");
+ }
+
+ public void setShort(int parameterIndex, short x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setShort", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setShort");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
+ addParamValue(parameterIndex, Short.toString(x));
+ }
+
+ public void setString(int parameterIndex, String x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setString", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setString");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ int dataType = inputDesc_[parameterIndex - 1].dataType_;
+
+ switch (dataType) {
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ case Types.DATE:
+ case Types.TIME:
+ case Types.TIMESTAMP:
+ case Types.OTHER: // This type maps to the Database
+ // INTERVAL
+ addParamValue(parameterIndex, x);
+ break;
+
+
+ case Types.ARRAY:
+ case Types.BINARY:
+ case Types.BIT:
+ case Types.DATALINK:
+ case Types.JAVA_OBJECT:
+ case Types.REF:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "datatype_not_supported", null);
+ case Types.BIGINT:
+ case Types.INTEGER:
+ case Types.SMALLINT:
+ case Types.TINYINT:
+ case Types.DECIMAL:
+ case Types.NUMERIC:
+ if (x != null) {
+ x = x.trim(); // SQLJ is using numeric string with
+ // leading/trailing whitespace
+ }
+ setObject(parameterIndex, x, dataType);
+ break;
+ case Types.BLOB:
+ case Types.BOOLEAN:
+ case Types.DOUBLE:
+ case Types.FLOAT:
+ case Types.LONGVARBINARY:
+ case Types.NULL:
+ case Types.REAL:
+ case Types.VARBINARY:
+ setObject(parameterIndex, x, dataType);
+ break;
+ default:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "fetch_output_inconsistent", null);
+ }
+
+ }
+
+ public void setTime(int parameterIndex, Time x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ Timestamp t1;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ if (x != null) {
+ if (dataType == Types.TIMESTAMP) {
+ t1 = new Timestamp(x.getTime());
+ addParamValue(parameterIndex, t1.toString());
+ } else {
+ addParamValue(parameterIndex, x.toString());
+ }
+ } else {
+ addParamValue(parameterIndex, null);
+ }
+ }
+
+ public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setTime", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setTime");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ long timeValue;
+ Time adjustedTime;
+ Timestamp t1;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ // Ignore the cal, since SQL would expect it to store it in the local
+ // time zone
+ if (x != null) {
+ if (dataType == Types.TIMESTAMP) {
+ t1 = new Timestamp(x.getTime());
+ addParamValue(parameterIndex, t1.toString());
+ } else {
+ addParamValue(parameterIndex, x.toString());
+ }
+ } else {
+ addParamValue(parameterIndex, null);
+ }
+ }
+
+ public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ Date d1;
+ Time t1;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.DATE && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ if (x != null) {
+ switch (dataType) {
+ case Types.DATE:
+ d1 = new Date(x.getTime());
+ addParamValue(parameterIndex, d1.toString());
+ break;
+ case Types.TIME:
+ t1 = new Time(x.getTime());
+ addParamValue(parameterIndex, t1.toString());
+ break;
+ default:
+ addParamValue(parameterIndex, x.toString());
+ break;
+ }
+ } else {
+ addParamValue(parameterIndex, null);
+ }
+ }
+
+ public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setTimestamp", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, cal);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setTimestamp");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ int dataType;
+ long timeValue;
+ Timestamp adjustedTime;
+ Date d1;
+ Time t1;
+
+ validateSetInvocation(parameterIndex);
+ dataType = inputDesc_[parameterIndex - 1].dataType_;
+ if (dataType != Types.CHAR && dataType != Types.VARCHAR && dataType != Types.LONGVARCHAR
+ && dataType != Types.DATE && dataType != Types.TIME && dataType != Types.TIMESTAMP) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "restricted_data_type",
+ null);
+ }
+ // Ignore the cal, since SQL would expect it to store it in the local
+ // time zone
+ if (x != null) {
+ switch (dataType) {
+ case Types.DATE:
+ d1 = new Date(x.getTime());
+ addParamValue(parameterIndex, d1.toString());
+ break;
+ case Types.TIME:
+ t1 = new Time(x.getTime());
+ addParamValue(parameterIndex, t1.toString());
+ break;
+ default:
+ addParamValue(parameterIndex, x.toString());
+ break;
+ }
+ } else {
+ addParamValue(parameterIndex, null);
+ }
+ }
+
+ public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setUnicodeStream", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x, length);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setUnicodeStream");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ byte[] buffer = new byte[length]; // length = number of bytes in
+ // stream
+ validateSetInvocation(parameterIndex);
+ String s;
+
+ if (x == null) {
+ addParamValue(parameterIndex, null);
+ } else {
+ int dataType = inputDesc_[parameterIndex - 1].dataType_;
+ switch (dataType) {
+ case Types.DECIMAL:
+ case Types.DOUBLE:
+ case Types.FLOAT:
+ case Types.NUMERIC:
+ case Types.SMALLINT:
+ case Types.INTEGER:
+ case Types.BIGINT:
+ case Types.TINYINT:
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_datatype_for_column", null);
+ default:
+ try {
+ x.read(buffer, 0, length);
+ } catch (java.io.IOException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "io_exception",
+ messageArguments);
+ }
+ try {
+ s = new String(buffer, "UnicodeBig");
+ addParamValue(parameterIndex, s);
+ } catch (java.io.UnsupportedEncodingException e) {
+ Object[] messageArguments = new Object[1];
+ messageArguments[0] = e.getMessage();
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "unsupported_encoding", messageArguments);
+ }
+ break;
+ }
+ }
+ }
+
+ public void setURL(int parameterIndex, URL x) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setURL", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setURL");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ validateSetInvocation(parameterIndex);
+ HPT4Messages.throwUnsupportedFeatureException(connection_.props_, connection_.getLocale(), "setURL()");
+ } // end setURL
+
+ // -------------------------------------------------------------------------------------------
+ /**
+ * This method will associate user defined data with the prepared statement.
+ * The user defined data must be in SQL/MX rowwise rowset format.
+ *
+ * @param numRows
+ * the number of rows contained in buffer
+ * @param buffer
+ * a buffer containing the rows
+ *
+ * @exception A
+ * SQLException is thrown
+ */
+ public void setDataBuffer(int numRows, ByteBuffer buffer) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, numRows, buffer);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "setDataBuffer", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, numRows, buffer);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("setDataBuffer");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ usingRawRowset_ = true;
+ paramRowCount_ = numRows;
+ rowwiseRowsetBuffer_ = buffer;
+ } // end setDataBufferBuffer
+
+ // -------------------------------------------------------------------------------------------
+
+ // Other methods
+ protected void validateExecuteInvocation() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "validateExecuteInvocation", "", p);
+ }
+ clearWarnings();
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "stmt_closed", null);
+ }
+ // connection_.getServerHandle().isConnectionOpen();
+ connection_.isConnectionOpen();
+ // close the previous resultset, if any
+ for (int i = 0; i < num_result_sets_; i++) {
+ if (resultSet_[i] != null) {
+ resultSet_[i].close();
+ }
+ }
+ if (paramRowCount_ > 0 && usingRawRowset_ == false) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "function_sequence_error", null);
+ }
+
+ if (usingRawRowset_ == false)
+ checkIfAllParamsSet();
+
+ }
+
+ private void checkIfAllParamsSet() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "checkIfAllParamsSet", "", p);
+ }
+ int paramNumber;
+
+ if (inputDesc_ == null) {
+ return;
+ }
+ for (paramNumber = 0; paramNumber < inputDesc_.length; paramNumber++) {
+ if (!inputDesc_[paramNumber].isValueSet_) {
+ Object[] messageArguments = new Object[2];
+ messageArguments[0] = new Integer(paramNumber + 1);
+ messageArguments[1] = new Integer(paramRowCount_ + 1);
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "parameter_not_set",
+ messageArguments);
+ }
+ }
+ }
+
+ private void validateSetInvocation(int parameterIndex) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "validateSetInvocation", "", p);
+ }
+ if (isClosed_) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "stmt_closed", null);
+ }
+ // connection_.getServerHandle().isConnectionOpen();
+ connection_.isConnectionOpen();
+ if (inputDesc_ == null) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_parameter_index", null);
+ }
+ if (parameterIndex < 1 || parameterIndex > inputDesc_.length) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_parameter_index", null);
+ }
+ if (inputDesc_[parameterIndex - 1].paramMode_ == DatabaseMetaData.procedureColumnOut) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(), "is_a_output_parameter",
+ null);
+ }
+ }
+
+ void addParamValue(int parameterIndex, Object x) {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, parameterIndex, x);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "addParamValue", "", p);
+ }
+
+ paramsValue_[parameterIndex - 1] = x;
+ inputDesc_[parameterIndex - 1].isValueSet_ = true;
+ }
+
+ Object[] getValueArray() {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "getValueArray", "", p);
+ }
+ Object[] valueArray;
+ int length;
+ int i;
+ int j;
+ int index;
+ Object[] rows;
+
+ if (paramRowCount_ > 0) {
+ valueArray = new Object[(paramRowCount_ + 1) * inputDesc_.length];
+ length = rowsValue_.size();
+ for (i = 0, index = 0; i < length; i++) {
+ rows = (Object[]) rowsValue_.get(i);
+ for (j = 0; j < rows.length; j++, index++) {
+ valueArray[index] = rows[j];
+ }
+ }
+ } else {
+ valueArray = paramsValue_;
+ }
+ return valueArray;
+ }
+
+ void logicalClose() throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "logicalClose", "", p);
+ }
+ isClosed_ = true;
+ if (rowsValue_ != null) {
+ rowsValue_.clear();
+
+ }
+ if (lobObjects_ != null) {
+ lobObjects_.clear();
+
+ }
+ paramRowCount_ = 0;
+ for (int i = 0; i < num_result_sets_; i++) {
+ if (resultSet_[i] != null) {
+ resultSet_[i].close();
+ // Clear the isValueSet_ flag in inputDesc_
+ }
+ }
+ result_set_offset = 0;
+ resultSet_[result_set_offset] = null;
+ if (inputDesc_ != null) {
+ for (int i = 0; i < inputDesc_.length; i++) {
+ inputDesc_[i].isValueSet_ = false;
+ paramsValue_[i] = null;
+ }
+ }
+ isAnyLob_ = false;
+ if (!connection_.closePreparedStatement(connection_, sql_, resultSetType_, resultSetConcurrency_,
+ resultSetHoldability_)) {
+ this.close(true); // if the statement is not in the cache
+ // hardclose it afterall
+ }
+
+ }
+
+ // ----------------------------------------------------------------------------------
+ // Method used by JNI Layer to update the results of Prepare
+ void setPrepareOutputs(HPT4Desc[] inputDesc, HPT4Desc[] outputDesc, int inputParamCount, int outputParamCount)
+ throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, inputDesc, outputDesc, inputParamCount,
+ outputParamCount);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "setPrepareOutputs", "", p);
+ }
+ inputDesc_ = inputDesc;
+ outputDesc_ = outputDesc;
+ paramRowCount_ = 0;
+
+ // Prepare updares inputDesc_ and outputDesc_
+ if (inputDesc_ != null) {
+ paramsValue_ = new Object[inputDesc_.length];
+ } else {
+ paramsValue_ = null;
+ }
+ } // end setPrepareOutputs
+
+ // ----------------------------------------------------------------------------------
+ void setPrepareOutputs2(HPT4Desc[] inputDesc, HPT4Desc[] outputDesc, int inputParamCount, int outputParamCount,
+ int inputParamsLength, int outputParamsLength, int inputDescLength, int outputDescLength)
+ throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, inputDesc, outputDesc, inputParamCount,
+ outputParamCount, inputParamsLength, outputParamsLength, inputDescLength, outputDescLength);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "setPrepareOutputs2", "", p);
+ }
+ inputParamCount_ = inputParamCount;
+ outputParamCount_ = outputParamCount;
+ inputParamsLength_ = inputParamsLength;
+ outputParamsLength_ = outputParamsLength;
+ inputDescLength_ = inputDescLength;
+ outputDescLength_ = outputDescLength;
+ setPrepareOutputs(inputDesc, outputDesc, inputParamCount, outputParamCount);
+ } // end setPrepareOutputs2
+
+ // ----------------------------------------------------------------------------------
+ // Method used by JNI layer to update the results of Execute
+ void setExecuteOutputs(int rowCount) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rowCount);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "setExecuteOutputs", "", p);
+ }
+ batchRowCount_ = new int[1];
+ batchRowCount_[0] = rowCount;
+ num_result_sets_ = 1;
+ result_set_offset = 0;
+ if (outputDesc_ != null) {
+ resultSet_[result_set_offset] = new TrafT4ResultSet(this, outputDesc_);
+ } else {
+ resultSet_[result_set_offset] = null;
+ }
+ }
+
+ /*
+ * //----------------------------------------------------------------------------------
+ * void setExecuteSingletonOutputs(SQLValue_def[] sqlValue_def_array, short
+ * rowsAffected) throws SQLException { batchRowCount_ = new int[1];
+ * batchRowCount_[0] = rowsAffected; if (outputDesc_ != null) { resultSet_ =
+ * new TrafT4ResultSet(this, outputDesc_); } else { resultSet_ = null; } if
- * (rowsAffected == 0) { resultSet_.setFetchOutputs(new Row[0], 0, true, 0); }
++ * (rowsAffected == 0) { resultSet_.setFetchOutputs(new ObjectRow[0], 0, true, 0); }
+ * else { resultSet_.irs_.setSingletonFetchOutputs(resultSet_, rowsAffected,
+ * true, 0, sqlValue_def_array); } }
+ */
+
+ // ----------------------------------------------------------------------------------
+ // Method used by JNI layer to update the results of Execute
+ void setExecuteBatchOutputs(int[] rowCount) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, rowCount);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "setExecuteBatchOutputs", "", p);
+ }
+ num_result_sets_ = 1;
+ result_set_offset = 0;
+ if (outputDesc_ != null) {
+ resultSet_[result_set_offset] = new TrafT4ResultSet(this, outputDesc_);
+ } else {
+ resultSet_[result_set_offset] = null;
+ }
+ batchRowCount_ = rowCount;
+ }
+
+ void reuse(TrafT4Connection connection, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ connection_.props_.t4Logger_.logp(Level.FINER, "TrafT4PreparedStatement", "reuse", "", p);
+ }
+ if (resultSetType != ResultSet.TYPE_FORWARD_ONLY && resultSetType != ResultSet.TYPE_SCROLL_INSENSITIVE
+ && resultSetType != ResultSet.TYPE_SCROLL_SENSITIVE) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_resultset_type", null);
+ }
+ if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) {
+ resultSetType_ = ResultSet.TYPE_SCROLL_INSENSITIVE;
+ setSQLWarning(null, "scrollResultSetChanged", null);
+ } else {
+ resultSetType_ = resultSetType;
+ }
+ if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY && resultSetConcurrency != ResultSet.CONCUR_UPDATABLE) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "invalid_resultset_concurrency", null);
+ }
+ resultSetConcurrency_ = resultSetConcurrency;
+ resultSetHoldability_ = resultSetHoldability;
+ queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
+ fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
+ maxRows_ = 0;
+ fetchDirection_ = ResultSet.FETCH_FORWARD;
+ isClosed_ = false;
+ }
+
+ public void close(boolean hardClose) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINER) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, hardClose);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "close", "", p);
+ }
+
+ if (connection_._isClosed()) {
+ return;
+ }
+ try {
+ if (hardClose) {
+ ist_.close();
+ } else {
+ logicalClose();
+ }
+ } catch (SQLException e) {
+ performConnectionErrorChecks(e);
+ throw e;
+ } finally {
+ isClosed_ = true;
+ if (hardClose) {
+ connection_.removeElement(pRef_);
+ }
+ }
+
+ }
+
+
+ TrafT4PreparedStatement(TrafT4Connection connection, String sql, String stmtLabel) throws SQLException {
+ this(connection, sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, connection.holdability_,
+ stmtLabel);
+ connection.ic_.t4props_.setUseArrayBinding(false);
+ connection.ic_.t4props_.setBatchRecovery(false);
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "",
+ "Note, this call is before previous constructor call.", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ }
+
+ // Constructors with access specifier as "default"
+ TrafT4PreparedStatement(TrafT4Connection connection, String sql) throws SQLException {
+ this(connection, sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, connection.holdability_);
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "",
+ "Note, this call is before previous constructor call.", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ }
+
+ TrafT4PreparedStatement(TrafT4Connection connection, String sql, int resultSetType, int resultSetConcurrency)
+ throws SQLException {
+ this(connection, sql, resultSetType, resultSetConcurrency, connection.holdability_);
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
+ resultSetConcurrency);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "",
+ "Note, this call is before previous constructor call.", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
+ resultSetConcurrency);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+
+ }
+ TrafT4PreparedStatement(TrafT4Connection connection, String sql, int resultSetType, int resultSetConcurrency,
+ int resultSetHoldability, String stmtLabel) throws SQLException {
+ super(connection, resultSetType, resultSetConcurrency, resultSetHoldability, stmtLabel);
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "",
+ "Note, this call is before previous constructor call.", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ // connection_.getServerHandle().isConnectionOpen();
+ connection_.isConnectionOpen();
+ sqlStmtType_ = ist_.getSqlStmtType(sql);
+ if (sqlStmtType_ == TRANSPORT.TYPE_STATS) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "infostats_invalid_error", null);
+ } else if (sqlStmtType_ == TRANSPORT.TYPE_CONFIG) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "config_cmd_invalid_error", null);
+ }
+ ist_.setTransactionStatus(connection_, sql);
+ sql_ = sql;
+
+
+ // stmtLabel_ = generateStmtLabel();
+ stmtLabel_ = stmtLabel;
+ // System.out.println("TrafT4PreparedStatement stmtLabel_ " + stmtLabel_);
+
+ usingRawRowset_ = false;
+ }
+
+ TrafT4PreparedStatement(TrafT4Connection connection, String sql, int resultSetType, int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException {
+ super(connection, resultSetType, resultSetConcurrency, resultSetHoldability);
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "",
+ "Note, this call is before previous constructor call.", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, connection, sql, resultSetType,
+ resultSetConcurrency, resultSetHoldability);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection_.props_.getLogWriter().println(temp);
+ }
+ // connection_.getServerHandle().isConnectionOpen();
+ connection_.isConnectionOpen();
+ sqlStmtType_ = ist_.getSqlStmtType(sql);
+ if (sqlStmtType_ == TRANSPORT.TYPE_STATS) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "infostats_invalid_error", null);
+ } else if (sqlStmtType_ == TRANSPORT.TYPE_CONFIG) {
+ throw HPT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
+ "config_cmd_invalid_error", null);
+ }
+ ist_.setTransactionStatus(connection_, sql);
+ sql_ = sql;
+
+
+ //stmtLabel_ = generateStmtLabel();
+
+ usingRawRowset_ = false;
+ }
+
+ TrafT4PreparedStatement(TrafT4Connection connection, String moduleName, int moduleVersion, long moduleTimestamp,
+ String stmtName, boolean isSelect, int holdability) {
+ if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, moduleName, moduleVersion,
+ moduleTimestamp, stmtName, isSelect, holdability);
+ connection.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "", "", p);
+ }
+ try {
+ if (connection.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection, moduleName, moduleVersion,
+ moduleTimestamp, stmtName, isSelect, holdability);
+ lr.setParameters(p);
+ lr.setSourceClassName("TrafT4PreparedStatement");
+ lr.setSourceMethodName("");
+ T4LogFormatter lf = new T4LogFormatter();
+ String temp = lf.format(lr);
+ connection.props_.getLogWriter().println(temp);
+ }
+ } catch (SQLException se) {
+ // ignore
+ }
+ connection_ = connection;
+ moduleName_ = moduleName;
+ moduleVersion_ = moduleVersion;
+ moduleTimestamp_ = moduleTimestamp;
+ stmtLabel_ = stmtName;
+ sqlStmtType_ = (isSelect) ? TRANSPORT.TYPE_SELECT : TRANSPORT.TYPE_UNKNOWN;
+ usingRawRowset_ = false;
+
+ // Make Sure you initialize the other fields to the right value
+ fetchSize_ = TrafT4ResultSet.DEFAULT_FETCH_SIZE;
+ maxRows_ = 0;
+ fetchDirection_ = ResultSet.FETCH_FORWARD;
+ queryTimeout_ = connection_.getServerHandle().getQueryTimeout();
+ resultSetType_ = ResultSet.TYPE_FORWARD_ONLY;
+ resultSetHoldability_ = holdability;
+ usingRawRowset_ = false;
+ }
+
+ // Interface methods
+ public void prepare(String sql, int queryTimeout, int holdability) throws SQLException {
+ if (connection_.props_.t4Logger_.isLoggable(Level.FINE) == true) {
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, queryTimeout, holdability);
+ connection_.props_.t4Logger_.logp(Level.FINE, "TrafT4PreparedStatement", "prepare", "", p);
+ }
+ if (connection_.props_.getLogWriter() != null) {
+ LogRecord lr = new LogRecord(Level.FINE, "");
+ Object p[] = T4LoggingUtilities.makeParams(connection_.props_, sql, queryTimeou
<TRUNCATED>