Wave - 8 months ago 48
Java Question

Using java to find version and start PostgreSQL

Is it possible to find version of PostgreSQL using java and also to start the PostgreSQL server using java code ?

To find version we have PG_VERSION file which has version under PostgreSQL data directory but we cannot rely on it since this file can be edited. Please help me out. Any suggestions are really appreciated.

select version();

Run it through JDBC, you have java anyway. As for running the the postgres server itself, I think the old way Runtime.exec/ProcessBuilder will do the job. You may want to create some kind of script above it but that the way it should work, I guess, there is no other way.