File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Getting trigger information usind JDBC API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Getting trigger information usind JDBC API" Watch "Getting trigger information usind JDBC API" New topic

Getting trigger information usind JDBC API

Mohanraj Naidu

Joined: Jun 29, 2003
Posts: 12
Hi All,
How to get trigger information from the database using JDBC API calls. I need to retrieve the entire trigger and its related information from the database for some reason.
Any help will be appreciated
Nagendra Prasad
Ranch Hand

Joined: Jul 11, 2002
Posts: 219
Any information available via system catalogs can be retrieved as long as the owner (DB User) through which u are obtaining your connection has the rights to do so.
At the end of the day, it is just a database call through a SQL Statement.
I cannot see why you cannot do it.
If you are having specific problems, please post.. and I might be able to tell something more..
best regards,

Best Regards,<br />Nagendra Prasad.
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1141

I may be misinterpreting your question, but, as far as I know, there are no methods in the JDBC API for retrieving information about the database triggers.
Most [O]RDBMS's that support database triggers, store information about the triggers in their data dictionary. Each DBMS has its own proprietary data dictionary, but usually you can access the data dictionary using SQL. So, for example using Oracle, the following query will give you the trigger definition:

So you could "wrap" the above query into an invocation of the "executeQuery()" method in class "java.sql.Statement", for example, and get the informaton that way. However, as I mentioned before, each DBMS data dictionary is different, so the above will only work for Oracle. That's why there is nothing in the JDBC API for returning that information.
Good luck,
Braj Prasad

Joined: Apr 08, 2002
Posts: 16
All you need is the select role on catalog objects, to retrive the trigger information.
For eg. in Oracle you would use the following statement:-
select trigger_body from dba_triggers where trigger_name=<your trigger_name>
I agree. Here's the link:
subject: Getting trigger information usind JDBC API
jQuery in Action, 3rd edition