Skip to content

Commit

Permalink
Changed serverName sent in LOGIN packet to include instanceName (#2140)
Browse files Browse the repository at this point in the history
* Initial changes

* paranthesis

* Delete mssql-jdbc.properties

* Issue with serverName in public pipelines, checking to see if issue is because we're not checking for instanceName to be filled before sending it in.

* Cleanup + moved some code to ServerPortPlaceholder

* Line length

* Undo line length

* One more try to see what the heck is going on with GitHub
  • Loading branch information
Jeffery-Wasty authored Jun 7, 2023
1 parent 953e4a0 commit 533c2c0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6324,10 +6324,18 @@ final boolean complete(LogonCommand logonCommand, TDSReader tdsReader) throws SQ
String interfaceLibName = "Microsoft JDBC Driver " + SQLJdbcVersion.MAJOR + "." + SQLJdbcVersion.MINOR;
String databaseName = activeConnectionProperties
.getProperty(SQLServerDriverStringProperty.DATABASE_NAME.toString());
String serverName = (null != currentConnectPlaceHolder) ? currentConnectPlaceHolder.getServerName()
: activeConnectionProperties.getProperty(
SQLServerDriverStringProperty.SERVER_NAME
.toString());

String serverName;
if (null != currentConnectPlaceHolder) {
serverName = currentConnectPlaceHolder.getFullServerName();
} else {
serverName = activeConnectionProperties.getProperty(SQLServerDriverStringProperty.SERVER_NAME.toString());
if (null != activeConnectionProperties.getProperty(SQLServerDriverStringProperty.INSTANCE_NAME.toString())) {
serverName += "\\" +
activeConnectionProperties.getProperty(SQLServerDriverStringProperty.INSTANCE_NAME.toString());
}
}

if (null != serverName && serverName.length() > 128) {
serverName = serverName.substring(0, 128);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ final class ServerPortPlaceHolder implements Serializable {

private final String serverName;
private final String parsedServerName;
private final String fullServerName;
private final int port;
private final String instanceName;
private final boolean checkLink;
Expand All @@ -33,6 +34,9 @@ final class ServerPortPlaceHolder implements Serializable {
int px = serverName.indexOf('\\');
parsedServerName = (px >= 0) ? serverName.substring(0, px) : serverName;

// serverName with named instance
fullServerName = (null != instance) ? (serverName + "\\" + instance) : serverName;

port = conPort;
instanceName = instance;
checkLink = fLink;
Expand All @@ -57,6 +61,10 @@ String getParsedServerName() {
return parsedServerName;
}

String getFullServerName() {
return fullServerName;
}

void doSecurityCheck() {
securityManager.checkConnect();
if (checkLink)
Expand Down

0 comments on commit 533c2c0

Please sign in to comment.