简体   繁体   中英

Get Table Name from prepared statement

I am thinking about designing a DB modify notification system. For this purpose I was wondering if I can get required information by extending PreparedStatement ?

For my purpose, I would like to get at least following of information:

  1. Type of operation (select/insert/update)
  2. Table name

We can get the table name from the following:

ResultSetMetaData resultSetMetaData = preparedStatement.getMetaData();        
System.out.println("Table name " + resultSetMetaData.getTableName(1)); 
//1 here is the first column of the table for which the operation is made.

Trying to figure out how can we get the operation performed.

We can manipulate the logic to see if it's select or insert or update and send notification with the operation and the retrieved table name from above step.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM