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.

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

Post

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 attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

Multiple versions installed? (2 comments)
Multiple versions installed?
Peter Taylor‭ wrote almost 3 years ago

Class file version 52 corresponds to Java 8. The most obvious explanation would be that you have multiple versions of Java installed, and when you get the error it's because you're launching with a version 8 JRE.

cuzzo‭ wrote almost 3 years ago

Yes, that is why I am confused. Regardless of if I have 2 java versions installed or not, the project is using a single JDK.