1

I just installed the RJDBC library but I am not able to make a connection to the database. The same connection string works when I use RODBC, so I am not sure why RJDBC is not able to make the connection. I would be very grateful if you could guide me to a solution. I am using R in MAC OSX 10.8.2

drv <- JDBC("com.microsoft.sqlserver.jdbc.SQLServerDriver","/Library/Java/Extensions/sqljdbc4.jar", "‘")
conn <- dbConnect(drv, "jdbc:sqlserver://data.rsquaredltd.com/****","****","****")

The drv objet is created successfully but the conn fails with an error message

"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."."

There are no firewalls blocking and as I mentioned, there is no problem connecting via RODBC.

Jilber Urbina
  • 58,147
  • 10
  • 114
  • 138
Arun
  • 275
  • 1
  • 3
  • 13

1 Answers1

2

Your URL is incorrect. You are using jdbc:sqlserver://data.rsquaredltd.com/SandP, that should be jdbc:sqlserver://data.rsquaredltd.com\SandP.

The format of the JDBC URL is:

jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]

See Building the Connection URL on MSDN for more information.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197