@@ -299,6 +299,12 @@ public String toString() {
299
299
/** flag indicating whether prelogin TLS handshake is required */
300
300
private boolean isTDS8 = false ;
301
301
302
+ /** flag to indicating whether QUOTED_IDENTIFIER is ON/OFF */
303
+ private OnOffOption isQuotedIdentifierOn = OnOffOption .NOT_SET ;
304
+
305
+ /** flag to indicating whether CONCAT_NULL_YIELDS_NULL is ON/OFF */
306
+ private OnOffOption isConcatNullYieldsNullOn = OnOffOption .NOT_SET ;
307
+
302
308
/** encrypted truststore password */
303
309
byte [] encryptedTrustStorePassword = null ;
304
310
@@ -1813,6 +1819,20 @@ final void setMaxFieldSize(int limit) throws SQLServerException {
1813
1819
}
1814
1820
}
1815
1821
1822
+ private void setCustomFlags () {
1823
+ try {
1824
+ if (OnOffOption .OFF .equals (isQuotedIdentifierOn )) {
1825
+ connectionCommand ("SET QUOTED_IDENTIFIER OFF" , "quotedIdentifier" );
1826
+ }
1827
+
1828
+ if (OnOffOption .OFF .equals (isConcatNullYieldsNullOn )) {
1829
+ connectionCommand ("SET CONCAT_NULL_YIELDS_NULL OFF" , "concatNullYieldsNull" );
1830
+ }
1831
+ } catch (SQLServerException e ) {
1832
+ loggerExternal .log (Level .WARNING , "Error setting QUOTED_IDENTIFIER and CONCAT_NULL_YIELDS_NULL properties" , e );
1833
+ }
1834
+ }
1835
+
1816
1836
/**
1817
1837
* This function is used both to init the values on creation of connection and resetting the values after the
1818
1838
* connection is released to the pool for reuse.
@@ -1828,36 +1848,7 @@ final void initResettableValues() {
1828
1848
sqlWarnings = null ;
1829
1849
sCatalog = originalCatalog ;
1830
1850
databaseMetaData = null ;
1831
-
1832
- try {
1833
- // check QUOTED_IDENTIFIER property
1834
- String quotedIdentifierProperty = SQLServerDriverStringProperty .QUOTED_IDENTIFIER .toString ();
1835
- String quotedIdentifierValue = activeConnectionProperties .getProperty (quotedIdentifierProperty );
1836
- if (null == quotedIdentifierValue ) {
1837
- quotedIdentifierValue = SQLServerDriverStringProperty .QUOTED_IDENTIFIER .getDefaultValue ();
1838
- activeConnectionProperties .setProperty (quotedIdentifierProperty , quotedIdentifierValue );
1839
- }
1840
-
1841
- String quotedIdentifierOption = OnOffOption .valueOfString (quotedIdentifierValue ).toString ();
1842
- if (quotedIdentifierOption .compareToIgnoreCase (OnOffOption .OFF .toString ()) == 0 ) {
1843
- connectionCommand ("SET QUOTED_IDENTIFIER OFF" , "quotedIdentifier" );
1844
- }
1845
-
1846
- // check CONCAT_NULL_YIELDS_NULL property
1847
- String concatNullYieldsNullProperty = SQLServerDriverStringProperty .CONCAT_NULL_YIELDS_NULL .toString ();
1848
- String concatNullYieldsNullValue = activeConnectionProperties .getProperty (concatNullYieldsNullProperty );
1849
- if (null == concatNullYieldsNullValue ) {
1850
- concatNullYieldsNullValue = SQLServerDriverStringProperty .CONCAT_NULL_YIELDS_NULL .getDefaultValue ();
1851
- activeConnectionProperties .setProperty (concatNullYieldsNullProperty , concatNullYieldsNullValue );
1852
- }
1853
- String concatNullYieldsNullOption = OnOffOption .valueOfString (concatNullYieldsNullValue ).toString ();
1854
- if (concatNullYieldsNullOption .compareToIgnoreCase (OnOffOption .OFF .toString ()) == 0 ) {
1855
- connectionCommand ("SET CONCAT_NULL_YIELDS_NULL OFF" , "concatNullYieldsNull" );
1856
-
1857
- }
1858
- } catch (SQLServerException e ) {
1859
- loggerExternal .log (Level .WARNING , "Error setting QUOTED_IDENTIFIER and CONCAT_NULL_YIELDS_NULL properties" , e );
1860
- }
1851
+ setCustomFlags ();
1861
1852
}
1862
1853
1863
1854
/** Limit for the maximum number of rows returned from queries on this connection */
@@ -3557,6 +3548,31 @@ else if (0 == requestedPacketSize)
3557
3548
3558
3549
state = State .OPENED ;
3559
3550
3551
+ // check QUOTED_IDENTIFIER property
3552
+ String quotedIdentifierProperty = SQLServerDriverStringProperty .QUOTED_IDENTIFIER .toString ();
3553
+ String quotedIdentifierValue = activeConnectionProperties .getProperty (quotedIdentifierProperty );
3554
+ if (null == quotedIdentifierValue ) {
3555
+ quotedIdentifierValue = SQLServerDriverStringProperty .QUOTED_IDENTIFIER .getDefaultValue ();
3556
+ activeConnectionProperties .setProperty (quotedIdentifierProperty , quotedIdentifierValue );
3557
+ }
3558
+
3559
+ isQuotedIdentifierOn = OnOffOption .valueOfString (quotedIdentifierValue );
3560
+ if (!isQuotedIdentifierOn .equals (OnOffOption .NOT_SET )) {
3561
+ connectionCommand ("SET QUOTED_IDENTIFIER " + isQuotedIdentifierOn , "quotedIdentifier" );
3562
+ }
3563
+
3564
+ // check CONCAT_NULL_YIELDS_NULL property
3565
+ String concatNullYieldsNullProperty = SQLServerDriverStringProperty .CONCAT_NULL_YIELDS_NULL .toString ();
3566
+ String concatNullYieldsNullValue = activeConnectionProperties .getProperty (concatNullYieldsNullProperty );
3567
+ if (null == concatNullYieldsNullValue ) {
3568
+ concatNullYieldsNullValue = SQLServerDriverStringProperty .CONCAT_NULL_YIELDS_NULL .getDefaultValue ();
3569
+ activeConnectionProperties .setProperty (concatNullYieldsNullProperty , concatNullYieldsNullValue );
3570
+ }
3571
+ isConcatNullYieldsNullOn = OnOffOption .valueOfString (concatNullYieldsNullValue );
3572
+ if (!isConcatNullYieldsNullOn .equals (OnOffOption .NOT_SET )) {
3573
+ connectionCommand ("SET CONCAT_NULL_YIELDS_NULL " + isConcatNullYieldsNullOn , "concatNullYieldsNull" );
3574
+ }
3575
+
3560
3576
// Socket timeout is bounded by loginTimeout during the login phase.
3561
3577
// Reset socket timeout back to the original value.
3562
3578
tdsChannel .resetTcpSocketTimeout ();
0 commit comments