agora inbox for pljava-dev@postgresql.org  
help / color / mirror / Atom feed
[Pljava-dev] reading a file
4+ messages / 0 participants
[nested] [flat]

* [Pljava-dev] reading a file
@ 2004-11-11 19:42  
  0 siblings, 1 reply; 4+ messages in thread

From:  @ 2004-11-11 19:42 UTC (permalink / raw)

Hi,
I wrote a Java class that needs to read in a properties text file.
Where should I put the properties file in the Postgres environment so
my class doesn't get a "File not found" error?
Thanks,
Russ





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* [Pljava-dev] reading a file
@ 2004-11-11 20:08  
  parent: 
  0 siblings, 1 reply; 4+ messages in thread

From:  @ 2004-11-11 20:08 UTC (permalink / raw)

Russ,

>Hi,
>I wrote a Java class that needs to read in a properties text file.
>Where should I put the properties file in the Postgres environment so
>my class doesn't get a "File not found" error?
>Thanks,
>Russ
>  
>
PL/Java doesn't have an opinion about the location of files. I guess 
that what you are after is some mechanism that would allow you to use a 
path that is relative to your PostgreSQL environment? If you're using 
PostgreSQL 8.0, you can accomplish this by defining a property in the 
postgresql.conf file. Simply add the following:

    pljava.vmoptions = '-Dpgsql.home=/the/path/to/the/pgsql/dir'

You can access this property from Java using:

    String pgsqlHome = System.getProperty("pgsql.home");

I know this is perhaps not a perfect solution. Suggestions on 
improvements are more then welcome.

Regards,
Thomas Hallgren






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* [Pljava-dev] reading a file
@ 2004-11-11 20:46  
  parent: 
  0 siblings, 0 replies; 4+ messages in thread

From:  @ 2004-11-11 20:46 UTC (permalink / raw)

Thomas Hallgren wrote:
> Russ,
> 
>> Hi,
>> I wrote a Java class that needs to read in a properties text file.
>> Where should I put the properties file in the Postgres environment so
>> my class doesn't get a "File not found" error?
>> Thanks,
>> Russ
>>  
>>

I guess you can always use the classloader resource mechanism, and locate the 
property file[s] near your classes or in the jar.

HTH,
-- 
Radu-Adrian Popescu
CSA, DBA, Developer
Aldrapay MD
Aldratech Ltd.
+40213212243
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3206 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20041111/dc1a0e96/attachment.bin;



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* [Pljava-dev] reading a file
@ 2004-11-12 00:15  
  0 siblings, 0 replies; 4+ messages in thread

From:  @ 2004-11-12 00:15 UTC (permalink / raw)

Russell Reeves wrote:

>Hi Thomas,
>Thanks for the reply.
>Please bear with me. I'm a newbie with pljava and Postgres.
>So, if I have a jar file up in Postgres with a class that is trying to read
>a file in,
>where does it look by default?
>I think I can use what you suggested.
>I'll let you know what happens.
>Many thanks,
>Russ
>  
>
Radu-Adrian Popescu wrote:

> I guess you can always use the classloader resource mechanism, and 
> locate the property file[s] near your classes or in the jar. 

If you are referring to the Class methods "getResource" and 
"getResourceAsStream", i.e. the stuff that Radu-Adrian mentioned, I must 
admit that there's a minor flaw in PL/Java at present. The resource 
finder semantics are not yet implemented in the ClassLoader.

The behavior that will be implemented in the coming release is to mimic 
the behavior of the standard Java ClassLoader and resolve the resource 
the same way as the class is resolved, i.e. by consulting the classpath. 
In PL/Java, the classpath is defined for the schema where the executing 
function is defined (as set by the function set_classpath).

Regards,
Thomas Hallgren






^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2004-11-12 00:15 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-11-11 19:42 [Pljava-dev] reading a file 
2004-11-11 20:08 ` 
2004-11-11 20:46   ` 
2004-11-12 00:15 [Pljava-dev] reading a file 

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox