Thread: Postgres registry access using java

Postgres registry access using java

From
"Anirban Pal"
Date:
Hi all,
 
Can any body tell me how to fetch directory path for lib or data directory for postgres installation in windows using registry. Solution using Java language will be highly solicited.
 
---  Thanks & Reagrds  ----
Anirban Pal  |  Software Engineer

Disclaimer :- This e-mail and any attachment may contain confidential, proprietary or legally privileged information. If you are not the origin al intended recipient and have erroneously received this message, you are prohibited from using, copying, altering or disclosing the content of this message. Please delete it immediately and notify the sender. Newgen Software Technologies Ltd (NSTL) accepts no responsibilities for los s or damage arising from the use of the information transmitted by this email including damages from virus and further acknowledges that no bin ding nature of the message shall be implied or assumed unless the sender does so expressly with due authority of NSTL.

Re: Postgres registry access using java

From
Joshua Tolley
Date:
On Wed, May 27, 2009 at 01:21:40PM +0530, Anirban Pal wrote:
>    Can any body tell me how to fetch directory path for lib or data directory
>    for postgres installation in windows using registry. Solution using Java
>    language will be highly solicited.

Some PL/Java or PL/J function might do what you want, provided Java gives you a
means to access the registry. But what's wrong with "SHOW data_directory;" or
"SELECT setting FROM pg_settings WHERE name = 'data_directory';"?

- Josh / eggyknap

Attachment

Re: Postgres registry access using java

From
"Albe Laurenz"
Date:
Anirban Pal wrote:
> Can any body tell me how to fetch directory path for lib or
> data directory for postgres installation in windows using
> registry. Solution using Java language will be highly solicited.

Java does not give you access to the Windows registry as this is not
portable to other operating systems.

You'd have to use native methods.

Yours,
Laurenz Albe

Re: Postgres registry access using java

From
"Anirban Pal"
Date:
Thanks Josh for your kind reply. In the pg_settings table all reference to
the folder is with reference to data directory. Like "config_file"
"C:/Program Files/PostgreSQL/8.3/data/postgresql.conf""data_directory"
"C:/Program Files/PostgreSQL/8.3/data""hba_file"   "C:/Program
Files/PostgreSQL/8.3/data/pg_hba.conf""ident_file"   "C:/Program
Files/PostgreSQL/8.3/data/pg_ident.conf"No reference to postgres instalation
base directory, i mean where postgres have been installed. And it is
possible to install data directory as users's convinient location, may be
outside instalation directory. In that case how to fetch postgres
instalation directory? I am looking for lib directory, which I can found out
by traversing directory path once I find what is base installed directory
for postgresql. Whatever thanks again for your reply. RegardsAnirban


Disclaimer :- This e-mail and any attachment may contain confidential, proprietary or legally privileged information.
Ifyou are not the original intended recipient and have erroneously received this message, you are prohibited from
using,copying, altering or disclosing the content of this message. Please delete it immediately and notify the sender.
NewgenSoftware Technologies Ltd (NSTL)  accepts no responsibilities for loss or damage arising from the use of the
informationtransmitted by this email including damages from virus and further acknowledges that no binding nature of
themessage shall be implied or assumed unless the sender does so expressly with due authority of NSTL.  


Re: Postgres registry access using java

From
"Anirban Pal"
Date:
 
Thanks Josh for your kind reply. In the pg_settings table all reference to the folder is with reference to data directory. Like 
"config_file"   "C:/Program Files/PostgreSQL/8.3/data/postgresql.conf"
"data_directory"   "C:/Program Files/PostgreSQL/8.3/data"
"hba_file"   "C:/Program Files/PostgreSQL/8.3/data/pg_hba.conf"
"ident_file"   "C:/Program Files/PostgreSQL/8.3/data/pg_ident.conf"
No reference to postgres instalation base directory, i mean where postgres have been installed. And it is possible to install data directory as users's convinient location, may be outside instalation directory. In that case how to fetch postgres instalation directory? I am looking for lib directory, which I can found out by traversing directory path once I find what is base installed directory for postgresql. Whatever thanks again for your reply. 
Regards
Anirban

