Kod jest nastepujacy:
try {
Connection conn = DriverManager.getConnection("jdbc:postgresql:usr", "usr", "pass");
//Pobranie danych z tabeli
PreparedStatement stmt = conn.prepareStatement("SELECT * FROM ?");
stmt.setString(1, "books");
rs = stmt.executeQuery();
} catch (SQLException ex) {
ex.printStackTrace();
}
Dostaje wyjatek:
org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1"
Position: 15
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273)
at test.MainPanel.<init>(MainPanel.java:43)
at test.MainFrame.<init>(MainFrame.java:9)
Ktos wie co jest nie tak?