Google Apps脚本:调用jdbc所需的权限? [英] Google apps script : calling jdbc required permissions?

查看:89
本文介绍了Google Apps脚本:调用jdbc所需的权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我添加并运行一个调用此代码的函数,则我将gscript保存在电子表格中:

i've gscript inside a spreadsheet, if i add and run a function calling this code :

var conn = Jdbc.getConnection('jdbc:mysql://sql4.freesqldatabase.com:3306/sql427377', 'sql427377', 'my_pass');

有效!

但是,如果我在Google应用脚本中复制/粘贴相同的代码:

But if i copy/paste the same code in a google app script :

function doGet() { 
    return HtmlService.createTemplateFromFile('index').evaluate(); 
} 
function getSql(){ 
    var conn = Jdbc.getConnection('jdbc:mysql://sql4.freesqldatabase.com:3306/sql427377', 'sql427377', 'my_pass'); 
} 

即使我不调用该函数,我也只是粘贴了代码,在执行脚本时得到了以下消息: "Vos Devez Disposer des Autorisations要求倒入粉尘效应器的清洁动作."
您必须具有执行此操作所需的权限."

even if i don't call the function, i've just paste the code, i ve got this message on execution of my script : "Vous devez disposer des autorisations requises pour pouvoir effectuer cette action."
"You must have the required permissions to perform this action."

我不明白为什么……需要帮助;)

I don't understand why... need help ;)

推荐答案

要求脚本项目中的权限 .是否实际使用此服务调用函数并不重要.

Permissions in a script project are asked for every service present in this project. Wether you actually call a function using this service or not is not important.

例如,如果我在脚本中有一个onOpen()函数,而另一个函数具有发送电子邮件的功能,即使我只是尝试运行onOpen(),也会要求我授予mailApp service的权限.

For example, if I have an onOpen() function in a script and another function that sends emails, I will be asked permission for mailApp service even if I simply try to run onOpen().

如果您的电子表格未询问有关Jdbc的任何信息,则意味着该项目已被授权使用此服务(并且您可能已经忘记了它),以及您在其他项目中描述的行为(doGet one,但这将是在其他任何项目中都一样).

If your spreadsheet does not ask anything about Jdbc, it means that the project was already authorized for this service (and you probably forgot it) and the behavior you describe in your other project (the doGet one , but it would be the same in any other project) is normal.

如果您要检查此内容,只需在虚拟函数中添加对另一个Google服务的调用,然后尝试执行另一个可以正常运行的函数而不会发出警告...您将获得预期的授权请求.

If you want to check this, simply add a call to another Google service in a dummy function and try to execute another function that used to work without warning... You'll get the authorization request as expected.

这篇关于Google Apps脚本:调用jdbc所需的权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