【问题标题】:JDBC: Apps Script and Google MySQL : Exception: You do not have permission to call Jdbc.getCloudSqlConnectionJDBC:Apps Script 和 Google MySQL:例外:您无权调用 Jdbc.getCloudSqlConnection
【发布时间】:2021-07-11 00:40:35
【问题描述】:

当我尝试在我的电子表格中使用此函数时,下面列出的代码出现以下错误:Google 脚本错误 - 异常:您无权调用 Jdbc.getCloudSqlConnection

关于如何解决这个问题的任何想法?似乎连接成功,但在创建表时卡住了

var connectionName = 'cosmic-tenure-310821:us-central1:propertydata';
var rootPwd = "password";
var user = "root";
var userPwd = 'password';
var db = 'propertydata';

var root = 'root';
var instanceUrl = "jdbc:google:mysql://" + connectionName;
var dbUrl = instanceUrl + "/" + db;

function createTable() {
  var conn = Jdbc.getCloudSqlConnection(dbUrl, user, userPwd);
  conn.createStatement().execute('CREATE TABLE myProperties(APN INT, APNObject MEDIUMBLOB)');
}

【问题讨论】:

  • user 是否拥有创建表所需的权限?

标签: mysql google-apps-script jdbc


【解决方案1】:

尝试添加“oauthScopes”

"oauthScopes": ["https://www.googleapis.com/auth/gmail.addons.execute","https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/sqlservice", "https://www.googleapis.com/auth/sqlservice.admin", "https://www.googleapis.com/auth/gmail.readonly", "https://www.googleapis.com/auth/script.external_request", "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/gmail.addons.current.action.compose"]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-04
    • 2018-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多