Does Jdbc in Google App Scripts (in Google Sheets) support named instances in MS SQL Server?

Viewed 82

Does anyone know how to get named instances to work, or, are they even supported?

The following doesn't work, it produces: Exception: Failed to establish a database connection. Check connection string, username and password.

var conn = Jdbc.getConnection("jdbc:sqlserver://myserver.com\\SQLEXPRESS;databaseName=MyDatabase;","MyUser","MyPassword")

The following works (given that 61570 is the port assigned to the instance SQLEXPRESS):

var conn = Jdbc.getConnection("jdbc:sqlserver://myserver.com:61570;databaseName=MyDatabase;","MyUser","MyPassword")

As far as I am aware, when you specify a named instance, there is some hand-shaking behind the scenes that normally happens:

  1. Contact the server and get the port for the named instance.
  2. Establish a connection with the returned port.
1 Answers

The Apps Script wrapper for Jdbc does not include a method for connecting to named instances. You do have to specify a port to connect to when requesting a connection.


References:

Related