【问题标题】:Connect to Oracle Cloud Database from Google Apps Script从 Google Apps 脚本连接到 Oracle 云数据库
【发布时间】:2022-11-23 12:46:38
【问题描述】:

我想使用 Google Apps 脚本直接连接到 Oracle 云数据库。从我在 https://developers.google.com/apps-script/guides/jdbc 上的阅读来看,Google Apps 脚本似乎支持与 Oracle 建立 JDBC 连接,它说

JDBC服务支持Google Cloud SQL MySQL、MySQL、Microsoft SQL 服务器和 Oracle 数据库。

诀窍似乎在于为“getConnection”方法的“url”属性获取正确的值,如https://developers.google.com/apps-script/reference/jdbc/jdbc#getconnectionurl所述

在 Oracle 云数据库文档中,我在 https://docs.oracle.com/en/cloud/paas/autonomous-database/adbsa/connect-jdbc-thin-tls.html#GUID-9C4FBA97-C486-42E9-883F-13B9EB1DB160 找到了一个讨论与 JDBC 连接的页面,该页面给出了如何构建用于建立 JDBC 连接的 DB_URL 的示例,如下所示:

DB_URL=jdbc:oracle:thin:@my_connect_string

并展示了如何获取云数据库的连接字符串。所以把它们放在一起,我有一个简单的谷歌应用程序脚本来测试与我的数据库的连接,如下所示:

function connect() {
    const dbUrl='jdbc:oracle:thin:@(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.us-sanjose-1.oraclecloud.com))(connect_data=(service_name=g814b8501162211_userdata_high.adb.oraclecloud.com))(security=(ssl_server_cert_dn="CN=adb.us-sanjose-1.oraclecloud.com, OU=Oracle ADB SANJOSE, O=Oracle Corporation, L=Redwood City, ST=California, C=US")))'    
    const conn = Jdbc.getConnection(dbUrl, 'username', 'password');
}

但是,此代码在第 3 行失败并显示错误消息

Exception: Invalid argument: url

我搜索了又搜索,但找不到建立此连接的任何示例。我将不胜感激任何帮助或指导——即使它不是一个完整的解决方案。

【问题讨论】:

标签: oracle google-apps-script jdbc


【解决方案1】:

请在自治数据库上启用 1-way TLS 并尝试一下。您应该看到端口号为 1521 的连接字符串

这是一个博客

https://blogs.oracle.com/datawarehousing/post/connecting-your-autonomous-database-has-never-been-easier

【讨论】:

    猜你喜欢
    • 2021-08-02
    • 2018-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多