[Pljava-dev] After an insert, the trigger can't find the row

Thomas Hallgren thhal at mailblocks.com
Fri Aug 26 08:49:01 UTC 2005


Eric BOYER wrote:

> String url="jdbc:postgresql://localhost:5432/bertha";
> Connection con = DriverManager.getConnection(url,"login","password");
> Statement select = con.createStatement();

Ok, that's what I suspected. You establish a whole new session to 
another postgresql backend. That session is not in anyway related to 
your ongoing transaction, that's why you don't see the changes. The 
correct way to obtain a connection is:

  Connection conn = DriverManager.getConnection("jdbc:default:connection");

That gives you the *current* connection, i.e. the one where your outer 
statement that caused the trigger was fired.

Another tip:
Somehow you make jar file for the PostgreSQL client jdbc driver 
available to PL/Java, either you loaded it using sqlj.install_jar or 
you've added it to a classpath somewhere. It should be removed altogether.

Regards,
Thomas Hallgren

>
> --------
>
> another test :
>
> In my bd :
> insert into exploitation.goupe values (170,'a','b');
>
> in my log with a select * from exploitation.goupe where 
> gid_number=170, the row is not in my db.
>
> in my bd again :
> insert into exploitation.goupe values (171,'c','d');
> in my class file (so int the log) with a
> select * from exploitation.groupe where gid_number=170, the row is 
> great in the db
> but with a
> select * from exploitation.groupe where gid_number=171, the row is not 
> in the db
>
>
> At the end of the execution of the trigger, in my psql command the 
> "select * from exploitation.groupe where gid_number=171" find the row !
>
> Eric
>





More information about the Pljava-dev mailing list