Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ enum SSType
DECIMAL (Category.NUMERIC, "decimal", JDBCType.DECIMAL),
NUMERIC (Category.NUMERIC, "numeric", JDBCType.NUMERIC),
GUID (Category.GUID, "uniqueidentifier", JDBCType.GUID),
SQL_VARIANT (Category.VARIANT, "sql_variant", JDBCType.VARCHAR),
SQL_VARIANT (Category.SQL_VARIANT, "sql_variant", JDBCType.CHAR),
UDT (Category.UDT, "udt", JDBCType.VARBINARY),
XML (Category.XML, "xml", JDBCType.LONGNVARCHAR),
TIMESTAMP (Category.TIMESTAMP, "timestamp", JDBCType.BINARY);
Expand Down Expand Up @@ -203,7 +203,7 @@ enum Category {
TIME,
TIMESTAMP,
UDT,
VARIANT,
SQL_VARIANT,
XML
}

Expand Down Expand Up @@ -358,7 +358,12 @@ enum GetterConversion
SSType.Category.GUID,
EnumSet.of(
JDBCType.Category.BINARY,
JDBCType.Category.CHARACTER));
JDBCType.Category.CHARACTER)),
Sql_Variant (
SSType.Category.SQL_VARIANT,
EnumSet.of(
JDBCType.Category.CHARACTER,
JDBCType.Category.SQL_VARIANT));

private final SSType.Category from;
private final EnumSet<JDBCType.Category> to;
Expand Down Expand Up @@ -842,7 +847,9 @@ enum JDBCType
TVP (Category.TVP, microsoft.sql.Types.STRUCTURED, "java.lang.Object"),
DATETIME (Category.TIMESTAMP, microsoft.sql.Types.DATETIME, "java.sql.Timestamp"),
SMALLDATETIME (Category.TIMESTAMP, microsoft.sql.Types.SMALLDATETIME, "java.sql.Timestamp"),
GUID (Category.CHARACTER, microsoft.sql.Types.GUID, "java.lang.String");
GUID (Category.CHARACTER, microsoft.sql.Types.GUID, "java.lang.String"),
SQL_VARIANT (Category.SQL_VARIANT, microsoft.sql.Types.SQL_VARIANT, "java.lang.String");


final Category category;
private final int intValue;
Expand Down Expand Up @@ -889,7 +896,8 @@ enum Category {
SQLXML,
UNKNOWN,
TVP,
GUID;
GUID,
SQL_VARIANT;
}

// This SetterConversion enum is based on the Category enum
Expand Down Expand Up @@ -981,7 +989,8 @@ enum SetterConversion {
JDBCType.Category.CHARACTER,
JDBCType.Category.LONG_CHARACTER,
JDBCType.Category.NCHARACTER,
JDBCType.Category.LONG_NCHARACTER)),
JDBCType.Category.LONG_NCHARACTER,
JDBCType.Category.SQL_VARIANT)),

DATE (
JDBCType.Category.DATE,
Expand Down Expand Up @@ -1184,7 +1193,8 @@ enum UpdaterConversion {
SSType.Category.CHARACTER,
SSType.Category.LONG_CHARACTER,
SSType.Category.NCHARACTER,
SSType.Category.LONG_NCHARACTER)),
SSType.Category.LONG_NCHARACTER,
SSType.Category.SQL_VARIANT)),

DATE (
JDBCType.Category.DATE,
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import javax.net.ssl.X509TrustManager;
import javax.xml.bind.DatatypeConverter;


final class TDS {
// TDS protocol versions
static final int VER_DENALI = 0x74000004; // TDS 7.4
Expand Down Expand Up @@ -4286,6 +4287,18 @@ void writeRPCReal(String sName,
writeInt(Float.floatToRawIntBits(floatValue.floatValue()));
}
}

void writeRPCSqlVariant(String sName,
SqlVariant sqlVariantValue,
boolean bOut) throws SQLServerException {
writeRPCNameValType(sName, bOut, TDSType.SQL_VARIANT);

// Data and length
if (null == sqlVariantValue) {
writeInt(0); // max length
writeInt(0); // actual length
}
}

/**
* Append a double value in RPC transmission format.
Expand Down Expand Up @@ -5433,6 +5446,12 @@ void writeRPCDateTimeOffset(String sName,

writeShort((short) minutesOffset);
}

void writeRPCSQLVariant(String sName,
String value,
boolean bOut) throws SQLServerException {
writeRPCStringUnicode(value);
}

/**
* Returns subSecondNanos rounded to the maximum precision supported. The maximum fractional scale is MAX_FRACTIONAL_SECONDS_SCALE(7). Eg1: if you
Expand Down Expand Up @@ -6456,7 +6475,7 @@ final void readBytes(byte[] value,
bytesRead += bytesToCopy;
payloadOffset += bytesToCopy;
}
}
}

final byte[] readWrappedBytes(int valueLength) throws SQLServerException {
assert valueLength <= valueBytes.length;
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Calendar;
import java.util.Locale;


/**
* Parameter represents a JDBC parameter value that is supplied with a prepared or callable statement or an updatable result set. Parameter is JDBC
* type specific and is capable of representing any Java native type as well as a number of Java object types including binary and character streams.
Expand Down Expand Up @@ -883,7 +884,9 @@ else if ((null != jdbcTypeSetByUser) && ((jdbcTypeSetByUser == JDBCType.NVARCHAR
case GUID:
param.typeDefinition = SSType.GUID.toString();
break;

case SQL_VARIANT:
param.typeDefinition = SSType.SQL_VARIANT.toString();
break;
default:
assert false : "Unexpected JDBC type " + dtv.getJdbcType();
break;
Expand Down Expand Up @@ -1138,6 +1141,15 @@ void execute(DTV dtv,
setTypeDefinition(dtv);
}

/* (non-Javadoc)
* @see com.microsoft.sqlserver.jdbc.DTVExecuteOp#execute(com.microsoft.sqlserver.jdbc.DTV, microsoft.sql.SqlVariant)
*/
@Override
void execute(DTV dtv,
SqlVariant SqlVariantValue) throws SQLServerException {
setTypeDefinition(dtv);
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,6 @@ private String getDestTypeFromSrcType(int srcColIndx,
else {
return "datetimeoffset(" + bulkScale + ")";
}

default: {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_BulkTypeNotSupported"));
Object[] msgArgs = {JDBCType.of(bulkJdbcType).toString().toLowerCase(Locale.ENGLISH)};
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/microsoft/sqlserver/jdbc/SqlVariant.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Microsoft JDBC Driver for SQL Server
*
* Copyright(c) Microsoft Corporation All rights reserved.
*
* This program is made available under the terms of the MIT License. See the LICENSE file in the project root for more information.
*/
package com.microsoft.sqlserver.jdbc;


public class SqlVariant {

}
Loading