Anjali
Anjali

Reputation: 1691

question about timezone in postgresql+java?

I am using postgresql9.0 and JDK6. I am running pg_controldata command in postgresql. in that I need "Time of latest checkpoint:" value. it is a date & time with timezone.

while running through java API it is dispalying everything otherthan timezone.

from direct postgres it it showing ---Time of latest checkpoint:Mon 12 Mar 2012 08:15:43 AM SGT

but when run through code then it is showing----Time of latest checkpoint:Mon Mar 12 08:15:43 2012

how to solve it?

String result = 
pe.executepsql("/data/PostgreSQL/bin/pg_controldata /data/PostgreSQL/data"); 
System.out.println("Output of cmd:" +result); 
String start = "Time of latest checkpoint:"; 
String end = "Minimum recovery ending location:"; 
String str = result.substring(result.indexOf(start)+
"Time of latest checkpoint:".length(),result.indexOf(end)).trim(); 
System.out.println("Time of latest checkpoint: " +str); 
executepsql()

is used to execute postgres command.

executepsql() is used to execute postgres command.

I tried psql -c command also with this method which is working fine. but pg_controldata is not working correctly.

Upvotes: 0

Views: 353

Answers (1)

Anjali
Anjali

Reputation: 1691

String result = pe.executepsql("/data/PostgreSQL/bin/pg_controldata /data/PostgreSQL/data");
System.out.println("Output of cmd:" +result);
String start = "Time of latest checkpoint:";
String end = "Minimum recovery ending location:";
String str = result.substring(result.indexOf(start)+"Time of latest checkpoint:".length(),result.indexOf(end)).trim();
System.out.println("Time of latest checkpoint: " +str);

executepsql() is used to execute postgres command.

I tried psql -c command also with this method which is working fine. but pg_controldata is not working correctly.

Upvotes: 1

Related Questions