Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
f8811ea
Implement Sybase migration support with dynamicPrepare property
divang Oct 24, 2025
7dac544
Revert "Implement Sybase migration support with dynamicPrepare property"
divang Oct 24, 2025
cfb0e43
Add SqlServerPreparedStatementExpander with comprehensive test coverage
divang Nov 11, 2025
73cc7e2
Fix SqlServerPreparedStatementExpander test failures
divang Nov 11, 2025
b5f2299
Add 7 new E2E test cases for various SQL Server data types
divang Nov 11, 2025
9acdfc8
Added Sybase test code
divang Nov 11, 2025
c49e2d3
Merge branch 'main' of https://github.com/microsoft/mssql-jdbc into d…
divang Nov 17, 2025
47009b3
Add comprehensive test coverage for EXEC prepare method (#2834)
Ananya2 Nov 17, 2025
70d8b30
Fixed PrepareMethod - EXEC method related test cases
divang Nov 17, 2025
6f5de5c
Fixed pom.xml typo
divang Nov 17, 2025
0615022
Remove Sybase-related test files
divang Nov 27, 2025
676f27d
Consolidate SQL parameter expansion into SQLServerConnection
divang Nov 27, 2025
665951c
Fix parameter expansion to respect sendStringParametersAsUnicode and …
divang Nov 27, 2025
caf775c
Apply sendStringParametersAsUnicode config to Clob and fallback strin…
divang Nov 27, 2025
f1d26c1
Refactor replaceParameterMarkers to simplify parameter substitution
divang Nov 28, 2025
ba3b584
Fixed batch update count issue and cleaned the code
divang Dec 1, 2025
37ebc5c
When prepareMethod is set to 'exec', batch execution was failing enti…
divang Dec 2, 2025
c7712a9
Update count in case of batch related sql statements
divang Dec 2, 2025
ed847f5
Batching of SQL statement in case of exec preparedmethod
divang Dec 4, 2025
d01859f
Added replaceParameterMarkersWithValues() method and propogated execp…
divang Dec 8, 2025
8e2db67
Correct temp table naming and constraint violation assertions in Batc…
divang Dec 15, 2025
9adf6bf
Cleaned up unused code.
divang Dec 15, 2025
4c77ac7
Fixed Datae/Time converiosn in formatLiteralValue() method
divang Dec 15, 2025
5c7c24f
Cleaned up the old approach and hanlded review comments
divang Dec 16, 2025
7f3ef8d
timeoutOccurred variable is not required at this place
divang Dec 16, 2025
677a709
Handled OOO case replaceParameterMarkersWithValues() method
divang Dec 17, 2025
6598483
Fixed ADO pipeline for JDK8
divang Dec 17, 2025
867f204
Rename exec to scopeTempTablesToConnection and add temp table detecti…
divang Dec 24, 2025
a35c878
Merge branch 'main' into dev/divang/sybase-migration-dynamic-prepare
divang Dec 24, 2025
c4fe035
Fixed the old exec and renamed it to PreparedStatementTest for the pr…
divang Dec 24, 2025
b3c2905
Merge branch 'dev/divang/sybase-migration-dynamic-prepare' of https:/…
divang Dec 24, 2025
941afe9
Simplify TEMP_TABLE_PATTERN to match only valid SQL Server syntax
divang Jan 5, 2026
bf868c0
- Added more test scenarios including:
divang Jan 6, 2026
32c8832
Fixed the failure test case - testContainsTemporaryTableOperations()
divang Jan 6, 2026
d601c60
Fix test improvements: assertTrue(!) patterns, batch execution, mixed…
divang Jan 14, 2026
153c20c
Fix dropProcedures to include prepareMethodProcedure cleanup
divang Jan 14, 2026
70a6158
Add PrepareMethodUseTempTableScopeTest tag to testRepeatedExecutionPe…
divang Jan 14, 2026
516413c
Fix BatchUpdateException constraint message check for scopeTempTables…
divang Jan 15, 2026
d2f27f7
Improve constraint violation message checking with helper methods
divang Jan 15, 2026
3771542
Fixed ADO pipeline failure: BatchExecutionTest.testConstraintViolatio…
divang Jan 15, 2026
2ab49b7
Fixed cleaup methods calls in BatchCombinedExecutionTest, PrepareMeth…
divang Jan 16, 2026
201ef59
Moved the formatLiteralValue and replaceParameterMarkers methods to S…
divang Jan 16, 2026
d4183a7
Remove incorrect '#' pre-check causing false temp table detection and…
divang Jan 16, 2026
c641579
Optimize TEMP_TABLE_PATTERN to skip string literals inline and fix fa…
divang Jan 16, 2026
6f34e5b
Test: Add batch execution tests using PreparedStatement with scopeTem…
divang Jan 16, 2026
8984ebd
BatchCombinedExecutionTest: every test cases have its own table for t…
divang Jan 16, 2026
084c00b
Consolidate formatLiteralValue tests into PrepareMethodScopeTempTable…
divang Jan 16, 2026
599457b
Fixed formatting SQLServerPreparedStatement
divang Jan 16, 2026
b0829c9
Fixed generic error message in BatchExecutionTest
divang Jan 19, 2026
135ca91
Add test for scopeTempTablesToConnection and useBulkCopyForBatchInser…
divang Jan 19, 2026
4da80d9
Add prepexec fallback for scopeTempTablesToConnection without temp ta…
divang Jan 20, 2026
b28add7
Cleaned test cases and use PreparedStatement for temp table creation …
divang Jan 20, 2026
51a5ee5
Add test cases for string literals and leading semicolons in temp tab…
divang Jan 20, 2026
af1147c
Merge remote-tracking branch 'origin/main' into dev/divang/sybase-mig…
divang Jan 21, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import java.net.InetSocketAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
Expand Down Expand Up @@ -8521,46 +8523,6 @@ void endRequestInternal() throws SQLException {
loggerExternal.exiting(loggingClassName, "endRequest", this);
}

/**
* Replaces JDBC syntax parameter markets '?' with SQL Server parameter markers @p1, @p2 etc...
*
* @param sql
* the user's SQL
* @throws SQLServerException
* @return the returned syntax
*/
static final char[] OUT = {' ', 'O', 'U', 'T'};

String replaceParameterMarkers(String sqlSrc, int[] paramPositions, Parameter[] params,
boolean isReturnValueSyntax) {
final int MAX_PARAM_NAME_LEN = 6;
char[] sqlDst = new char[sqlSrc.length() + (params.length * (MAX_PARAM_NAME_LEN + OUT.length))
+ (params.length * 2)];
int dstBegin = 0;
int srcBegin = 0;
int nParam = 0;

int paramIndex = 0;
while (true) {
int srcEnd = (paramIndex >= paramPositions.length) ? sqlSrc.length() : paramPositions[paramIndex];
sqlSrc.getChars(srcBegin, srcEnd, sqlDst, dstBegin);
dstBegin += srcEnd - srcBegin;

if (sqlSrc.length() == srcEnd)
break;

dstBegin += makeParamName(nParam++, sqlDst, dstBegin, true);
srcBegin = srcEnd + 1 <= sqlSrc.length() - 1 && sqlSrc.charAt(srcEnd + 1) == ' ' ? srcEnd + 2 : srcEnd + 1;

if (params[paramIndex++].isOutput() && (!isReturnValueSyntax || paramIndex > 1)) {
System.arraycopy(OUT, 0, sqlDst, dstBegin, OUT.length);
dstBegin += OUT.length;
}
}

return new String(sqlDst, 0, dstBegin);
}

/**
* Makes a SQL Server style parameter name.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,8 @@ public String toString() {

enum PrepareMethod {
PREPEXEC("prepexec"), // sp_prepexec, default prepare method
PREPARE("prepare");
PREPARE("prepare"),
SCOPE_TEMP_TABLES_TO_CONNECTION("scopeTempTablesToConnection");

private final String value;

Expand Down Expand Up @@ -840,7 +841,8 @@ public final class SQLServerDriver implements java.sql.Driver {
SQLServerDriverStringProperty.SERVER_CERTIFICATE.getDefaultValue(), false, null),
new SQLServerDriverPropertyInfo(SQLServerDriverStringProperty.PREPARE_METHOD.toString(),
SQLServerDriverStringProperty.PREPARE_METHOD.getDefaultValue(), false,
new String[] {PrepareMethod.PREPEXEC.toString(), PrepareMethod.PREPARE.toString()}),
new String[] { PrepareMethod.PREPEXEC.toString(), PrepareMethod.PREPARE.toString(),
PrepareMethod.SCOPE_TEMP_TABLES_TO_CONNECTION.toString() }),
new SQLServerDriverPropertyInfo(SQLServerDriverStringProperty.FAILOVER_PARTNER.toString(),
SQLServerDriverStringProperty.FAILOVER_PARTNER.getDefaultValue(), false, null),
new SQLServerDriverPropertyInfo(SQLServerDriverStringProperty.HOSTNAME_IN_CERTIFICATE.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ private void checkClosed() throws SQLServerException {
else {
queryMetaMap = new HashMap<>();
if (con.getServerMajorVersion() >= SQL_SERVER_2012_VERSION && !st.getUseFmtOnly()) {
String preparedSQL = con.replaceParameterMarkers(stmtParent.userSQL,
String preparedSQL = stmtParent.replaceParameterMarkers(stmtParent.userSQL,
stmtParent.userSQLParamPositions, stmtParent.inOutParam, stmtParent.bReturnValueSyntax);

try (SQLServerCallableStatement cstmt = (SQLServerCallableStatement) con
Expand Down
Loading
Loading