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 https://www.youtube.com/watch?v=DYleroLay5E 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 = "jdbc:oracle:thin:@CSHAY-7420.oradev.oraclecorp.com:1521:XEPDB1";
String userName= "demouser";
String userPassword = "demouser";
java.sql.Connection connection = DriverManager.getConnection(dbUrl,userName,userPassword);
connection.setAutoCommit(false);
//...

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

It doesn't matter if I replace "XE" for "XEPDB1" or shorten "CSHAY-7420.oradev.oraclecorp.com" 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/demouser@CSHAY-7420.oradev.oraclecorp.com:1521/XEPDB1;
)
---

At this point I thought of using the only string with userName and password in the form:
String dbUrl = "demouser/demouser@CSHAY-7420.oradev.oraclecorp.com:1521/XEPDB1";
java.sql.Connection connection = DriverManager.getConnection(dbUrl);
connection.setAutoCommit(false);
//...

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.setDriverType("thin");
ds.setServerName("CSHAY-7420");// NO "CSHAY-7420.oradev.oraclecorp.com"
ds.setPortNumber(1521);
ds.setDatabaseName("XE"); // Oracle SID // NO XEPDB1
//ds.setUser("demouser"); // NO
//ds.setPassword("demouser"); // NO
ds.setUser("SYSTEM");
ds.setPassword("<my password>");
java.sql.Connection connection=ds.getConnection();
connection.setAutoCommit(false);
//...

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

Comments
Post Details
Added on May 11 2022
5 comments
523 views