2

I'm trying to connect to SQL Server via JDBC (yes, I know ODBC is better, but I'd need to make changes to the server security do to that).

  library(RJDBC)
  library(rJava)
  drv <- JDBC("com.microsoft.sqlserver.jdbc.SQLServerDriver" , 
              "C:/SQL JDBC/sqljdbc_4.1/enu/jre7/sqljdbc41.jar" ,identifier.quote="`")

But I can't seem to find the right version of the driver:

Error in .jfindClass(as.character(driverClass)[1]) : 
  java.lang.UnsupportedClassVersionError: com/microsoft/sqlserver/jdbc/SQLServerDriver has been compiled by a more recent version of the Java Runtime (class file version 58.0), this version of the Java Runtime only recognizes class file versions up to 52.0

I've tried with drivers for 4.0, 4.1, 4.2, and 8.4:

https://learn.microsoft.com/en-us/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server-support-matrix?view=sql-server-ver15#java-and-jdbc-specification-support

I have 64-bit R and 64-bit Java installed on Windows 10.

1 Answer 1

1

The problem is that you have Java 8 installed on your machine, but Driver was build for java 14 (class file version 58.0 tells that).

You can either install java 14 on your machine or get a JDBC driver for Java 8.

A link for SQL Server JDBC driver for java 8

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for updating the link. Unfortunately, I get the same error even with the new driver you linked to (mssql-jdbc-8.4.0.jre8.jar)
Maybe a stupid question but did you update your JDBC classpath parameter so it is the path to a new jar?
Not a stupid question since that was my problem. Restarting the R session clears whatever variable was cached.
Now on to the next step. Connecting using dbConnect(drv, "jdbc:sqlserver://ServerName;databaseName=DBname") gives this error: 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 TPS-db2, port 1433 has failed. Error: "TPS-db2. 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.".
It could be one of three problems: 1. The host TPS-db2 is down or is not reachable (try ping TPS-db2 to check if it is reachable) 2. Firewall on TPS-db2 blocks your connection to port 1433 3. SQL Server on TPS-db2 is not configured properly. In this case, you can take a look at this manual: docs.sdl.com/801922/570899/sdl-tridion-docs-13-sp2/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.