Disclaimer :- This e-mail and any attachment may contain confidential, proprietary or legally privileged information. If you are not the origin al intended recipient and have erroneously received this message, you are prohibited from using, copying, altering or disclosing the content of this message. Please delete it immediately and notify the sender. Newgen Software Technologies Ltd (NSTL) accepts no responsibilities for los s or damage arising from the use of the information transmitted by this email including damages from virus and further acknowledges that no bin ding nature of the message shall be implied or assumed unless the sender does so expressly with due authority of NSTL.

Re: Postgres registry access using java

From
"Anirban Pal"
Date:
@  Laurenz Albe, All

  1st of all thanks for your kind reply. But I can access registry values
using java. The problem I am facing is, in case of postgres settings
informations are kept under a subdirectory named after the product key. I am
able to access from the registry if the path is unique for all the
computers. Since product key is different for each installed computer, my
code written for one computer will not work in another. If it is possible to
traverse folders under registry pane, as seen left side of registry, my
problem will be solved. In my computer.

HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\{B823632E-3B72-4514-8865-B961CE263224}

The last value is different from machine to machine. I am able to fetch key
values upto HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations. But not
after that. Yes it is true registry will not make code compatible for linux,
but I have OS checking part in my code. So, registry part will not run while
on linux. I have different logic (sompe file reading/scanning) for linux ,
solaris.

Regards
Anirban

Anirban Pal wrote:
> Can any body tell me how to fetch directory path for lib or
> data directory for postgres installation in windows using
> registry. Solution using Java language will be highly solicited.

Java does not give you access to the Windows registry as this is not
portable to other operating systems.

You'd have to use native methods.

Yours,
Laurenz Albe

Disclaimer :- This e-mail and any attachment may contain confidential, proprietary or legally privileged information.
Ifyou are not the original intended recipient and have erroneously received this message, you are prohibited from
using,copying, altering or disclosing the content of this message. Please delete it immediately and notify the sender.
NewgenSoftware Technologies Ltd (NSTL)  accepts no responsibilities for loss or damage arising from the use of the
informationtransmitted by this email including damages from virus and further acknowledges that no binding nature of
themessage shall be implied or assumed unless the sender does so expressly with due authority of NSTL.  


Re: Postgres registry access using java

From
Dave Page
Date:
On Thu, May 28, 2009 at 10:33 AM, Anirban Pal <anirban.pal@newgen.co.in> wrote:
> @  Laurenz Albe, All
>
>  1st of all thanks for your kind reply. But I can access registry values
> using java. The problem I am facing is, in case of postgres settings
> informations are kept under a subdirectory named after the product key. I am
> able to access from the registry if the path is unique for all the
> computers. Since product key is different for each installed computer, my
> code written for one computer will not work in another.

The product key is unique to each major version of PostgreSQL (ie.
8.3, 8.4 and so on) - it doesn't change for each computer.

--
Dave Page
EnterpriseDB UK:   http://www.enterprisedb.com

Re: Postgres registry access using java

From
"Albe Laurenz"
Date:
Anirban Pal wrote:
>   1st of all thanks for your kind reply. But I can access registry values
> using java.

Ok, then you have some additional native code installed :^)

Does the documentation of this add-on suggest a way to search and
traverse Windoes registry keys?

>> Can any body tell me how to fetch directory path for lib or
>> data directory for postgres installation in windows using
>> registry. Solution using Java language will be highly solicited.

Asking the database server does not work for you?

Yours,
Laurenz Albe

Re: Postgres registry access using java

From
"Albe Laurenz"
Date:
Anirban Pal wrote:
> In the pg_settings table, all reference to folder is with reference to data
> directory.

> No reference to postgres instalation
> base directory, i mean where postgres have been installed.

That's true, you won't find that in the database.

Yurs,
Laurenz Albe

Re: Postgres registry access using java

From
Jasen Betts
Date:
On 2009-05-27, Anirban Pal <anirban.pal@newgen.co.in> wrote:
> This is a multi-part message in MIME format.
>
> ------=_NextPart_000_0041_01C9DECE.11E417C0
> Content-Type: text/plain;
>     charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
> Hi all,
>
> Can any body tell me how to fetch directory path for lib or data =
> directory for postgres installation in windows using registry. Solution =
> using Java language will be highly solicited.=20

