agora inbox for pljava-dev@postgresql.org
help / color / mirror / Atom feedSubject: [Pljava-dev] Trigger problem
Date: Sun, 23 Apr 2006 10:06:20 +0200
Message-ID: <444B357C.7010805@tada.se> (raw)
In-Reply-To: <000001c66671$519dee00$c800a8c0@DUR.AC.UK>
References: <000001c66671$519dee00$c800a8c0@DUR.AC.UK>
Hi Mark,
My guess would be that you have a jar containing the javax.mail stuff on
the classpath when you compile and run your test harness but you never
load this jar into your database. The JVM is then unable to instantiate
your SendMail class since it's depedent on Message, MimeMessage, etc.
Kind Regards,
Thomas Hallgren
Mark Colman wrote:
> Hi,
>
> I am running PostgreSQL 8.1 on Windows and installed pl/java automatically
> using the Windows installer. I have created a simple table and executed the
> following:
>
> Create function emailme()
> Returns trigger
> As 'dbudf.SendMail.send'
> Language java;
>
> Create trigger trg_emailme
> After insert on aTable
> For each row
> Execute procedure emailme();
>
> I have written the following class:
>
> package dbudf;
>
> import javax.mail.*;
> import javax.mail.internet.*;
> import java.util.*;
>
> public class SendMail
> {
> public static void send(org.postgresql.pljava.TriggerData td)
> {try{
> Properties props = System.getProperties();
> props.put("mail.smtp.host", "smtp.tiscali.co.uk");
> Session session = Session.getDefaultInstance(props, null);
> Message msg = new MimeMessage(session);
> msg.setFrom(new InternetAddress("macolman at tiscali.co.uk"));
> msg.setRecipients(Message.RecipientType.TO,
> InternetAddress.parse("m.a.colman at durham.ac.uk", false));
> msg.setSubject("A change to your data");
> msg.setText("Your database has been changed.\n\nPlease use
> the PGAdmin tool to browse the table involved.\n\nMark Colman");
> msg.setHeader("X-Mailer", "LOTONtechEmail");
> msg.setSentDate(new Date());
> Transport.send(msg);
> }
> catch (Exception e)
> {
> System.err.println("Error: "+e.toString());
> }
> }
> }
> Which compiles fine, put it in a directory dbudf, and added the directory to
> a jar called SendMail.jar - I can then call dbudf.SendMail.send(null) from
> within a simple test harness and it sends the e-mail message expected.
>
> I have then executed
>
> Select
> sqlj.install_jar('file:///c:/j2sdk1.4.2_09/lib/SendMail.jar','SendMail',true
> );
> Select sqlj.set_classpath('public','SendMail');
>
> Which seems fine. Then I insert a row into the table, and get
>
> ERROR: Unable to find static method dbudf.SendMail.send with signature
> (Lorg/postgresql/pljava/TriggerData;)V
>
> Any help greatly appreciated - I am sure this is something glaringly obvious
> that I'm missing.
>
> Mark
> _______________________________________________
> Pljava-dev mailing list
> Pljava-dev at gborg.postgresql.org
> http://gborg.postgresql.org/mailman/listinfo/pljava-dev
>
view thread (8+ messages) latest in thread
Message-ID: <444B357C.7010805@tada.se>
Permalink: ../444B357C.7010805@tada.se/
Also on: postgresql.org/message-id/444B357C.7010805@tada.se
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pljava-dev@postgresql.org
Subject: Re: [Pljava-dev] Trigger problem
In-Reply-To: <444B357C.7010805@tada.se>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox