[Pljava-dev] How use external java class ?

From: thhal at mailblocks(dot)com (Thomas Hallgren)
To:
Subject: [Pljava-dev] How use external java class ?
Date: 2005-07-11 13:37:08
Message-ID: thhal-0hw6uA3O+zzYAEJJkBM17SmI4HwznY9@mailblocks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

Yes, you normally load all 50 jars into PostgreSQL. There's a couple of
reasons for that:

1. There's a difference in how you access the file-system and the
database server. A client often resides on another machine and access
the server using TCP/IP. So there's no guarantee that a jar file that
resides on the client can be accessed by a server and no guarantee that
a client have access to install files in the file system on the server
machine.

2. A trusted language in the database is not permitted to access the
file system on the server. To allow that would be very insecure. PL/Java
can use the PostgreSQL grant/revoke etc. to control who can install a
jar file and access the functions there. If jar files could simply be
placed in the file-system all such control would be in vain.

3. If you use database replication, you'd probably like changes to jars
that is part of your app to be replicated as well.

Having said that, there still is a way to actually have jars reside in
the file system. But to access them you have to use the untrusted
version of PL/Java, i.e. your functions must be declared with LANGAGE
'javaU' (only the super user can declare such functions but anyone can
run them). If they are, then you can set the pljava.classpath
environment in postgresql.conf to include your jar files. But please
note, this is NOT something that I recommend. A much better solution is
to create a script that maintains your jars in the database.

Regards,
Thomas Hallgren

brice rouanet wrote:

> Yes,
> but if I have 50 jars files, i must install all files into postgres ?
> At time i have just a jar file in postgres with a simple function
> which is call a method (callClient(TriggerData td)) which is a XML RPC
> client...
>
> Thx
> Brice.
>
>> No, you load the jar into the database using the sqlj.install_jar and
>> sqlj.set_classpath commands. Please read the user guide.
>>
>> Regards,
>> Thomas Hallgren
>>
>> brice rouanet wrote:
>>
>>> I'm not really good in english, but I will try to explain this.
>>>
>>> I have a jar in /home/brice/test.jar, and I want than the Pl/Java
>>> function call a methode in test.jar,
>>> is I must add my jar in the classpath setting of postgres.conf ?
>>>
>>> Thanks,
>>> Brice.
>>>
>>>
>>>> brice rouanet wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> how to set the classpath to use external java classes ?
>>>>>
>>>>> ie :
>>>>>
>>>>> POSTRGRES / PLJAVA call a method in a class out of postgres.
>>>>>
>>>>> Best regards,
>>>>>
>>>>> Brice.
>>>>>
>>>>>
>>>> I'm not sure what you mean by "external". Can you elaborate please?
>>>>
>>>> Regards,
>>>> Thomas Hallgren
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>
>

In response to

Browse pljava-dev by date

  From Date Subject
Next Message brice rouanet 2005-07-13 09:14:22 [Pljava-dev] Get columns names in TriggerData ?
Previous Message Thomas Hallgren 2005-07-11 13:16:03 [Pljava-dev] How use external java class ?