Обсуждение: pg_start_backup question
How to execute "SELECT pg_start_backup('label');" from java as a SQL statement? I tries to use:
Statement.execute("SELECT pg_start_backup('label')")
But it does not work.
Thanks.
Jack
Statement.execute("SELECT pg_start_backup('label')")
But it does not work.
Thanks.
Jack
Le vendredi 30 octobre 2009 à 23:41:54, db de a écrit : > How to execute "SELECT pg_start_backup('label');" from java as a SQL > statement? I tries to use: > Statement.execute("SELECT pg_start_backup('label')") > > But it does not work. > You should have an error message in your PostgreSQL logs. Without this, I don't think we can help you. -- Guillaume. http://www.postgresqlfr.org http://dalibo.com
Below is what I did:
I opened a super user connection to creat a super user statement. Then use the super user statement to execute "SELECT pg_start_backup('label')".
try
{
superuserCont = java.sql.DriverManager.getConnection(URL, su, suPassword);
suStatement = superuserCont.createStatement();
boolean ret = suStatement.execute("SELECT pg_start_backup('label')"); //LINE1
}
catch(SQLException e)
{
System.out.println("exception"); //LINE2
}
finally
{
System.out.println("ret:" + ret); //LINE3
}
After LINE1 is executed, LINE3 is run and the output is: ret:false. LINE2 is not executed.
Thanks.
Jack
I opened a super user connection to creat a super user statement. Then use the super user statement to execute "SELECT pg_start_backup('label')".
try
{
superuserCont = java.sql.DriverManager.getConnection(URL, su, suPassword);
suStatement = superuserCont.createStatement();
boolean ret = suStatement.execute("SELECT pg_start_backup('label')"); //LINE1
}
catch(SQLException e)
{
System.out.println("exception"); //LINE2
}
finally
{
System.out.println("ret:" + ret); //LINE3
}
After LINE1 is executed, LINE3 is run and the output is: ret:false. LINE2 is not executed.
Thanks.
Jack
On Fri, Oct 30, 2009 at 4:06 PM, Guillaume Lelarge <guillaume@lelarge.info> wrote:
Le vendredi 30 octobre 2009 à 23:41:54, db de a écrit :You should have an error message in your PostgreSQL logs. Without this, I> How to execute "SELECT pg_start_backup('label');" from java as a SQL
> statement? I tries to use:
> Statement.execute("SELECT pg_start_backup('label')")
>
> But it does not work.
>
don't think we can help you.
--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com
Le samedi 31 octobre 2009 à 00:39:54, db de a écrit : > Below is what I did: > I opened a super user connection to creat a super user statement. Then use > the super user statement to execute "SELECT pg_start_backup('label')". > > try > { > superuserCont = java.sql.DriverManager.getConnection(URL, su, > suPassword); > suStatement = superuserCont.createStatement(); > boolean ret = suStatement.execute("SELECT > pg_start_backup('label')"); //LINE1 > } > catch(SQLException e) > { > System.out.println("exception"); > > //LINE2 > } > finally > { > System.out.println("ret:" + > ret); > //LINE3 > } > > After LINE1 is executed, LINE3 is run and the output is: ret:false. LINE2 > is not executed. > Which PostgreSQL release do you use? did you activate archive_mode? what's in your archive_command? -- Guillaume. http://www.postgresqlfr.org http://dalibo.com
db de wrote: > Below is what I did: > I opened a super user connection to creat a super user > statement. Then use the super user statement to execute > "SELECT pg_start_backup('label')". > > try > { > superuserCont = java.sql.DriverManager.getConnection(URL, su, suPassword); > suStatement = superuserCont.createStatement(); > boolean ret = suStatement.execute("SELECT pg_start_backup('label')"); > //LINE1 > } > catch(SQLException e) > { > System.out.println("exception"); > > //LINE2 > } > finally > { > System.out.println("ret:" + ret); > > //LINE3 > } > > After LINE1 is executed, LINE3 is run and the output is: > ret:false. LINE2 is not executed. Maybe something else than an SQLException was thrown, and maybe by some statement before the last in the try/catch block. You should debug this. Possible starting points: - Change "catch (SQLException" to "catch (Throwable" and see if you catch something. - Execute it in a debugger or have status messages printed out after every line. See which flow the execution takes. - Set "log_statements='all'" in postgresql.conf on the database server and see what you find in the log. - See what you get when you issue that SQL statement with psql. Yours, Laurenz Albe