Skip to content

Commit d3823a5

Browse files
committed
Merge branch 'main' into users/muskgupta/githubIssue#2690
2 parents 1d2ca53 + 44d6010 commit d3823a5

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,10 @@ void enableSSL(String host, int port, String clientCertificate, String clientKey
16761676
.getProperty(SQLServerDriverStringProperty.TRUST_STORE_TYPE.toString());
16771677

16781678
if (StringUtils.isEmpty(trustStoreType)) {
1679-
trustStoreType = SQLServerDriverStringProperty.TRUST_STORE_TYPE.getDefaultValue();
1679+
trustStoreType = System.getProperty("javax.net.ssl.trustStoreType");
1680+
if (StringUtils.isEmpty(trustStoreType)) {
1681+
trustStoreType = SQLServerDriverStringProperty.TRUST_STORE_TYPE.getDefaultValue(); // Default to JKS if not specified
1682+
}
16801683
}
16811684

16821685
String serverCert = con.activeConnectionProperties

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ static SqlAuthenticationToken getDefaultAzureCredAuthToken(String resource,
450450
dacBuilder.additionallyAllowedTenants(additionallyAllowedTenants);
451451
}
452452

453-
dac = dacBuilder.build();
453+
dac = dacBuilder.build(); // CodeQL [SM05141] This is a client library supporting all scenarios (dev, test, prod, etc.), not just prod environments.
454454

455455
Credential credential = new Credential(dac);
456456
CREDENTIAL_CACHE.put(key, credential);

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ final void doExecuteStatement(StmtExecCmd execCmd) throws SQLServerException {
962962
// then add on the query to return them.
963963
if (RETURN_GENERATED_KEYS == execCmd.autoGeneratedKeys
964964
&& (EXECUTE_UPDATE == executeMethod || EXECUTE == executeMethod)
965-
&& sql.trim().toUpperCase().startsWith("INSERT")) {
965+
&& isInsert(sql)) {
966966
tdsWriter.writeString(IDENTITY_QUERY);
967967
}
968968

src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/StatementTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,6 +2749,31 @@ public void testExecuteUpdateInsertAndGenKeys() {
27492749
}
27502750
}
27512751

2752+
/**
2753+
* Tests executeUpdate for Insert with comments followed by getGenerateKeys
2754+
*
2755+
* @throws Exception
2756+
*/
2757+
@Test
2758+
public void testExecuteUpdateInsertWithCommentsAndGenKeys() {
2759+
try (Connection con = getConnection()) {
2760+
try(Statement stmt = con.createStatement()) {
2761+
String sql = "/* my comment */INSERT INTO " + tableName + " (NAME) VALUES('test')";
2762+
List<String> lst = Arrays.asList("ID");
2763+
String[] arr = lst.toArray(new String[0]);
2764+
stmt.executeUpdate(sql, arr);
2765+
try (ResultSet generatedKeys = stmt.getGeneratedKeys()) {
2766+
if (generatedKeys.next()) {
2767+
int id = generatedKeys.getInt(1);
2768+
assertEquals(id, 4, "id should have been 4, but received : " + id);
2769+
}
2770+
}
2771+
}
2772+
} catch (SQLException e) {
2773+
fail(TestResource.getResource("R_unexpectedException") + e.getMessage());
2774+
}
2775+
}
2776+
27522777
/**
27532778
* Tests executeUpdate using PreparedStatement for Insert followed by getGenerateKeys
27542779
*

0 commit comments

Comments
 (0)