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
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...
#2: Post edited
- 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
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; } }