?????. DB2 ? XpertMon ??? ???!
? ????????? DB ??????.
??? ????? Code Objects(COs) ? ?? ????? ?????.
COs ? ???? ?????, Trigger? Stored Procedure, User Define Function (UDF)??
RDBMS? ???? DB2 ? ???? Object? ????.
Business rules as code objects
COs ? ???? ?? ?? ????? ?? ? ??, DB?? ???? ???,
???? ??? ? ???, ???? ??? ? ? ?????.
??? UDF ? Trigger? ???? ??? Business Logic? ??? ?????.
UDF ? Java? ???????.
???? ??
ABC ?? ??? ??? ?????, ? ??? ?? ??? ??? ???? ???.
?? ?? ??? ??? ???(15?)? ???? ?? e-mail? ??? ?????
??? ????? ?????.
??? ?? ? ??? Insert
UDF ??
Java ?? ???? Mail API ? ???? e-mail? ??? UDF ? ?????.
http://java.sun.com/products/javamail ????? mail.jar ? activation .jar ???
???? CLASSPATH ? ?????.
export CLASSPATH=$CLASSPATH:/home/hjlee/UDF/mail.jar:
export CLASSPATH=$CLASSPATH:/home/hjlee/UDF/activation.jar
??? ??? ?? JAVA ??? UDF ? ?????.
import java.util.*;
import java.math.BigDecimal;
import javax.mail.*;
import javax.mail.internet.*;
public class PARTSupplyUDF{
public static String PARTSupply(int part, String description, String supplier){
try{
// ??? ?? from e-mail ??? ??? ?? ?????.
String host = "www.iteg.co.kr";
InternetAddress from = new InternetAddress("donna91@empal.com");
InternetAddress sendto = new InternetAddress(supplier);
//Retrieve the system properties
Properties props = new Properties();
props.put("mail.smtp.protocol","smtp");
props.put("mail.smtp.host",host);
props.put("mail.smtp.port","25");
//Create session (triggered fired (tf))
Session tfSession = Session.getInstance(props);
//Create the message
MimeMessage tfMessage = new MimeMessage(tfSession);
tfMessage.setFrom(from);
tfMessage.setSubject("ABC ??? ????? ??? ?????.");
String msgText = " ??? ????. 15? ?????.";
msgText +=" ?? : " + description + "
";
msgText +=" ?? ?? :" + part + "
";
tfMessage.setText(msgText);
tfMessage.addRecipient(Message.RecipientType.TO,sendto);
//Send the message
javax.mail.Transport.send(tfMessage);
}
catch(Exception e){
System.out.println("UDF have caught an error: " + e);
return "UDF have caught an error: " + e;
}
return "An Email has been sent to : " + supplier;
} // End PARTSupply
} // End PARTSupplyUDF
UDF ??
UDF ? Java? ??????, ?? Function ? DB? ???? ???.
????? ??? ????.
- ??? ??? Class ??? $instance home directory/sqllib/function ? copy ???.
- ??? ?? create function? ?????.
TRIGGER ??
???? ?????. stock ?? 15??? ???? ??, ??? ??? UDF? ????
????? ??? ???? ???.
?? ??
?? ?? UDF? Trigger? ??????? ?????.
??? ?? stock ? 15? ??? update ???.
???? Trigger ? ???? ??? ?? ??? ??? ???.
XpertMon for DB2 UDB V2
DB ???
Tel : 02-2108-1458
Fax : 02-2108-1459
Mobile : 011-896-6545
E-mail :
hjlee@iteg.co.kr
URL :
http://iteg.co.kr