Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs

Dashboard
Notifications
Mark all as read
Q&A

java.lang.UnsupportedClassVersionError: when trying to connect to JDBC with JDK 14 in Eclipse

+3
−0

I'm trying to connect to a db file in my project but having some troubles. I'm using JDK 14 with ojdbc11 however I am still getting this when trying to connect:

java.lang.UnsupportedClassVersionError: 
oracle/jdbc/driver/OracleDriver has been compiled by a more recent 
version of the Java Runtime (class file version 54.0), this version 
of the Java Runtime only recognizes class file versions up to 52.0

Looking off of this post, I should be able to recognize class files up to 58. My code is below for reference in case I've done something wrong there but it seems like my JRE is out of date despite it being version 14. Maybe I am using the wrong ojdbc file?

java -version
java version "14.0.2" 2020-07-14
Java(TM) SE Runtime Environment (build 14.0.2+12-46)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.2+12-46, mixed mode, 
sharing)

package commands;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Connect {  
	private static String fileName = "builderData.db";

public static String connect() { 
	String status = "";
	Connection conn = null;  
	try {  
		String url = "jdbc:sqlite:" + System.getProperty("user.dir") + "/src/main/java/resources/" + fileName;  
		Class.forName("oracle.jdbc.driver.OracleDriver"); //<-- cause of error
		conn = DriverManager.getConnection(url);  
         
		status = "Database connection established.";  
         
	} catch (SQLException e) {  
		status = e.getMessage(); 
	} catch (ClassNotFoundException e) {
		status = "Class Not Found: " + e.getMessage();
	} finally {  
		try {  
			if (conn != null) {  
				conn.close();  
			}  
		} catch (SQLException ex) {  
			status = ex.getMessage();  
		}  
	} 
	return status;
}  
}  
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

Multiple versions installed? (2 comments)

1 answer

+2
−0

Apparently despite me changing my JDK locally on the project itself, once pushed to Heroku, the application was still being built and compiled using JDK 1.8.

To solve the issue, I included a system.properties file in the project directory with: java.runtime.version=14 for JDK 14

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »