Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Sending mail from a SP

Re: Sending mail from a SP

From: <akragl_at_hotmail.com>
Date: Mon, 08 Nov 1999 08:07:20 GMT
Message-ID: <8060bn$ghu$1@nnrp1.deja.com>


I am working on a custom solution based on javamail trying to move it into the Oracle 8.1.5
database. I did EVERYTHING like mentioned below (with minor differences which I will explain), but am getting Oracle internal error messages.

The setup is as follows:
- Archive files activation.jar and mail.jar are loaded with loadjava util into my own schema (not SYS as below). All classes didn't resolve properly so had to do that manually using CREATE JAVA CLASS statements.

ERROR at line 1:
ORA-29516: Aurora assertion failure:
ORA-00600: internal error code, arguments: [510], [2147535824], [shared pool],
[], [], [], [], []
ORA-00600: internal error code, arguments: [510], [2147535824], [shared pool],
[], [], [], [], []
ORA-06512: at "MY_SCHEMA.TEST", line 0
ORA-06512: at line 1

Looks like shared pool size is too small. Or is it something else. Also, if I try to create my class with CREATE JAVA SOURCE statement (by compiling it in the database) Oracle comes with error that in essence says that Aurora environment error happened and that it is bug in the compiler and not in my source.

Any help is greatly appreciated!

>In article <7ui8hc$jav$1_at_nnrp1.deja.com>,
> jeperkins4_at_my-deja.com wrote:
> Make sure that you get all the contents of the META-INF directory when
> you recreate the jar.
>
> In article <7ufcc9$k5n$1_at_nnrp1.deja.com>,
> haaseg_at_my-deja.com wrote:
> > If you are using Oracle 8i you can develop a java stored procedure
for
> > sending mails.
> > I've done this 3 month ago but didn't put the solution in production
> > because we integrated the mail functionality in the java client.
> >
> > Steps for developing such a procedures are:
> >
> > #################################
> > 1. load java mail archives as sys
> > #################################
> >
> > loadjava -u sys/<password>@<db> -v -r -f activation.jar
> > loadjava -u sys/<password>@<db> -v -r -f mail.jar (uncompressed)
> >
> > You can get activation.jar/mail.jar from
> > http://java.sun.com/products/javamail
> >
> > Oracle 8i expects the jar file to be uncompressed but mail.jar can
be
> > compressed (I've needed 2 hours to learn this).
> > To uncompress it use:
> > jar x mail.jar
> > jar cvf0 mail.jar com javax meta-inf
> >
> > #################################
> > 2. develop java mail procedure
> > #################################
> >
> > You can use this as a starting point:
> >
> > package TestMail;
> >
> > import java.util.*;
> > import java.io.*;
> > import javax.mail.*;
> > import javax.mail.internet.*;
> > import javax.activation.*;
> >
> > public class SendMail
> > {
> > static void print(String out)
> > {
> > System.out.println(out);
> > }
> >
> > public static void sendFrom(
> > String sendTo,
> > String subject,
> > String bodyText,
> > String from)
> > {
> > // mail variables
> > Properties props;
> > String mailHost = "<smtp host>";
> > Session session;
> >
> > // create some properties and get the default Session
> > props = System.getProperties();
> > props.put("mail.smtp.host", mailHost);
> >
> > session = Session.getDefaultInstance(props, null);
> > session.setDebug(false);
> >
> > sendMail(session,sendTo,from,subject,bodyText);
> > }
> >
> > static void sendMail(
> > Session session,
> > String sendTo,
> > String from,
> > String subject,
> > String bodyText)
> > {
> > try {
> > // create a mime message
> > MimeMessage mail = new MimeMessage(session);
> > mail.setFrom(new InternetAddress(from));
> > InternetAddress[] address = {new InternetAddress(sendTo)};
> > mail.setRecipients(Message.RecipientType.TO, address);
> > mail.setSubject(subject);
> >
> > // create and fill the first message part (bodyText)
> > MimeBodyPart bodyPart1 = new MimeBodyPart();
> > bodyPart1.setText(bodyText);
> >
> > // create the Multipart and its parts to it
> > Multipart multiPart = new MimeMultipart();
> > multiPart.addBodyPart(bodyPart1);
> >
> > // add the Multipart to the message
> > mail.setContent(multiPart);
> >
> > // set the Date: header
> > mail.setSentDate(new Date());
> >
> > // send the message
> > Transport.send(mail);
> > }
> > catch (MessagingException mex)
> > {
> > print("SendTo: " + sendTo);
> > print("From: " + from);
> > print("Subject: " + subject);
> > print("BodyText: " + bodyText);
> >
> > mex.printStackTrace();
> > Exception ex = null;
> > if ((ex = mex.getNextException()) != null) {
> > ex.printStackTrace();
> > }
> > }
> > }
> > }
> >
> > #################################
> > 3. load java mail procedure
> > #################################
> >
> > loadjava -u <user>/<password>@<db> -v -r -f TestMail.jar
> > -- execute dbms_java.set_output(2000)
> >
> > #################################
> > 4. define call specification
> > #################################
> >
> > CREATE OR REPLACE PROCEDURE send_mail_from (
> > sendTo VARCHAR2,
> > subject VARCHAR2,
> > bodyText VARCHAR2,
> > sendFrom VARCHAR2)
> > AS LANGUAGE JAVA
> > NAME
> > 'TestMail.SendMail.sendFrom
> (java.lang.String,java.lang.String,java.lang.
> > String,java.lang.String)';
> >
> > #################################
> > The disadvantages of this method are:
> > 1. You have to know a lot of JavaMail API, Java Stored Procedures
and
> > perhaps JDBC
> > 2. You need Oracle 8i
> >
> > The advantages are
> > 1. The solution is clean and doesn't depend on a (perhaps unstable)
> dbms
> > pipe.
> > 2. You can easily get data from the database (e.g. attachments)
> because
> > you are "in the database".
> > 3. JavaMail API is very powerfull so you can do what you want.
> >
> > In article <yiPL3.70767$L6.7841083_at_news1.rdc1.on.wave.home.com>,
> > "marasoft" <marasoft_at_home.com> wrote:
> > > Does anyone know if it is possible to send an email message from a
> > stored
> > > procedure (PL/SQL)? Is there any package that can do this?
> > >
> > > Thank's
> > > David
> > >
> > >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Mon Nov 08 1999 - 02:07:20 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US