Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting vacuum results

6 views
Skip to first unread message

Joseph Shraibman

unread,
Sep 1, 2005, 11:38:21 PM9/1/05
to
If I run VACUUM VERBOSE from jdbc, how do I get the output? There are
no SQLWarnings attached to the resultset.

Kris Jurka

unread,
Sep 13, 2005, 6:21:35 PM9/13/05
to

On Thu, 1 Sep 2005, Joseph Shraibman wrote:

> If I run VACUUM VERBOSE from jdbc, how do I get the output? There are no
> SQLWarnings attached to the resultset.
>

SQLWarnings are attached to the Statement because VACUUM does not produce
a query result. The attached test case shows this working
fine for me. The one complication is that vacuum puts out
some of its interesting information in the Detail: part of the
log message. The JDBC driver doesn't normally put this
information into the warning message, so you must either
increase the loglevel URL parameter or use the 8.1 series and
write pg specific code to access the individual fields of the
ServerErrorMessage class. We plan to increase the number of fields
used to construct the error string to include the Detail field, but
haven't gotten around to it yet.

Kris Jurka

Vacuum.java

Joseph Shraibman

unread,
Sep 13, 2005, 6:52:34 PM9/13/05
to
It's funny. Your test program works, but in my server I get this:

Got SQLException: Something unusual has occured to cause the driver to
fail. Please report this exception.

... and nothing else.

> ------------------------------------------------------------------------
>
> import java.sql.*;
>
> public class Vacuum {
>
> public static void main(String args[]) throws Exception {
> Class.forName("org.postgresql.Driver");
> Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/jurka?loglevel=1","jurka","");
> Statement stmt = conn.createStatement();
> stmt.execute("VACUUM VERBOSE");
> SQLWarning warn = stmt.getWarnings();
> System.out.println(warn);
> while (warn != null) {
> warn = warn.getNextWarning();
> System.out.println(warn);
> }
> stmt.close();
> conn.close();
> }
> }
>
>

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Kris Jurka

unread,
Sep 13, 2005, 6:55:33 PM9/13/05
to

On Tue, 13 Sep 2005, Joseph Shraibman wrote:

> It's funny. Your test program works, but in my server I get this:
>
> Got SQLException: Something unusual has occured to cause the driver to fail.
> Please report this exception.
>

What's the stacktrace coming from this?

Kris Jurka

Joseph Shraibman

unread,
Sep 13, 2005, 8:49:31 PM9/13/05
to
Something unusual has occured to cause the driver to fail. Please report
this exception.
org.postgresql.util.PSQLException: Something unusual has occured to
cause the driver to fail. Please report this exception.
at org.postgresql.Driver.connect(Driver.java:249)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at <snip>
Caused by: java.security.AccessControlException: access denied
(java.sql.SQLPermission setLog)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
at
java.security.AccessController.checkPermission(AccessController.java:427)
at
java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.sql.DriverManager.setLogWriter(DriverManager.java:109)
at
org.postgresql.jdbc2.AbstractJdbc2Connection.enableDriverManagerLogging(AbstractJdbc2Connection.java:1086)
at
org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:98)
at
org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
at
org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
at org.postgresql.Driver.connect(Driver.java:235)
... 7 more

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majo...@postgresql.org so that your
message can get through to the mailing list cleanly

Joseph Shraibman

unread,
Sep 13, 2005, 9:08:06 PM9/13/05
to
OK from the stack trace I figured out that I had to add a permission to
java.policy.

FYI this doesn't work:

ResultSet rs = stmt.executeQuery("VACUUM VERBOSE profuser;");
SQLWarning warn = rs.getWarnings();

Kris Jurka

unread,
Sep 13, 2005, 10:27:33 PM9/13/05
to

On Tue, 13 Sep 2005, Joseph Shraibman wrote:

> OK from the stack trace I figured out that I had to add a permission to
> java.policy.
>
> FYI this doesn't work:
>
> ResultSet rs = stmt.executeQuery("VACUUM VERBOSE profuser;");
> SQLWarning warn = rs.getWarnings();
>


With both 8.0 and 8.1dev I get:

Exception in thread "main" org.postgresql.util.PSQLException: No results
were returned by the query.
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:232)
at Vacuum.main(Vacuum.java:9)

and this is the result that I would expect.

Kris Jurka


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

0 new messages