Search code examples
sql-serverjdbcazure-sql-databasegoogle-app-maker

Can Google App Maker connect to MS SqlServer Database in Azure?


thanks for reading. I have added the App Maker APIs to the Azure firewall as described here I have tried connecting from App Maker to the sqlserver database on azure several ways, and I have triple checked my username and password and used it to connect directly to the database in other applications.

Here are some things I have tried:

var dbUrl = 'jdbc:sqlserver://mydatabase.database.windows.net:1433/mydatabase';
var user = 'myusername';
var userPwd = 'mypassword';

function getJDBCConnection() {
  try {
    return Jdbc.getConnection(dbUrl, user, userPwd);
  } catch (err) {
    if (err.message.match(/Failed to establish a database connection/)) {
      throw new Error(err.message + ' Please refer to the ReadMe and edit ' +
                      'your database settings!');
    } else {
      throw err;
    }
  }
}

and I have also tried creating the connection directly with two methods, first:

    var conn = Jdbc.getConnection('jdbc:sqlserver://mydatabase.database.windows.net:1433/mydatabase','username', 'password');

and also like this

    var conn = Jdbc.getConnection('jdbc:sqlserver://mydatabase.database.windows.net:1433/mydatabase', {user: 'username', password: 'password'});

any advice is greatly appreciated.


Solution

  • According what I found, when Gooele APP using JDBC connect to Microsoft SQL server, the connection string has some difference.

    Here's the example of connection URL :

    String connectionUrl = "jdbc:sqlserver://<server>:<port>;" +  
       "databaseName=AdventureWorks;user=MyUserName;password=*****;"; 
    

    Reference:

    1. JDBC: Making a simple connection to a database
    2. JDBC: Connection URL sample

    This blog has the same error when connect to Microsoft SQL server, and it solved by change the connection URL: Error when connecting to MSSQL Server with Google Apps Script via JDBC

    Hope this helps.