Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -926,7 +926,7 @@ public SQLServerDriver() {
static Properties fixupProperties(Properties props) throws SQLServerException {
// assert props !=null
Properties fixedup = new Properties();
Enumeration<?> e = props.keys();
Enumeration<?> e = props.propertyNames();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
String newname = getNormalizedPropertyName(name, drLogger);
Expand Down Expand Up @@ -962,8 +962,6 @@ static Properties mergeURLAndSuppliedProperties(Properties urlProps,
Properties suppliedProperties) throws SQLServerException {
if (null == suppliedProperties)
return urlProps;
if (suppliedProperties.isEmpty())
return urlProps;
Properties suppliedPropertiesFixed = fixupProperties(suppliedProperties);
// Merge URL properties and supplied properties.
for (SQLServerDriverPropertyInfo DRIVER_PROPERTY : DRIVER_PROPERTIES) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

import com.microsoft.sqlserver.jdbc.SQLServerConnection;
import com.microsoft.sqlserver.jdbc.TestUtils;
import com.microsoft.sqlserver.testframework.PrepUtil;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

Expand Down Expand Up @@ -69,4 +74,12 @@ public void testInvalidConnectWithIPAddressPreference() throws SQLException {
}
}

@Test
public void testDefaultProperties() throws SQLException {
Properties defaults = new Properties();
defaults.setProperty("iPAddressPreference", "IPv6First");
try (SQLServerConnection con = PrepUtil.getConnection(connectionString, new Properties(defaults))) {
assertEquals("IPv6First", con.getIPAddressPreference());
}
}
}