agora inbox for pljava-dev@postgresql.org  
help / color / mirror / Atom feed
Subject: [Pljava-dev] java.lang.SecurityException
Date: Wed, 20 Apr 2005 13:09:08 +0200
Message-ID: <2276557F1C7668499FF59EC75B84624FC7A6B6@salsa.cefriel.it> (raw)

I made as you suggested. But the result now is: no suitable driver.
The CLASSPATH does not exist and in the postgresql.conf 
variable pljava.classpath has only pljava.jar.

this is my change in the source

public class Test {

	public static String test() {
		String ret = "nu cazz!!!!!!!!";
		try {
			/*
			Class.forName("org.postgresql.Driver");
			String url =
"jdbc:postgresql://etechsviluppo.cefriel.it/context";
			Properties props = new Properties();
			props.setProperty("user", "context");
			props.setProperty("password", "context");
			Connection conn =
DriverManager.getConnection(url, props);
			*/
			Connection conn =
DriverManager.getConnection("jdbc.default.connection");
			Statement s = conn.createStatement();
			...

thank you,
Luca

-----Original Message-----
From: Thomas Hallgren [mailto:thhal at mailblocks.com] 
Sent: Wednesday, April 20, 2005 12:20 PM
To: Luca Rasconi
Cc: Pljava-dev at gborg.postgresql.org
Subject: Re: [Pljava-dev] java.lang.SecurityException

Luca Rasconi wrote:

> I wrote a litlle class test to see pljava in action. This class named 
> test.jar and the jar name used in the install routine is test_luca.
>
> My procedure is very simple:
>
> public class Test {
>
> public static String test() {
>
> String ret = "nu cazz!!!!!!!!";
>
> try {
>
> Class.forName("org.postgresql.Driver");
>
> String url = "jdbc:postgresql://myhost/mydb";
>
> Properties props = new Properties();
>
> props.setProperty("user", "user");
>
> props.setProperty("password", "password");
>
> Connection conn = DriverManager.getConnection(url, props);
>
> Statement s = conn.createStatement();
>
> int uid = 13;
>
> String _url = "some url";
>
> String sql = "insert into request(UID, url) values(" + uid + ", '" + 
> _url + "')";
>
> s.execute(sql);
>
> s.close();
>
> s = conn.createStatement();
>
> sql = "select * from request where uid = 13";
>
> ResultSet rs = s.executeQuery(sql);
>
> rs.first();
>
> ret = rs.getString("url");
>
> rs.close();
>
> conn.close();
>
> } catch (ClassNotFoundException e) {
>
> // TODO Auto-generated catch block
>
> ret = "non ho trovato la classe del dirver jdbc!!";
>
> //e.printStackTrace();
>
> } catch (SQLException e1) {
>
> ret = e1.getMessage();
>
> //e1.printStackTrace();
>
> }
>
> return ret;
>
> }
>
> }
>
> when I try to execute this is the result:
>
> SELECT test_luca();
>
> ERROR: java.lang.SecurityException: read on \C:\Program 
> Files\PostgreSQL\8.0\jdbc\postgresql-8.0-310.jdbc3.jar
>
> Some body can help me?
>
1) Don't use the PostgreSQL client jdbc driver inside of PL/Java since 
that will a) create a network connection to another PostgreSQL session 
and b) have a transaction-scope that is decoupled from the 
transaction-scope of the executing function. In order to obtain a 
connection, please do:

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

2) Never have anything but the pljava.jar in the postgresql.conf 
variable pljava.classpath or in the CLASSPATH env seen by the postmaster

process . Jar files *must* be loaded using sqlj.install_jar

Regards,
Thomas Hallgren





view thread (35+ messages)  latest in thread

Message-ID: <2276557F1C7668499FF59EC75B84624FC7A6B6@salsa.cefriel.it>
Permalink:  ../2276557F1C7668499FF59EC75B84624FC7A6B6@salsa.cefriel.it/
Also on:    postgresql.org/message-id/2276557F1C7668499FF59EC75B84624FC7A6B6@salsa.cefriel.it

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] java.lang.SecurityException
  In-Reply-To: <2276557F1C7668499FF59EC75B84624FC7A6B6@salsa.cefriel.it>

* 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