简体   繁体   English

Google Cloud - 将 Sql Server 连接到 Google Apps 脚本

[英]Google Cloud - Connect Sql Server to Google Apps Script

I have problems to connect sql server on google cloud to google apps script, have tried many options do url connection like: Jdbc.getCloudSqlConnection("jdbc:google:mysql://apis-para-pap:southamerica-east1:revistamarcasserver","sqlserver", "*****");我在将google cloud 上的 sql server连接到 google apps 脚本时遇到问题,尝试了很多选项来进行 url 连接,例如:Jdbc.getCloudSqlConnection("jdbc:google:mysql://apis-para-pap:southamerica-east1:revistamarcasserver", "sqlserver", "*****"); but is not connecting, Exception: Failed to establish a database connection.但未连接,异常:无法建立数据库连接。 Check connection string.检查连接字符串。 Do you can help me to solve this problem to connect Sql Server to Google Apps Script ?你能帮我解决这个问题,将 Sql Server 连接到 Google Apps 脚本吗?

Information about google cloud Sql Server:谷歌云Sql Server的相关资料:

  • DB Type: SQL Server 2017 Standard数据库类型:SQL Server 2017 标准版
  • Location: southamerica-east1-b位置:南美洲-east1-b
  • Instance name: apis-para-pap:southamerica-east1:revistamarcasserver实例名称:apis-para-pap:southamerica-east1:revistamarcasserver
  • Public address: 34.95.157.142公众号:34.95.157.142
  • White list: (72.14.192.0/18) (64.233.160.0/19) (209.85.128.0/17) (66.102.0.0/20) (74.125.0.0/16) (173.194.0.0/16) (66.249.80.0/20) (64.18.0.0/20) (216.239.32.0/19) (207.126.144.0/20)白名单:(72.14.192.0/18) (64.233.160.0/19) (209.85.128.0/17) (66.102.0.0/20) (74.125.0.0/16) (173.194.0.0/16) (66.249.80.0/ 20) (64.18.0.0/20) (216.239.32.0/19) (207.126.144.0/20)

(observation: Using sql server management studio, i have tested and connected successfully, with this informations). (观察:使用 sql server management studio,我已经成功测试并连接了这些信息)。

Thank you so much太感谢了

I created a Cloud SQL instance , authorize the following IP ranges and was able to connect to it using the Public Ip Address.我创建了一个Cloud SQL 实例授权了以下 IP 范围,并能够使用公共 IP 地址连接到它。 I could not connect using Instance connection name.我无法使用实例连接名称进行连接。


var db = 'mydatabase';
var instanceUrl = "jdbc:mysql://Public_IP_address_SQL";
var dbUrl = instanceUrl + '/' + db;

/**
* Create a new database within a Cloud SQL instance.

*/
function createDatabase() {
var conn = Jdbc.getConnection(instanceUrl,{user: 'root', password: '****'} );
conn.createStatement().execute('CREATE DATABASE ' + db);
}

/**
* Create a new user for your database with full privileges.
*/
function createUser() {
var conn = Jdbc.getConnection(dbUrl,{user: 'root', password: '****'});

var stmt = conn.prepareStatement('CREATE USER ? IDENTIFIED BY ?');
stmt.setString(1, user);
stmt.setString(2, userPwd);
stmt.execute();

conn.createStatement().execute('GRANT ALL ON `%`.* TO ' + user);
}

/**
* Create a new table in the database.
*/
function createTable() {
var conn = Jdbc.getConnection(dbUrl, {user: 'new_user', password: '****'});
conn.createStatement().execute('CREATE TABLE entries '
    + '(guestName VARCHAR(255), content VARCHAR(255), '
    + 'entryID INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(entryID));');
}


createDatabase()
createUser() 
createTable()

}   

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从元数据库云连接到谷歌云 Sql - Connect To Google Cloud Sql From Metabase cloud 使用 Google Cloud API 测试 Google Apps 脚本 - Testing Google Apps Script using Google Cloud APIs 无法将 Cloud Data Fusion 与 Google Cloud SQL 连接为 PostgreSQL - Can't connect Cloud Data Fusion with Google Cloud SQL for PostgreSQL 从谷歌应用程序脚本连接到 Amazon S3 - Connect to Amazon S3 from google apps script 无法使用 Cloud SQL 代理从 Google Compute Engine 连接到 Google Cloud SQL - Can't connect to Google Cloud SQL from Google Compute Engine with Cloud SQL Proxy 我使用了Google Cloud Platform App Engine和Google Cloud SQL,Sequelize,但是Error: connect ETIMEDOUT错误 - I used Google Cloud Platform App Engine and Google Cloud SQL, Sequelize, but Error: connect ETIMEDOUT error Google App Engine 上的 Django 连接到云 SQL,无法连接 - Django on Google App Engine connection to Cloud SQL, cannot connect 通过 VPN 将 Google Cloud SQL 实例连接到外部副本 - Connect Google Cloud SQL instance to external replica via VPN 无法从 App Engine 标准环境连接到 Google 云 SQL - Cannot connect to Google cloud SQL from App Engine Standard Environment 谷歌云 SQL 定价 - Google Cloud SQL Pricing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM