I'm pretty new to java and specially to android and i got stuck making a little project on my own so i'd be very glad someone could help me.
I'm trying to make my app connect to a free tier oracle database (19c) and despite having set the ojdbc8.jar driver inside app/libs I keep getting java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver.
I also searched several threads and none of the solutions has worked for me.
I don't want to purchase oracle mobile connector given that is just a test app to learn.
Here's my code.
import java.sql.*;
public class ConnectionToOracleDB {
private static final String DEFAULT_DRIVER = "oracle.jdbc.driver.OracleDriver";
private static final String DEFAULT_URL = "jdbc:oracle:thin:@dbmc_high...?TNSADMIN=(tnsnames location)";
private static final String DEFAULT_USERNAME = "USER";
private static final String DEFAULT_PASSWORD = "PASSWORD";
private Connection connection;
public void main() {
try {
this.connection = createConnection();
Statement stmt=connection.createStatement();
StringBuffer stringBuffer = new StringBuffer();
ResultSet rs=stmt.executeQuery("select 1 from DUAL");
while(rs.next()) {
stringBuffer.append( rs.getString(1)+"\n");
}
System.out.println(stringBuffer.toString());
connection.close();
}
catch (Exception e) {
System.out.println(e);
}
}
public static Connection createConnection(String driver, String url, String username, String password) throws ClassNotFoundException, SQLException {
Class.forName(driver);
return DriverManager.getConnection(url, username, password);
}
}