Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue699 #1

Merged
merged 17 commits into from
Dec 11, 2018
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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ 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.3] Preview Release
### Added
- Added a new SQLServerMetaData constructor for string values of length greater than 4000 [#876](https://github.com/Microsoft/mssql-jdbc/pull/876)

### Fixed Issues
- Fixed an issue with Geography.point() having coordinates reversed [#853](https://github.com/Microsoft/mssql-jdbc/pull/853)
- Fixed intermittent test failures [#854](https://github.com/Microsoft/mssql-jdbc/pull/854) [#862](https://github.com/Microsoft/mssql-jdbc/pull/862) [#888](https://github.com/Microsoft/mssql-jdbc/pull/888)
- Fixed an issue with setAutoCommit() leaving a transaction open when running against Azure SQL Data Warehouse [#881](https://github.com/Microsoft/mssql-jdbc/pull/881)

### Changed
- Changed query timeout logic to use a single thread [#842](https://github.com/Microsoft/mssql-jdbc/pull/842)
- Code cleanup [#857](https://github.com/Microsoft/mssql-jdbc/pull/857) [#873](https://github.com/Microsoft/mssql-jdbc/pull/873)
- Removed populating Lobs when calling ResultSet.wasNull() [#875](https://github.com/Microsoft/mssql-jdbc/pull/875)
- Improved retry logic for intermittent TLS1.2 issue when establishing a connection [#882](https://github.com/Microsoft/mssql-jdbc/pull/882)

## [7.1.2] Preview Release
### Added
- Added support for JDK 11 [#824](https://github.com/Microsoft/mssql-jdbc/pull/824) [#837](https://github.com/Microsoft/mssql-jdbc/pull/837) [#807](https://github.com/Microsoft/mssql-jdbc/pull/807)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>7.1.2.jre11-preview</version>
<version>7.1.3.jre11-preview</version>
</dependency>
```

Expand Down Expand Up @@ -123,7 +123,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>7.1.2.jre11-preview</version>
<version>7.1.3.jre11-preview</version>
<scope>compile</scope>
</dependency>

Expand All @@ -140,7 +140,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>7.1.2.jre11-preview</version>
<version>7.1.3.jre11-preview</version>
<scope>compile</scope>
</dependency>

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

apply plugin: 'java'

version = '7.1.3-SNAPSHOT'
version = '7.1.4-SNAPSHOT'
def jreVersion = ""
def testOutputDir = file("build/classes/java/test")
def archivesBaseName = 'mssql-jdbc'
Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>7.1.3-SNAPSHOT</version>
<version>7.1.4-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Microsoft JDBC Driver for SQL Server</name>
Expand Down Expand Up @@ -153,6 +153,12 @@
<version>1.7.25</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.gemini.blueprint</groupId>
<artifactId>gemini-blueprint-mock</artifactId>
<version>3.0.0.M01</version>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/microsoft/sqlserver/jdbc/DDC.java
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,14 @@ static final Object convertStreamToObject(BaseInputStream stream, TypeInfo typeI
if (JDBCType.GUID == jdbcType) {
return Util.readGUID(byteValue);
} else if (JDBCType.GEOMETRY == jdbcType) {
if (!typeInfo.getSSTypeName().equalsIgnoreCase(jdbcType.toString())) {
DataTypes.throwConversionError(typeInfo.getSSTypeName().toUpperCase(), jdbcType.toString());
}
return Geometry.STGeomFromWKB(byteValue);
} else if (JDBCType.GEOGRAPHY == jdbcType) {
if (!typeInfo.getSSTypeName().equalsIgnoreCase(jdbcType.toString())) {
DataTypes.throwConversionError(typeInfo.getSSTypeName().toUpperCase(), jdbcType.toString());
}
return Geography.STGeomFromWKB(byteValue);
} else {
String hexString = Util.bytesToHexString(byteValue, byteValue.length);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/microsoft/sqlserver/jdbc/Geography.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static Geography parse(String wkt) throws SQLServerException {
* if an exception occurs
*/
public static Geography point(double lat, double lon, int srid) throws SQLServerException {
return new Geography("POINT (" + lat + " " + lon + ")", srid);
return new Geography("POINT (" + lon + " " + lat + ")", srid);
}

/**
Expand Down Expand Up @@ -212,8 +212,8 @@ public boolean hasZ() {
* @return double value that represents the latitude.
*/
public Double getLatitude() {
if (null != internalType && internalType == InternalSpatialDatatype.POINT && xValues.length == 1) {
return xValues[0];
if (null != internalType && internalType == InternalSpatialDatatype.POINT && yValues.length == 1) {
return yValues[0];
}
return null;
}
Expand All @@ -224,8 +224,8 @@ public Double getLatitude() {
* @return double value that represents the longitude.
*/
public Double getLongitude() {
if (null != internalType && internalType == InternalSpatialDatatype.POINT && yValues.length == 1) {
return yValues[0];
if (null != internalType && internalType == InternalSpatialDatatype.POINT && xValues.length == 1) {
return xValues[0];
}
return null;
}
Expand Down
45 changes: 27 additions & 18 deletions src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1794,31 +1794,40 @@ else if (con.getTrustManagerClass() != null) {
+ tmfDefaultAlgorithm + "\n") : "")
+ ((null != ksProvider) ? ("KeyStore provider info: " + ksProvider.getInfo() + "\n") : "")
+ "java.ext.dirs: " + System.getProperty("java.ext.dirs"));
// Retrieve the localized error message if possible.
String localizedMessage = e.getLocalizedMessage();
String errMsg = (localizedMessage != null) ? localizedMessage : e.getMessage();
/*
* Retrieve the error message of the cause too because actual error message can be wrapped into a different
* message when re-thrown from underlying InputStream.
*/
String causeErrMsg = null;
Throwable cause = e.getCause();
if (cause != null) {
String causeLocalizedMessage = cause.getLocalizedMessage();
causeErrMsg = (causeLocalizedMessage != null) ? causeLocalizedMessage : cause.getMessage();
}

MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_sslFailed"));
Object[] msgArgs = {e.getMessage()};

// It is important to get the localized message here, otherwise error messages won't match for different
// locales.
String errMsg = e.getLocalizedMessage();
// If the message is null replace it with the non-localized message or a dummy string. This can happen if a
// custom
// TrustManager implementation is specified that does not provide localized messages.
if (errMsg == null) {
errMsg = e.getMessage();
}
if (errMsg == null) {
errMsg = "";
}
// The error message may have a connection id appended to it. Extract the message only for comparison.
// This client connection id is appended in method checkAndAppendClientConnId().
if (errMsg.contains(SQLServerException.LOG_CLIENT_CONNECTION_ID_PREFIX)) {
Object[] msgArgs = {errMsg};

/*
* The error message may have a connection id appended to it. Extract the message only for comparison. This
* client connection id is appended in method checkAndAppendClientConnId().
*/
if (errMsg != null && errMsg.contains(SQLServerException.LOG_CLIENT_CONNECTION_ID_PREFIX)) {
errMsg = errMsg.substring(0, errMsg.indexOf(SQLServerException.LOG_CLIENT_CONNECTION_ID_PREFIX));
}

if (causeErrMsg != null && causeErrMsg.contains(SQLServerException.LOG_CLIENT_CONNECTION_ID_PREFIX)) {
causeErrMsg = causeErrMsg.substring(0,
causeErrMsg.indexOf(SQLServerException.LOG_CLIENT_CONNECTION_ID_PREFIX));
}

// Isolate the TLS1.2 intermittent connection error.
if (e instanceof IOException && (SSLHandhsakeState.SSL_HANDHSAKE_STARTED == handshakeState)
&& (errMsg.equals(SQLServerException.getErrString("R_truncatedServerResponse")))) {
&& (SQLServerException.getErrString("R_truncatedServerResponse").equals(errMsg)
|| SQLServerException.getErrString("R_truncatedServerResponse").equals(causeErrMsg))) {
con.terminate(SQLServerException.DRIVER_ERROR_INTERMITTENT_TLS_FAILED, form.format(msgArgs), e);
} else {
con.terminate(SQLServerException.DRIVER_ERROR_SSL_FAILED, form.format(msgArgs), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
final class SQLJdbcVersion {
static final int major = 7;
static final int minor = 1;
static final int patch = 3;
static final int patch = 4;
static final int build = 0;
}
17 changes: 17 additions & 0 deletions src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ public SQLServerMetaData(String columnName, int sqlType, int precision, int scal
this.scale = scale;
}

/**
* Constructs a SQLServerMetaData with the column name, SQL type, and length (for String data).
* The length is used to differentiate large strings from strings with length less than 4000 characters.
*
* @param columnName
* the name of the column
* @param sqlType
* the SQL type of the column
* @param length
* the length of the string type
*/
public SQLServerMetaData(String columnName, int sqlType, int length) {
this.columnName = columnName;
this.javaSqlType = sqlType;
this.precision = length;
}

/**
* Constructs a SQLServerMetaData.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,6 @@ public boolean next() throws SQLServerException {
public boolean wasNull() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "wasNull");
checkClosed();
fillLOBs();
loggerExternal.exiting(getClassNameLogging(), "wasNull", lastValueWasNull);
return lastValueWasNull;
}
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/com/microsoft/sqlserver/jdbc/osgi/Activator.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/*
* 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.
* 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.osgi;

Expand All @@ -17,6 +14,7 @@

import com.microsoft.sqlserver.jdbc.SQLServerDriver;


/**
*
* publishes the service to the OSGi Framework
Expand All @@ -31,13 +29,13 @@ public void start(BundleContext context) throws Exception {
SQLServerDriver driver = new SQLServerDriver();
properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, driver.getClass().getName());
properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_NAME, "Microsoft JDBC Driver for SQL Server");
properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_VERSION, driver.getMajorVersion() + "." + driver.getMinorVersion());
service = context.registerService(DataSourceFactory.class, new MSSQLDataSourceFactory(), properties);
properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_VERSION,
driver.getMajorVersion() + "." + driver.getMinorVersion());
service = context.registerService(DataSourceFactory.class, new SQLServerDataSourceFactory(), properties);
}

@Override
public void stop(BundleContext context) throws Exception {
service.unregister();
}

}
Original file line number Diff line number Diff line change
@@ -1,15 +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.
* 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.osgi;

import java.sql.Driver;
import java.sql.SQLException;
import java.util.Properties;
import java.util.logging.Level;

import javax.activation.DataSource;
import javax.sql.ConnectionPoolDataSource;
Expand All @@ -22,14 +20,17 @@
import com.microsoft.sqlserver.jdbc.SQLServerDriver;
import com.microsoft.sqlserver.jdbc.SQLServerXADataSource;


/**
* Implementation of the Data Service Specification for JDBC™ Technology
*
* see https://osgi.org/specification/osgi.cmpn/7.0.0/service.jdbc.html
*/
public class MSSQLDataSourceFactory implements DataSourceFactory {

public class SQLServerDataSourceFactory implements DataSourceFactory {

private static java.util.logging.Logger osgiLogger = java.util.logging.Logger
.getLogger("com.microsoft.sqlserver.jdbc.osgi.SQLServerDataSourceFactory");
private static String NOT_SUPPORTED_MSG = "The Microsoft SQL Server JDBC Driver currently does not support the property: {0}";

@Override
public javax.sql.DataSource createDataSource(Properties props) throws SQLException {
Expand Down Expand Up @@ -69,13 +70,13 @@ private void setup(SQLServerDataSource source, Properties props) {
source.setDatabaseName(props.getProperty(JDBC_DATABASE_NAME));
}
if (props.containsKey(JDBC_DATASOURCE_NAME)) {
//not supported?
osgiLogger.log(Level.WARNING, NOT_SUPPORTED_MSG, JDBC_DATASOURCE_NAME);
}
if (props.containsKey(JDBC_DESCRIPTION)) {
source.setDescription(props.getProperty(JDBC_DESCRIPTION));
}
if (props.containsKey(JDBC_NETWORK_PROTOCOL)) {
//not supported?
osgiLogger.log(Level.WARNING, NOT_SUPPORTED_MSG, JDBC_NETWORK_PROTOCOL);
}
if (props.containsKey(JDBC_PASSWORD)) {
source.setPassword(props.getProperty(JDBC_PASSWORD));
Expand All @@ -84,7 +85,7 @@ private void setup(SQLServerDataSource source, Properties props) {
source.setPortNumber(Integer.parseInt(props.getProperty(JDBC_PORT_NUMBER)));
}
if (props.containsKey(JDBC_ROLE_NAME)) {
//not supported?
osgiLogger.log(Level.WARNING, NOT_SUPPORTED_MSG, JDBC_ROLE_NAME);
}
if (props.containsKey(JDBC_SERVER_NAME)) {
source.setServerName(props.getProperty(JDBC_SERVER_NAME));
Expand All @@ -98,28 +99,27 @@ private void setup(SQLServerDataSource source, Properties props) {
}

/**
* Setup the basic and extended properties for {@link XADataSource}s and
* {@link ConnectionPoolDataSource}s
* Setup the basic and extended properties for {@link XADataSource}s and {@link ConnectionPoolDataSource}s
*/
private void setupXSource(SQLServerConnectionPoolDataSource source, Properties props) {
if (props == null) {
return;
}
setup(source, props);
if (props.containsKey(JDBC_INITIAL_POOL_SIZE)) {
//not supported?
osgiLogger.log(Level.WARNING, NOT_SUPPORTED_MSG, JDBC_INITIAL_POOL_SIZE);
}
if (props.containsKey(JDBC_MAX_IDLE_TIME)) {
//not supported?
osgiLogger.log(Level.WARNING, NOT_SUPPORTED_MSG, JDBC_MAX_IDLE_TIME);
}
if (props.containsKey(JDBC_MAX_STATEMENTS)) {
//not supported?
osgiLogger.log(Level.WARNING, NOT_SUPPORTED_MSG, JDBC_MAX_STATEMENTS);
}
if (props.containsKey(JDBC_MAX_POOL_SIZE)) {
//not supported?
osgiLogger.log(Level.WARNING, NOT_SUPPORTED_MSG, JDBC_MAX_POOL_SIZE);
}
if (props.containsKey(JDBC_MIN_POOL_SIZE)) {
//not supported?
osgiLogger.log(Level.WARNING, NOT_SUPPORTED_MSG, JDBC_MIN_POOL_SIZE);
}
}

Expand Down
Loading