Reputation: 63
I have tried several ideas using prepared statement, but none of them worked. These are:
String insertSQL = "INSERT INTO APP.TEST (Name, 'role') VALUES (?, ?)";
String insertSQL = "INSERT INTO APP.TEST (Name, [role]) VALUES (?, ?)";
String insertSQL = "INSERT INTO APP.TEST (Name, role) VALUES (?, ?)";
Upvotes: 0
Views: 555
Reputation: 270607
Apache Derby's documentation specifies that delimited SQL identifiers may be double-quoted. So your SQL string would eventually look like:
INSERT INTO APP.TEST (Name, "role") VALUES (?, ?)
Since that is being placed inside a string already double-quoted, backslash-escape the inner quotes:
String insertSQL = "INSERT INTO APP.TEST (Name, \"role\") VALUES (?, ?)";
Derby's list of reserved words does not currently specify role
as reserved, but if in your implementation it does appear to be reserved, you must quote it accordingly.
Upvotes: 2