jdbc connection error-java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist - jdbc

I have a user in oracle, if I am selecting some data with the user in sqldeveloper its working fine
But when I am trying to connect to the same database and with the same username and password, I am getting error as java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
I can see the table exists in the database as I can query via sqldeveloper.
I tried searching forums but no answer yet. Do I need to give special permission to the user when connecting from Java (basically Java program using eclipse)

Related

How to query tables and pull data into an Oracle APEX application from another schema?

I am working in an Oracle APEX application and am trying to query tables in another schema (that another Oracle APEX application sits on) to pull in data to my application.
The applications are hosted within the same APEX workspace and on the same Oracle 11g instance. Our application have tables that are structurally the same as the tables we're trying to query in the other schema.
Using the schema prefix (SELECT * FROM "SCHEMA2".TABLE1;) when querying is throwing an error that the tables do not exist (ORA-00942: table or view does not exist)
The second thing I tried is creating a database link between the two schemas, but when trying to establish the connection I'm getting the following error: ORA-01031: insufficient privileges
Can someone identify where I'm going wrong here / help me figure out how to query the other schema?
Database link is used when there are different databases involved; your schemas reside in the same database which means that the first attempt was correct: prefixing table name with its owner, e.g.
SELECT * FROM SCHEMA2.TABLE1
However, first connect as schema2 user and issue
grant select on table1 to schema1;
Otherwise, schema1 can't see the table. If schema1 is supposed to do something else with that table, you'll have to grant additional privileges, such as insert, update, delete, ....

DBlink error when querying the remote table

I am creating DB link by using below command. I have not updated tnsnames.ora instead I used details in the commmand.
CREATE DATABASE LINK test
CONNECT TO apps IDENTIFIED BY xyzabc
USING '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=awsss3270429.us.dell.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=dell122de))';
The DBLink was created successfully. but
When I fired below query I got the error.
select * from USER_CS_SRS#test; . table `USER_CS_SRS` exist in remote database.
Error is attached.
I am quite new to DB. Can anybody help me on the same.
You are missing a closing parenthesis at the end of your connection string. Your create statement should end:
...(CONNECT_DATA=(SERVICE_NAME=opm122de)))';
-----------------------------------------^
Recreating what you posted:
CREATE DATABASE LINK test
CONNECT TO apps IDENTIFIED BY xyzabc
USING '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rws3270429.us.oracle.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=opm122de))';
select * from USER_CS_SRS#test;
Error report -
SQL Error: ORA-12154: TNS:could not resolve the connect identifier specified
...
Adding the final ) changes that:
drop database link test;
CREATE DATABASE LINK test
CONNECT TO apps IDENTIFIED BY xyzabc
USING '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rws3270429.us.oracle.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=opm122de)))';
select * from USER_CS_SRS#test;
Error report -
SQL Error: ORA-12545: Connect failed because target host or object does not exist
...
which is a different error; for me that's entirely reasonable because I can't resolve rws3270429.us.oracle.com, never mind reach it. As your profile says you work for Oracle, presumably you can - and this either works or throws a different error. Either way the original ORA-12154 error has been fixed.

Connected to Pluggable Database - Cannot See Any Tables - SQL*PLUS

I am using sqlplus to connect to a pluggable database that is running on my localhost. However, when I connect I cannot see any of the tables from the major schemas.
Does anyone know how to trouble shoot this type of problem? When I connect using PL/SQL Developer however I am able to see the tables. I am connecting to the pluggable database using sql*plus like so:
sqlplus localhost:1521/services.domain as sysdba
When I try to select a table I see an error that the table or view does not exist. When I connect with PL/SQL developer like so, shown below in Figure 1, I do not have the problem of not being able to select any tables.
Figure 1: Logging into PL/SQL Developer

ORA-01219 - "database or pluggable database not open: queries allowed on fixed tables or views only"

I've just installed oracle database 18c on my windows 10 machine. Then I used Oracle SQL Developer to login to the database that I've created during the installation with connection information below:
The connection was successful and when I tried to open the Tables, it showed an error OCA-01219:
I've found this solution:
ORA-01219: database not open: queries allowed on fixed tables/views only
that trying to make the database open. I have tried this but still no success, my database status:
Can anyone please help to to solve this problem? Thank you very much in advanced.
I run into the same problem after having to restart the Oracle Service. The problem was the state of the pluggable database not that of the instance itself, which was "open" like in your case.
The following command worked for me (please replace "orclpdb" with your pluggable DB name):
alter pluggable database orclpdb open;
If output of 'select status from v$instance' is open, can you please execute below query and let me know the out put:
select name, open_mode from v$database;
Also, please let me know if you are trying to connect pluggable database. In case you are connecting to pluggable db, then run below query:
alter session set container='';
Then after apply above approach. please let me know if any query further

H2 database write access reqd

I installed Talend Open Studio for MDM and Master data gets stored in H2 Database(which is the only DB provided by product). I created an entity in MDM. But I need to make changes in that entity datatype. I need to drop the entity which I already created. When I am trying to do this, I am getting below error.
sa#TMDM_DB/PUBLIC> drop table contact;
An error occurred when executing the SQL command: drop table contact
The database is read only; SQL statement: drop table contact [90097-176] [SQL State=90097, DB Errorcode=90097]
how to make this H2 DB as write mode. I need to have write access.

Resources