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 2018/04/09 14:59:16 UTC
[1/2] trafodion git commit: TRAFODION-3019 pstmt.setByte cannot
support string.getbyte well
Repository: trafodion
Updated Branches:
refs/heads/master 51cdb91d7 -> 0551efb0b
TRAFODION-3019 pstmt.setByte cannot support string.getbyte well
Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/7914d91e
Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/7914d91e
Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/7914d91e
Branch: refs/heads/master
Commit: 7914d91ec16e631adacf5d866675bb6f7326e7fa
Parents: 659e8ec
Author: aven <sh...@esgyn.cn>
Authored: Wed Apr 4 10:22:22 2018 +0800
Committer: aven <sh...@esgyn.cn>
Committed: Wed Apr 4 10:22:22 2018 +0800
----------------------------------------------------------------------
.../trafodion/jdbc/t4/InterfaceStatement.java | 45 ++++++++++----------
.../jdbc_type2/native/SQLMXCommonFunctions.cpp | 9 ++++
.../org/apache/trafodion/jdbc/t2/SQLMXDesc.java | 2 +-
.../jdbc/t2/SQLMXPreparedStatement.java | 24 ++++++++---
4 files changed, 52 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafodion/blob/7914d91e/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
index ff5179e..7b42ed1 100644
--- 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
@@ -161,28 +161,29 @@ class InterfaceStatement {
// 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 TrafT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
- charSet);
- }
- } // end if (paramValue instanceof String)
+ } else if (paramValue instanceof byte[] || 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);
+ }
+ if (paramValue instanceof byte[]) {
+ tmpBarray = (new String((byte[]) paramValue)).getBytes(charSet);
+ } else {
+ tmpBarray = (((String) paramValue)).getBytes(charSet);
+ }
+ } catch (Exception e) {
+ throw TrafT4Messages.createSQLException(pstmt.connection_.props_, locale, "unsupported_encoding",
+ charSet);
+ }
+ } // end if (paramValue instanceof String)
else {
throw TrafT4Messages.createSQLException(pstmt.connection_.props_, locale, "invalid_parameter_value",
"CHAR data should be either bytes or String for column: " + paramNumber);
http://git-wip-us.apache.org/repos/asf/trafodion/blob/7914d91e/core/conn/jdbc_type2/native/SQLMXCommonFunctions.cpp
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type2/native/SQLMXCommonFunctions.cpp b/core/conn/jdbc_type2/native/SQLMXCommonFunctions.cpp
index 75d4613..9151076 100644
--- a/core/conn/jdbc_type2/native/SQLMXCommonFunctions.cpp
+++ b/core/conn/jdbc_type2/native/SQLMXCommonFunctions.cpp
@@ -1577,6 +1577,15 @@ static Charset_def CHARSET_INFORMATION[] = {
if (dataLengthNotExceeded(charSet, dataLen, allocLength))
{
memcpy(dataPtr, (const void *)byteValue, dataLen);
+ memset(dataPtr + (dataLen), ' ', allocLength - (dataLen));
+ if (charSet == SQLCHARSETCODE_UCS2)
+ {
+ // Back fill target buffer with double byte 'space' characters (i.e. 0x00 0x20)
+ for (int i = (dataLen+1); i < allocLength-dataLen; i+=2)
+ {
+ *(dataPtr+i) = 0;
+ }
+ }
}
else
{
http://git-wip-us.apache.org/repos/asf/trafodion/blob/7914d91e/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXDesc.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXDesc.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXDesc.java
index 252c790..9a2d70e 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXDesc.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXDesc.java
@@ -424,7 +424,7 @@ class SQLMXDesc
public static final int SQLCHARSETCODE_GB2312 = 17;
public static final String SQLCHARSETSTRING_UNKNOWN = "UNKNOWN";
- public static final String SQLCHARSETSTRING_ISO88591 = "ISO88591";
+ public static final String SQLCHARSETSTRING_ISO88591 = "ISO-8859-1";
public static final String SQLCHARSETSTRING_KANJI = "KANJI";
public static final String SQLCHARSETSTRING_KSC5601 = "KSC5601";
public static final String SQLCHARSETSTRING_SJIS = "MS932";
http://git-wip-us.apache.org/repos/asf/trafodion/blob/7914d91e/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPreparedStatement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPreparedStatement.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPreparedStatement.java
index 352bfe1..e7fd377 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPreparedStatement.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPreparedStatement.java
@@ -26,6 +26,7 @@ package org.apache.trafodion.jdbc.t2;
import java.io.InputStream;
import java.io.Reader;
+import java.io.UnsupportedEncodingException;
import java.lang.ref.WeakReference;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -1953,11 +1954,12 @@ public class SQLMXPreparedStatement extends SQLMXStatement implements
}
- byte[] tmpArray = new byte[x.length];
- System.arraycopy(x, 0, tmpArray, 0, x.length);
+ //byte[] tmpArray = new byte[x.length];
+ //System.arraycopy(x, 0, tmpArray, 0, x.length);
validateSetInvocation(parameterIndex);
dataType = inputDesc_[parameterIndex - 1].dataType_;
+ int dataCharSet = inputDesc_[parameterIndex - 1].sqlCharset_;
switch (dataType) {
case Types.BLOB:
long dataLocator = connection_.getDataLocator(
@@ -1969,12 +1971,24 @@ public class SQLMXPreparedStatement extends SQLMXStatement implements
isAnyLob_ = true;
paramContainer_.setLong(parameterIndex, dataLocator);
break;
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ String charSet = SQLMXDesc.SQLCHARSETSTRING_ISO88591;
+ if (dataCharSet == SQLMXDesc.SQLCHARSETCODE_UCS2)
+ charSet = "UTF-16LE";
+ try {
+ x = (new String(x)).getBytes(charSet);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ throw Messages.createSQLException(connection_.locale_, "unsupported_encoding",
+ new Object[] { charSet });
+ }
+ paramContainer_.setObject(parameterIndex, x);
+ break;
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP:
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
[2/2] trafodion git commit: Merge [TRAFODION-3019] PR 1505 Fix issue
with pstmt.setByte
Posted by db...@apache.org.
Merge [TRAFODION-3019] PR 1505 Fix issue with pstmt.setByte
Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/0551efb0
Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/0551efb0
Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/0551efb0
Branch: refs/heads/master
Commit: 0551efb0bc95753d69d1b47f91895b459ef5c7d3
Parents: 51cdb91 7914d91
Author: Dave Birdsall <db...@apache.org>
Authored: Mon Apr 9 14:58:10 2018 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Mon Apr 9 14:58:10 2018 +0000
----------------------------------------------------------------------
.../trafodion/jdbc/t4/InterfaceStatement.java | 45 ++++++++++----------
.../jdbc_type2/native/SQLMXCommonFunctions.cpp | 9 ++++
.../org/apache/trafodion/jdbc/t2/SQLMXDesc.java | 2 +-
.../jdbc/t2/SQLMXPreparedStatement.java | 24 ++++++++---
4 files changed, 52 insertions(+), 28 deletions(-)
----------------------------------------------------------------------