I'm trying to set a Resource
inside my context.xml which contains all the information regarding the connection to the SQL Server database:
<Resource
name="jdbc/TestDB"
auth="Container"
type="javax.sql.DataSource"
maxActive="25"
maxIdle="10"
maxWait="10000"
removeAbandoned="true"
removeAbandonedTimeout="300"
defaultAutoCommit="true"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://myip;databaseName=mydb;integratedSecurity=true"
/>
And then I get my Connection
object like this in code:
InitialContext ctx = new InitialContext();
DataSource datasource = (DataSource) ctx.lookup("jdbc/TestDB");
connection = datasource.getConnection();
But whenever I try to start my Tomcat server with Eclipse an exception is thrown in console:
Caused by: java.lang.UnsupportedClassVersionError: com/microsoft/sqlserver/jdbc/SQLServerDriver has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Which makes no sense to me, as I have the JDK 1.8 (241) and I use this dependency in my maven:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>7.2.2.jre8</version>
</dependency>
I made sure I had the right Java version on my project's build path.
The wierd thing is that the connection used to work when I got it like this:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
connection = DriverManager.getConnection(connectionURL);
Any ideas on what could be causing this?