I am trying to doing some SQL queries out of Oracle 11g and am having issues using ora:contains. I am using Spring's JDBC implementation and my code generates the sql statement:
select *
from view_name
where column_a = ?
and column_b = ?
and existsNode(xmltype(clob_column),
'record/name [ora:contains(text(), "name1") > 0]',
'xmlns:ora="http://xmlns.oralce.com/xdb"') = 1
I have removed the actual view / column names obviously, but when I copy that into sqlplus and substitute in random values, the select executes properly. When I try to run it in my DAO code I get this stack trace:
org.springframework.jdbc.UncatergorizedSQLException: PreparedStatementCallback;
uncatergorizedSQLException for SQL [the big select above]; SQL state [99999];
error code [31011];
ORA-31011: XML parsing failed.
ORA-19202: Error occured in XML processing
LPX-00607: Invalid reference: 'contains';nested exception is java.sql.SQLException:
ORA-31011: XML parsing failed
ORA-19202: Error occured in XML processing
LPX-00607: Invalid reference: 'contains'
(continues on like this for awhile....)
I think it is worth mentioning that I am using Maven and it is possible I am missing some dependency that is required for this. Sorry the post is so long, but I wanted to err on the side of too much info.
Thanks for taking the time to read this at least =)
-Windle
You appear to have a spelling mistake in your namespace declaration:
'xmlns:ora="http://xmlns.oralce.com/xdb"'
^^
If that really is a typo in your code (rather than just in your posting here) it can't hurt to fix it.
Related
Currently in one of our application we are getting below error :
org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{call test_pkg.set_user_details(?)}?)}]; SQL state [99999]; error code [17041]; Missing IN or OUT parameter at index:: 2; nested exception is java.sql.SQLException: Missing IN or OUT parameter at index:: 2
Procedure Body :
PROCEDURE set_user_details(ID NUMBER DEFAULT -1)
IS
BEGIN
//
//
END set_user_details;
There is no issue in Java or DB code. Same code is working since long time and there is no recent change.
From Java code we are passing single parameter to that stored proc.
This is an intermittent issue. It happens only when we restart the server. As per my knowledge this is happening because if we do any transaction during server startup,
DB and application can be in different state and those 2 will not be in sync. Please correct me if I am wrong.
My question is, if its a state related issue, then why its giving Missing IN or OUT parameter at index:: 2 instead of giving state related error\exception ?
Also, even though that stored proc accept only one param , that exception says parameter is missing at index 2. Why its expecting param at index 2 ?
Currently we are using Oracle 12c and using JdbcTemplate to execute stored proc
Thank you
It's an issue with the prepared statement, it's [{call test_pkg.set_user_details(?)}?)}]; but definitely should be [{call test_pkg.set_user_details(?)}]; - somehow the part ?)} gets doubled...
I'm trying to use count query inside the #Formula (Spring boot app)
#Formula("select count(te.id) from task_execution te")
however when starting server, getting exception
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
says I have syntax error in query and following query printed in log:
select count(te.id) from task_execution te as formula6_ from node_info nodeinfo0
my question where this from node_info nodeinfo0 came from? My NodeInfo class is not related to TaskExecution class in any way
Thanks
So the solution was to put the expression into braces. The error was very misleading.
Using Java Spring Batch, I am generating a file based off of a query sent to a Oracle database:
SELECT
REPLACE(CLIENT.FirstName, chr(13), ' ')
FROM client_table CLIENT;
This query works fine when I run it in Oracle SQL Developer when I spool the result, but doesn't work when I try to utilize it to generate a file in Java Spring batch. It throws the error:
Message=Encountered an error executing step preparePrimaryIpData in job extract-primary-ip-job
org.springframework.jdbc.BadSqlGrammarException: Attempt to process next row failed; bad SQL grammar [
SELECT
REPLACE(CLIENT.FirstName, chr(13), ' ')
FROM client_table CLIENT
]; nested exception is java.sql.SQLException: Invalid column name
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:237)
Why is this working fine in Oracle Sql Developer but not when I try to utilize it in Java Spring Batch?
Also, the alias is necessary, because my actual query has a lot more joins, I just wanted to simplify it as an example.
you need to check the spelling of columns in your query as well as where you will be getting the result set. I was facing the same problem and the problem was in spelling in one of the "rs.getString("COLUMN_NAME")".
It is not the sql that has failed but you are misspelling the column name somewhere in your code.
Try some thing like :
SELECT REPLACE(CLIENT.FirstName, chr(13), ' ') columnNameX FROM client_table CLIENT
When I try to load an Entity with Hibernate I get the following error in postgres-log:
ERROR: column appuser0_.device_token does not exist at character 35
STATEMENT: select appuser0_.id as id1_27_0_, appuser0_.device_token as device_t2_27_0_,....
The column device_token definitely exists - and if I copy-paste the whole logged statement and execute it in PGAdmin, I get the expected result.
So what do I forget? What is the difference between the Hibernate statement and the manually executed one?
This issue was caused by the multi tenant configuration so that the wrong DataSource has been chosen.
Depending on how you defined the query, the problem might be located somewhere else: For example, HQL Queries are using the "property-names" of the class, not the column names.
And if you have something like:
#Column("device_token")
private String deviceToken;
Then your HQL-Query should target "deviceToken" and not "device_token". We also encountered a similar error once: Hibernate was reporting "user_id" is missing, because we named the property "userId" with the underscored version for the column name only.
This might be not the problem for you but worth double checking it.
In my java program an update query is used like below,
update unsub_tbl set stat=1 where stat=0 and emp_id='4441' and action='1';
if unsub_tbl is empty, then trying to update using above update query gives exception:
java.sql.SQLException: Can't find record in 'unsub_tbl'
But it's not giving the exception all the time for same condition. Why does it only give the exception sometimes?
It seems that it is a bug with MySQL 4.0.14+
Refer MySQL Bugs