java - Oracle database - invalid identifier (that is not even part of the SQL query) - Stack Overflow

I use the QueryRunner to execute SQL commands on the Oracle database.QueryRunner queryRunner = new Que

I use the QueryRunner to execute SQL commands on the Oracle database.

QueryRunner queryRunner = new QueryRunner();
int result = queryRunner.update(this.conn, "UPDATE system_user SET last_login_timestamp = systimestamp WHERE sys_user_code = ? ", "myuser");

But I get the following error:

ORA-00904: "YSTIMESTAMPHEREYS_USER_CODE": Invalid identified。
 Query: UPDATE system_user SET last_login_timestamp = systimestamp WHERE sys_user_code = ?  Parameters: [myuser]

So my question is, why does it think that there is YSTIMESTAMPHEREYS_USER_CODE in the connection string even if it is not there? Are there some encoding problems?

Note:

When I execute the same script in DBeaver (for example), the query is executed without any problems.

EDIT

After debugging the QueryRunner code I have found out that the error happens here (↓) in PreparedStatement.getParameterMetaData. source code

I use the QueryRunner to execute SQL commands on the Oracle database.

QueryRunner queryRunner = new QueryRunner();
int result = queryRunner.update(this.conn, "UPDATE system_user SET last_login_timestamp = systimestamp WHERE sys_user_code = ? ", "myuser");

But I get the following error:

ORA-00904: "YSTIMESTAMPHEREYS_USER_CODE": Invalid identified。
 Query: UPDATE system_user SET last_login_timestamp = systimestamp WHERE sys_user_code = ?  Parameters: [myuser]

So my question is, why does it think that there is YSTIMESTAMPHEREYS_USER_CODE in the connection string even if it is not there? Are there some encoding problems?

Note:

When I execute the same script in DBeaver (for example), the query is executed without any problems.

EDIT

After debugging the QueryRunner code I have found out that the error happens here (↓) in PreparedStatement.getParameterMetaData. source code

Share Improve this question edited Mar 3 at 2:45 Mihails Kuzmins asked Mar 3 at 1:47 Mihails KuzminsMihails Kuzmins 616 bronze badges 2
  • Are there any triggers on that table? – Player One Commented Mar 3 at 2:25
  • looks like your client is munging the SQL - dropping pieces of it out – Paul W Commented Mar 3 at 2:41
Add a comment  | 

2 Answers 2

Reset to default 3

Not an answer, but just an observation that I can't show easily in a comment:

Your error:

ORA-00904: "YSTIMESTAMPHEREYS_USER_CODE": Invalid identified?

Now line up those characters underneath your original SQL:

 Query: UPDATE system_user SET last_login_timestamp = systimestamp WHERE sys_user_code = ?  Paramete
                                                       YSTIMESTAMP  HERE  YS_USER_CODE

It would appear that something in your client API (not Oracle) is dropping the first letter of each word after that initial = and then collapsing the spaces that remain. Hopefully that's a useful clue to finding the source of the problem.

OK, the answer was that getParameterMetaData() is causing this issue. I was using ojdbc7 v12.1.0 and it does not seem to recognise the systimestamp keyword.

QueryRunner queryRunner = new QueryRunner();
int result = queryRunner.update(this.conn, "UPDATE system_user SET last_login_timestamp = systimestamp WHERE sys_user_code = ? ", "myuser");

If I provide systimestamp as a parameter then this error does not occur anymore.

QueryRunner queryRunner = new QueryRunner();
int result = queryRunner.update(this.conn, "UPDATE system_user SET last_login_timestamp = ? WHERE sys_user_code = ? ", "2015-03-03 11:45:57.676", "myuser");

It was also possible to avoid this issue by upgrading ojdbc7 to ojdbc8 v19.7.0.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745112991a4611956.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信