Skip to Main Content

Oracle XE 21c database and Eclipse

User_AW11TMay 11 2022

I have a problem connecting Oracle XE 21c database to Eclipse.
During the installation I did everything that is in the video and I have not encountered any problems, for fun the testtable table has 3 records.
At the Eclipse project I inserted between the libraries ojdbc11.jar and ucp11.jar (even if the latter would not be needed because there is a single connection).
In Main() method before creating the connection I insert:
Class.forName ("oracle.jdbc.driver.OracleDriver");

(Obviously my values are different and I use those in the video to make things easier) If I use:
String dbUrl = "";
String userName= "demouser";
String userPassword = "demouser";
java.sql.Connection connection = DriverManager.getConnection(dbUrl,userName,userPassword);

I get:
java.sql.SQLException: No suitable driver found

It doesn't matter if I replace "XE" for "XEPDB1" or shorten "" with "CSHAY-7420"
I always get that exception.
(I mentioned "CSHAY-7420" because using SQLPLUS, for me, this worked:
SQL> connect demouser/demouser@CSHAY-7420:1521/XEPDB1;
and this not:
SQL> connect demouser/;

At this point I thought of using the only string with userName and password in the form:
String dbUrl = "demouser/";
java.sql.Connection connection = DriverManager.getConnection(dbUrl);

Even using the variants I get the same:
java.sql.SQLException: No suitable driver found

So I wanted to change my approach:
oracle.jdbc.pool.OracleDataSource ds = new oracle.jdbc.pool.OracleDataSource();
ds.setServerName("CSHAY-7420");// NO ""
ds.setDatabaseName("XE"); // Oracle SID // NO XEPDB1
//ds.setUser("demouser"); // NO
//ds.setPassword("demouser"); // NO
ds.setPassword("<my password>");
java.sql.Connection connection=ds.getConnection();

this works until it finds it:
ResultSet resultSet = statement.executeQuery("SELECT * FROM TESTTABLE");

where do i get:
java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

In theory from Eclipse I would create tables in the same schema as TESTTABLE, so what is the solution?
Best regards

Post Details
Added on May 11 2022