Reputation: 2662
When I am running following Code I am getting following error.
public Consent insert(Consent c) {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(
"INSERT INTO KIT.CONSENT (tr_number, customer, id_data, user, fk_user) "
+ "VALUES (?, ?, ?, ?, ?)",
new String[] { "ID" });
ps.setString(1, c.getTr_number());
ps.setString(2, c.getCustomer());
ps.setString(3, c.getId_data());
ps.setString(4, c.getUser());
ps.setInt(5, c.getFk_user());
ps.executeUpdate();
ResultSet rs = ps.getGeneratedKeys();
while(rs.next()){
int id = rs.getInt(1);
c.setId(id);
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
Error:
Caused by: java.sql.SQLSyntaxErrorException: ORA-01747: invalid user.table.column, table.column, or column specification
This code works on MySQL but in Oracle throws following error
Upvotes: 2
Views: 2925
Reputation: 1948
ORA-01747 - You are using a reserved word as column name. If you try to create table with column name user you will get an error. You have created the table with column name "user" which is different of user and now when you do insert you should use "user" as column name.
INSERT INTO KIT.CONSENT (tr_number, customer, id_data, "user", fk_user)
It is not recommended to use reserved words as column names
Upvotes: 2