Skip to content

Commit

Permalink
Merge pull request #565 from Microsoft/dev
Browse files Browse the repository at this point in the history
Update JDBC4.3 branch with latest changes from Dev branch
  • Loading branch information
AfsanehR-zz authored Nov 27, 2017
2 parents 4cc67a1 + a940fbc commit 6f9fec6
Show file tree
Hide file tree
Showing 86 changed files with 3,476 additions and 3,689 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ install:
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild42

before_script:
- docker pull microsoft/mssql-server-linux
- docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' -p 1433:1433 -d microsoft/mssql-server-linux
- docker pull microsoft/mssql-server-linux:2017-latest
- docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' -p 1433:1433 -d microsoft/mssql-server-linux:2017-latest

script:
- docker ps -a
Expand Down
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,43 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)

## [6.3.5] Preview Release
### Added
- Added handle for Account Locked Exception 18486 during login in SQLServerConnection [#522](https://github.com/Microsoft/mssql-jdbc/pull/522)

### Fixed Issues
- Fixed the issues with Prepared Statement Metadata Caching implementation [#543](https://github.com/Microsoft/mssql-jdbc/pull/543)
- Fixed issues with static logger member in abstract class 'SQLServerClobBase' [#537](https://github.com/Microsoft/mssql-jdbc/pull/537)

## [6.3.4] Preview Release
### Added
- Added new ThreadGroup creation to prevent IllegalThreadStateException if the underlying ThreadGroup has been destroyed. [#474](https://github.com/Microsoft/mssql-jdbc/pull/474)
- Added try-with-resources to JUnit tests [#520](https://github.com/Microsoft/mssql-jdbc/pull/520)

### Fixed Issues
- Fixed the issue with passing parameters names that start with '@' to a CallableStatement [#495](https://github.com/Microsoft/mssql-jdbc/pull/495)
- Fixed SQLServerDataTable creation being O(n^2) issue [#514](https://github.com/Microsoft/mssql-jdbc/pull/514)

### Changed
- Changed some manual array copying to System.arraycopy() [#500](https://github.com/Microsoft/mssql-jdbc/pull/500)
- Removed redundant toString() on String objects [#501](https://github.com/Microsoft/mssql-jdbc/pull/501)
- Replaced literals with constants [#502](https://github.com/Microsoft/mssql-jdbc/pull/502)

## [6.3.3] Preview Release
### Added
- Added connection properties for specifying custom TrustManager [#74](https://github.com/Microsoft/mssql-jdbc/pull/74)

### Fixed Issues
- Fixed exception thrown by getters on null columns [#488](https://github.com/Microsoft/mssql-jdbc/pull/488)
- Fixed issue with DatabaseMetaData#getImportedKeys() returns wrong value for DELETE_RULE [#490](https://github.com/Microsoft/mssql-jdbc/pull/490)
- Fixed issue with ActivityCorrelator causing a classloader leak [#465](https://github.com/Microsoft/mssql-jdbc/pull/465)

### Changed
- Removed explicit extends Object [#469](https://github.com/Microsoft/mssql-jdbc/pull/469)
- Removed unnecessary return statements [#471](https://github.com/Microsoft/mssql-jdbc/pull/471)
- Simplified overly complex boolean expressions [#472](https://github.com/Microsoft/mssql-jdbc/pull/472)
- Replaced explicit types with <> (the diamond operator) [#420](https://github.com/Microsoft/mssql-jdbc/pull/420)

## [6.3.2] Preview Release
### Added
- Added new connection property: sslProtocol [#422](https://github.com/Microsoft/mssql-jdbc/pull/422)
Expand Down Expand Up @@ -52,6 +89,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
- Updated ADAL4J dependency to version 1.2.0 [#392](https://github.com/Microsoft/mssql-jdbc/pull/392)
- Updated azure-keyvault dependency to version 1.0.0 [#397](https://github.com/Microsoft/mssql-jdbc/pull/397)

## [6.2.2] Hotfix & Stable Release
### Changed
- Updated ADAL4J to version 1.2.0 and AKV to version 1.0.0 [#516](https://github.com/Microsoft/mssql-jdbc/pull/516)

## [6.2.1] Hotfix & Stable Release
### Fixed Issues
- Fixed queries without parameters using preparedStatement [#372](https://github.com/Microsoft/mssql-jdbc/pull/372)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ We're now on the Maven Central Repository. Add the following to your POM file to
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.2.1.jre8</version>
<version>6.2.2.jre8</version>
</dependency>
```
The driver can be downloaded from the [Microsoft Download Center](https://go.microsoft.com/fwlink/?linkid=852460).
Expand All @@ -90,7 +90,7 @@ To get the latest preview version of the driver, add the following to your POM f
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.3.2.jre8-preview</version>
<version>6.3.5.jre8-preview</version>
</dependency>
```

Expand Down Expand Up @@ -120,7 +120,7 @@ Projects that require either of the two features need to explicitly declare the
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.3.2.jre8-preview</version>
<version>6.3.5.jre8-preview</version>
<scope>compile</scope>
</dependency>

Expand All @@ -130,7 +130,7 @@ Projects that require either of the two features need to explicitly declare the
<version>1.0.0</version>
</dependency>
```
***Please note*** as of the v6.3.0-preview, the way to construct a `SQLServerColumnEncryptionAzureKeyVaultProvider` object has changed. Please refer to this [Wiki](https://github.com/Microsoft/mssql-jdbc/wiki/New-Constructor-Definition-for-SQLServerColumnEncryptionAzureKeyVaultProvider-after-6.3.0-Preview-Release) page for more information.
***Please note*** as of the v6.2.2, the way to construct a `SQLServerColumnEncryptionAzureKeyVaultProvider` object has changed. Please refer to this [Wiki](https://github.com/Microsoft/mssql-jdbc/wiki/New-Constructor-Definition-for-SQLServerColumnEncryptionAzureKeyVaultProvider-after-6.2.2-Release) page for more information.

## Guidelines for Creating Pull Requests
We love contributions from the community. To help improve the quality of our code, we encourage you to use the mssql-jdbc_formatter.xml formatter provided on all pull requests.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ repositories {
}

dependencies {
compile 'com.microsoft.azure:azure-keyvault:0.9.7',
compile 'com.microsoft.azure:azure-keyvault:1.0.0',
'com.microsoft.azure:adal4j:1.1.3'

testCompile 'junit:junit:4.12',
Expand Down
18 changes: 12 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.3.3-SNAPSHOT</version>

<version>6.3.6-SNAPSHOT.${jreVersion}-preview</version>
<packaging>jar</packaging>

<name>Microsoft JDBC Driver for SQL Server</name>
Expand All @@ -29,8 +28,6 @@

<developers>
<developer>
<name>Andrea Lam</name>
<email>andrela@microsoft.com</email>
<organization>Microsoft</organization>
<organizationUrl>http://www.microsoft.com</organizationUrl>
</developer>
Expand Down Expand Up @@ -142,6 +139,11 @@
<profiles>
<profile>
<id>build41</id>

<properties>
<jreVersion>jre7</jreVersion>
</properties>

<build>
<plugins>
<plugin>
Expand All @@ -160,7 +162,6 @@
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<finalName>${project.artifactId}-${project.version}.jre7-preview</finalName>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
Expand All @@ -173,9 +174,15 @@

<profile>
<id>build42</id>

<activation>
<activeByDefault>true</activeByDefault>
</activation>

<properties>
<jreVersion>jre8</jreVersion>
</properties>

<build>
<plugins>
<plugin>
Expand All @@ -194,7 +201,6 @@
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<finalName>${project.artifactId}-${project.version}.jre8-preview</finalName>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/microsoft/sqlserver/jdbc/DDC.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static final Object convertFloatToObject(float floatVal,
return new BigDecimal(Float.toString(floatVal));
case FLOAT:
case DOUBLE:
return (Float.valueOf(floatVal)).doubleValue();
return (new Float(floatVal)).doubleValue();
case BINARY:
return convertIntToBytes(Float.floatToRawIntBits(floatVal), 4);
default:
Expand Down Expand Up @@ -275,7 +275,7 @@ static final Object convertDoubleToObject(double doubleVal,
case DOUBLE:
return doubleVal;
case REAL:
return (Double.valueOf(doubleVal)).floatValue();
return (new Double(doubleVal)).floatValue();
case INTEGER:
return (int) doubleVal;
case SMALLINT: // small and tinyint returned as short
Expand Down Expand Up @@ -439,9 +439,7 @@ private static byte[] convertToBytes(BigDecimal value,
}
}
int offset = numBytes - unscaledBytes.length;
for (int i = offset; i < numBytes; ++i) {
ret[i] = unscaledBytes[i - offset];
}
System.arraycopy(unscaledBytes, offset - offset, ret, offset, numBytes - offset);
return ret;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void setupInfo(SQLServerConnection con) throws SQLServerException {
instancePort = con.getInstancePort(failoverPartner, instanceValue);

try {
portNumber = Integer.parseInt(instancePort);
portNumber = new Integer(instancePort);
}
catch (NumberFormatException e) {
// Should not get here as the server should give a proper port number anyway.
Expand Down
31 changes: 22 additions & 9 deletions src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand All @@ -72,6 +73,7 @@
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import javax.xml.bind.DatatypeConverter;

final class TDS {
// TDS protocol versions
Expand Down Expand Up @@ -497,7 +499,7 @@ class GregorianChange {

GregorianCalendar cal = new GregorianCalendar(Locale.US);
cal.clear();
cal.set(1, 1, 577738, 0, 0, 0);// 577738 = 1+577737(no of days since epoch that brings us to oct 15th 1582)
cal.set(1, Calendar.FEBRUARY, 577738, 0, 0, 0);// 577738 = 1+577737(no of days since epoch that brings us to oct 15th 1582)
if (cal.get(Calendar.DAY_OF_MONTH) == 15) {
// If the date calculation is correct(the above bug is fixed),
// post the default gregorian cut over date, the pure gregorian date
Expand Down Expand Up @@ -4827,7 +4829,7 @@ private void writeInternalTVPRowValues(JDBCType jdbcType,
else {
if (isSqlVariant) {
writeTVPSqlVariantHeader(10, TDSType.FLOAT8.byteValue(), (byte) 0);
writeDouble(Double.valueOf(currentColumnStringValue.toString()));
writeDouble(Double.valueOf(currentColumnStringValue));
break;
}
writeByte((byte) 8); // len of data bytes
Expand Down Expand Up @@ -4955,7 +4957,7 @@ else if (DataTypes.UNKNOWN_STREAM_LENGTH == dataLength)
isShortValue = columnPair.getValue().precision <= DataTypes.SHORT_VARTYPE_MAX_BYTES;
isNull = (null == currentObject);
if (currentObject instanceof String)
dataLength = isNull ? 0 : (ParameterUtils.HexToBin(currentObject.toString())).length;
dataLength = isNull ? 0 : (toByteArray(currentObject.toString())).length;
else
dataLength = isNull ? 0 : ((byte[]) currentObject).length;
if (!isShortValue) {
Expand All @@ -4974,7 +4976,7 @@ else if (DataTypes.UNKNOWN_STREAM_LENGTH == dataLength)
if (dataLength > 0) {
writeInt(dataLength);
if (currentObject instanceof String)
writeBytes(ParameterUtils.HexToBin(currentObject.toString()));
writeBytes(toByteArray(currentObject.toString()));
else
writeBytes((byte[]) currentObject);
}
Expand All @@ -4988,7 +4990,7 @@ else if (DataTypes.UNKNOWN_STREAM_LENGTH == dataLength)
else {
writeShort((short) dataLength);
if (currentObject instanceof String)
writeBytes(ParameterUtils.HexToBin(currentObject.toString()));
writeBytes(toByteArray(currentObject.toString()));
else
writeBytes((byte[]) currentObject);
}
Expand Down Expand Up @@ -5025,6 +5027,9 @@ private void writeTVPSqlVariantHeader(int length,
writeByte(probBytes);
}

private static byte[] toByteArray(String s) {
return DatatypeConverter.parseHexBinary(s);
}

void writeTVPColumnMetaData(TVP value) throws SQLServerException {
boolean isShortValue;
Expand Down Expand Up @@ -7115,13 +7120,21 @@ final class TimeoutTimer implements Runnable {
private volatile Future<?> task;

private static final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
private final ThreadGroup tg = new ThreadGroup(threadGroupName);
private final String threadNamePrefix = tg.getName() + "-";
private final AtomicReference<ThreadGroup> tgr = new AtomicReference<>();
private final AtomicInteger threadNumber = new AtomicInteger(0);

@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(tg, r, threadNamePrefix + threadNumber.incrementAndGet());
public Thread newThread(Runnable r)
{
ThreadGroup tg = tgr.get();

if (tg == null || tg.isDestroyed())
{
tg = new ThreadGroup(threadGroupName);
tgr.set(tg);
}

Thread t = new Thread(tg, r, tg.getName() + "-" + threadNumber.incrementAndGet());
t.setDaemon(true);
return t;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
final class SQLJdbcVersion {
static final int major = 6;
static final int minor = 3;
static final int patch = 2;
static final int patch = 5;
static final int build = 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import static java.nio.charset.StandardCharsets.UTF_8;

import java.text.MessageFormat;
import java.util.Base64;
import java.util.concurrent.ConcurrentHashMap;

import javax.xml.bind.DatatypeConverter;

/**
* Factory for SQLServerAeadAes256CbcHmac256Algorithm
Expand All @@ -38,7 +38,7 @@ SQLServerEncryptionAlgorithm create(SQLServerSymmetricKey columnEncryptionKey,
}

StringBuilder factoryKeyBuilder = new StringBuilder();
factoryKeyBuilder.append(Base64.getEncoder().encodeToString(new String(columnEncryptionKey.getRootKey(), UTF_8).getBytes()));
factoryKeyBuilder.append(DatatypeConverter.printBase64Binary(new String(columnEncryptionKey.getRootKey(), UTF_8).getBytes()));

factoryKeyBuilder.append(":");
factoryKeyBuilder.append(encryptionType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.time.OffsetTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
Expand Down Expand Up @@ -574,7 +575,7 @@ public Object[] getRowData() throws SQLServerException {
case Types.BIGINT: {
BigDecimal bd = new BigDecimal(data[pair.getKey() - 1].trim());
try {
dataRow[pair.getKey() - 1] = bd.setScale(0, RoundingMode.DOWN).longValueExact();
dataRow[pair.getKey() - 1] = bd.setScale(0, BigDecimal.ROUND_DOWN).longValueExact();
} catch (ArithmeticException ex) {
String value = "'" + data[pair.getKey() - 1] + "'";
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_errorConvertingValue"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,7 @@ private String createInsertBulkCommand(TDSWriter tdsWriter) throws SQLServerExce
if (it.hasNext()) {
bulkCmd.append(" with (");
while (it.hasNext()) {
bulkCmd.append(it.next().toString());
bulkCmd.append(it.next());
if (it.hasNext()) {
bulkCmd.append(", ");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static Object getTemporalObjectFromCSVWithFormatter(String valueStrUntrimmed,
return ts;
case java.sql.Types.TIME:
// Time is returned as Timestamp to preserve nano seconds.
cal.set(connection.baseYear(), 00, 01);
cal.set(connection.baseYear(), Calendar.JANUARY, 01);
ts = new java.sql.Timestamp(cal.getTimeInMillis());
ts.setNanos(taNano);
return new java.sql.Timestamp(ts.getTime());
Expand Down
Loading

0 comments on commit 6f9fec6

Please sign in to comment.