support set_nocount swith from jdbc url property - #2972
Conversation
|
I have tested using simple java code return 3 |
|
qmarsun We are currently reviewing the PR. Could you please add test cases for this change as well, covering: Property parsing and validation for ON/OFF values. |
|
default behavior is set_nocount on. or jdbc connection does not have property passed |
|
qmarsun It would be very helpful if you could provide a minimal repro/sample application that depends on configuring SET NOCOUNT through the JDBC connection string. Understanding the real-world use case will help us validate both the necessity of the feature and the proposed implementation. |
|
qmarsun please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
qmarsun
Could you please confirm the exact behavior in your environment? The statement “MSSQL by default is not returning affected-row counts” does not appear to be universally true. On an unmodified (main branch code) Microsoft JDBC driver, a new SQL Server session returned the expected affected-row count when NOCOUNT was OFF. Missing counts may instead be caused by environment or execution context, such as:
The Microsoft JDBC driver does not currently provide an equivalent generic URL property; applications must execute SET NOCOUNT OFF after opening each connection or use a framework/pool initialization hook. Your PR #2972 appears to address this migration gap through the narrower set_nocount=on|off property. Could you confirm: |
To support set_nocount propert as part URL jdbc connection string
jdbc:sqlserver://localhost:1433;databaseName=testdb;encrypt=true;trustServerCertificate=true;set_nocount=on
return -1
and
jdbc:sqlserver://localhost:1433;databaseName=testdb;encrypt=true;trustServerCertificate=true;set_nocount=off
that will automatically return rows
Connected to SQL Server successfully.
101 | John | sk | IT | 75000.0
102 | Mary | Johnson | HR | 68000.0
103 | David | Brown | Finance | 82000.0
104 | Lisa | Davis | Operations | 71000.0
105 | James | Wilson | Support | 65000.0
106 | John | sk | it | 100000.0
107 | John | sk | it | 100000.0
UPDATE Employee SET LastName ='sk' where FirstName = ?
Rows affected: 3