title: SQLException: ERROR: syntax error at or near "\"
body: <p>I want to get a list of tables in ma database to String. I have connect with database, but when I try use Postgres "\dt" function, getTables() throws <code>org.postgresql.util.PSQLException: ERROR: syntax error at or near "\".</code>
  What is the problem? A simple backslash is reported as an error by 
  JDK (treats <code>\dt</code> as regex).</p>
  
  <pre><code>import java.sql.*;
  import java.util.ArrayList;
  
  public class DataConnect {
      Statement statement = null;
      Connection connection = null;
      DataConnect() {
          try {
              Class.forName("org.postgresql.Driver");
              connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres", "", "");
              statement = connection.createStatement();
          } catch (ClassNotFoundException e) {
  
              e.printStackTrace();
              System.out.append("Driver is missing");
              end();
          } catch (SQLException e) {
              e.printStackTrace();
              System.out.append("Wrong order");
              end();
          }
      }
      ArrayList&lt;String&gt; getTables() {
          ArrayList tables = new ArrayList();
          try {
              ResultSet rs = statement.executeQuery("\\dt");
              while (rs.next()) {
                  String databaseName = rs.getString("Name");
              }
              return tables;
          } catch (Exception e) {
              e.printStackTrace();
              end();
              return null;
          }
      }
  }
  </code></pre>