[Pljava-dev] reading a file

Thomas Hallgren thhal at mailblocks.com
Thu Nov 11 20:08:45 UTC 2004


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





More information about the Pljava-dev mailing list