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
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

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

+3
−1

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;
}  
}  
History
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

History
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 »