How do I get all trigger names from the database using Java JDBC?

I want to get all trigger names from Oracle database schema.

I am using getFunctions to fetch all functions, but I cannot find another one for triggers.

DatabaseMetaData dbmd;
ResultSet result = dbmd.getFunctions(null, Ousername, null);

      

+3


source to share


2 answers


You can do this using metadata.



DatabaseMetaData dbmd = dbConnection.getMetaData(); 
ResultSet result = dbmd.getTables("%", Ousername, "%", new String[]{ "TRIGGER" });
while (result.next()) {
     result.getString("TABLE_NAME")
}

      

+2


source


The JDBC API does not provide a standard way to retrieve trigger information from DatabaseMetaData. In fact, the word "trigger" doesn't even appear in the Javadoc. The accepted answer may work for Oracle, but it is not documented and certainly does not work for other databases like HSQL and PostgreSQL.



The only way to get trigger information without looking for an undocumented backdoor hack in the JDBC driver is with a specific database query question.

+1


source







All Articles