Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f6277eb
use matrix to test against both SQL Server 2016 and 2008
xiangyushawn Aug 2, 2017
0587b66
miss a `;`
xiangyushawn Aug 2, 2017
e650225
use matrix and init to start services
xiangyushawn Aug 2, 2017
f4c7604
simplify appveyor configuration
xiangyushawn Aug 2, 2017
fddcb30
fix 2 test failures against sql server 2008
xiangyushawn Aug 9, 2017
89c92b7
Fix for EnablePrepareOnFirstPreparedStatementCall with statement pooling
TobiasSQL Sep 27, 2017
0046d3c
fix for 477
peterbae Nov 15, 2017
c006af2
add check for updatable resultsets.
peterbae Nov 16, 2017
6607087
Merge branch 'dev' of https://github.com/Microsoft/mssql-jdbc into te…
xiangyushawn Nov 17, 2017
d69e01b
Updating POM File for next preview snapshot
cheenamalhotra Nov 20, 2017
b247869
Merge branch 'dev' into dev
cheenamalhotra Nov 20, 2017
a940fbc
Merge pull request #557 from cheenamalhotra/dev
cheenamalhotra Nov 21, 2017
21fde63
use preparedStatementHandleCache with database name
xiangyushawn Nov 21, 2017
a9b6a7c
retrieve db name without check connection
xiangyushawn Nov 22, 2017
3a60d34
Adding changes to logger implementation for avoiding logger lookup
cheenamalhotra Nov 23, 2017
40a9bf5
update ADAL4J version to 1.3.0 and also add it into readme file based…
xiangyushawn Nov 24, 2017
8344415
Merge pull request #564 from v-xiangs/update-dependencies
xiangyushawn Nov 29, 2017
ba22e94
Merge pull request #561 from v-xiangs/v-xiangs-handle-DBName
xiangyushawn Nov 29, 2017
01e8013
Merge pull request #513 from Microsoft/metadataCaching
xiangyushawn Nov 30, 2017
907e1a6
Merge pull request #428 from v-xiangs/test-agaist-both-2008-and-2016
xiangyushawn Dec 1, 2017
a8ed6f6
Merge pull request #552 from peterbae/github-477
peterbae Dec 5, 2017
9fe90f7
Merge pull request #563 from cheenamalhotra/staticLogger
cheenamalhotra Dec 5, 2017
823f08e
Fix issue with rowDeleted() causing issues with testing
peterbae Dec 6, 2017
4c90c8e
Revert "Fix issue with rowDeleted() causing issues with testing"
peterbae Dec 6, 2017
557fdf3
Reverting PR 563, due to test failures
peterbae Dec 6, 2017
6fdab44
6.3.6 preview release
peterbae Dec 7, 2017
ab733d3
Merge pull request #574 from peterbae/github-477
peterbae Dec 7, 2017
2c357ce
Merge pull request #575 from peterbae/peter-6.3.6-release
peterbae Dec 7, 2017
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ 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.6] Preview Release
### Added
- Added support for using database name as part of the key for handle cache [#561](https://github.com/Microsoft/mssql-jdbc/pull/561)
- Updated ADAL4J version to 1.3.0 and also added it into README file [#564](https://github.com/Microsoft/mssql-jdbc/pull/564)

### Fixed Issues
- Fixed issues with static loggers being set by every constructor invocation [#563](https://github.com/Microsoft/mssql-jdbc/pull/563)

## [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)
Expand Down
20 changes: 18 additions & 2 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>6.3.5.jre8-preview</version>
<version>6.3.6.jre8-preview</version>
</dependency>
```

Expand All @@ -115,12 +115,28 @@ mvn dependency:tree
### Azure Key Vault and Azure Active Directory Authentication Dependencies
Projects that require either of the two features need to explicitly declare the dependency in their pom file.

***For Example:*** If you are using *Azure Active Directory Authentication feature* then you need to redeclare *adal4j* dependency in your project's pom file. Please see the following snippet:
```xml
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.3.6.jre8-preview</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<version>1.3.0</version>
</dependency>
```

***For Example:*** If you are using *Azure Key Vault feature* then you need to redeclare *azure-keyvault* dependency in your project's pom file. Please see the following snippet:
```xml
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.3.5.jre8-preview</version>
<version>6.3.6.jre8-preview</version>
<scope>compile</scope>
</dependency>

Expand Down
13 changes: 8 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
version: '{build}'

init:
- cmd: net start MSSQL$%SQL_Instance%

environment:
mssql_jdbc_test_connection_properties: jdbc:sqlserver://localhost:1433;instanceName=SQL2016;databaseName=master;username=sa;password=Password12!;
JAVA_HOME: C:\Program Files\Java\jdk1.8.0
mssql_jdbc_test_connection_properties: jdbc:sqlserver://localhost:1433;instanceName=%SQL_Instance%;databaseName=master;username=sa;password=Password12!;

matrix:
- JAVA_HOME: C:\Program Files\Java\jdk1.8.0
- SQL_Instance: SQL2008R2SP2
- SQL_Instance: SQL2016

services:
- mssql2016

install:
- ps: Write-Host 'Installing JCE with powershell'
- ps: cd AppVeyorJCE
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.3.5.${jreVersion}-preview</version>
<version>6.3.6.${jreVersion}-preview</version>
<packaging>jar</packaging>

<name>Microsoft JDBC Driver for SQL Server</name>
Expand Down Expand Up @@ -54,7 +54,7 @@
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>
<optional>true</optional>
</dependency>

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 = 5;
static final int patch = 6;
static final int build = 0;
}
14 changes: 9 additions & 5 deletions src/main/java/com/microsoft/sqlserver/jdbc/SQLServerClob.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@

public class SQLServerClob extends SQLServerClobBase implements Clob {
private static final long serialVersionUID = 2872035282200133865L;

// Loggers should be class static to avoid lock contention with multiple threads
private static final Logger logger = Logger.getLogger("com.microsoft.sqlserver.jdbc.internals.SQLServerClob");

/**
* Create a new CLOB
Expand All @@ -47,19 +50,19 @@ public class SQLServerClob extends SQLServerClobBase implements Clob {
@Deprecated
public SQLServerClob(SQLServerConnection connection,
String data) {
super(connection, data, (null == connection) ? null : connection.getDatabaseCollation(), null);
super(connection, data, (null == connection) ? null : connection.getDatabaseCollation(), logger, null);

if (null == data)
throw new NullPointerException(SQLServerException.getErrString("R_cantSetNull"));
}

SQLServerClob(SQLServerConnection connection) {
super(connection, "", connection.getDatabaseCollation(), null);
super(connection, "", connection.getDatabaseCollation(), logger, null);
}

SQLServerClob(BaseInputStream stream,
TypeInfo typeInfo) throws SQLServerException, UnsupportedEncodingException {
super(null, stream, typeInfo.getSQLCollation(), typeInfo);
super(null, stream, typeInfo.getSQLCollation(), logger, typeInfo);
}

final JDBCType getJdbcType() {
Expand Down Expand Up @@ -89,7 +92,7 @@ abstract class SQLServerClobBase implements Serializable {

transient SQLServerConnection con;

private final Logger logger = Logger.getLogger(getClass().getName());
private final Logger logger;

final private String traceID = getClass().getName().substring(1 + getClass().getName().lastIndexOf('.')) + ":" + nextInstanceID();

Expand Down Expand Up @@ -128,6 +131,7 @@ private String getDisplayClassName() {
SQLServerClobBase(SQLServerConnection connection,
Object data,
SQLCollation collation,
Logger logger,
TypeInfo typeInfo) {
this.con = connection;
if (data instanceof BaseInputStream) {
Expand All @@ -137,8 +141,8 @@ private String getDisplayClassName() {
this.value = (String) data;
}
this.sqlCollation = collation;
this.logger = logger;
this.typeInfo = typeInfo;

if (logger.isLoggable(Level.FINE)) {
String loggingInfo = (null != connection) ? connection.toString() : "null connection";
logger.fine(toString() + " created by (" + loggingInfo + ")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ public class SQLServerConnection implements ISQLServerConnection {
static class Sha1HashKey {
private byte[] bytes;

Sha1HashKey(String sql, String parametersDefinition) {
this(String.format("%s%s", sql, parametersDefinition));
Sha1HashKey(String sql,
String parametersDefinition,
String dbName) {
this(String.format("%s%s%s", sql, parametersDefinition, dbName));
}

Sha1HashKey(String s) {
Expand Down Expand Up @@ -3097,6 +3099,10 @@ final void poolCloseEventNotify() throws SQLServerException {
return sCatalog;
}

String getSCatalog() throws SQLServerException {
return sCatalog;
}

/* L0 */ public void setTransactionIsolation(int level) throws SQLServerException {
if (loggerExternal.isLoggable(Level.FINER)) {
loggerExternal.entering(getClassNameLogging(), "setTransactionIsolation", level);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,11 @@ private CallableStatement getCallableStatementHandle(CallableHandles request,
hassoc = new HandleAssociation(catalog, CS);
HandleAssociation previous = handleMap.put(request, hassoc);
if (null != previous) {
((SQLServerCallableStatement) previous.stmt).handleDBName = previous.databaseName;

previous.close();

((SQLServerCallableStatement) previous.stmt).handleDBName = null;
}
}
return hassoc.stmt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.io.UnsupportedEncodingException;
import java.sql.NClob;
import java.util.logging.Logger;

/**
* SQLServerNClob represents a National Character Set LOB object and implements java.sql.NClob.
Expand All @@ -19,13 +20,16 @@ public final class SQLServerNClob extends SQLServerClobBase implements NClob {

private static final long serialVersionUID = 1L;

// Loggers should be class static to avoid lock contention with multiple threads
private static final Logger logger = Logger.getLogger("com.microsoft.sqlserver.jdbc.internals.SQLServerNClob");

SQLServerNClob(SQLServerConnection connection) {
super(connection, "", connection.getDatabaseCollation(), null);
super(connection, "", connection.getDatabaseCollation(), logger, null);
}

SQLServerNClob(BaseInputStream stream,
TypeInfo typeInfo) throws SQLServerException, UnsupportedEncodingException {
super(null, stream, typeInfo.getSQLCollation(), typeInfo);
super(null, stream, typeInfo.getSQLCollation(), logger, typeInfo);
}

final JDBCType getJdbcType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS

/** The prepared statement handle returned by the server */
private int prepStmtHandle = 0;
String handleDBName = null;

/** Statement used for getMetadata(). Declared as a field to facilitate closing the statement. */
private SQLServerStatement internalStmt = null;
Expand Down Expand Up @@ -184,7 +185,9 @@ String getClassNameInternal() {
// Parse or fetch SQL metadata from cache.
ParsedSQLCacheItem parsedSQL = getCachedParsedSQL(sqlTextCacheKey);
if(null != parsedSQL) {
isExecutedAtLeastOnce = true;
if(null != connection && connection.isStatementPoolingEnabled()) {
isExecutedAtLeastOnce = true;
}
}
else {
parsedSQL = parseAndCacheSQL(sqlTextCacheKey, sql);
Expand Down Expand Up @@ -535,7 +538,8 @@ final void doExecutePreparedStatement(PrepStmtExecCmd command) throws SQLServerE
hasNewTypeDefinitions = buildPreparedStrings(inOutParam, true);
}

if (reuseCachedHandle(hasNewTypeDefinitions, false)) {
String dbName = connection.getSCatalog();
if (reuseCachedHandle(hasNewTypeDefinitions, false, dbName)) {
hasNewTypeDefinitions = false;
}

Expand Down Expand Up @@ -581,8 +585,14 @@ boolean onRetValue(TDSReader tdsReader) throws SQLServerException {
setPreparedStatementHandle(param.getInt(tdsReader));

// Cache the reference to the newly created handle, NOT for cursorable handles.
if (null == cachedPreparedStatementHandle && !isCursorable(executeMethod)) {
cachedPreparedStatementHandle = connection.registerCachedPreparedStatementHandle(new Sha1HashKey(preparedSQL, preparedTypeDefinitions), prepStmtHandle, executedSqlDirectly);
if (null == cachedPreparedStatementHandle && !isCursorable(executeMethod)) {
String dbName = connection.getSCatalog();
if (null != handleDBName) {
dbName = handleDBName;
}

cachedPreparedStatementHandle = connection.registerCachedPreparedStatementHandle(
new Sha1HashKey(preparedSQL, preparedTypeDefinitions, dbName), prepStmtHandle, executedSqlDirectly);
}

param.skipValue(tdsReader, true);
Expand Down Expand Up @@ -904,7 +914,7 @@ private void getParameterEncryptionMetadata(Parameter[] params) throws SQLServer
}

/** Manage re-using cached handles */
private boolean reuseCachedHandle(boolean hasNewTypeDefinitions, boolean discardCurrentCacheItem) {
private boolean reuseCachedHandle(boolean hasNewTypeDefinitions, boolean discardCurrentCacheItem, String dbName) {
if (definitionChanged || connection.contextChanged) {
prepStmtHandle = -1; // so that hasPreparedStatementHandle() also returns false

Expand Down Expand Up @@ -945,7 +955,8 @@ private boolean reuseCachedHandle(boolean hasNewTypeDefinitions, boolean discard

// Check for new cache reference.
if (null == cachedPreparedStatementHandle) {
PreparedStatementHandle cachedHandle = connection.getCachedPreparedStatementHandle(new Sha1HashKey(preparedSQL, preparedTypeDefinitions));
PreparedStatementHandle cachedHandle = connection
.getCachedPreparedStatementHandle(new Sha1HashKey(preparedSQL, preparedTypeDefinitions, dbName));

// If handle was found then re-use, only if AE is not on and is not a batch query with new type definitions (We shouldn't reuse handle
// if it is batch query and has new type definition, or if it is on, make sure encryptionMetadataIsRetrieved is retrieved.
Expand Down Expand Up @@ -2615,8 +2626,9 @@ final void doExecutePreparedStatementBatch(PrepStmtBatchExecCmd batchCommand) th
batchParam[i].cryptoMeta = cryptoMetaBatch.get(i);
}
}

if (reuseCachedHandle(hasNewTypeDefinitions, false)) {

String dbName = connection.getSCatalog();
if (reuseCachedHandle(hasNewTypeDefinitions, false, dbName)) {
hasNewTypeDefinitions = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ public boolean next() throws SQLServerException {
moveFirst();
else
moveForward(1);

boolean value = hasCurrentRow();
loggerExternal.exiting(getClassNameLogging(), "next", value);
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,9 @@ public void readvarBinary8000() throws SQLException, SecurityException, IOExcept
public void readSQLVariantProperty() throws SQLException, SecurityException, IOException {
String value = "hi";
createAndPopulateTable("binary(8000)", "'" + value + "'");
rs = (SQLServerResultSet) stmt.executeQuery("SELECT SQL_VARIANT_PROPERTY(col1,'BaseType') AS 'Base Type',"
+ " SQL_VARIANT_PROPERTY(col1,'Precision') AS 'Precision' from " + tableName);
rs = (SQLServerResultSet) stmt.executeQuery(
"SELECT SQL_VARIANT_PROPERTY(col1,'BaseType') AS 'Base Type', SQL_VARIANT_PROPERTY(col1,'Precision') AS 'Precision' from "
+ tableName);
rs.next();
assertTrue(rs.getString(1).equalsIgnoreCase("binary"), "unexpected baseType, expected: binary, retrieved:" + rs.getString(1));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,11 @@ public void testSetup() throws TestAbortedException, Exception {

@AfterAll
public static void terminateVariation() throws SQLException {
connection = DriverManager.getConnection(connectionString);

SQLServerStatement stmt = (SQLServerStatement) connection.createStatement();
Utils.dropTableIfExists("esimple", stmt);

if (null != connection) {
connection.close();
}
if (null != pstmt) {
pstmt.close();
}
Expand All @@ -136,5 +134,8 @@ public static void terminateVariation() throws SQLException {
if (null != rs) {
rs.close();
}
if (null != connection) {
connection.close();
}
}
}
Loading