Create mssql trigger from java program

2019-09-06 15:22发布

问题:

Is it possible to create a trigger from java using mssql jdbc driver?

I am having one audit trigger which is saved in a .sql file. The UI will show all the tables available in client db. Sometimes they need to enable the auditing for some specific tables, so I need to run the sql script by replacing the table name with the user selected one. The client needs this to be achieved from our java software. As I am new to JDBC, I am unable to figure this out. Any better ideas/help appreciated

回答1:

Execute trigger creation SQL as a plain query. You may also need to wrap the SQL with exec('...') as mentioned in: https://stackoverflow.com/a/951956/92063