将Google电子表格连接到具有JDBC的MySQL [英] Connecting Google Spreadsheets to MySQL w/ JDBC
问题描述
我一直在深入挖掘,尝试在Google和Google上找到答案......希望有人能够提供帮助。
我试图通过Google Spreadsheet脚本连接到MySQL:
https://developers.google.com/apps-script/jdbc#reading_from_a_database
首先,我按照以下说明设置服务器:
https://help.ubuntu.com/community/JDBCAndMySQL
我得到这个错误:无法建立数据库连接,请检查连接字符串,用户名和密码(第2行,文件代码)关闭
第2行如下所示:
var conn = Jdbc.getConnection(jdbc:mysql://65.65.65.65:3306 / dbname,user,password)
然后我发现JDBC中存在一个错误,但是这是由于Hostnames造成的,解决方案是使用IP。我已经在使用IP,所以我不认为这个bug是
这里提到: Google Apps脚本 - JDBC连接失败
和这里:后面的根错误是什么无法建立数据库连接。检查连接字符串,用户名和密码。
此处已确认并详细说明: https://code.google.com/p/google-apps-script-issues/issues/detail?id= 1856
.......现在我不相信我的问题是与上述错误。我认为它是由于mysql只能通过SSH访问?
如果是这种情况,我认为需要帮助的是修改我的代码以通过SSH连接。
或者,也许我错了,我需要探讨如何让mysql公开......但是这样做感觉不对。
任何和所有的想法都是值得欢迎的。
叹息......解决方案正好在我面前。我需要授予Google App Server IP。我确定你可以添加更多的代码通过ssh进行连接,并且它更安全,但现在情况良好。
以下是IP地址范围:
216.239.32.0 - 216.239.63.255
64.233.160.0 - 64.233.191.255
66.249.80.0 - 66.249.95.255
72.14.192.0 - 72.14.255.255
209.85.128.0 - 209.85.255.255
66.102.0.0 - 66.102.15.255
74.125.0.0 - 74.125.255.255
64.18.0.0 - 64.18.15.255
207.126.144.0 - 207.126.159.255
173.194.0.0 - 173.194.255.255
https://developers.google.com/apps-script/ jdbc #access_local_databases
I have been digging deep to try and find the answer here and on Google...hopefully someone can help.
What I am trying to do is connect to MySQL from a Google Spreadsheet script found here:
https://developers.google.com/apps-script/jdbc#reading_from_a_database
First I set up the server following these instructions:
https://help.ubuntu.com/community/JDBCAndMySQL
I get this error: "Failed to establish a database connection. Check connection string, username and password. (line 2, file "Code")Dismiss"
Line 2 looks like this:
var conn = Jdbc.getConnection("jdbc:mysql://65.65.65.65:3306/dbname", "user", "password")
Then I find out that there is a bug in the JDBC however it is due to Hostnames and the solution is to use the IP instead. I am already using the IP so I don't think this bug is
Mentioned here: Google Apps Script - JDBC Connection Failed
Confirmed and detailed here: https://code.google.com/p/google-apps-script-issues/issues/detail?id=1856
.......now I don't believe my problem is with the above mentioned bug. I think its due to mysql being only accessible via SSH?
If that is the case then what I believe I need help with is modifying my code to connect over SSH.
Or maybe I am wrong and I need to explore making mysql public...but that just doesn't feel right.
Any and all thoughts are more than welcome.
Sigh...The solution was right in front of my face. I needed to grant the Google App Server IPs. Im sure you could add more code to connect over ssh and its more secure but this is fine for now.
Here are IP address range:
216.239.32.0 - 216.239.63.255 64.233.160.0 - 64.233.191.255 66.249.80.0 - 66.249.95.255 72.14.192.0 - 72.14.255.255 209.85.128.0 - 209.85.255.255 66.102.0.0 - 66.102.15.255 74.125.0.0 - 74.125.255.255 64.18.0.0 - 64.18.15.255 207.126.144.0 - 207.126.159.255 173.194.0.0 - 173.194.255.255
https://developers.google.com/apps-script/jdbc#accessing_local_databases
这篇关于将Google电子表格连接到具有JDBC的MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!