[Pljava-dev] PlJava Function-Mapping

From: l(dot)paige at live(dot)com (Larry)
To:
Subject: [Pljava-dev] PlJava Function-Mapping
Date: 2011-09-07 03:37:24
Message-ID: 1315366644852-4777098.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

I seem to having problems writing a PLJava function-mapping. Consider the
code examples shown below that demonstrates in a very simple manner the
problem I am having:

*Consider I define the following PL Java function in PostgreSQL:*

CREATE OR REPLACE FUNCTION stringtest(character varying)
RETURNS tuple AS
'test.Org.getString'
LANGUAGE java VOLATILE

SELECT * FROM teststring(?hello?);

*The in Java I have:*

public class Org {

public static boolean getString(String input, ResultSet receiver)
throws SQLException{

String input_ = Common.getParam2();
receiver.updateString("first", input);
receiver.updateString("second", input_);

return true;
}
}

public class Common {

public static String getParam2(){
try {
Class.forName("org.postgresql.Driver");
Connection connection = DriverManager.getConnection(
"jdbc:postgresql://localhost:5432/mydb",
?username",
?password");
ResultSet rs = connection.createStatement().executeQuery(
"select id FROM events"
);
if(rs.next())
return rs.getString("id");
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}

}

So now the problem is: if I don?t call /Common.param2()/ and instead just
hard-code some dummy-string everything works fine. But when I try calling
some other function, such as /.getParam2()/, I get an error, as follows:

/ ERROR: java.lang.NoClassDefFoundError: Could not initialize class
java.net.InetAddress/

Clearly the above is just the standard SDK, so this is really confusing me
as to why it is happening.

Any help would be much appreciated.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/PlJava-Function-Mapping-tp4777098p4777098.html
Sent from the PL/Java mailing list archive at Nabble.com.

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Vorarlberger 2011-09-07 06:38:58 [Pljava-dev] PlJava Function-Mapping
Previous Message marc_firth 2011-09-05 21:30:20 [Pljava-dev] PostgresSQL 8.4 PL/Java IO access issue.