agora inbox for pljava-dev@postgresql.org  
help / color / mirror / Atom feed
Subject: [Pljava-dev] ERROR:  Unable to find static method...
Date: Wed, 1 Dec 2004 21:32:09 -0500
Message-ID: <001101c4d817$1fdea970$dc8055aa@mlcamer> (raw)

I am trying to develop a view that calls a function that will ultimately
make a separate connection to a XML database and return attributes back into
the view, but for testing it simply returns dummy values.  In selecting from
the view, I find that I'm getting "method not found" errors on the first and
second query attempts, but it succeeds on the third!

PostgreSQL log file is attached.

Would "preloading" the pljava library help?  I used "preload_libraries =
'/pgsql/lib/libpljava'", but the system appears to hang after the point of
"Creating JavaVM" (no more messages appear in the log file after that point,
even at debug level 5).  Eventually I would like to preload the java
libraries since the code will get used quite heavily.

Thanks

Morgan Cameron

#======= System ===========
Red Hat Linux Advanced Server release 2.1AS/i686 (Pensacola)
Linux 2.4.9-e.49
gcc version 3.4.3
PostgreSQL 7.4.6
PL/Java, 1.0.0 beta 5 (compiled with USE_GCJ=1)


#======= Example session ===========
Welcome to psql 7.4.6, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
      \h for help with SQL commands
      \? for help on internal slash commands
      \g or terminate with semicolon to execute query
      \q to quit

testjdbc=# select * from v_testtbl;
ERROR:  Unable to find static method com.tester.database.GetInfo. with
signature
(ILjava/sql/ResultSet;)Z
testjdbc=# select * from v_testtbl;
ERROR:  java.lang.NoSuchMethodError
testjdbc=# select * from v_testtbl;
  code    |   name
-----------+-----------
Test Code | Test Name
Test Code | Test Name
Test Code | Test Name
(3 rows)

testjdbc=#


#======= Database code ===========
createuser -PaD testjdbc
createdb -O testjdbc testjdbc

DROP VIEW v_testtbl;
DROP FUNCTION GetInfo(integer);
DROP TYPE udt_testtbl;
DROP TABLE testtbl;

CREATE TYPE udt_testtbl AS
(
 Code varchar(16),
 Name varchar(64)
);

CREATE OR REPLACE FUNCTION GetInfo(integer) RETURNS udt_testtbl
AS 'com.tester.database.GetInfo.getInfo'
LANGUAGE java STABLE
;

CREATE TABLE testtbl(
    ID   INTEGER,
    code VARCHAR(16) not null,
    name varchar(64) not null,
    CONSTRAINT PK_testtbl PRIMARY KEY (ID)
);

insert into testtbl values (1, 'ABC', 'ABC Name');
insert into testtbl values (2, '123', '123 Name');
insert into testtbl values (3, 'XYZ', 'XYZ Name');

CREATE OR REPLACE VIEW v_testtbl AS
select
 (GetInfo(id)).code,
 (GetInfo(id)).name
from testtbl
;

#======= Java code ===========
package com.tester.database;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.postgresql.pljava.ResultSetProvider;
public class GetInfo implements ResultSetProvider
{
  private final int m_fid;
  public GetInfo(int fid)
  {
    m_fid = fid;
  }

  public boolean assignRowValues(ResultSet receiver, int currentRow)
  throws SQLException
  {
    if(currentRow > 1)
      return false;

    receiver.updateString(1, "Dummy Code");
    receiver.updateString(2, "Dummy Name");
    return true;
  }


  public static boolean getInfo(int fid, ResultSet receiver)
  throws SQLException
  {
    receiver.updateString(1, "Test Code");
    receiver.updateString(2, "Test Name");
    return true;
  }
}




-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pgsql.log.txt
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20041201/5470cd89/attachment.txt;



view thread (2+ messages)  latest in thread

Message-ID: <001101c4d817$1fdea970$dc8055aa@mlcamer>
Permalink:  ../001101c4d817$1fdea970$dc8055aa@mlcamer/
Also on:    postgresql.org/message-id/001101c4d817$1fdea970$dc8055aa@mlcamer

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] ERROR:  Unable to find static method...
  In-Reply-To: <001101c4d817$1fdea970$dc8055aa@mlcamer>

* 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