How to check with if an Oracle's view exist in the DB ? Before execute a query
database, java, oracle
Solution
You can always query the Oracle data dictionary. Something like
SELECT COUNT(*)
FROM all_views
WHERE view_name = <<the name of the view>>
AND owner = <<the owner of the view>>
will tell you whether you have access to a view owned by the specified user with the specified name.
Alternately, you can use a more Java-centric approach. You can create a `DatabaseMetaData` object from your `Connection` and call `getTables` to get a list of all the tables and views that you have access to. You can pass `getTables` a specific table or view name (or a pattern) to restrict the results.
Problem
I need to know a way to check from a Java Desktop App, if a Oracle's view exist in the current DB before execute a query otherwise I will get a lot of troubles... thanks in advance