I want to make Java code (using Oracle 11g and JDBC also) which will check if a particular User or Schema exists or not. How can I do this by using only Java code and not by executing SQL queries (inside my java code) to do the checking ?
Thanks.
EDIT -
METHOD 1:
In MySQL, we can use something like this -
Connection conn = DriverManager.getConnection(url,username,password);
DatabaseMetaData DMD = conn.getMetaData();
ResultSet res = DMD.getCatalogs();
while (res.next()) {
String database = res.getString("TABLE_CAT");
}
Now put an if inside the while to check it given DB exists.
METHOD 2:
OR, you can execute some queries like mentioned in this post. Using SQL query to determine if a table exists
I want to use something like method 1 to do the job instead of method 2 - That is what i meant.
connectauthority.conn.getMetaData()(which of course runs SQL queries behind the scenes to get its data).