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.

Post History

62%
+3 −1
Q&A java.lang.UnsupportedClassVersionError: when trying to connect to JDBC with JDK 14 in Eclipse

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.UnsupportedClassVersionEr...

1 answer  ·  posted 3y ago by cuzzo‭  ·  edited 3y ago by Alexei‭

#3: Post edited by user avatar Alexei‭ · 2022-01-07T06:14:11Z (almost 3 years ago)
added relevant tag
#2: Post edited by user avatar cuzzo‭ · 2022-01-06T19:41:05Z (almost 3 years ago)
  • 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](https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi), 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");
  • 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;
  • }
  • }
  • 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](https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi), 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;
  • }
  • }
#1: Initial revision by user avatar cuzzo‭ · 2022-01-06T19:39:50Z (almost 3 years ago)
java.lang.UnsupportedClassVersionError: when trying to connect to JDBC with JDK 14 in Eclipse
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](https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi), 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"); 
			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;
	}  
    }