I recently installed PostgreSQL 8.2.11-1 on my Windows machine for use with my java application. I need to get a list of the databases available so that the user can choose one. Issuing a query of "\list" using jdbc doesn't seem to work:
Connection connection = DriverManager.getConnection("jdbc:postgresql:postgres", "user", "pass");
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("\\list");
which produces:
org.postgresql.util.PSQLException: ERROR: syntax error at or near "\"
Why is this and how can I fix it?