[Pljava-dev] ERROR: Unable to find static method...

From: morgan at ftgrp(dot)com (Morgan Cameron)
To:
Subject: [Pljava-dev] ERROR: Unable to find static method...
Date: 2004-12-02 02:32:09
Message-ID: 001101c4d817$1fdea970$dc8055aa@mlcamer
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

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>

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Thomas Hallgren 2004-12-02 10:09:30 [Pljava-dev] ERROR: Unable to find static method...
Previous Message Thomas Hallgren 2004-11-30 09:42:47 [Pljava-dev] Re: worked