Subject: [Pljava-dev] problem implementing with ResultSetProvider

From: JDW at Fodoze.com (John D. West)
Date: Tue, 3 Aug 2010 19:05:05 -0700

Hi, All.

When I create and try to run a function implementing
ResultSetProvider, I get a "Unable to find static method with
signature..." error.

Java code:
import edu.sc.seis.TauP.Arrival;
import edu.sc.seis.TauP.TauModelException;
import edu.sc.seis.TauP.TauP_Time;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.postgresql.pljava.ResultSetProvider;

public class emTauP implements ResultSetProvider {

     private ResultSet rs;
     private static TauP_Time tt;
     private static Arrival[] arr;

     public emTauP(String model, String phaselist, double depth,
double gcarc) throws SQLException {

          // instantiate TauP_Time object, passing it the model name
          tt = new TauP_Time(model);

          // add the list of phases
          tt.parsePhaseList(phaselist);

          // correct for the source depth
          tt.depthCorrect(depth);

          // calculate for the distance in degrees
          tt.calculate(gcarc);

          // get the array of Arrival objects
          arr = tt.getArrivals();
     }

     public static ResultSetProvider TTimes(String model, String
phaselist, double depth, double gcarc) throws SQLException {
          // instantiate a new TauP class object
          return new emTauP(model, phaselist, depth, gcarc);
     }

     public boolean assignRowValues(ResultSet trs, int RowNum) throws
SQLException {
          if (rs.next()) {
          trs.updateString(1, arr[RowNum].getName());
          trs.updateDouble(2, arr[RowNum].getTime());
          trs.updateDouble(3, arr[RowNum].getRayParam());
          return(true);
          } else {
               return(false);
          }
     }

     public void close() throws SQLException {
          // does nothing, but required to implement ResultSetProvider
     }

}

I install the class in postgres (8.4), using: SELECT sqlj.install_jar(
'file:///EMERALD/Java/emTauP/emTauP.jar', 'emTauP', true )

I create the function:
CREATE OR REPLACE FUNCTION em_ttimes(em_model text, em_phaselist text,
em_depth double precision, em_gcarc double precision) RETURNS SETOF
public.em_ttime AS
	'emTauP.TTimes(java.lang.String, java.lang.String, double, double)'
	LANGUAGE java;

Then when I run it, I get the following error:
ERROR: Unable to find static method emTauP.TTimes with signature
(Ljava/lang/String;Ljava/lang/String;DD)Lorg/postgresql/pljava/ResultSetProvider;

I can create and run functions which do not implement
ResultSetProvider, no problem.  Can anyone see something I'm doing
wrong, or is this a bug?

Thanks very much!
? ?? -- John

---

From: fluca1978 at infinito.it (Luca Ferrari)
Date: Wed, 4 Aug 2010 08:59:16 +0200

On Wednesday, August 04, 2010 04:05:05 am John D. West's cat walking on the 
 
> ResultSetProvider, no problem.  Can anyone see something I'm doing

I have recreated it on my system and I can invoke the function. It should not 
be a classpath problem, since that will lead to a class not found exception. 
Could you post the log to see if there is an hint?

Luca

---

From: JDW at Fodoze.com (John D. West)
Date: Wed, 4 Aug 2010 10:32:56 -0600

I set the logging levels to Debug5, and this is what I got when trying
to run the function:
2010-08-04 09:22:04 PDT DEBUG:  00000: 04 Aug 10 09:22:04
org.postgresql.pljava.internal.Backend Using SecurityManager for
trusted language
2010-08-04 09:22:04 PDT LOCATION:
Java_org_postgresql_pljava_internal_Backend__1log,
/usr/share/pljava/src/C/pljava/Backend.c:890
2010-08-04 09:22:04 PDT STATEMENT:  select * from em_ttimes('PREM',
'SKS', 50, 99);
2010-08-04 09:22:04 PDT DEBUG:  00000: className = 'emTauP',
methodName = 'TTimes', parameters =
'java.lang.String,java.lang.String,double,double', returnType = 'null'
2010-08-04 09:22:04 PDT LOCATION:  parseFunction,
/usr/share/pljava/src/C/pljava/Function.c:400
2010-08-04 09:22:04 PDT STATEMENT:  select * from em_ttimes('PREM',
'SKS', 50, 99);
2010-08-04 09:22:04 PDT DEBUG:  00000: 04 Aug 10 09:22:04
org.postgresql.pljava.sqlj.Loader Creating typeMappings for schema
public
2010-08-04 09:22:04 PDT LOCATION:
Java_org_postgresql_pljava_internal_Backend__1log,
/usr/share/pljava/src/C/pljava/Backend.c:890
2010-08-04 09:22:04 PDT STATEMENT:  select * from em_ttimes('PREM',
'SKS', 50, 99);
2010-08-04 09:22:04 PDT DEBUG:  00000: Loading class emTauP
2010-08-04 09:22:04 PDT LOCATION:  Function_init,
/usr/share/pljava/src/C/pljava/Function.c:539
2010-08-04 09:22:04 PDT STATEMENT:  select * from em_ttimes('PREM',
'SKS', 50, 99);
2010-08-04 09:22:04 PDT DEBUG:  00000: Obtaining method emTauP.TTimes
(Ljava/lang/String;Ljava/lang/String;DD)Lorg/postgresql/pljava/ResultSetProvider;
2010-08-04 09:22:04 PDT LOCATION:  Function_init,
/usr/share/pljava/src/C/pljava/Function.c:569
2010-08-04 09:22:04 PDT STATEMENT:  select * from em_ttimes('PREM',
'SKS', 50, 99);
2010-08-04 09:22:04 PDT DEBUG:  00000: Method emTauP.TTimes
(Ljava/lang/String;Ljava/lang/String;DD)Lorg/postgresql/pljava/ResultSetProvider;
not found
2010-08-04 09:22:04 PDT LOCATION:  Function_init,
/usr/share/pljava/src/C/pljava/Function.c:578
2010-08-04 09:22:04 PDT STATEMENT:  select * from em_ttimes('PREM',
'SKS', 50, 99);
2010-08-04 09:22:04 PDT DEBUG:  00000: Obtaining method emTauP.TTimes
(Ljava/lang/String;Ljava/lang/String;DD)Lorg/postgresql/pljava/ResultSetHandle;
2010-08-04 09:22:04 PDT LOCATION:  Function_init,
/usr/share/pljava/src/C/pljava/Function.c:608
2010-08-04 09:22:04 PDT STATEMENT:  select * from em_ttimes('PREM',
'SKS', 50, 99);
2010-08-04 09:22:04 PDT ERROR:  XX000: Unable to find static method
emTauP.TTimes with signature
(Ljava/lang/String;Ljava/lang/String;DD)Lorg/postgresql/pljava/ResultSetProvider;
2010-08-04 09:22:04 PDT LOCATION:  PgObject_throwMemberError,
/usr/share/pljava/src/C/pljava/PgObject.c:101
2010-08-04 09:22:04 PDT STATEMENT:  select * from em_ttimes('PREM',
'SKS', 50, 99);

