I'm looking for a way to get information about triggers (like name and other details) in MS_SQL, MySQL, PostgreSQL, and Oracle.
I found the following code in this answer but when I tried using it with a MySQL database it did not work.
package jdbc.core;
import java.sql.*;
public class ListProcedures {
public static void main(String[] args) {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/db1", "root", "xxx");
DatabaseMetaData meta = con.getMetaData();
ResultSet res = meta.getTables(null, "root", "public", new String[] { "TRIGGER" });
System.out.println("List Of the trigger :-");
while (res.next()) {
// res.getString("TABLE_NAME");
System.out.println("!!" + res.getString(1));
System.out.println("::" + res.getString(2));
System.out.println("::" + res.getString(3));
}
res.close();enter code here
con.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Can anyone suggest some other way to retrieve the information I need?