I want to update table:
id integer NOT NULL,
"first" character varying(255),
"last" character varying(255),
age integer,
CONSTRAINT registration_pkey PRIMARY KEY (id)
using method:
void updateTable(String tableName, String columnName, String value,
String columnName2, String value2) {
try {
String sql = "UPDATE " + tableName + " SET " + columnName + " = "
+ value + " WHERE " + columnName2 + " = " + value2;
stmt.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
If i run
.updateTable("employees", "last", "11", "id", "100");
everything is ok, but if i try
.updateTable("employees", "last", "xx", "id", "100");
i recieve
org.postgresql.util.PSQLException: ERROR: column "xx" does not exist
Position: 29
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2270)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1998).....
can you tell me, where is the problem?