I am using below code to establish the connection to Oracle DB
protected static void connectDatabase(String serverName,String host,String userName,String passWord,String portNumber,String schema) throws Exception {
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
String url = "jdbc:oracle:thin:@//" + host + ":" + portNumber + "/" + serverName;
connection = java.sql.DriverManager.getConnection(url, userName, passWord);
setDefaultSchema(schema);
}
private static void setDefaultSchema(String schemaName) throws Exception {
Statement s = connection.createStatement();
s.executeQuery("Alter Session Set Current\_schema="+schemaName);
}
Above code is working fine for maven project with JDK8 but when we upgrade JAVA8 to JAVA15 /JAVA 17, Class.forName(driverName); this line of code is throwing below exception in variable window while debugging but when we try to run the test script which is having query to execute neither not throwing any exception in eclipse console nor executing the test script and execution is stopping.
Exception:java.lang.NoClassDefFoundError: java/sql/Driver
Eclipse IDE:2023-03
Java Version: 15
Below are decencies version which are added in POM.XML
OJDBC8 version: 23.2.0.0
WebdriverManager version: 5.3.1
Selenium Java version: 4.9.0
We tried adding ojdbc8.jar in project classpath , tried commenting Class.forName(driverName) and tried with new driver class “oracle.jdbc..OracleDrive” but not working. Please help me on above problem.
Thanks and Regards,
Sudharani