public Function getFunction(String name) { Assert.notNull(name, "function name can not be null"); String message = "Get database(MySql) function information error!"; String schema = getSchemaName(); Function p = JDBCUtils.query( dbm, GET_FUNCTION_SQL, message, new ResultSetExtractor<Function>() { public Function extractData(ResultSet rs) throws SQLException { Function p = null; while (rs.next()) { String name = rs.getString("name"); String definition = rs.getString("definition"); if (p == null) { p = new Function(); p.setName(name); } p.appendStr(definition); } return p; } }, name, schema); return p; }
public Procedure getProcedure(String procedureName) { Assert.notNull(procedureName, "procedure name can not be null"); String message = "Get database(MySql) procedure information error!"; String schema = getSchemaName(); Procedure p = JDBCUtils.query( dbm, GET_PROCEDURE_SQL, message, new ResultSetExtractor<Procedure>() { public Procedure extractData(ResultSet rs) throws SQLException { Procedure p = null; while (rs.next()) { String name = rs.getString("name"); String definition = rs.getString("definition"); if (p == null) { p = new Procedure(); p.setName(rs.getString("name")); } p.appendStr(definition); } return p; } }, procedureName, schema); return p; }
public Trigger getTrigger(String triggerName) { Assert.notNull(triggerName, "triggerName can not be null"); String message = "Get database(Oracle) " + triggerName + "'s definition information error!"; String schema = getSchemaName(); Trigger trigger = JDBCUtils.query( dbm, GET_TRIGGER_SQL, message, new ResultSetExtractor<Trigger>() { public Trigger extractData(ResultSet rs) throws SQLException { Trigger trigger = null; while (rs.next()) { String definer = rs.getString("definer"); String trigger_schema = rs.getString("trigger_schema"); String trigger_name = rs.getString("trigger_name"); String action_timing = rs.getString("action_timing"); String table = rs.getString("event_object_table"); String action_orientation = rs.getString("action_orientation"); String action_statement = rs.getString("action_statement"); trigger = new Trigger(); trigger.appendStr("CREATE DEFINER = " + definer + "\n"); trigger.appendStr( "\tTrigger " + Utility.quote(trigger_schema) + "." + Utility.quote(trigger_name) + "\n"); trigger.appendStr("\t" + action_timing + " on " + Utility.quote(table) + "\n"); trigger.appendStr("\tFor each " + action_orientation + "\n"); trigger.appendStr(action_statement); trigger.setName(trigger_name); trigger.setTableName(table); } return trigger; } }, schema, triggerName); return trigger; }