why do you want to know that?

here's one way using SQL:
  select setting from pgcatalog.pg_settings where name='data_directory'


Re: Postgres registry access using java

From
John R Pierce
Date:
Anirban Pal wrote:
>
> Thanks Josh for your kind reply. In the pg_settings table all reference to the folder is with reference to data
directory.Like  
> "config_file"   "C:/Program Files/PostgreSQL/8.3/data/postgresql.conf"
> "data_directory"   "C:/Program Files/PostgreSQL/8.3/data"
> "hba_file"   "C:/Program Files/PostgreSQL/8.3/data/pg_hba.conf"
> "ident_file"   "C:/Program Files/PostgreSQL/8.3/data/pg_ident.conf"
> No reference to postgres instalation base directory, i mean where postgres have been installed. And it is possible to
installdata directory as users's convinient location, may be outside instalation directory. In that case how to fetch
postgresinstalation directory? I am looking for lib directory, which I can found out by traversing directory path once
Ifind what is base installed directory for postgresql. Whatever thanks again for your reply.  


in fact, the data directory can be somewhere quite different from where
the software is installed.  further, there can be several postgres
installs on a single system.

that said, in Windows registry key...

HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\Services, you'll
find a subkey for each install, such as...
HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Services\pgsql-8.3

and in that subkey, you'll find value "Product Code"... append this
value to...
HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\  and you'll find
values like "Base Directory"


here's that whole section of my registry...


[HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Services\pgsql-8.3]
    "Display Name"="PostgreSQL Database Server 8.3"
    "Service Account"="MYCOMPUTER\\postgres"
    "Data Directory"="D:\\postgres\\8.3\\data\\"
    "Port"=dword:00001538
    "Database Superuser"="postgres"
    "Encoding"="UTF8"
    "Locale"="English_United States"
    "Product Code"="{B823632F-3B72-4514-8861-B961CE263224}"

[HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\{B823632F-3B72-4514-8861-B961CE263224}]
    "Base Directory"="D:\\postgres\\8.3\\"
    "Data Directory"="D:\\postgres\\8.3\\data\\"
    "Version"="8.3"
    "Service ID"="pgsql-8.3"



Re: Postgres registry access using java

From
"Anirban Pal"
Date:
In the pg_settings table, all reference to folder is with reference to data
directory. Like "config_file"   "C:/Program
Files/PostgreSQL/8.3/data/postgresql.conf""data_directory"   "C:/Program
Files/PostgreSQL/8.3/data""hba_file"   "C:/Program
Files/PostgreSQL/8.3/data/pg_hba.conf""ident_file"   "C:/Program
Files/PostgreSQL/8.3/data/pg_ident.conf"No reference to postgres instalation
base directory, i mean where postgres have been installed. We know it is
possible to install data directory as users's convinient location, may be
outside instalation directory. In that case how to fetch postgres
instalation directory? I am looking for lib directory, which I can found out
by traversing directory path, once I find what is base installed directory
for postgresql. Whatever thanks again for your reply. I have opened every
system table, to find base directory location. I didn't find, may be I am
missing something. Can you enrich me with the table name, where home
directory (or installed directory not the data directory) location is
mentioned.RegardsAnirban


Anirban Pal wrote:
>   1st of all thanks for your kind reply. But I can access registry values
> using java.

Ok, then you have some additional native code installed :^)

Does the documentation of this add-on suggest a way to search and
traverse Windoes registry keys?

>> Can any body tell me how to fetch directory path for lib or
>> data directory for postgres installation in windows using
>> registry. Solution using Java language will be highly solicited.

Asking the database server does not work for you?

Yours,
Laurenz Albe

Disclaimer :- This e-mail and any attachment may contain confidential, proprietary or legally privileged information.
Ifyou are not the original intended recipient and have erroneously received this message, you are prohibited from
using,copying, altering or disclosing the content of this message. Please delete it immediately and notify the sender.
NewgenSoftware Technologies Ltd (NSTL)  accepts no responsibilities for loss or damage arising from the use of the
informationtransmitted by this email including damages from virus and further acknowledges that no binding nature of
themessage shall be implied or assumed unless the sender does so expressly with due authority of NSTL.