From 2a8fd43ddc88f09fc714a1d5b6be7d3fbba54132 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Tue, 28 Aug 2018 16:11:51 -0700 Subject: [PATCH 1/2] Update version + changelog for release + Format driver source code --- CHANGELOG.md | 13 +++++++++++++ README.md | 8 ++++---- build.gradle | 2 +- pom.xml | 2 +- .../microsoft/sqlserver/jdbc/SQLJdbcVersion.java | 2 +- ...rverColumnEncryptionJavaKeyStoreProvider.java | 3 +-- .../sqlserver/jdbc/SQLServerResultSet.java | 7 +++---- .../sqlserver/jdbc/SQLServerSpatialDatatype.java | 4 ++-- .../java/com/microsoft/sqlserver/jdbc/Util.java | 12 ++++-------- .../sqlserver/jdbc/resultset/ResultSetTest.java | 16 +++++++--------- 10 files changed, 37 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba5de404f9..fa7ce4c3f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) +## [7.1.0] Preview Release +### Added +- Added support for LocalDate, LocalTime and LocalDateTime to be passed as 'type' in ResultSet.getObject() [#749](https://github.com/Microsoft/mssql-jdbc/pull/749) +- Added support to read SQL Warnings after ResultSet is read completely [#785](https://github.com/Microsoft/mssql-jdbc/pull/785) + +### Fixed Issues +- Fixed JavaDoc warnings and removed obselete HTML tags from Javadocs [#786](https://github.com/Microsoft/mssql-jdbc/pull/786) +- Fixed random Junit failures in framework tests [#762](https://github.com/Microsoft/mssql-jdbc/pull/762) + +### Changed +- Improved performance of readLong() function by unrolling loop and using bitwise operators instead of additions [#763](https://github.com/Microsoft/mssql-jdbc/pull/763) +- Removed logging logic which caused performance degradation in AE [#773](https://github.com/Microsoft/mssql-jdbc/pull/773) + ## [7.0.0] Stable Release ### Added - Added 'Automatic-Module-Name' manifest entry to jre10 Jar, allowing JDK 10 users to access driver module 'com.microsoft.sqlserver.jdbc' [#732](https://github.com/Microsoft/mssql-jdbc/pull/732) diff --git a/README.md b/README.md index e0645c2599..6c304ec078 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ To get the latest preview version of the driver, add the following to your POM f com.microsoft.sqlserver mssql-jdbc - 6.5.4.jre10-preview + 7.1.0.jre10-preview ``` ### Using driver as Java Module @@ -119,7 +119,7 @@ Projects that require either of the two features need to explicitly declare the com.microsoft.sqlserver mssql-jdbc - 7.0.0.jre10 + 7.1.0.jre10-preview compile @@ -135,7 +135,7 @@ Projects that require either of the two features need to explicitly declare the com.microsoft.sqlserver mssql-jdbc - 7.0.0.jre10 + 7.1.0.jre10-preview compile @@ -183,7 +183,7 @@ Preview releases happen approximately monthly between stable releases. This give You can see what is going into a future release by monitoring [Milestones](https://github.com/Microsoft/mssql-jdbc/milestones) in the repository. ### Versioning convention -Starting with 6.0, stable versions have an even minor version. For example, 6.0, 6.2, 6.4. Preview versions have an odd minor version. For example, 6.1, 6.3, 6.5. +Starting with 6.0, stable versions have an even minor version. For example, 6.0, 6.2, 6.4, 7.0. Preview versions have an odd minor version. For example, 6.1, 6.3, 6.5, 7.1. ## Contributors Special thanks to everyone who has contributed to the project. diff --git a/build.gradle b/build.gradle index c33447edc9..6c4011116d 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ apply plugin: 'java' -version = '7.1.0-SNAPSHOT' +version = '7.1.0' def jreVersion = "" def testOutputDir = file("build/classes/java/test") def archivesBaseName = 'mssql-jdbc' diff --git a/pom.xml b/pom.xml index 456a008f55..10f016db55 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.microsoft.sqlserver mssql-jdbc - 7.1.0-SNAPSHOT + 7.1.0 jar Microsoft JDBC Driver for SQL Server diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLJdbcVersion.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLJdbcVersion.java index 824dfdf8f9..09074842c6 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLJdbcVersion.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLJdbcVersion.java @@ -7,7 +7,7 @@ final class SQLJdbcVersion { static final int major = 7; - static final int minor = 0; + static final int minor = 1; static final int patch = 0; static final int build = 0; } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java index 0b72c58f9f..41d012b65e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java @@ -257,8 +257,7 @@ public byte[] encryptColumnEncryptionKey(String masterKeyPath, String encryption System.arraycopy(signedHash, 0, encryptedColumnEncryptionKey, currentIndex, signedHash.length); javaKeyStoreLogger.exiting(SQLServerColumnEncryptionJavaKeyStoreProvider.class.getName(), - "encryptColumnEncryptionKey", - "Finished encrypting Column Encryption Key."); + "encryptColumnEncryptionKey", "Finished encrypting Column Encryption Key."); return encryptedColumnEncryptionKey; } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java index 2899b0186c..612c44ab33 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java @@ -2381,16 +2381,15 @@ public T getObject(int columnIndex, Class type) throws SQLException { returnValue = getTime(columnIndex); } else if (type == java.sql.Timestamp.class) { returnValue = getTimestamp(columnIndex); - } else if (type == java.time.LocalDateTime.class - || type == java.time.LocalDate.class + } else if (type == java.time.LocalDateTime.class || type == java.time.LocalDate.class || type == java.time.LocalTime.class) { java.sql.Timestamp ts = getTimestamp(columnIndex, Calendar.getInstance(java.util.TimeZone.getTimeZone("UTC"))); if (ts == null) { returnValue = null; } else { - java.time.LocalDateTime ldt = java.time.LocalDateTime - .ofInstant(ts.toInstant(), java.time.ZoneId.of("UTC")); + java.time.LocalDateTime ldt = java.time.LocalDateTime.ofInstant(ts.toInstant(), + java.time.ZoneId.of("UTC")); if (type == java.time.LocalDateTime.class) { returnValue = ldt; } else if (type == java.time.LocalDate.class) { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSpatialDatatype.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSpatialDatatype.java index 6959dec93b..672982ce98 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSpatialDatatype.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSpatialDatatype.java @@ -175,9 +175,9 @@ protected void serializeToWkb(boolean noZM, SQLServerSpatialDatatype type) { * multiple corresponding data structures. * * @param type - * Type of Spatial Datatype (Geography/Geometry) + * Type of Spatial Datatype (Geography/Geometry) * @throws SQLServerException - * if an Exception occurs + * if an Exception occurs */ protected void parseWkb(SQLServerSpatialDatatype type) throws SQLServerException { srid = readInt(); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Util.java b/src/main/java/com/microsoft/sqlserver/jdbc/Util.java index f3501be4b3..4b7378f587 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Util.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Util.java @@ -197,14 +197,10 @@ static BigDecimal readBigDecimal(byte valueBytes[], int valueLength, int scale) * @return long value as read from bytes. */ /* L0 */static long readLong(byte data[], int nOffset) { - return ((long) (data[nOffset + 7] & 0xff) << 56) - | ((long) (data[nOffset + 6] & 0xff) << 48) - | ((long) (data[nOffset + 5] & 0xff) << 40) - | ((long) (data[nOffset + 4] & 0xff) << 32) - | ((long) (data[nOffset + 3] & 0xff) << 24) - | ((long) (data[nOffset + 2] & 0xff) << 16) - | ((long) (data[nOffset + 1] & 0xff) << 8) - | ((long) (data[nOffset] & 0xff)); + return ((long) (data[nOffset + 7] & 0xff) << 56) | ((long) (data[nOffset + 6] & 0xff) << 48) + | ((long) (data[nOffset + 5] & 0xff) << 40) | ((long) (data[nOffset + 4] & 0xff) << 32) + | ((long) (data[nOffset + 3] & 0xff) << 24) | ((long) (data[nOffset + 2] & 0xff) << 16) + | ((long) (data[nOffset + 1] & 0xff) << 8) | ((long) (data[nOffset] & 0xff)); } /** diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/resultset/ResultSetTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/resultset/ResultSetTest.java index eb73fd3ff2..8fbdeff2c2 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/resultset/ResultSetTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/resultset/ResultSetTest.java @@ -254,28 +254,26 @@ public void testGetObjectAsLocalDateTime() throws SQLException { try (Connection con = DriverManager.getConnection(connectionString); Statement stmt = con.createStatement()) { TimeZone prevTimeZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("America/Edmonton")); - + // a local date/time that does not actually exist because of Daylight Saving Time final String testValueDate = "2018-03-11"; final String testValueTime = "02:00:00.1234567"; final String testValueDateTime = testValueDate + "T" + testValueTime; - - stmt.executeUpdate( - "CREATE TABLE " + tableName + " (id INT PRIMARY KEY, dt2 DATETIME2)"); - stmt.executeUpdate( - "INSERT INTO " + tableName + " (id, dt2) VALUES (1, '" + testValueDateTime + "')"); + + stmt.executeUpdate("CREATE TABLE " + tableName + " (id INT PRIMARY KEY, dt2 DATETIME2)"); + stmt.executeUpdate("INSERT INTO " + tableName + " (id, dt2) VALUES (1, '" + testValueDateTime + "')"); try (ResultSet rs = stmt.executeQuery("SELECT dt2 FROM " + tableName + " WHERE id=1")) { rs.next(); - + LocalDateTime expectedLocalDateTime = LocalDateTime.parse(testValueDateTime); LocalDateTime actualLocalDateTime = rs.getObject(1, LocalDateTime.class); assertEquals(expectedLocalDateTime, actualLocalDateTime); - + LocalDate expectedLocalDate = LocalDate.parse(testValueDate); LocalDate actualLocalDate = rs.getObject(1, LocalDate.class); assertEquals(expectedLocalDate, actualLocalDate); - + LocalTime expectedLocalTime = LocalTime.parse(testValueTime); LocalTime actualLocalTime = rs.getObject(1, LocalTime.class); assertEquals(expectedLocalTime, actualLocalTime); From afa462813b4e7e1be6b0ecc965393fd1ff11fe57 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Tue, 28 Aug 2018 17:04:48 -0700 Subject: [PATCH 2/2] Minor changes --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa7ce4c3f4..ad51b2223e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) - Added support to read SQL Warnings after ResultSet is read completely [#785](https://github.com/Microsoft/mssql-jdbc/pull/785) ### Fixed Issues -- Fixed JavaDoc warnings and removed obselete HTML tags from Javadocs [#786](https://github.com/Microsoft/mssql-jdbc/pull/786) -- Fixed random Junit failures in framework tests [#762](https://github.com/Microsoft/mssql-jdbc/pull/762) +- Fixed Javadoc warnings and removed obselete HTML tags from Javadocs [#786](https://github.com/Microsoft/mssql-jdbc/pull/786) +- Fixed random JUnit failures in framework tests [#762](https://github.com/Microsoft/mssql-jdbc/pull/762) ### Changed - Improved performance of readLong() function by unrolling loop and using bitwise operators instead of additions [#763](https://github.com/Microsoft/mssql-jdbc/pull/763)