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
- 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
2 Answers
Reset to default 3Not 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条)