Am I using the syntax incorrectly in the PreparedStatement?
When executing:
1 statement = conn.prepareStatement("insert into ?.? (?) values(?)");
2 statement.setString(1, schemaName);
3 statement.setString(2, tableName);
4 statement.setString(3, columnName);
5 statement.setString(4, columnValue);
6 statement.executeUpdate();
7 conn.commit();
The exception thrown:
org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1"
Position: 13
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2477)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2190)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:300)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:428)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:354)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:169)
at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:136)
at PostgreSQLDatabase.updateTable(MyClass.java:6)