我刚刚安装了 RJDBC 库,但无法连接到数据库。当我使用 RODBC 时,相同的连接字符串有效,所以我不确定为什么 RJDBC 无法建立连接。如果您能指导我找到解决方案,我将不胜感激。我在 MAC OSX 10.8.2 中使用 R
drv <- JDBC("com.microsoft.sqlserver.jdbc.SQLServerDriver","/Library/Java/Extensions/sqljdbc4.jar", "‘")
conn <- dbConnect(drv, "jdbc:sqlserver://data.rsquaredltd.com/****","****","****")
drv 对象已成功创建,但 conn 失败并显示错误消息
"Error in .jcall(drv@jdrv, "Ljava/sql/Connection;", "connect", as.character(url)[1], :
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host data.rsquaredltd.com/SandP, port 1433 has failed. Error: "null. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall."."
没有防火墙阻止,正如我提到的,通过 RODBC 连接没有问题。