Connection to a MS SQL database from Google scripts

jdbc.getconnection google script
connect google spreadsheet to sql server
failed to establish a database connection. check connection string, username and password.
connect google spreadsheet to mysql server
connect to google cloud sql with java
google apps script
connection url uses an unsupported jdbc protocol.
google script query

I'm trying to connect to a MS SQL database (2012) using google script using the JDBC service https://developers.google.com/apps-script/guides/jdbc

I'm having issues connecting and keep getting the message 'Failed to establish a database connection. Check connection string, username and password. (line 4, file "Code")'

I have setup the port and followed the instructions from the website above. Here is the statement below that I am using:

var conn = Jdbc.getConnection("jdbc:sqlserver://<ip>:<port>;databaseName=<db name>;user=<user>;password=<password>");

Does anyone see anything wrong. I keep reading about needing the JDBC driver installed on the MS SQL server, do I need to call it in the script somewhow?


I figured it out. Didn't need a driver. What I had above was correct. On the MS SQL server, I had the sql username and password set as 'Change on next Logon'. so I unchecked this. Make sure your firewall and port settings are correct.

Check the Event log on the server. This is how I found out that it was connecting and it was a username/password issue.

Querying SQL Server with Google Apps Script via JDBC, Apps Script can connect to external databases through the JDBC service. It supports Google Cloud SQL, MySQL, Microsoft SQL Server, and  App Script comes with a JDBC Service that lets you connect to MySQL, Microsoft SQL Server, and Oracle databases. Steps To Connect Google Sheets To A Database. 1) Open the Script Editor in Sheets using “Tools” → “Script editor”. Or just copy this Sheet here. Access Apps Script under the menu Tools > Script editor. 2) Replace “Code.gs” with the code here. (Skip this if you copied the Sheet above)


i got same error but now resolved after doing following things :

var conn = Jdbc.getConnection("jdbc:sqlserver://hostname:1433;databaseName={dbname};user={user@hostname};password={passowrd@hostname};");

and whit-list following ip on firewall :

64.18.0.0 - 64.18.15.255 64.233.160.0 - 64.233.191.255 66.102.0.0 - 66.102.15.255 66.249.80.0 - 66.249.95.255 72.14.192.0 - 72.14.255.255 74.125.0.0 - 74.125.255.255 173.194.0.0 - 173.194.255.255 207.126.144.0 - 207.126.159.255 209.85.128.0 - 209.85.255.255 216.239.32.0 - 216.239.63.255

Google Sheets Script to Automatically Retrieve SQL Data, Coyne : Hi Mahesh Rathor: Were you able to connect to MS SQL Server? I was not able to get connection to  Apps Script can connect to external databases through the JDBC service, a wrapper around the standard Java Database Connectivity technology . The JDBC service supports Google Cloud SQL, MySQL,


Google Scripts and Azure SQL Server worked for me with this:

var conn = Jdbc.getConnection('jdbc:sqlserver://your-server.database.windows.net:1433;databaseName=your-db-name;user=username@your-catalog;password=yourpassword;'); Logger.log(conn);

So you got to take JSBC connection string from Azure and replace portion of that string: instead of: ...1433;database=... in Google Script you should have: ...1433;databaseName=

your-catalog for me is the same as your-server.database.windows.net

How to Use Google Apps Script to Fetch Databases to a Google , App Script comes with a JDBC Service that lets you connect to MySQL, Microsoft SQL Server, and Oracle databases. Steps To Connect Google  Here's how I do it. Change all the capitalised bits to the appropriate URL, database name, Google Spreadsheet ID, etc. To this function pass the SQL query you want to execute on the MSSQL database and the name of the sheet within the Spreadsheet that you want to put the data into.


How To Connect Google Sheets To A Database, Using Apps Script -, This article shows how to use the SQL Gateway to access ODBC data sources from Google Apps Script. You can write data from MySQL database to Google doc spreadsheet auto with just click of a button or scheduled time. This is great use for retrieving data in spreadsheet format. Step 2: Insert


Connecting to ODBC Data Sources in Google Apps Script, How do I import data into a SQL table in Google Sheets? The JDBC service allows scripts to connect to Google Cloud SQL, MySQL, Microsoft SQL Server, and Oracle databases. For more information, see the guide to JDBC.


How To Connect Google Sheets To A Database, Using Apps Script , Google Apps script has a feature that helps us to . You can also connect your Google sheets Duration: 6:40 Posted: Dec 7, 2019 7. Update your application to connect to Cloud SQL using the proxy. The exact code statement required to use the proxy to connect to your Cloud SQL instance depends on the language and framework you are using. You connect to the proxy the same way you would to a TCP or Unix socket (depending on how you invoked the proxy):