0

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.

2
  • 1
    show us the code which doesn't display the timezone. Commented May 17, 2011 at 10:29
  • 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. Commented May 18, 2011 at 4:14

1 Answer 1

1
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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.