Does that cast light on anything?

Thanks!

     -- John

On Wed, Aug 4, 2010 at 12:59 AM, Luca Ferrari <fluca1978 at infinito.it> wrote:
>> ResultSetProvider, no problem. ?Can anyone see something I'm doing
>> wrong, or is this a bug?
>>
>
> _______________________________________________
> Pljava-dev mailing list
> Pljava-dev at pgfoundry.org
> http://pgfoundry.org/mailman/listinfo/pljava-dev
>

---

From: JDW at Fodoze.com (John D. West)
Date: Wed, 4 Aug 2010 13:20:37 -0700

This seems to have been caused by my not installing into the database
(using sqlj.install_jar()) the external jar files this function
depends on.  It mostly works now.

thanks!

? ?? -- John

On Wed, Aug 4, 2010 at 9:32 AM, John D. West <JDW at fodoze.com> wrote:
> 2010-08-04 09:22:04 PDT DEBUG: ?00000: 04 Aug 10 09:22:04
> 2010-08-04 09:22:04 PDT STATEMENT: ?select * from em_ttimes('PREM',
> 'SKS', 50, 99);
> 2010-08-04 09:22:04 PDT DEBUG: ?00000: className = 'emTauP',
> 2010-08-04 09:22:04 PDT LOCATION: ?parseFunction,
> 2010-08-04 09:22:04 PDT STATEMENT: ?select * from em_ttimes('PREM',
> 'SKS', 50, 99);
> 2010-08-04 09:22:04 PDT DEBUG: ?00000: 04 Aug 10 09:22:04
> 2010-08-04 09:22:04 PDT STATEMENT: ?select * from em_ttimes('PREM',
> 'SKS', 50, 99);
> 2010-08-04 09:22:04 PDT DEBUG: ?00000: Loading class emTauP
> 2010-08-04 09:22:04 PDT LOCATION: ?Function_init,
> 2010-08-04 09:22:04 PDT STATEMENT: ?select * from em_ttimes('PREM',
> 'SKS', 50, 99);
> 2010-08-04 09:22:04 PDT DEBUG: ?00000: Obtaining method emTauP.TTimes
> 2010-08-04 09:22:04 PDT LOCATION: ?Function_init,
> 2010-08-04 09:22:04 PDT STATEMENT: ?select * from em_ttimes('PREM',
> 'SKS', 50, 99);
> 2010-08-04 09:22:04 PDT DEBUG: ?00000: Method emTauP.TTimes
> 2010-08-04 09:22:04 PDT LOCATION: ?Function_init,
> 2010-08-04 09:22:04 PDT STATEMENT: ?select * from em_ttimes('PREM',
> 'SKS', 50, 99);
> 2010-08-04 09:22:04 PDT DEBUG: ?00000: Obtaining method emTauP.TTimes
> 2010-08-04 09:22:04 PDT LOCATION: ?Function_init,
> 2010-08-04 09:22:04 PDT STATEMENT: ?select * from em_ttimes('PREM',
> 'SKS', 50, 99);
> 2010-08-04 09:22:04 PDT ERROR: ?XX000: Unable to find static method
> 2010-08-04 09:22:04 PDT LOCATION: ?PgObject_throwMemberError,
> 2010-08-04 09:22:04 PDT STATEMENT: ?select * from em_ttimes('PREM',
> 'SKS', 50, 99);
>
> ? ? -- John